setting initial conditions #3781
Unanswered
francispoulin
asked this question in
Computational science!
Replies: 1 comment 1 reply
-
do you mean something like this? initial_conditions = Dict(
1 => (; a = 1, b = 2, c = 3),
2 => (; a = 4, b = 5, d = 3),
)
function test(; a = 1, b = 2, c = 3, d = 4)
@show a, b, c, d
end where julia> test(; initial_conditions[2]...)
(a, b, c, d) = (4, 5, 3, 3)
(4, 5, 3, 3)
julia> test(; initial_conditions[1]...)
(a, b, c, d) = (1, 2, 3, 4)
(1, 2, 3, 4) In this way, you could write up all your cases in the one dictionary initial_conditions = Dict(
1 => (; P = 0.03, Z = 0.03, NO₃ = 4.0, NH₄ = 0.05),
2 => (; P = 0.03, Z = 0.03, N = 4.0, T = 10),
) and then for i in eachindex(models)
set!(models[i]; initial_conditions[i]...)
end would save you the if condition but not much more... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am currently using
OceanBioME
to test different models of biogeochemistry.I set set things up to loop over the different models and have been able to do everything clearly except for the following,
Is there a way I can define a dictionary (or something else) and store the initial conditions in there and then specify that in set?
The problem is that there are different fields for the two cases so the initial conditions must be different.
Beta Was this translation helpful? Give feedback.
All reactions