Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ __pycache__/

# User-local config (contains machine-specific paths)
build-config.json
opencode.json

# MoorDyn workaround: copied at configure time (upstream CMAKE_SOURCE_DIR defect).
# /LICENSE.txt is MoorDyn's BSD-3, NOT the SEA-Stack project license.
Expand Down
2 changes: 2 additions & 0 deletions apps/seastack/gui/guihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ GUI::GUI(ViewerBackend backend) : backend_(backend) {
}
simulationStarted = false; // VSG viewer provides Start button
#else
// No viewer in this build: there is no Start button, so stepping stays on
// (the UI default) and the run proceeds as a headless one.
(void)backend;
pImpl = std::make_shared<seastack::viz::GUIImpl>();
#endif
Expand Down
5 changes: 4 additions & 1 deletion apps/seastack/gui/guihelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ class UI {
*/
::chrono::ChSystem* GetSystem() const { return pSystem; }

bool simulationStarted = false; // VSG viewer provides Start button
/// True while the simulation loop should step. A UI with no window has
/// no Start button, so it starts true and a headless run steps from the
/// first frame; a viewer with a Start button clears it until pressed.
bool simulationStarted = true;

/// Requested playback speed [simulated s per wall s], set from the GUI.
/// <= 0 means unlimited (step as fast as possible). Never changes dt.
Expand Down
2 changes: 2 additions & 0 deletions data/verification/CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ All quantities use SI units:
| Time | s | Starting at 0 |
| Length / heave | m | Displacement relative to equilibrium |
| Angle / pitch | rad | Right-hand rule about Y axis |
| Velocity | m/s | |
| Force | N | |
| Pressure | Pa | |
| RAO (linear) | m/m | Dimensionless |
| RAO (angular) | rad/m | **Not** deg/m |
| Frequency | rad/s | |
Expand Down
3 changes: 2 additions & 1 deletion data/verification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ Each verification case follows this layout:
| `oswec_decay_wecsim/` | OSWEC | WEC-Sim | Normalized |
| `oswec_rao_sweep/` | OSWEC | WEC-Sim | Normalized |
| `rm3_decay_wecsim/` | RM3 | WEC-Sim | Normalized (data only; not registered in CTest) |
| `rm3_hydraulic_pto_wecsim/` | RM3 with hydraulic PTO | WEC-Sim (PTO-Sim) | Normalized |
| `f3of_decay_multicode/` | F3OF | INW, WSM, WDN, PDS, HydroChrono | Normalized |

## Canonical conventions

All normalized data conforms to [CONVENTIONS.md](CONVENTIONS.md):

- **Units**: SI throughout — m, rad, N, s. Angular RAOs in rad/m (not deg/m).
- **Units**: SI throughout — m, rad, N, s (and m/s, Pa). Angular RAOs in rad/m (not deg/m).
- **Reference frame**: Global, Z-up, origin at mean water level.
- **Displacements**: Relative to equilibrium (not absolute CG position).
- **Sign conventions**: Positive up (heave), positive bow-up (pitch).
Expand Down
2 changes: 1 addition & 1 deletion data/verification/check_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
REQUIRED_FIELDS = {'format', 'source', 'model', 'quantity', 'units', 'columns'}

CANONICAL_UNITS = {
's', 'm', 'rad', 'N', 'm/m', 'rad/m', 'rad/s', '-', 'kg',
's', 'm', 'rad', 'N', 'm/m', 'rad/m', 'rad/s', '-', 'kg', 'm/s', 'Pa',
}

MANIFEST_REQUIRED_DATASET_KEYS = {'coordinate_frame', 'sign_convention'}
Expand Down
2 changes: 1 addition & 1 deletion data/verification/normalize_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def load_standard(path):

# Canonical units per CONVENTIONS.md.
_CANONICAL_UNITS = {
's', 'm', 'rad', 'N', 'm/m', 'rad/m', 'rad/s', '-', 'kg',
's', 'm', 'rad', 'N', 'm/m', 'rad/m', 'rad/s', '-', 'kg', 'm/s', 'Pa',
}


Expand Down
214 changes: 214 additions & 0 deletions data/verification/rm3_hydraulic_pto_wecsim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
# RM3 hydraulic PTO against WEC-Sim (`rm3_hydraulic_pto_wecsim`)

Cross-code check of the compressible-chamber bridge of `RectifiedHydraulicPTO`
against the WEC-Sim PTO-Sim case `RM3_cHydraulic_PTO` (WEC-Sim_Applications,
`PTO-Sim/RM3/RM3_cHydraulic_PTO`).

## What is compared

- **Open loop.** The relative displacement and velocity logged by the WEC-Sim
case as shipped (irregular waves, Pierson-Moskowitz, Hs 2.5 m, Tp 8 s, 400 s,
step 0.01 s) are fed through the SEA-Stack PTO, sample by sample. No
multibody or hydrodynamic model is involved: this tests the PTO equations.
- **Coupled.** RM3 float and plate in heave with the PTO between them, regular
wave H 2.5 m, T 8 s, 400 s, both codes at a step of 0.005 s. WEC-Sim:
`regularCIC`, `simu.b2b = 1`.
- Quantities: PTO force, HP and LP accumulator pressures, mean absorbed power
(mean of `-F v`); coupled run also float heave, relative displacement and
velocity, and the amplitude and phase of the relative displacement at the
wave frequency.
- Window: t >= 100 s, after the wave ramp. NRMSE = RMS(SEA-Stack - WEC-Sim) /
std(WEC-Sim) over the window, on the WEC-Sim time base.
- Oil added (make-up) or flow blocked at the accumulator limits, and time with
a chamber pressure at its floor, must all be zero. Agreement with a limit
acting is not a match.
- Electrical power is not compared. The generator models differ (WEC-Sim: an
equivalent circuit with a controlled load resistance; SEA-Stack: a PI torque
controller), and the WEC-Sim product of voltage and current is negative in
every sample after 100 s of both runs, so it is not treated as an electrical
output.

Test: `tests/verification/rm3_hydraulic_pto_wecsim/` (`test_rm3_hydraulic_pto_wecsim.cpp`,
`compare_rm3_hydraulic_pto_wecsim.py`); CTest
`test_verification_rm3_hydraulic_pto_wecsim` and `..._verification`.

## Equations of the chamber bridge

`x`, `v`: relative displacement and velocity (float minus plate; positive `x`
shrinks chamber A). `A`: piston area. `beta`: bulk modulus.

- Chambers: `V_A = V_A0 - A x`, `V_B = V_B0 + A x`,
`dp_A/dt = beta / V_A (A v + Q_A)`, `dp_B/dt = beta / V_B (Q_B - A v)`.
- Orifice check valve, forward pressure drop `dp`:
`Q = Cd Av(dp) sqrt(2 dp tanh(k1 dp) / rho)`,
`Av = Amin + (Amax - Amin) (1 + tanh(k2 (dp - (pMax + pMin) / 2))) / 2`.
- Bridge: valve 1 A to HP, 2 B to HP, 3 LP to B, 4 LP to A;
`Q_A = -Q1 + Q4`, `Q_B = -Q2 + Q3`, `Q_HP = Q1 + Q2`, `Q_LP = -Q3 - Q4`.
- Force: `F = -(p_A - p_B) A`.
- Accumulator with oil volume `V_oil` in a shell `V_0` precharged to `p_0`:
`p = p_0 (V_0 / (V_0 - V_oil))^gamma`, `V_oil` bounded to `[0, 0.99 V_0]` and
starting at `initial_oil_volume`.
- Ideal rectifier (the library default bridge model), for comparison: no chamber
states, `F = -s(v) (p_HP - p_LP) A` with `s(v) = v / sqrt(v^2 + eps^2)`, and
all of the swept volume `A v s(v)` goes to the HP side.

Integration and the limit policies are described in
[`libs/pto/README.md`](../../../libs/pto/README.md).

## Parameter sets

Defined in `demos/rm3/rm3_hydraulic_pto_wecsim_configs.h` (`--config` of the
harness programs `demo_rm3_hydraulic_pto_wecsim_replay` and `_matched`).

| | WEC-Sim case | Matched (Config A) | Realistic (Config B) | v1 (`--config v1`, negative control) |
|---|---|---|---|---|
| Bridge | chambers, four orifice check valves | `kCompressibleChambers` | `kCompressibleChambers` | `kIdealRectifier` |
| Chamber oil at `x = 0`, each side | 1.323 m^3 (35 m column) | 1.323 m^3 | 0.0856 m^3 | none |
| Valves: `Amax`; opening range | 0.002 m^2; 0 to 1.5 MPa | as WEC-Sim | 0.003 m^2; 0.02 to 0.2 MPa | none |
| Accumulator gas at the start, HP / LP | 8.5 m^3 at 19.200 MPa / 8.5 m^3 at 9.600 MPa | as WEC-Sim | 0.45 m^3 at 6.0 MPa / 0.30 m^3 at 2.0 MPa | as WEC-Sim |
| Oil at the start, HP / LP | 0 / 0, no bounds | 1.0 / 6.5 m^3 (shells 9.5 / 15 m^3) | 0.15 / 0.50 m^3 (shells 0.6 / 0.8 m^3) | 0 / 0 (`initial_oil_volume = 0.0`) |
| At an accumulator limit | no limits: the volume goes negative | `kConserveVolume` | `kConserveVolume` | `kIdealMakeUp`, set explicitly: oil is created or removed, not a closed circuit |
| Motor | 120 cm^3/rev | 120 cm^3/rev | 500 cm^3/rev | 120 cm^3/rev |
| Generator | circuit, PID on the load resistance | PI torque, kp 7.2, ki 20, 1000 rev/min | torque `kp omega`, kp 11.11 | PI torque, kp 7.2, ki 20, 1000 rev/min |

Only the matched set is compared with WEC-Sim in this case. The v1 column sets
the bridge model and the limit policy explicitly in the harness
(`V1Defaults()`); it does not follow the library default.

Two other configurations are named in the text below and are not columns of
this table:

| Configuration | Bridge, limit policy | Device data | Status |
|---|---|---|---|
| Library default, `RectifiedHydraulicPTOParams{}` | `kIdealRectifier`, `kConserveVolume` | none: the caller sets all of it; accumulators start empty (`initial_oil_volume = 0.0`) | closed circuit; with empty accumulators the flow it cannot supply is blocked and reported, so it needs accumulators that start with oil to pump |
| Shipped demo, `demos/rm3/demo_rm3_hydraulic_pto.cpp` | `kIdealRectifier`, `kIdealMakeUp` (explicit) | its own: 0.05 m^3 accumulators that start empty, precharge 16 / 8 MPa, motor 6.0e-5 m^3/rad, PI kp 5, ki 8, setpoint 104.72 rad/s, torque limit 1000 N m | the historical v1 demo circuit; not closed, so not physical if an accumulator bound is hit |

## Why the matched set is a verification case and not a default

- **It agrees with WEC-Sim by copying the WEC-Sim device**: 35 m oil columns
on each side of the piston, the WEC-Sim accumulator gas state on top of oil
reserves of 1.0 m^3 (HP) and 6.5 m^3 (LP), the orifice check valves, and
`kConserveVolume`.
- **That device is not physically sensible and could not be built.** The oil
columns are 35 m long for a relative motion within -1.41 to +1.20 m (open
loop). The reserves exist only to represent the WEC-Sim accumulators without
negative oil: WEC-Sim has no volume bounds, and its transferred volume falls
to -0.088 m^3 (HP) and -1.155 m^3 (LP) in the open-loop run, and to -0.084
and -2.592 m^3 in the coupled run.
- **The library default is a different model and has no device data**: ideal
rectifier, no chambers, a closed circuit, and accumulators that start empty.
Source defaults: `BridgeModel bridge_model = BridgeModel::kIdealRectifier;`,
`AccumulatorLimitPolicy accumulator_limit_policy = AccumulatorLimitPolicy::kConserveVolume;`,
`double initial_oil_volume = 0.0;`. Earlier versions defaulted to
`kIdealMakeUp`, which made the empty accumulators an open circuit from the
first stroke; that must now be asked for (`IdealRectifierMakeUpParams()`).
`--config v1` below is that explicit open-circuit choice on the WEC-Sim
device data.
- The v1 circuit (ideal rectifier + `kIdealMakeUp` + empty accumulators, with
the WEC-Sim device data, `--config v1`) does not
reproduce WEC-Sim. Open loop: 123.50 against 77.413 kW absorbed, force NRMSE
113 %. Coupled, both codes at 0.01 s: 378.9 against 185.542 kW, with
4.557 m^3 of make-up oil. **These v1 numbers are not physical results**: the
circuit is not closed.
- **The realistic set (Config B)** uses the chamber bridge with engineering
judgement values for a device that could be built, as a closed circuit. In
the coupled case it absorbs about 386.1 kW with no make-up and no blocked
flow. It is a different device and is not expected to match WEC-Sim; its
values are not validated.

## Results and limits

Run of 4 December 2026 (Windows, MSVC, Release). PASS at or below the first
limit, WARN up to the second, FAIL beyond. NRMSE and power in percent.

| Run | Metric | Result | PASS | WARN |
|---|---|---|---|---|
| Open loop | PTO force NRMSE | 0.917 | 1.5 | 3.0 |
| Open loop | HP pressure NRMSE | 0.274 | 0.5 | 1.0 |
| Open loop | LP pressure NRMSE | 0.276 | 0.5 | 1.0 |
| Open loop | absorbed power, abs. difference | 0.80 (78.031 against 77.413 kW) | 1.25 | 2.5 |
| Coupled | float heave NRMSE | 0.142 | 0.25 | 0.5 |
| Coupled | relative displacement NRMSE | 0.106 | 0.2 | 0.4 |
| Coupled | relative velocity NRMSE | 0.200 | 0.35 | 0.7 |
| Coupled | PTO force NRMSE | 0.327 | 0.5 | 1.0 |
| Coupled | HP pressure NRMSE | 0.536 | 0.85 | 1.7 |
| Coupled | LP pressure NRMSE | 0.427 | 0.7 | 1.4 |
| Coupled | absorbed power, abs. difference | 0.34 (187.164 against 186.524 kW) | 0.55 | 1.1 |
| Coupled | relative displacement amplitude, largest of three windows | 0.067 | 0.2 | 0.4 |
| Coupled | relative displacement phase, largest of three windows [deg] | 0.060 | 0.2 | 0.4 |
| Both | make-up volume, blocked volume, chamber floor time | 0 | must be 0 | |

SEA-Stack is higher in absorbed power in both runs (+0.80 % and +0.34 %).

How the limits were chosen:

- They are set from the residuals in the table, not from an accuracy
requirement. The PASS limit is the observed residual with a margin, about
1.5 to 1.9 times the observed value rounded to a convenient number; WARN is
twice PASS.
- The amplitude and phase residuals are below 0.1, so a ratio would give
limits tighter than the comparison can resolve reliably; a floor of 0.2 is
used for PASS.
- A WARN or FAIL therefore reports a change (in the PTO model, in the coupled
solution or in the platform), which needs an explanation. A PASS says that
the two codes still agree as they did when the case was added. It says
nothing about the physical validity of the device.

## Scope and limitations

- The evidence is **one open-loop irregular run and one coupled regular sea
state**. Coupled irregular waves, other sea states and stress cases have not
been compared with the chamber bridge.
- Residual differences. WEC-Sim advances the chamber pressures by explicit
forward Euler at the model step. Its coupled absorbed power is 185.54,
186.53 and 186.84 kW at steps of 0.01, 0.005 and 0.0025 s, and the
difference from SEA-Stack at equal steps falls from +0.90 % to +0.34 % to
+0.17 %. That the remaining differences are the step error of the WEC-Sim
update is **inferred from this trend, not proven**.
- SEA-Stack integrates the chamber pressures by backward Euler with
sub-steps. The explicit WEC-Sim update and its unbounded accumulators are
not reproduced in SEA-Stack.
- The case as shipped has `simu.b2b = 0` (no hydrodynamic interaction between
the bodies in WEC-Sim). The coupled reference was run with `simu.b2b = 1`;
the shipped run is used only as the source of the open-loop motion.
- The coupled reference is stored every 5th sample (0.025 s apart). On every
0.005 s sample the absorbed power is 187.169 against 186.529 kW, the same
+0.34 %, and the NRMSE values agree to three significant digits. The
open-loop reference keeps every sample: at 0.01 s the WEC-Sim valve flow
alternates from sample to sample, so a decimated record is a biased sample.
- The hydrodynamic data are the RM3 files of each code (`rm3.h5` of the
SEA-Stack demos and of WEC-Sim_Applications); they are not the same file.
- WEC-Sim body masses are set by `mass = 'equilibrium'`; SEA-Stack uses the
masses of the RM3 demos.

## Related library behaviour

- **Make-up oil.** `kConserveVolume` is the default policy; `kIdealMakeUp`
is an explicit choice (`IdealRectifierMakeUpParams()`). The library
measures the oil that the accumulator limits add or remove
(`PTODiagnostics::hp_makeup_volume`, `lp_makeup_volume`, `makeup_energy`)
and logs a warning the first time.
- **Headless runs.** `UI::simulationStarted` (`apps/seastack/gui/guihelper.h`)
starts `true`, so a headless UI, and a GUI in a build without VSG, step from
the first frame. The `GUI` constructor of a VSG build still sets it `false`
until Start is pressed. **This has not been run in a build with VSG.**

## Data and provenance

| File | Content |
|---|---|
| `raw/wecsim/open_loop_irregular_dt0p01.csv` | WEC-Sim open-loop run, every sample (40001 rows) |
| `raw/wecsim/coupled_regular_dt0p005_every5.csv` | WEC-Sim coupled run, every 5th sample (16001 rows) |
| `normalized/wecsim/open_loop_irregular.txt` | time, relative displacement and velocity (also the replay input), PTO force, HP and LP pressure |
| `normalized/wecsim/coupled_regular.txt` | time, float heave from rest, relative displacement and velocity, PTO force, HP and LP pressure |
| `manifest.json` | versions, run copies and dates, overrides, steps, hashes |
| `extract_wecsim_ref.py` | writes `raw/` from the WEC-Sim `signals.mat` files (run once) |
| `normalize.py` | writes `normalized/` from `raw/` |

WEC-Sim 0753b2e, WEC-Sim_Applications d53d4d4, MATLAB R2026b.

To run:

```bash
ctest --test-dir build -C Release -R "^test_verification_rm3_hydraulic_pto_wecsim"
```
Loading
Loading