-
Notifications
You must be signed in to change notification settings - Fork 5
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
BMI docs page #1521
Merged
Merged
BMI docs page #1521
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f901b0c
First draft of BMI docs page
SouthEndMusic 2ec9b52
Merge branch 'main' into bmi_docs_page
SouthEndMusic 3a7948b
Comments adressed
SouthEndMusic 8f0e314
Merge branch 'main' into bmi_docs_page
SouthEndMusic 3028ea9
Indicate that Julia is column major
SouthEndMusic 9263f6a
Merge branch 'main' into bmi_docs_page
SouthEndMusic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Basic Model Interface (BMI) | ||
|
||
For runtime data exchange and coupling with other kernels, the Julia kernel is wrapped in a Python API (`ribasim_api`) which implements the Basic Modelling Interface [BMI](https://bmi-spec.readthedocs.io/en/latest/). | ||
|
||
## Functions | ||
|
||
The following functions are available to interact with the Ribasim model" | ||
|
||
signature | description | ||
------------------------- | ------------- | ||
`initialize(config_path)` | Initialize a model from the path to the TOML configuration file | ||
`finalize()` | Write all results to the configured files | ||
`get_current_time()` | Get the current time of the Ribasim simulation | ||
`get_end_time()` | Get the final time of the Ribasim simulation in seconds | ||
`get_start_time()` | Get the start time of the Ribasim simulation (`0.0`) | ||
`get_time_step()` | Get the proposed next internal Ribasim timestep | ||
`get_time_units()` | Get the time unit (`s`) | ||
`get_value_ptr(string)` | Get the pointer to a Ribasim internal array (see below) | ||
`update()` | Set a single Ribasim internal time step | ||
`update_until(time)` | Set Ribasim internal timesteps until the specified time | ||
|
||
Depending on what is specified in the Ribasim TOML configuration file, Ribasim can internally have adaptive (non-constant) timesteps. `update_until` will always try to progress the Ribasim simulation to exactly the time specified. This however can fail for algorithms that only support a fixed timestep if that timestep does not fit into the interval until the specified time an integer amount of times. | ||
|
||
## Data pointers | ||
|
||
The following internal array data is exposed via the BMI using `get_value_ptr(string)`: | ||
|
||
string | meaning | type | unit | sorted by | ||
------------------------------- | -------------------------------------- | ------- | ------------ | ---------- | ||
`basin.storage` | storage per basin | Float64 | $m^3$ | basin node ID | ||
`basin.level` | level per basin | Float64 | $m$ | basin node ID | ||
`basin.infiltration` | infiltration per basin | Float64 | $m^3 s^{-1}$ | basin node ID | ||
`basin.drainage` | drainage per basin | Float64 | $m^3 s^{-1}$ | basin node ID | ||
`basin.infiltration_integrated` | time integrated infiltration per basin | Float64 | $m^3$ | basin node ID | ||
`basin.drainage_integrated` | time integrated drainage per basin | Float64 | $m^3$ | basin node ID | ||
`basin.subgrid_level` | subgrid level | Float64 | $m$ | subgrid ID | ||
`user_demand.demand` | demand per node ID per priority | Float64 | $m^3 s^{-1}$ | user_demand node ID, priority index | ||
`user_demand.realized` | time integrated intake flow per user | Float64 | $m^3$ | user_demand node ID | ||
|
||
Additional notes: | ||
|
||
- `user_demand.demand` yields the only 2D array, the other arrays are 1D. This array is indexed as `(node_idx, priority_idx)` | ||
- The index of e.g. basins and user demand nodes needs to be inferred from the Ribasim input. The same holds for `priority_idx`, which is global over all subnetworks | ||
- The `*_integrated` values are integrated from the start of the simulation onward. It might be beneficial to reset this to $0$ at certain times for long simulations to avoid loss of accuracy. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend to add a note indicating that the flows are averaged over the timestep (if I am correct from t-1 tot t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is different between what is exposed via the BMI and what is in the output. The output gives averaged values, the BMI exposes an integrated value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way the coupler has the freedom to decide over which period to average, and Ribasim doesn't have to worry about whether the coupler accesses the data before or after averaging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you already indicate that `*_integrated' is the accumulation.
but your description of the other variables can be more precise, by indicating it is instantaneous, averaged or whatever it is. It now is still a bit open-ended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, that can be its own column. The differences between the BMI exposed data and the output are also worth mentioning