Loading Conditions#
Classes for managing mass inventories and tank fill overrides to define operational profiles.
MassCategory#
MassItem#
- class MassItem(name, mass, cog, category=None)#
A single mass item with name, mass, position, and optional category.
- Parameters:
name – Identifier for the mass item.
mass – Mass in kg.
cog – Center of gravity (lcg, tcg, vcg) in meters.
category – Optional MassCategory (default: Other).
- __init__(name, mass, cog, category=None)#
Creates a MassItem.
Properties
- name: str
- category: MassCategory#
LoadingCondition#
- class LoadingCondition(name)#
A complete loading condition with mass items and tank fill overrides.
- Parameters:
name – Name of the loading condition.
- __init__(name)#
Creates a LoadingCondition.
Properties
- name: str
Name of the loading condition.
Mass Management
- add_mass(item)#
Add a MassItem.
- Parameters:
item – A MassItem instance.
- add_mass_simple(name, mass, cog, category=None)#
Add a mass item by parameters (convenience).
- Parameters:
name – Identifier for the mass item.
mass – Mass in kg.
cog – Center of gravity (lcg, tcg, vcg) in meters.
category – Optional MassCategory (default: Other).
- remove_mass(name)#
Remove a mass item by name.
- Parameters:
name – Name of the mass.
- Returns:
True if found and removed.
- Return type:
Tank Fill Overrides
- set_tank_fill(tank_name, fill_level)#
Set a tank fill override by fill level (0.0 to 1.0).
- set_tank_fill_percent(tank_name, fill_percent)#
Set a tank fill override by percentage (0 to 100).
- remove_tank_fill(tank_name)#
Remove a tank fill override.
- Returns:
True if found and removed.
- Return type:
- get_tank_fills()#
Returns tank fill overrides as a dictionary.
Application & Calculation
- apply(vessel)#
Apply tank fill overrides to the vessel’s tanks. Only tanks listed in overrides are modified. Other tanks keep their current fill level.
- Parameters:
vessel – Vessel instance.
- total_displacement(vessel)#
Returns the total displacement (masses + tank fluid masses) in kg. Must be called after apply().
- Parameters:
vessel – Vessel instance.
- Return type:
- total_cog(vessel)#
Returns the combined center of gravity in meters. Must be called after apply().
- resolve(vessel)#
Returns (total_displacement, (lcg, tcg, vcg)) in a single call. Must be called after apply().
- item_displacement()#
Returns the displacement of mass items only (excluding tank fluids) in kg.
- Return type:
- item_cog()#
Returns the center of gravity of mass items only (lcg, tcg, vcg) in meters.
- resolve_items()#
Returns (item_displacement, (lcg, tcg, vcg)) in a single call. Use this for stability calculations to avoid double-counting tank masses.
Note
It is highly recommended to use the convenience methods directly on the calculators:
gz_curve_from_loading()andfrom_loading(). These methods automatically handle the save/restore process for tank configurations.Serialization and Copying
- static from_json(json_str)#
Deserialize from JSON string.
- Return type:
- save_json(path)#
Save to JSON file.
- static load_json(path)#
Load from JSON file.
- static from_csv(csv_str)#
Deserialize from CSV string. A unified CSV format is used to handle both Mass Items and Tank Fill Overrides.
CSV Format Example:
Type,Name,Mass,LCG,TCG,VCG,Category,FillPercent Mass,Lightship,5000000.0,45.0,0.0,4.5,Lightship, Mass,Crew,3000.0,35.0,0.0,8.0,Other, Tank,FO_1P,,,,,,95.0 Tank,FW_1,,,,,,50.0You can download this template here:
loading_condition_template.csv
- Return type:
- static load_csv(path)#
Load from CSV file. Uses the same unified format as
from_csv.
- Return type:
- copy(name=None)#
Create a copy, optionally with a new name.
- Parameters:
name – New name
- Return type: