Back to SL Mar

LCSMar Local-First

Liquid Cargo System Simulator — Technical Reference

LCSMar cargo synoptic during a live loading

Physics-based simulator for liquid cargo operations on oil and chemical tankers. Models inert gas atmosphere, cargo heating, crude oil washing, vapour generation, piping hydraulics, methanol dual-fuel operations, and intact stability & hull-girder strength in a unified real-time environment.

The pilot installation is configured document-true to a Reference MR Tanker — a ~50,000 DWT IMO II chemical/product carrier with methanol dual-fuel (LGIM) propulsion: twenty cargo tanks including a dedicated methanol storage pair served by deepwell pumps, a combustion-type inert gas generator, segregated ballast with treatment plant (filter + UV), and a daily methanol service tank feeding the main engine. Tank calibration tables, hydrostatics, cross-curves and the piping topology are all extracted from the vessel's class documentation; the ship herself stays anonymous here.

Designed as a digital twin for cargo operations training — the architecture prioritises ingestion of real operational documents (loadicator condition exports, sounding logs, gas readings) to anchor the physical engines against actual vessel behaviour.

Validation Status

The stability and strength chain is validated against the vessel's class-approved documents: the hydrostatic pipeline reproduces capacity-plan load-line points within 0.02 m and six worked conditions of the trim & intact stability booklet (KMT within 0.05 m); still-water shear force and bending moment reproduce the booklet curves via an inverse-calibrated buoyancy model (mean R² ≈ 0.99 across the LD02–LD23 envelope); loading conditions round-trip against real loadicator exports within instrument tolerance. LCSMar is a training simulator — it is not a class-approved loading instrument and does not replace the ship's loadicator.

Architecture

┌─────────────────────────────────────────────────────────┐
│                    React + TypeScript                    │
│  P&ID Renderer (SVG) │ Stability │ Calibration │ Tanks  │
├─────────────────────────────────────────────────────────┤
│              WebSocket (real-time frames)                │
├─────────────────────────────────────────────────────────┤
│                  FastAPI + Python 3.12                   │
│  Simulation Engine │ Flow Solver │ Calibration Solver    │
├─────────────────────────────────────────────────────────┤
│           Vessel Definition Spec (VDS / JSON)           │
├──────────────┬──────────────┬───────────────────────────┤
│  PostgreSQL  │    Redis     │  Calibration Store (JSON)  │
└──────────────┴──────────────┴───────────────────────────┘

Frontend — React 19, TypeScript, Zustand. SVG-based P&ID renderer driven by vessel definition geometry. Views: Cargo (P1/P2), Ballast (tanks/pump room), Inert Gas, Tank Cleaning, Methanol, Bunker/ER, Heating, Tanks, Stability.

Backend — FastAPI, Python 3.12. Eight physics subsystems run at fixed 0.5 s timesteps, accelerable to 16×. Newton-Raphson flow solver, lumped-parameter thermal model, exponential gas dilution. WebSocket pushes delta-compressed frames to the frontend.

Vessel Definition Spec — JSON schema defining hull geometry, tank calibration tables (ullage → volume → VCG → IT), piping networks, hydrostatic tables, cross-curve data, P&ID layout coordinates, and alarm thresholds. Vessel-agnostic: any tanker can be modelled by providing a VDS file.

Calibration Loop — Operators log observations (measured vs. predicted) via the UI or Excel upload. A statistical solver computes parameter adjustment suggestions from residual analysis, which the operator reviews and applies.

Installation

# Prerequisites: Docker, Docker Compose
docker compose up -d

# Frontend: http://localhost:3002
# API:      http://localhost:8002
# DB:       localhost:5437 (PostgreSQL 16)

Development

# Backend
cd backend && python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8001

# Frontend
cd frontend && npm install && npm run dev

# Tests
cd backend && pytest                          # 750+ tests
cd frontend && npm test                       # 42 tests

Tech Stack

LayerTechnology
FrontendReact 19, TypeScript, Zustand, Recharts, Vite
BackendPython 3.12, FastAPI, NumPy, SciPy, openpyxl
InfrastructurePostgreSQL 16, Redis 7, Docker Compose
Testingpytest (750+, incl. class-data validation oracles), vitest (42)

Inert Gas Atmosphere

Models O2 and HC concentration decay in cargo tank ullage spaces during inerting, purging, and gas-freeing.

Dilution

Exponential decay assuming perfect mixing:

Concentration Decay
\[ C(t + \Delta t) = C_{\text{supply}} + \bigl(C(t) - C_{\text{supply}}\bigr) \times \exp\!\Bigl(-\frac{Q \cdot \Delta t}{V_{\text{ullage}}}\Bigr) \]
Where Q is the volumetric IG flow rate (m³/h) and Vullage is the tank ullage volume. O2 supply defaults to 3% (flue gas), HC supply to 0.1%.

Pressure

Driven by IG inflow and liquid level change:

Ullage Pressure
\[ \Delta P = \frac{\Delta V_{\text{ig}}}{V_{\text{ullage}}} \cdot P_{\text{atm}} + \frac{\Delta V_{\text{liquid}}}{V_{\text{ullage}}} \cdot P_{\text{atm}} \]

P/V Valve

Proportional relief (not binary). The valve modulates flow proportionally to pressure deviation from setpoint:

P/V Valve Flow
\[ Q_{\text{vent}} = K \cdot \max(0,\; P - P_{\text{setpoint}}) \]
K = 200 m³/h per mmWG, pressure setpoint 1400 mmWG (vent), −350 mmWG (vacuum admit). Hard backstops at +1800 / −500 mmWG simulate P/V breaker behaviour.

Flow Distribution

Total IG supply from running blowers splits equally among open tank isolation valves, after mast riser diversion (85% when open). Deck isolating valve gates all flow.

Piping Hydraulics

Steady-state Newton-Raphson network solver for multi-system piping (cargo, ballast, IG, tank cleaning run simultaneously with shared tank states).

Pipe Friction

Darcy-Weisbach with Churchill correlation (all Reynolds regimes):

Darcy-Weisbach
\[ \Delta P_{\text{pipe}} = f \cdot \frac{L}{D} \cdot \frac{v^2}{2g} \]

Valve Loss

Cv method with equal-percentage characteristic:

Valve Pressure Drop
\[ \Delta P_{\text{valve}} = \left(\frac{Q}{C_{v,\text{eff}}}\right)^2 \cdot SG, \quad C_{v,\text{eff}} = C_{v,\text{full}} \cdot \left(\frac{\text{opening}}{100}\right)^2 \]

Pump Head

Parabolic H-Q curve with affinity law speed scaling:

Pump Characteristic
\[ H = H_{\text{shutoff}} - (H_{\text{shutoff}} - H_{\text{rated}}) \cdot \left(\frac{Q}{Q_{\text{rated}}}\right)^2 \]

Convergence

Damped Newton updates (α = 100/max(dx)), regularisation near zero flow, max 50 iterations, tolerance 1×10−6 m³/h. Check valves enforced via iterative re-solve blocking reverse flow; pump discharge non-return valves make line-up direction physically meaningful — deballasting must enter through the suction crossovers, exactly as on the real system. Inventory is conserved across tank-full and run-dry events to numerical precision.

Ballast pump room synoptic — live deballast through the suction crossover, BWTS in service

Ballast pump room during a live deballast: tank → main → suction crossover → pump → treatment train → overboard, with the permissive panel granting the line-up.

Stability & Hydrostatics

Intact stability calculation from weight/moment summation and hydrostatic table interpolation.

  1. Displacement: Δ = mlightship + Σ(Vtank × ρcargo)
  2. Centre of gravity: KG = Σ(mi × KGi) / Δ, LCG and TCG likewise
  3. Draft: reverse-interpolated from hydrostatic table (draft → displacement)
  4. GM: GMsolid = KMT − KG; free surface correction FSE = Σ(ρ × IT / Δ) for slack tanks (2–98% fill); GMfluid = GMsolid − FSE
  5. Trim: trim = Δ × (LCG − LCB) / MCTC
  6. List: tan(θ) = TCG / GMfluid
  7. GZ curve: GZ(θ) = KN(θ) − KG × sin(θ), interpolated from cross-curve tables
IMO Criteria

IMO intact stability criteria (A.749) checked automatically: area under GZ curve to 30°/40°, maximum GZ, angle of maximum GZ, initial GM.

Hull-girder still-water shear force and bending moment are computed live from the same tank states, against the class allowable envelope. The buoyancy distribution is inverse-calibrated from the trim & stability booklet's own SF curves (no Bonjean data required), reproducing the booklet within a few percent across the operational envelope.

