|
1 | | -# HydroChrono |
2 | 1 |
|
3 | | -**HydroChrono** is an emerging hydrodynamics simulation tool designed to model complex ocean systems. Seamlessly integrated with the [Project Chrono](https://projectchrono.org/) physics engine, it offers a powerful C++ API for a wide range of simulations. |
| 2 | +<p align="center"> |
| 3 | + <img src="docs/assets/img/hydrochrono_banner.png" /> |
| 4 | + <br/> |
| 5 | + <a href="https://github.com/NREL/HydroChrono/releases"><img src="https://img.shields.io/badge/version-v0.3-blue.svg" /></a> |
| 6 | + <a href="#"><img src="https://img.shields.io/badge/status-Prototype-orange.svg" /></a> |
| 7 | +</p> |
4 | 8 |
|
5 | | -## Capabilities |
| 9 | +> ⚠️ HydroChrono is under active development (`v0.3` prototype). This early release focuses on a YAML‑driven CLI and portable HDF5 outputs so you can try the code and share feedback. Expect rapid iteration over the coming year (inc. more advanced PTO, control, mooring & hydrodynamics) — please get in touch if you have any issues or feature requests. |
6 | 10 |
|
7 | | -HydroChrono extends the versatility of Project Chrono to hydrodynamic applications, enabling you to simulate multibody wave energy converters (WECs) and floating offshore wind turbines (FOWTs) with Chrono::FEA for flexible bodies. |
8 | 11 |
|
9 | | -## Get Started |
| 12 | +HydroChrono (Hydrodynamics for Project Chrono) is a hydrodynamics simulation toolkit built on [Project Chrono](https://projectchrono.org/). It is designed for simulating wave energy converters (WECs) and other complex ocean systems, and is **100% free and open‑source** end‑to‑end — no proprietary dependencies required. This repo ships a prototype, YAML‑driven CLI app for running simulations and exporting portable results. |
10 | 13 |
|
11 | | -Visit the [HydroChrono website](https://nrel.github.io/HydroChrono/) for information about the underlying theory, build instructions, and usage details. Currently, HydroChrono is available as a source build, offering customization and optimization opportunities. A binary distribution with Python wrapper is in development and coming soon. |
| 14 | +📄 Publications: See the end of this README. |
12 | 15 |
|
13 | | -## Limitations |
| 16 | +🌐 Website: https://nrel.github.io/HydroChrono/ |
14 | 17 |
|
15 | | -- Currently only supports first-order linear potential flow forces. |
16 | | -- Hydrodynamic forces are currently limited to rigid bodies. |
| 18 | +## What it does (under the hood) |
17 | 19 |
|
18 | | -## Vision and Future Goals |
| 20 | +- Uses Boundary Element Method (BEM) hydrodynamic coefficients (e.g., from [Capytaine](https://github.com/capytaine/capytaine)) to describe added mass, radiation damping, and wave excitation. HydroChrono reads these coefficients from BEMIO‑format HDF5 (.h5) files, an approach familiar to [WEC‑Sim](https://github.com/WEC-Sim/WEC-Sim) users. |
| 21 | +- Runs time‑domain simulations via the Cummins equation (impulse‑response/convolution form for radiation effects). |
| 22 | +- Builds complex, nonlinear multibody systems using Project Chrono; hydrodynamic loads are currently first‑order, with expanded models planned. |
| 23 | +- Supports a YAML-driven CLI, with logging, GUI and exports portable results to HDF5 for post‑processing and validation. |
19 | 24 |
|
20 | | -- Expand hydrodynamics to incorporate nonlinear and 2nd order forces. |
21 | | -- Integrate advanced simulation features using Project Chrono's DEM and FEA modules. |
22 | | -- Support seamless transitioning from potential flow to CFD and SPH for detailed FSI analysis. |
23 | | -- Develop a Python API to broaden accessibility and ease of use. |
24 | | -- Foster and support open-source collaboration in the research community. |
| 25 | +## Download |
25 | 26 |
|
26 | | -## Build Instructions |
| 27 | +- Get the latest Windows binaries from the [Releases](https://github.com/NREL/HydroChrono/releases) page. |
27 | 28 |
|
28 | | -### Prerequisites |
| 29 | +## Quick start (CLI) |
29 | 30 |
|
30 | | -- **Visual Studio 2022** with C++ toolchain |
31 | | -- **CMake 3.18+** |
32 | | -- **Project Chrono** (built from source; tested v9.0.0–v9.0.1) |
33 | | -- **HDF5 1.10.8+** |
34 | | -- **Eigen 3.4+** (header-only unzip is fine) |
35 | | -- **Irrlicht 1.8.x** (optional but required for GUI helper) |
36 | | -- **Python 3.8+** (only for docs/tools) |
| 31 | +After downloading, open a terminal in the app folder and run: |
37 | 32 |
|
38 | | -### Building from Source (using `build-config.json` + script) |
| 33 | +```powershell |
| 34 | +run_hydrochrono.exe -h # help |
| 35 | +run_hydrochrono.exe -i # info/banner |
39 | 36 |
|
40 | | -1. **Clone the repository** |
41 | | - ```powershell |
42 | | - git clone https://github.com/NREL/HydroChrono.git |
43 | | - cd HydroChrono |
44 | | - ``` |
| 37 | +# Run a case by directory (auto-detects setup) |
| 38 | +run_hydrochrono.exe .\cases\my_model\ |
45 | 39 |
|
46 | | -2. **Create your local config from the example** |
47 | | - ```powershell |
48 | | - copy build-config.example.json build-config.json |
49 | | - ``` |
| 40 | +# Or run directly from a setup file |
| 41 | +run_hydrochrono.exe .\cases\my_model\my_model.setup.yaml |
50 | 42 |
|
51 | | -3. **Edit `build-config.json`** and set paths for your machine |
52 | | - |
53 | | - **Example:** |
54 | | - ```json |
55 | | - { |
56 | | - "ChronoDir": "C:/path/to/chrono/build/cmake", |
57 | | - "Hdf5Dir": "C:/path/to/hdf5/share/cmake", |
58 | | - "EigenDir": "C:/path/to/eigen-3.4.0", |
59 | | - "IrrlichtDir": "C:/path/to/irrlicht-1.8.4", |
60 | | - "PythonRoot": "C:/Users/<you>/.conda/envs/<env>", |
61 | | - "CMakeModulePath": "C:/path/to/chrono/build/cmake" |
62 | | - } |
63 | | - ``` |
| 43 | +# Useful options |
| 44 | +run_hydrochrono.exe .\cases\my_model\ --nogui --output-h5 results.h5 |
| 45 | +``` |
| 46 | + |
| 47 | +### CLI Example |
| 48 | + |
| 49 | +The CLI prints a concise summary of what will run so you can check inputs and spot mistakes quickly: |
| 50 | + |
| 51 | +- Banner and version/status |
| 52 | +- Input summary: directory or setup file, resolved `*.model.yaml`, `*.simulation.yaml`, `*.hydro.yaml`, output directory |
| 53 | +- Simulation summary: bodies, constraints, estimated DoFs, time step, duration |
| 54 | +- Hydrodynamic data summary (from HDF5): file name, number of bodies, DoFs/body, frequency count, IRF/excitation/radiation/added‑mass flags |
| 55 | +- Wave model summary (type, height, period or spectrum) |
| 56 | +- Start/complete markers with steps and wall time; exported HDF5 path echoed for traceability |
64 | 57 |
|
65 | | -4. **Build (from repo root)** |
| 58 | +Tips: use `--quiet` to reduce logs, `--debug`/`--trace` for deeper diagnostics. |
66 | 59 |
|
67 | | - - Clean configure + build (default `Release`): |
68 | | - ```powershell |
69 | | - .\quick-build.ps1 -Clean |
70 | | - ``` |
71 | | - - Build a different configuration (e.g., `Debug`): |
72 | | - ```powershell |
73 | | - .\quick-build.ps1 -BuildType Debug |
74 | | - ``` |
| 60 | +<p align="center"><img src="docs/assets/img/cli_example.png" width="75%" /></p> |
75 | 61 |
|
76 | | -4. **Post-Build Steps** |
| 62 | +### GUI Example |
77 | 63 |
|
78 | | -Copy the following DLL files from your Chrono build directory to your build directory's `build/bin` folder: |
79 | | -- ChronoEngine.dll |
80 | | -- ChronoEngine_irrlicht.dll (if using Irrlicht) |
81 | | -- Irrlicht.dll (if using Irrlicht) |
| 64 | +Use the GUI to visually inspect the assembled multibody system (bodies, joints, actuators) and verify that YAML inputs are wired correctly. Use the `--nogui` option to disable visualization straight from CLI, or change the settings in the `*.simulation.yaml` file. |
82 | 65 |
|
83 | | -5. **Run the tests** |
| 66 | +<p align="center"><img src="docs/assets/img/gui_example.png" width="40%" /></p> |
| 67 | + |
| 68 | + |
| 69 | +## YAML-based UI |
| 70 | + |
| 71 | +HydroChrono uses separate YAML files so you can describe a mechanical system once and run it across different hydrodynamic backends (potential flow today; SPH/CFD next). This keeps your Chrono model clean and reusable. Everything is defined in text based files - making it easier to automate. |
| 72 | + |
| 73 | +``` |
| 74 | +cases/my_model/ |
| 75 | + my_model.setup.yaml # references the files below (recommended) |
| 76 | + my_model.model.yaml # bodies, joints, actuators |
| 77 | + my_model.simulation.yaml # time step, duration, GUI, waves |
| 78 | + my_model.hydro.yaml # hydrodynamics |
| 79 | +``` |
| 80 | + |
| 81 | +- `my_model.setup.yaml` — simulation 'orchestrator' |
| 82 | + - Specifies the input files you want to run |
| 83 | +- `my_model.model.yaml` — the multibody system |
| 84 | + - Bodies, joints, constraints, actuators, sensors (pure Chrono) |
| 85 | +- `my_model.simulation.yaml` — how to run it |
| 86 | + - Time step, duration, output options, GUI flags (pure Chrono) |
| 87 | +- `my_model.hydro.yaml` — hydrodynamics inputs |
| 88 | + - BEMIO `.h5` path (e.g., from Capytaine), body ↔ hydrodynamic body mapping, desired wave inputs |
| 89 | + |
| 90 | + |
| 91 | +Run with either the folder path (auto-detects `*.setup.yaml`) or the setup file directly: |
| 92 | +```powershell |
| 93 | +run_hydrochrono.exe .\cases\my_model\ |
| 94 | +run_hydrochrono.exe .\cases\my_model\my_model.setup.yaml |
| 95 | +``` |
| 96 | + |
| 97 | +### Example *.model.yaml file |
| 98 | + |
| 99 | +<p align="center"><img src="docs/assets/img/yaml_example.png" width="25%" /></p> |
| 100 | + |
| 101 | + |
| 102 | +## HDF5 outputs (portable) |
| 103 | + |
| 104 | +- Simulations produce a single `.h5` file with time series and model results. |
| 105 | +- Typical datasets include: |
| 106 | + - body position (XYZ): |
| 107 | + - `/results/model/bodies/<body_name>/position` (columns 0..2) |
| 108 | + - body orientation (roll, pitch, yaw): |
| 109 | + - `/results/model/bodies/<body_name>/orientation_xyz` (columns 0..2) |
| 110 | + - translational spring–dampers: |
| 111 | + - `/results/model/tsdas/<actuator_name>/` (force components, extension, speed, etc.) |
| 112 | + - rotational spring–dampers: |
| 113 | + - `/results/model/rsdas/<actuator_name>/` (torque components, angle, angular_velocity, etc.) |
| 114 | +- View/plot with HDFView or VS Code HDF5 extensions. |
| 115 | + - HDFView: `https://www.hdfgroup.org/downloads/hdfview/` |
| 116 | + |
| 117 | +<p align="center"><img src="docs/assets/img/h5_example.png" width="75%" /></p> |
| 118 | + |
| 119 | + |
| 120 | +## Run the included tests (from the Release ZIP, requires Python) |
| 121 | + |
| 122 | +Use either of the two options below. |
| 123 | + |
| 124 | +Option A — one-command setup (creates a local venv): |
| 125 | +1) Download and unzip the Release ZIP. |
| 126 | +2) Open PowerShell in the unzipped folder (you should see `bin/`, `tests/`, `data/`). |
| 127 | +3) Run: |
84 | 128 | ```powershell |
85 | | - cd build |
86 | | - ctest -C Release |
| 129 | + cd .\tests |
| 130 | + .\RUN-TESTS.ps1 |
87 | 131 | ``` |
| 132 | + - The script detects `bin\run_hydrochrono.exe`, prompts to create `.venv`, installs needed packages from PyPI, and runs the full suite headless. |
| 133 | + |
| 134 | +Option B — use your existing (conda/venv/system) Python: |
| 135 | +1) Ensure your environment has: `numpy`, `h5py`, `PyYAML`, `matplotlib`. |
| 136 | +2) From the unzipped folder run: |
| 137 | + ```powershell |
| 138 | + cd .\tests\run_hydrochrono |
| 139 | + # optional: python -m pip install -r requirements.txt |
| 140 | + python .\run_tests.py --all --exe ..\..\bin\run_hydrochrono.exe |
| 141 | + ``` |
| 142 | + |
| 143 | +What you’ll see: |
| 144 | +- The suite runs several regression tests for standard WEC verification cases (IEA sphere, OSWEC, RM3, F3OF). |
| 145 | +- PASS/FAIL summary prints in the console. |
| 146 | +- Results and plots are written under each case: `tests\run_hydrochrono\<case>\<test>\outputs\` (HDF5: `results.still.h5`, plots: `outputs\plots\*.png`). |
88 | 147 |
|
89 | | ---- |
| 148 | +<p align="center"><img src="docs/assets/img/oswec_decay_test_comparison.png" width="66%" /></p> |
90 | 149 |
|
91 | | -### Clean Build |
92 | 150 |
|
| 151 | +Run a single test (optional): |
93 | 152 | ```powershell |
94 | | -# From the project root |
95 | | -Remove-Item -Recurse -Force build |
96 | | -# then reconfigure/build |
97 | | -.\quick-build.ps1 -Clean |
| 153 | +cd .\tests\run_hydrochrono |
| 154 | +python .\run_tests.py --sphere-decay --exe ..\..\bin\run_hydrochrono.exe |
98 | 155 | ``` |
99 | 156 |
|
100 | | -For more detailed build instructions, including Visual Studio setup and running demos, see the [developer documentation](https://nrel.github.io/HydroChrono/developer_docs/build_instructions.html). |
| 157 | + |
| 158 | +## Developers |
| 159 | + |
| 160 | +- Full build and contribution docs: [Developer documentation](https://nrel.github.io/HydroChrono/developer_docs/build_instructions.html) |
| 161 | + |
| 162 | +## Papers |
| 163 | + |
| 164 | +- Ogden, 2023 — HydroChrono background, theory, and implementation details: [PDF](docs/assets/papers/Ogden2023%20-%20HydroChrono.pdf) |
| 165 | +- Ogden, 2025 — Automated design exploration with meshing, Capytaine, and HydroChrono in the loop: [PDF](docs/assets/papers/Ogden2025%20-%20Automated%20Design%20Exploration%20of%20TALOS%20Using%20TOP-WEC.pdf) |
0 commit comments