Skip to content

Support storage column in basin profile - #2278

Merged
verheem merged 37 commits into
mainfrom
Ribasim#2254-Support-storage-column-in-Basin-profile
Jun 3, 2025
Merged

verheem merged 37 commits into
mainfrom
Ribasim#2254-Support-storage-column-in-Basin-profile

Conversation

@verheem

@verheem verheem commented May 15, 2025

Copy link
Copy Markdown
Contributor

Fixes #2254

Notes:

  • supports now 3 cases of initialisation of Basins with either level-area, level-storage or both relations as input
  • we interpolate level-area piecewise linear and storage-level is always done using the inverse of the integral of area-level, no matter how the basin was initialized

@SouthEndMusic SouthEndMusic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good! I left a few comments. I'm also missing an update of the Basin documentation in basin.qmd.

Comment thread core/src/Ribasim.jl Outdated
Comment thread core/src/read.jl
Comment thread core/src/read.jl
Comment thread core/src/read.jl Outdated
Comment thread core/src/read.jl Outdated
Comment thread core/src/validation.jl Outdated

"""
Validated the initialisation of basins. Each basin at least need a level-area or level storage relationship.
We recommend to initialise all basins in the same way, which can be level-area, level-storage or level-area-storage.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to have this here, but this is typically something that you also put into the documentation.

Comment thread core/src/validation.jl Outdated
Comment thread core/src/validation.jl Outdated
Comment thread core/test/run_models_test.jl
Comment thread python/ribasim_testmodels/ribasim_testmodels/basic.py Outdated
@SouthEndMusic
SouthEndMusic marked this pull request as ready for review May 20, 2025 13:07
verheem and others added 3 commits May 20, 2025 15:10
Co-authored-by: Bart de Koning <74617371+SouthEndMusic@users.noreply.github.com>
@evetion evetion changed the title Ribasim#2254 support storage column in basin profile Support storage column in basin profile May 21, 2025
Comment on lines +679 to +700

@testitem "init_basin_only_storage" begin
toml_path = normpath(
@__DIR__,
"../../generated_testmodels/basic_basin_only_storage/ribasim.toml",
)
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model isa Ribasim.Model
@test success(model)
end

@testitem "init_basin_only_area" begin
toml_path =
normpath(@__DIR__, "../../generated_testmodels/basic_basin_only_area/ribasim.toml")
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model isa Ribasim.Model
@test success(model)
end

@testitem "init_basin_both_area_and_storage" begin

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if you don't have model specific tests but just want to make sure the models run without error, there is no need to add them here, because all testmodels will be run as part of

Ribasim/pixi.toml

Lines 166 to 169 in b50232d

ribasim-core-testmodels = { cmd = "julia --project --threads=4 utils/testmodelrun.jl", depends-on = [
"generate-testmodels",
"initialize-julia",
] }
.

@SouthEndMusic SouthEndMusic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some final comments, nice work!

Comment thread .vscode/extensions.json
Comment thread core/src/read.jl
end

function Basin(db::DB, config::Config, graph::MetaGraph)
function Basin(db::DB, config::Config, graph::MetaGraph)::Basin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit inconsistent to only have this here. Either do it for all node types or none of them. We don't need it, so it's fine to leave this out.

Comment thread core/src/read.jl
Comment thread core/src/read.jl
profiles::StructVector{BasinProfileV1},
)::Nothing
for (i, group) in enumerate(IterTools.groupby(row -> row.node_id, profiles))
group_area = getproperty.(group, :area)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evetion @visr do you mind that there are now 2 places where profiles is parsed?

Comment thread core/src/validation.jl
Comment thread docs/reference/node/basin.qmd
Comment thread docs/reference/node/basin.qmd
Comment thread docs/reference/node/basin.qmd
@verheem
verheem merged commit dcdc46b into main Jun 3, 2025
@verheem
verheem deleted the Ribasim#2254-Support-storage-column-in-Basin-profile branch June 3, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support storage column in Basin / profile

3 participants