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

Add some basic concentration tests. #1934

Merged
merged 3 commits into from
Nov 14, 2024
Merged
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 core/src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ function FlatVector(saveval::Vector{<:SavedFlow}, sym::Symbol)
v = isempty(saveval) ? Vector{Float64}[] : getfield.(saveval, sym)
FlatVector(v)
end
FlatVector(v::Vector{Matrix{Float64}}) = FlatVector(vec.(v))

"""
Function that goes smoothly from 0 to 1 in the interval [0,threshold],
Expand Down
5 changes: 5 additions & 0 deletions core/test/run_models_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ end

# flows are recorded at the end of each period, and are undefined at the start
@test unique(table.time) == Ribasim.datetimes(model)[1:(end - 1)]

@test isfile(joinpath(dirname(toml_path), "results/concentration.arrow"))
table = Ribasim.concentration_table(model)
@test "Continuity" in table.substance
@test all(isapprox.(table.concentration[table.substance .== "Continuity"], 1.0))
end

@testitem "basic arrow model" begin
Expand Down
3 changes: 2 additions & 1 deletion python/ribasim_testmodels/ribasim_testmodels/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pandas as pd
import ribasim
from ribasim.config import Node
from ribasim.config import Experimental, Node
from ribasim.input_base import TableModel
from ribasim.nodes import (
basin,
Expand All @@ -26,6 +26,7 @@ def basic_model() -> ribasim.Model:
starttime="2020-01-01",
endtime="2021-01-01",
crs="EPSG:28992",
experimental=Experimental(concentration=True),
)
model.logging = ribasim.Logging(verbosity="debug")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import pandas as pd
from ribasim.config import Node
from ribasim.config import Experimental, Node
from ribasim.model import Model, Solver
from ribasim.nodes import (
basin,
Expand Down Expand Up @@ -604,6 +604,7 @@ def continuous_concentration_condition_model() -> Model:
endtime="2020-02-01",
crs="EPSG:28992",
solver=Solver(saveat=86400 / 8),
experimental=Experimental(concentration=True),
)

basi = model.basin.add(
Expand Down