Skip to content

Commit

Permalink
Add some basic concentration tests. (#1934)
Browse files Browse the repository at this point in the history
Ideally we merge this before #1933 and #1929, so we know they don't
break anything.

---------

Co-authored-by: Martijn Visser <[email protected]>
  • Loading branch information
evetion and visr authored Nov 14, 2024
1 parent 8c96dfc commit 47b4fa7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
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

0 comments on commit 47b4fa7

Please sign in to comment.