Tanks#

Classes for tank management and free surface effects.

Tank#

class Tank(file_path, fluid_density=1025.0, name=None)#

A tank with fluid management capabilities.

Parameters:
  • file_path – Path to the geometry file (STL or VTK)

  • fluid_density – Fluid density in kg/m³

  • name – Optional name for the tank

__init__(file_path, fluid_density=1025.0, name=None)#

Creates a Tank from a file.

static from_box_hull_intersection(hull, x_min, x_max, y_min, y_max, z_min, z_max, fluid_density=1025.0, name='HullTank')#

Creates a Tank as the intersection of a box with a hull geometry. Useful for double bottom tanks or side tanks that follow the hull shape.

Parameters:
  • hull – Hull object to intersect with

  • x_min – Minimum x coordinate (aft)

  • x_max – Maximum x coordinate (fwd)

  • y_min – Minimum y coordinate (stbd)

  • y_max – Maximum y coordinate (port)

  • z_min – Minimum z coordinate (bottom)

  • z_max – Maximum z coordinate (top)

  • fluid_density – Fluid density in kg/m³

  • name – Tank name

static from_box(name, x_min, x_max, y_min, y_max, z_min, z_max, fluid_density)#

Creates a box-shaped tank.

Parameters:
  • name – Tank name

  • x_min – Minimum x coordinate

  • x_max – Maximum x coordinate

  • y_min – Minimum y coordinate

  • y_max – Maximum y coordinate

  • z_min – Minimum z coordinate

  • z_max – Maximum z coordinate

  • fluid_density – Fluid density in kg/m³

Properties

name: str#

Tank name.

total_volume: float#

Total tank volume (m³).

Fill State

fill_level: float#

Fill level as fraction (0.0 to 1.0).

permeability: float#

Permeability fraction of the tank’s contents (0.0 to 1.0). Defaults to 1.0.

fill_percent: float#

Fill level as percentage (0 to 100).

fill_volume: float#

Filled volume (m³).

fluid_mass: float#

Fluid mass (kg).

Center of Gravity

center_of_gravity: list[float]#

Center of gravity [x, y, z].

Free Surface Moments

free_surface_moment_t: float#

Transverse free surface moment (m⁴).

free_surface_moment_l: float#

Longitudinal free surface moment (m⁴).

FSM Configuration

fsm_mode: str#

Current FSM calculation mode (‘actual’, ‘maximum’, ‘fixed’).

set_fsm_mode(mode, t=None, l=None)#

Sets the free surface moment calculation mode.

Parameters:
  • mode – Mode string (‘actual’, ‘maximum’, ‘fixed’)

  • t – Transverse FSM (m^4), required if mode is ‘fixed’

  • l – Longitudinal FSM (m^4), required if mode is ‘fixed’

Geometry

get_vertices()#

Returns the vertices of the tank shell mesh.

Returns:

List of (x, y, z) tuples

Return type:

list[tuple[float, float, float]]

get_faces()#

Returns the faces (triangles) of the tank shell mesh.

Returns:

List of (i, j, k) indices tuples

Return type:

list[tuple[int, int, int]]

get_fluid_vertices(heel=0.0, trim=0.0)#

Returns the vertices of the fluid mesh at specified attitude.

Parameters:
  • heel (float) – Heel angle in degrees

  • trim (float) – Trim angle in degrees

Returns:

List of (x, y, z) tuples

Return type:

list[tuple[float, float, float]]

get_fluid_faces(heel=0.0, trim=0.0)#

Returns the faces of the fluid mesh at specified attitude.

Parameters:
  • heel (float) – Heel angle in degrees

  • trim (float) – Trim angle in degrees

Returns:

List of (i, j, k) indices tuples

Return type:

list[tuple[int, int, int]]