Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ Versions follow [semantic versioning](https://semver.org/), with `0.x` meaning t
junction in place remains a known limitation documented in `docs/architecture.md`). A refused write leaves
nothing outside the root; on multi-file saves such as `model.save`, the hull file inside the root may
already be written before a linked sidecar is refused.
- Floodable length curves, for spacing watertight bulkheads: `seacraft floodable` and the MCP tool
`floodable_length` draw, for each position along the hull, the longest full-breadth compartment that can flood
without immersing the margin line (76 mm below the deck edge at side by default), upright and free to trim, one
curve per permeability. With a factor of subdivision and bulkhead positions, each compartment is judged against
the permissible length at its centre, as a table, JSON, CSV or an SVG plot with the terminals and the bulkhead
triangles, in English or Turkish. The curves are checked against a box barge's closed form and against
SeaCraft's damage solver, not against a published floodable length table. Not in the window yet.

## 0.7.0 (2026-11-26)

Expand Down
9 changes: 9 additions & 0 deletions DISCLAIMER.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ calculations, in the figures read for this, show the same pattern, though not at
program to the gaps measured. Nothing else about seakeeping has been compared with experiments: not other hulls,
transom sterns, other headings, the irregular-sea statistics or the MSI.

Floodable length curves (`seacraft floodable`, the MCP tool `floodable_length`) follow the definitions in Rawson &
Tupper (*Basic Ship Theory*, Vol. 1) and Gillmer & Johnson (*Introduction to Naval Architecture*, 1982), the
trial-waterline method of Gillmer & Johnson and the triangle check of Rawson & Tupper; neither book prints worked
numbers. They are checked against a box barge's closed form and against SeaCraft's own
damage solver ([`docs/oracles.md`](docs/oracles.md) §53-§55), not against a published floodable length table or
approved software. The margin line is measured from the moulded deck edge, with no deck thickness, every
compartment is full breadth with one permeability, and the factor of subdivision is the user's: SeaCraft does not
compute it from the rules. A compartment that passes the check is not shown to meet SOLAS or any other rule.

The wave pattern (`seacraft waves`, the MCP tool `wave_pattern`, the Wave pattern view and Plan view contours in the
window, the design report) is far-field thin-ship theory: free waves only, without the local disturbance, so near the hull
it is not the hull wave profile. It is computed upright at the draft; heel and trim are ignored. It has been
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ FREE!ship does **not** use ordinate tables. `TFreeHydrostaticCalc.Calculate`
| CPU z-buffer rasterizer + waterplane depth + PNG | `raster.rs` |
| OBJ / STL / 3MF / PLY / IGES / HTML viewer | `export.rs` |
| Deterministic damage stability (lost buoyancy) | `damage.rs` |
| Floodable length curves and the bulkhead check | `floodable.rs` |
| IMO 2008 IS Code weather criterion | `weather.rs` |
| Holtrop & Mennen still-water resistance | `resistance.rs` |
| Michell thin-ship wave resistance | `michell.rs` |
Expand Down Expand Up @@ -427,6 +428,15 @@ curve from equilibrium (heels 0–60°, free trim), and evaluates indicative
SOLAS-style residual criteria (SOLAS II-1 Reg. 7-2 spirit: range $\ge 15^\circ$,
max $GZ \ge 0.10$ m, area $\ge 0.015$ m·rad).

`floodable::evaluate` (`seacraft floodable hull.fef` / MCP `floodable_length`)
draws floodable length curves by trial waterlines tangent to the margin line
(76 mm below the deck edge at side by default): for each position, the longest
full-breadth compartment, centred there, that floods without immersing the
margin line, ship upright and free to trim, one curve per permeability. With a
factor of subdivision (`--factor`) and bulkhead positions (`--bulkheads`), each
compartment is judged against the permissible length at its centre; `--svg`
draws the curves with the terminals and the bulkhead triangles.

### Project file (`hull.seacraft.json`)

