Skip to content

Commit

Permalink
Tries
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Aug 20, 2024
1 parent 54a92ab commit a41363f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions core/src/Ribasim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ using MetaGraphsNext:
using NonlinearSolve: solve
using PreallocationTools: LazyBufferCache
using OrdinaryDiffEq:
OrdinaryDiffEq, OrdinaryDiffEqRosenbrockAdaptiveAlgorithm, get_du, SteadyStateProblem
OrdinaryDiffEq,
OrdinaryDiffEqRosenbrockAdaptiveAlgorithm,
get_du,
SteadyStateProblem,
ImplicitEuler
using SciMLBase:
init,
solve!,
Expand All @@ -72,7 +76,7 @@ using SciMLBase:
ODESolution,
VectorContinuousCallback,
get_proposed_dt
using SteadyStateDiffEq: DynamicSS
using SteadyStateDiffEq: DynamicSS, SSRootfind
using SQLite: SQLite, DB, Query, esc_id
using StructArrays: StructVector
using Tables: Tables, AbstractRow, columntable
Expand Down
8 changes: 7 additions & 1 deletion core/src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,14 @@ function Model(config::Config)::Model
(; basin) = parameters

# Compute steady state
println("Computing steady state...")
parameters.fixed_t[] = 0.0
sol = solve(SteadyStateProblem(prob), DynamicSS())
sol = solve(
SteadyStateProblem(RHS, u0, parameters),
DynamicSS(ImplicitEuler());
abstol = 1e-10,
reltol = 1e-10,
)
parameters.fixed_t[] = -1.0

# Check steady state
Expand Down
6 changes: 6 additions & 0 deletions core/src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ function water_balance!(
# Formulate du (controlled by PidControl)
formulate_du_pid_controlled!(du, graph, pid_control)

if eltype(du) == Float64
println(p.basin.node_id[argmax(du.storage)])
end
#println(sum(u.storage))
#println("$(sqrt(sum(du .^ 2))),")

return nothing
end

Expand Down
2 changes: 1 addition & 1 deletion core/src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ function get_jac_prototype(du0, u0, p, t0)
TracerSparsityDetector(),
)
p.all_nodes_active[] = false
jac_prototype
Float64.(jac_prototype)
end

# Custom overloads
Expand Down

0 comments on commit a41363f

Please sign in to comment.