Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/atol' into equal_ratio_allocatio…
Browse files Browse the repository at this point in the history
…n_objective
  • Loading branch information
SouthEndMusic committed Apr 15, 2024
2 parents ab91921 + 2adf139 commit 430e8b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "22708fb864a341d70b001d75765852e92f1f5399"
project_hash = "122f7ec8a573942606ded1bed87e60f2356f603a"

[[deps.ADTypes]]
git-tree-sha1 = "016833eb52ba2d6bea9fcb50ca295980e728ee24"
Expand Down Expand Up @@ -401,9 +401,9 @@ version = "6.149.0"

[[deps.DiffEqCallbacks]]
deps = ["DataStructures", "DiffEqBase", "ForwardDiff", "Functors", "LinearAlgebra", "Markdown", "NonlinearSolve", "Parameters", "RecipesBase", "RecursiveArrayTools", "SciMLBase", "StaticArraysCore"]
git-tree-sha1 = "a731383bbafb87d496fb5e66f60c40e4a5f8f726"
git-tree-sha1 = "173d6a313878635b6c764163f639ac2d5f201fdc"
uuid = "459566f4-90b8-5000-8ac3-15dfb0a30def"
version = "3.4.0"
version = "3.6.0"

[deps.DiffEqCallbacks.weakdeps]
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand Down
2 changes: 1 addition & 1 deletion core/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DataInterpolations = "4.4"
DataStructures = "0.18"
Dates = "<0.0.1,1"
Dictionaries = "0.3.25, 0.4"
DiffEqCallbacks = "=3.4.0"
DiffEqCallbacks = "3.6"
Documenter = "0.27,1"
EnumX = "1.0"
FiniteDiff = "2.21"
Expand Down
6 changes: 5 additions & 1 deletion core/src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function Model(config::Config)::Model
TimerOutputs.enable_debug_timings(Ribasim) # causes recompilation (!)
end

t_end = seconds_since(config.endtime, config.starttime)
if t_end <= 0
error("Model starttime is not before endtime.")
end

# All data from the database that we need during runtime is copied into memory,
# so we can directly close it again.
db = SQLite.DB(db_path)
Expand Down Expand Up @@ -108,7 +113,6 @@ function Model(config::Config)::Model
# Integrals for PID control
integral = zeros(length(parameters.pid_control.node_id))
u0 = ComponentVector{Float64}(; storage, integral)
t_end = seconds_since(config.endtime, config.starttime)
# for Float32 this method allows max ~1000 year simulations without accuracy issues
@assert eps(t_end) < 3600 "Simulation time too long"
t0 = zero(t_end)
Expand Down
6 changes: 4 additions & 2 deletions core/test/allocation_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ end
# lower the subnetwork demands
@test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] [3.1, 4.0, 0.0] atol =
1e-4
@test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))] [0.004, 0.0, 0.0]
@test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] [0.001, 0.001]
@test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))] [0.004, 0.0, 0.0] atol =
1e-4
@test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] [0.001, 0.001] atol =
1e-4
end

@testitem "Allocation level control" begin
Expand Down

0 comments on commit 430e8b5

Please sign in to comment.