Design data that the `.fef` format has no place for lives in a sidecar next to
Expand Down
194 changes: 194 additions & 0 deletions crates/seacraft-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ enum Command {
Heel(HeelArgs),
/// Deterministic damage stability by the lost-buoyancy method
Damage(DamageArgs),
/// Floodable length curves: the longest compartment that can flood without immersing the margin line
Floodable(FloodableArgs),
/// Strip-theory heave and pitch motion RAOs in regular head seas (Salvesen, Tuck & Faltinsen 1970)
Seakeeping(SeakeepingArgs),
/// Linesplan: stations, buttocks and waterlines as SVG or DXF
Expand Down Expand Up @@ -1425,6 +1427,47 @@ struct DamageArgs {
json: bool,
}

#[derive(Args, Debug)]
struct FloodableArgs {
/// Input .fef file
file: PathBuf,
/// Project file for `--condition` (defaults to the model's `<model>.seacraft.json` sidecar)
#[arg(long, requires = "condition")]
project: Option<PathBuf>,
/// Loading condition of the project to float at (default: the hull at its design draft)
#[arg(long)]
condition: Option<String>,
/// Displacement (t), instead of a loading condition
#[arg(long)]
displacement: Option<f64>,
/// Longitudinal centre of gravity (m, model x); with `--displacement`
#[arg(long, requires = "displacement")]
lcg: Option<f64>,
/// Permeabilities, one curve each
#[arg(long, value_delimiter = ',', default_values_t = seacraft_core::floodable::DEFAULT_PERMEABILITIES)]
permeability: Vec<f64>,
/// Margin line depth below the deck edge (m)
#[arg(long, default_value_t = seacraft_core::floodable::DEFAULT_MARGIN_M)]
margin: f64,
/// Factor of subdivision: permissible length = factor x floodable length
#[arg(long)]
factor: Option<f64>,
/// Watertight bulkhead positions (m, model x), aft to forward, to check each compartment
#[arg(long, value_delimiter = ',')]
bulkheads: Vec<f64>,
/// Write the curves as an SVG plot
#[arg(long)]
svg: Option<PathBuf>,
#[command(flatten)]
subdiv: SubdivArgsCli,
/// Emit JSON instead of a table
#[arg(long, conflicts_with = "csv")]
json: bool,
/// Emit CSV, one row per curve point
#[arg(long)]
csv: bool,
}

#[derive(Args, Debug)]
struct SeakeepingArgs {
/// Input .fef file
Expand Down Expand Up @@ -1776,6 +1819,7 @@ fn run() -> Result<()> {
Command::Materials(a) => cmd_materials(a, tr),
Command::Heel(a) => cmd_heel(a, tr),
Command::Damage(a) => cmd_damage(a, tr),
Command::Floodable(a) => cmd_floodable(a, tr),
Command::Seakeeping(a) => cmd_seakeeping(a, tr),
Command::Linesplan(a) => cmd_linesplan(a, tr),
Command::Templates(a) => cmd_templates(a, tr),
Expand Down Expand Up @@ -5025,6 +5069,156 @@ fn cmd_stability(a: StabilityArgs, tr: Tr) -> Result<()> {
Ok(())
}

fn cmd_floodable(a: FloodableArgs, tr: Tr) -> Result<()> {
use seacraft_core::floodable::{self, FloodableOptions};
let s = load(&a.file)?;
if a.displacement.is_some() && a.condition.is_some() {
bail!("give either --displacement or --condition, not both");
Comment thread
havan marked this conversation as resolved.
Resolved
}
let mut case = damage::DamageCase::default();
if let Some(d) = a.displacement {
// `kg` does not enter the floodable length; set, it selects the explicit loading.
case.displacement_t = Some(d);
case.kg = Some(0.0);
case.lcg = a.lcg;
} else if let Some(name) = &a.condition {
let (source, path) = read_case_or_project(&a.file, a.project.as_deref())?;
let CaseSource::Project(p) = source else {
bail!("{} is not a project file", path.display());
};
case.loading_condition_name = Some(name.clone());
case = p
.resolve_damage_case(&case)
.map_err(|e| anyhow::anyhow!("{}: {e}", path.display()))?;
}
let hopts = HydroOptions::from_surface(
&s,
SubdivisionOptions {
level: a.subdiv.level,
mode: a.subdiv.mode.into(),
},
);
let opts = FloodableOptions {
permeabilities: a.permeability.clone(),
margin_m: a.margin,
factor: a.factor,
bulkheads: a.bulkheads.clone(),
..FloodableOptions::default()
};
let res = floodable::evaluate(&s, &hopts, &case, &opts).map_err(|e| anyhow::anyhow!("{e}"))?;

if let Some(path) = &a.svg {
let title = tr.fmt(Key::CliFloodableHeading, &[("name", &s.settings.name)]);
seacraft_core::io::write_atomic(path, floodable::svg_tr(&res, &title, tr))
.with_context(|| format!("cannot write {}", path.display()))?;
if a.json || a.csv {
eprintln!(
"{}",
tr.fmt(
Key::CliCommonWrote,
&[("path", &path.display().to_string())]
)
);
}
}
if a.json {
println!("{}", serde_json::to_string_pretty(&res)?);
return Ok(());
}
if a.csv {
println!("permeability,x_mid,length,x_aft,x_fwd,trim_m,draft");
for c in &res.curves {
for p in &c.points {
println!(
"{},{:.4},{:.4},{:.4},{:.4},{:.4},{:.4}",
c.permeability, p.x_mid, p.length, p.x_aft, p.x_fwd, p.trim_m, p.draft
);
}
}
for w in &res.warnings {
eprintln!("{}", tr.msg(w));
}
return Ok(());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

println!(
"{}",
tr.fmt(Key::CliFloodableHeading, &[("name", &s.settings.name)])
);
println!();
let row = |label: &str, value: String| println!(" {label:<26} {value}");
row(
tr.s(Key::CliFloodableLoading),
format!(
"{:.3} t, LCG {:.3} m, ρ {:.3} t/m³",
res.displacement_t, res.lcg, res.water_density
),
);
row(
tr.s(Key::FloodableSvgMarginLine),
tr.fmt(
Key::CliFloodableMarginVal,
&[("margin", &format!("{:.3}", res.margin_m))],
),
);
for c in &res.curves {
println!();
println!(
"{}",
tr.fmt(
Key::CliFloodableCurve,
&[("mu", &format!("{:.2}", c.permeability))]
)
);
if c.points.is_empty() {
println!(
" {}",
tr.fmt(
Key::WarnFloodableNoCurve,
&[("mu", &format!("{:.2}", c.permeability))]
)
);
} else {
println!(" {}", tr.s(Key::CliFloodableColumns));
for p in &c.points {
println!(
" {:>9.3} {:>9.3} {:>9.3} {:>9.3} {:>+9.3} {:>9.3}",
p.x_mid, p.length, p.x_aft, p.x_fwd, p.trim_m, p.draft
);
}
}
// Without a curve the compartments are still listed, each not judged.
if !c.checks.is_empty() {
println!();
println!(
" {}",
tr.fmt(
Key::CliFloodableChecks,
&[("factor", &format!("{:.2}", res.factor.unwrap_or(1.0)))]
)
);
for k in &c.checks {
let verdict = match k.passed {
Some(true) => tr.s(Key::CliFloodablePass),
Some(false) => tr.s(Key::CliFloodableFail),
None => tr.s(Key::CliFloodableNotJudged),
};
let permissible = k
.permissible
.map_or_else(|| "-".to_owned(), |v| format!("{v:.3}"));
println!(
" {:>8.3} .. {:<8.3} {:>8.3} / {:>8} m {verdict}",
k.x_aft, k.x_fwd, k.length, permissible
);
}
}
}
for w in &res.warnings {
eprintln!("{}", tr.msg(w));
}
Ok(())
}

enum CaseSource {
/// A bare loading condition or damage case, still to be parsed.
Bare(String),
Expand Down
Loading
Loading