Stability view with a full loadicator condition: GZ curve, trim/heel, hull girder SF/BM within envelope

A full 77-tank departure condition loaded from a loadicator PDF export: drafts, GM, GZ curve and still-water SF/BM all within the class envelope.

Thermal Model

Lumped-parameter heat balance per tank:

Tank Temperature
\[ \Delta T = \frac{(Q_{\text{coil}} - Q_{\text{loss}}) \cdot \Delta t}{m \cdot C_p} \]

\( Q_{\text{coil}} = U_{\text{coil}} \cdot A_{\text{coil}} \cdot (T_{\text{steam}} - T_{\text{cargo}}) \) — heating only

\( Q_{\text{loss}} = U_{\text{hull}} \cdot A_{\text{hull}} \cdot (T_{\text{cargo}} - T_{\text{ambient}}) \) — always active

Defaults: Ucoil = 50 W/(m²·K), Uhull = 5 W/(m²·K), steam at 170 °C, Cp = 2000 J/(kg·K). Coil and hull areas scale with tank volume. Alarms on flash point and pour point approach.

Crude Oil Washing

Surface coverage model:

COW Progress
\[ \frac{d\,\text{Progress}}{dt} = \frac{Q_{\text{wash}} \cdot k \cdot A_{\text{surface\_factor}}}{A_{\text{surface}}} \]
Where Asurface = 6 × V2/3. Requires IG pressure ≥ 100 mmWG (safety interlock). One full cycle calibrated to ~60 min at 80 m³/h.

Vapour Generation

VOC generation from cargo surface, proportional to Reid Vapour Pressure:

VOC Rate
\[ \frac{d\,\text{HC}}{dt} = k_{\text{base}} \cdot \text{RVP} \cdot A_{\text{surface}} \cdot \frac{\text{loading\_factor}}{V_{\text{ullage}}} \]
Loading factor 3× during active cargo transfer (turbulence-driven evaporation). Dissipation when O2 > 5%. Alarms at 30% and 50% LEL.

Methanol Operations

A dedicated trainer for methanol-as-fuel operations, built from the vessel's methanol safety-system cause-and-effect documentation and bunkering procedure: bunkering (shore/barge → manifold → storage), transfer (storage → deepwell pump → daily service tank) and normal running (service tank → supply unit → master fuel valve → main engine).

  • Start-permissive chains rendered as live logic bars per operation — N&sub2; mode, tank inerting ≤5% O&sub2; via the main IG line, vapour-return connection, N&sub2; line pressure tests, level-alarm tests, valve line-up in procedure order, manifold last.
  • ESD cause-and-effect matrix: gas detection ≥40% LEL in any zone, fire detection (engine surround / pump room), service-tank high-high, bilge leak, manual trip — each cause and every effect (supply shutdown, ESD valve closure, master fuel valve, second-fuel changeover, N&sub2; purge) tracked live.
  • Mass-conserving hydraulics: transfers run through the real network solver — storage loss equals service gain to numerical precision, verified end-to-end in the test suite.
Methanol bunkering synoptic with the full start-permissive chain granted

Methanol bunkering with the full permissive chain granted — manifold flow live, both storage tanks filling, vapour return to shore.

Loading Conditions

Real loadicator condition exports (text-based PDF) are parsed directly in the browser session — the PDF itself is never stored server-side. The parsed snapshot (per-tank fill, density, grade, plus the stability summary) is saved as a named condition in the simulator's library and can be re-applied to a running session in one click; stability, trim and hull-girder stress recompute live as the 70+ tanks fill.

Ballast tank overview with live levels after loading a condition

Ballast overview with per-tank level, volume and weight boxes wired to the live simulation.

Instructor Facilities

Aligned with the instructor-station requirements of DNV-ST-0033 (maritime simulator systems):

  • Malfunction injection — stuck valve (ignores commands, freezes an in-flight actuator stroke), pump trip (refuses every start order until cleared), frozen level sensor (the indication freezes while the real level keeps moving underneath).
  • Exercise snapshots — named save/restore of the complete simulation state, including random-generator state, so a restored exercise continues deterministically.
  • Session event log — timestamped record of every operator command, alarm first-appearance, injection and snapshot, for structured debriefing.
  • Deterministic replay — a session seed drives actuator travel times and initial tank atmospheres; the same scenario with the same seed replays identically for assessment.

