#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TankOptions {
pub include_mass: bool,
pub include_fsm: bool,
}
impl Default for TankOptions {
fn default() -> Self {
Self {
include_mass: false,
include_fsm: true,
}
}
}
impl TankOptions {
pub fn none() -> Self {
Self {
include_mass: false,
include_fsm: false,
}
}
pub fn all() -> Self {
Self {
include_mass: true,
include_fsm: true,
}
}
pub fn mass_only() -> Self {
Self {
include_mass: true,
include_fsm: false,
}
}
pub fn fsm_only() -> Self {
Self {
include_mass: false,
include_fsm: true,
}
}
}
#[derive(Debug, Clone)]
pub struct HydrostaticState {
pub draft: f64,
pub trim: f64,
pub heel: f64,
pub draft_ap: f64,
pub draft_fp: f64,
pub draft_mp: f64,
pub volume: f64,
pub displacement: f64,
pub vessel_displacement: f64,
pub tank_displacement: f64,
pub cob: [f64; 3],
pub cog: Option<[f64; 3]>,
pub vessel_cog: Option<[f64; 3]>,
pub waterplane_area: f64,
pub lcf: f64,
pub bmt: f64,
pub bml: f64,
pub gmt: Option<f64>,
pub gml: Option<f64>,
pub gmt_dry: Option<f64>,
pub gml_dry: Option<f64>,
pub lwl: f64,
pub bwl: f64,
pub wetted_surface_area: f64,
pub midship_area: f64,
pub cm: f64,
pub cb: f64,
pub cp: f64,
pub thickness_volume: f64,
pub contact_surface_area: f64,
pub free_surface_correction_t: f64,
pub free_surface_correction_l: f64,
pub stiffness_matrix: [f64; 36],
pub los: f64,
pub sectional_areas: Vec<(f64, f64)>,
pub freeboard: Option<f64>,
}
impl HydrostaticState {
pub fn lcb(&self) -> f64 {
self.cob[0]
}
pub fn tcb(&self) -> f64 {
self.cob[1]
}
pub fn vcb(&self) -> f64 {
self.cob[2]
}
pub fn lcg(&self) -> Option<f64> {
self.cog.map(|c| c[0])
}
pub fn tcg(&self) -> Option<f64> {
self.cog.map(|c| c[1])
}
pub fn vcg(&self) -> Option<f64> {
self.cog.map(|c| c[2])
}
pub fn vessel_lcg(&self) -> Option<f64> {
self.vessel_cog.map(|c| c[0])
}
pub fn vessel_tcg(&self) -> Option<f64> {
self.vessel_cog.map(|c| c[1])
}
pub fn vessel_vcg(&self) -> Option<f64> {
self.vessel_cog.map(|c| c[2])
}
}
impl Default for HydrostaticState {
fn default() -> Self {
Self {
draft: 0.0,
trim: 0.0,
heel: 0.0,
volume: 0.0,
displacement: 0.0,
vessel_displacement: 0.0,
tank_displacement: 0.0,
cob: [0.0, 0.0, 0.0],
cog: None,
vessel_cog: None,
waterplane_area: 0.0,
lcf: 0.0,
bmt: 0.0,
bml: 0.0,
gmt: None,
gml: None,
gmt_dry: None,
gml_dry: None,
lwl: 0.0,
bwl: 0.0,
wetted_surface_area: 0.0,
midship_area: 0.0,
cm: 0.0,
cb: 0.0,
cp: 0.0,
thickness_volume: 0.0,
contact_surface_area: 0.0,
free_surface_correction_t: 0.0,
free_surface_correction_l: 0.0,
stiffness_matrix: [0.0; 36],
los: 0.0,
draft_ap: 0.0,
draft_fp: 0.0,
draft_mp: 0.0,
sectional_areas: Vec::new(),
freeboard: None,
}
}
}