Hi, how would I make the parameter map for running a modelingtoolkit system using an optional defaults approach like
fun(sys::ODEsystem; p1=1,p2=0.2,p3=0.47)
# Goal: end up with an assignment map that uses the defaults in the function header which can be passed to ODEProblem
# I tried these:
p=[p1=>p1,p2=>p2,p3=>p3] # this does not work
p=[eval(Symbol(x)) for x in parameters(sys)] # Neither does this
u0=[X=>0]
prob=ODEProblem(sys,u0,tspan,p);
return solve(prob,Tsit5(),saveat=1.0)
end
*Note: one needs a map [x=>value] since the order of the parameters is not easily predictable unless you iterate through parameters(sys) as I did here (but apparently I am somehow not able to get the value from the defaults given in the function header…
The variables are just Julia variables, so they are global only if you make them global. But the default is tagged metadata, so if you use that variable it will bring along its metadata.