Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline coupling with Delwaq #1137

Merged
merged 45 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c61348e
Implement external timeseries and adds concentration field to Basin.
evetion Feb 12, 2024
a22631b
Code dump for Delwaq coupling.
evetion Feb 16, 2024
2ab71b5
Generate correct substances.
evetion Feb 16, 2024
4494cb0
Parse Delwaq output and save back to Ribasim model.
evetion Feb 17, 2024
fbdd56d
Merged main.
evetion Mar 4, 2024
5d7b84f
Merged main.
evetion Mar 13, 2024
0e3659e
Merged main.
evetion Mar 13, 2024
bb85cfe
Merge main.
evetion Mar 13, 2024
d51e422
New tables.
evetion Mar 14, 2024
44f562f
Add dependencies to pixi.
evetion Mar 15, 2024
632804d
Fix boundaries Delwaq.
evetion Mar 15, 2024
6fe6e5c
Allow running gen_delwaq.py from other dirs
visr Mar 18, 2024
ea655de
Merge branch 'main' into feat/delwaq-coupling
visr Mar 18, 2024
8bf8923
Reset pixi files to main
visr Mar 18, 2024
e7c3cba
Add jinja2 again
visr Mar 18, 2024
0072b09
No need for MeshKernel
visr Mar 18, 2024
f3366ff
Don't use node index
visr Mar 18, 2024
b0d870a
Fix network for node ordering
visr Mar 19, 2024
b9658e4
Add extra timestep at the end
visr Mar 19, 2024
c0798a0
Merge main.
evetion Apr 18, 2024
04b23d0
Merge main.
evetion Apr 20, 2024
17d8adf
Merge main.
evetion May 6, 2024
d1d38e7
Happy mypy.
evetion May 6, 2024
cf81086
Simplify network.
evetion May 8, 2024
9a74fd4
refine readme.md
Jingru923 May 13, 2024
97a9e8f
Merge main.
evetion May 16, 2024
04f0050
Run Delwaq on Teamcity.
evetion May 16, 2024
d5b7e59
Add parsing test.
evetion May 16, 2024
ed9faa9
Merge main.
evetion May 16, 2024
dc1a748
Merge main.
evetion May 16, 2024
64362b4
Merge main.
evetion May 16, 2024
c8b033d
Merge main.
evetion May 16, 2024
e5cd1bb
Fix some errors.
evetion May 16, 2024
de9052c
Merge main.
evetion May 17, 2024
2ae4fd6
Merge main.
evetion May 17, 2024
9cf68ec
Merge main.
evetion May 17, 2024
077b6fb
Merge remote-tracking branch 'origin/main' into feat/delwaq-coupling
evetion May 17, 2024
80d160a
Change input path on Windows. Allow selection of test model.
evetion May 17, 2024
333e2ac
Removed debug line.
evetion May 17, 2024
44fb105
Make mypy happy.
evetion May 17, 2024
8ea2149
Update coupling/delwaq/README.md
evetion May 17, 2024
6b97f73
Apply suggestions from code review
evetion May 17, 2024
4762e4a
Further addressed comments.
evetion May 17, 2024
e27bb59
Update lock.
evetion May 17, 2024
faf3374
Add documentation.
evetion May 17, 2024
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
5 changes: 5 additions & 0 deletions coupling/delwaq/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model
*.map
*.nc
*.pdf
*.out
47 changes: 47 additions & 0 deletions coupling/delwaq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Ribasim Delwaq coupling
This folder contains scripts to setup a Delwaq model from a Ribasim model, and to update the Ribasim model with the Delwaq output.

## Steps
Setup a Ribasim model with substances and concentrations and run it. For example, we can run the basic testmodel with some default concentrations using the Ribasim CLI:

```bash
ribasim generated_testmodels/basic/ribasim.toml
```

Afterwards we can use the Ribasim model and the generated output to setup a Delwaq model using Python from this folder.

```python
from pathlib import Path

from generate import generate
from parse import parse
from util import run_delwaq

toml_path = Path("generated_testmodels/basic/ribasim.toml")

graph, substances = generate(toml_path)
run_delwaq()
model = parse(toml_path, graph, substances)
```

The resulting Ribasim model will have an updated `model.basin.concentration_external` table with the Delwaq output.
We also store the same table in the `basin_concentration_external.arrow` file in the results folder, which can be
referred to using the Ribasim config file.

## Running Delwaq
If you have access to a DIMR release, you can find the Delwaq executables in the `bin` folder. You can run a model directly with the `run_dimr.bat` script, and providing the path to the generated `.inp` file to it. In `util.py` we provide a `run_delwaq` (as used above) that does this for you, if you set the `D3D_HOME` environment variable to the path of the unzipped DIMR release, using the generated `model/ribasim.inp` configuration file.

### Running Delwaq with Docker
Alternative to running Delwaq with a DIMR release, you can also run the Delwaq model in a Docker container if you are a Deltares employee.
First install WSL and install docker in WSL, then create a CLI secret and log into the Deltares containers. To install docker in WSL and create a CLI secret for the following steps, follow this guide https://publicwiki.deltares.nl/display/Delft3DContainers/.

Log into Deltares containers in docker:
```bash
docker login containers.deltares.nl # use your deltares email + token
```

You can now run the Delwaq model from this directory.
```bash
docker run --mount type=bind,source="$(pwd)/model",target=/mnt/myModel \
--workdir /mnt/myModel containers.deltares.nl/delft3d/delft3dfm run_dimr.sh
```
Loading