-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom initial condition equations for an ODESystem
#2382
Custom initial condition equations for an ODESystem
#2382
Conversation
Yeah let's keep it out of the docs for now until it's tried a bit more but this looks right. |
If I understand these changes, the initial equations are being associated with variables. This doesn't feel right to me. From the test: (x(t) = dx ~ dx_ss), [guess = 0.5]
(y(t) = dy ~ 0), [guess = -0.5] These equations have nothing to do with these variables. Why associated them like this? Also, what happens when you want to add initial equations to a system where the variables have already been defined? Here is an example of exactly this from my book: model QuiescentModelWithInheritance "Steady state model with inheritance"
extends ClassicModel;
initial equation
der(x) = 0;
der(y) = 0;
end QuiescentModelWithInheritance; Is there a reason we are associated these equation directly with variables? I just don't think this would scale very well. Why not simple include an additional field in # Define the Lotka Volterra system which begins at steady state
@parameters t
pars = @parameters a=1.5 b=1.0 c=3.0 d=1.0 dx_ss = 1e-5
vars = @variables begin
dx(t),
dy(t),
x(t), [guess = 0.5]
y(t), [guess = -0.5]
end
D = Differential(t)
init_eqs = [dx ~ dx_ss
dy ~ 0]
eqs = [dx ~ a * x - b * x * y
dy ~ -c * y + d * x * y
D(x) ~ dx
D(y) ~ dy]
@named sys = ODESystem(eqs, t, vars, pars; init_eqs=init_eqs) |
Just use the defaults as before. It still does the equivalent thing. |
| Just use the defaults as before. It still does the equivalent thing. @ChrisRackauckas , I don't really understand this comment. I don't understand what you mean by before. There was not previously a way to specify initial condition equations, right? Keep in mind, I am not talking about how to programmatically formulate |
No, specification of initial equations existed before and this uses the same representation without change. All this does is add the building of a nonlinear system from them. |
Can someone (@MarcBerliner , @ChrisRackauckas , @bradcarman ) show me an example of formulating a non-linear system that combines the differential equations and the initial equations "[using] the defaults as before"? |
Previously, we could only specify a linear system of initial equations for IVPs. For example, vars = @variables begin
dx(t),
dy(t),
x(t) = 1, [guess = 0.5]
y(t) = 2, [guess = -0.5]
end creates a system equivalent to vars = @variables begin
dx(t),
dy(t),
(x(t) = x ~ 1), [guess = 0.5]
(y(t) = y ~ 2), [guess = -0.5]
end where This PR allows the user to write arbitrary initial condition equations. The line |
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
This change allows specifying custom initial condition equations for an ODE model which requires metadata for the initial
guess
. Theinitializesystem
function takes anODESystem
as an argument and returns aNonlinearSystem
.TODO: I added docs for the
guess
variable metadata, but this still needs docs forinitializesystem
. Where is an appropriate place for these docs?https://github.com/JuliaComputing/JuliaSim.jl/issues/747