Sessions & Access

Each account runs its own isolated simulation — engine, event log and snapshot set are private per login, resolved from the authenticated session (never from a client parameter). Ship and office staff train in parallel without interaction. A running simulation with no connected client auto-pauses after two hours and resumes exactly where it stood at the next login. Authentication is cookie-based (HMAC-signed, PBKDF2 password storage) behind a TLS gateway.

Calibration System

The calibration architecture accepts manual observations — the kind of data already recorded in tanker logbooks — and uses them to tune physics parameters.

Observation Types

IG O2 decay rate, IG tank pressure, thermal rate, flow rate, COW duration.

Solver

Groups observations by type (minimum 3), computes mean bias and standard deviation of residuals, derives confidence metric (1 − σ/(|bias| + σ)), suggests parameter corrections via ratio or inverse-ratio adjustment. Only suggestions with >50% confidence and >1% bias are surfaced.

Workflow

Observe → Log → Suggest → Review → Apply. No automatic parameter changes — the operator always decides.

A downloadable Excel template is provided for bulk observation entry.

Physics Parameters

All 20 parameters have sensible defaults and can be overridden per vessel:

ParameterDefaultUnitControls
ig_supply_o20.03fractionO2 in flue gas supply
ig_hc_supply0.001fractionHC in clean IG
ig_blower_rated_flow5000m³/hBlower capacity at 100%
pv_valve_press1400mmWGP/V valve vent setpoint
pv_valve_vac−350mmWGP/V valve vacuum setpoint
pv_valve_gain200m³/h per mmWGP/V proportional gain
mast_vent_fraction0.85fractionMast riser diversion ratio
u_coil50W/(m²·K)Heating coil U-value
u_hull5W/(m²·K)Hull heat transfer
steam_temp_c170°CSteam supply temperature
cp_cargo2000J/(kg·K)Cargo specific heat
coil_area_per_m30.1m²/m³Coil surface per tank volume
hull_area_per_m30.15m²/m³Wetted surface per tank volume
cow_effectiveness0.3COW washing rate factor
cow_ig_pressure_min100mmWGMinimum IG for safe COW
voc_base_rate0.001frac/s/m²Base VOC generation rate
surface_area_per_vol0.05m²/m³Tank surface estimate
loading_factor3.0multiplierVOC multiplier during loading
default_cargo_density850kg/m³Fallback cargo density
default_ballast_density1025kg/m³Seawater density

Vessel Definition Spec

Any tanker can be modelled by providing a VDS JSON file defining:

Hull & Tanks

  • Hull geometry (LBP, beam, depth)
  • Tank calibration tables (ullage → volume → VCG → IT)
  • Lightship parameters (weight, KG, LCG)

Piping Networks

  • Pipe segments (length, diameter, material)
  • Valves (Cv, type, position)
  • Pumps (H-Q curves, speed control)

Hydrostatics

  • Hydrostatic tables (draft → displacement, KMT, LCB, MCTC)
  • Cross-curve data (KN values at heel angles)

P&ID Layout

  • Equipment coordinates and symbols
  • Pipe routing for SVG rendering
  • Alarm thresholds per system

Dev Log

v0.2.0 2026-06-10 Latest

Pilot release. Methanol dual-fuel operations trainer (bunkering / transfer / running, permissive chains + ESD cause-and-effect from the vessel's safety documentation). Stability & hull-girder strength validated against class documents (six booklet worked conditions; SF/BM via inverse-calibrated buoyancy, R²≈0.99). Loadicator-PDF condition library. Instructor facilities: malfunction injection, deterministic snapshots, session event log. Per-account parallel sessions with idle auto-pause. Hydraulic inventory conservation across tank-full / run-dry events. 750+ pytest, 42 vitest.

v0.0.1 2026-03-07

Baseline version. Onboard development of a cargo digital twin. Core simulation engine with 8 physics subsystems (inert gas, piping hydraulics, stability, thermal, COW, vapour generation, cargo transfer, ballast), multi-system piping with Newton-Raphson flow solver, real-time P&ID visualisation, and per-vessel calibration framework. 524 pytest + 36 vitest, 92% backend coverage.