-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
BifKit extension, conservation laws, and changing initial conditions #1095
Comments
This doesn't work, but at least it errors: rn = @reaction_network begin
@parameters M
@species A(t) = M
(1.0,1.0), A <--> B
end
osys = complete(convert(ODESystem, rn; remove_conserved = true))
u_guess = [osys.B => 2.0]
p_start = [osys.M => 3.0]
bprob = BifurcationProblem(osys, u_guess, p_start, osys.M; plot_var = osys.A) giving ERROR: ArgumentError: SymbolicUtils.BasicSymbolic{Real}[M] are either missing from the variable map or missing from the system's unknowns/parameters list.
Stacktrace:
[1] throw_missingvars_in_sys(vars::Vector{SymbolicUtils.BasicSymbolic{Real}})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/XHRvt/src/utils.jl:765
[2] promote_to_concrete(vs::Vector{SymbolicUtils.BasicSymbolic{Real}}; tofloat::Bool, use_union::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/XHRvt/src/utils.jl:784
[3] varmap_to_vars(varmap::Vector{…}, varlist::Vector{…}; defaults::Dict{…}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/XHRvt/src/variables.jl:171
[4] BifurcationProblem(::NonlinearSystem, ::Vector{…}, ::Vector{…}, ::Num; plot_var::Num, record_from_solution::Function, jac::Bool, kwargs::@Kwargs{})
@ MTKBifurcationKitExt ~/.julia/packages/ModelingToolkit/XHRvt/ext/MTKBifurcationKitExt.jl:104
[5] BifurcationProblem(::ODESystem, ::Vector{Pair{Num, Float64}}, ::Vararg{Any}; kwargs::@Kwargs{plot_var::Num})
@ MTKBifurcationKitExt ~/.julia/packages/ModelingToolkit/XHRvt/ext/MTKBifurcationKitExt.jl:152
[6] top-level scope
@ REPL[35]:1
Some type information was truncated. Use `show(err)` to see complete types.
|
using Catalyst, BifurcationKit, Plots
rn = @reaction_network begin
(1.0,1.0), A <--> B
end
osys = structural_simplify(convert(ODESystem, rn; remove_conserved = true))
u_guess = [osys.A => 1.0, osys.B => 2.0]
p_start = [osys.Γ[1] => 3.0] # A = 1.0 then
bprob = BifurcationProblem(osys, u_guess, p_start, osys.Γ[1]; plot_var = osys.A)
p_span = (3.0, 20.) # A goes from 1.0 to 18.0
opts_br = ContinuationPar(p_min = p_span[1], p_max = p_span[2], max_steps = 1000)
bif_dia = bifurcationdiagram(bprob, PALC(), 2, opts_br; bothside = true)
plot(bif_dia; xlabel = "A(0) + B(0)", label = "A(t)") Actually this is right and I'm just being dumb. So that is good. |
Seems like we need to disallow changing initial conditions and/or the conservation constant in the current extension setup. |
@rveltz is there any way you could use |
Do you want the same name because there is I was worried about type piracy so that s why the new name. I can name it as in SciMLBase if needed |
Does that hook into the symbolic |
no, it does not extend it |
Yeah, so I suspect that if one has parameters that are functions of initial conditions, initial conditions that are functions of parameters, or parameters that are functions of other parameters, one may be likely to get incorrect results (because these may need to get updated as the bifurcation parameter changes). |
If this https://github.com/SciML/SciMLBase.jl/blob/0f8ec1f501e916e5f8c39d94ddc02757d574cc9c/src/remake.jl#L27 is enough, it wont take me long. But if you want this one then I have to think |
Maybe this would be easier by having a |
I guess trying to worry about changing a parameter in an initial condition is a bit much, but I'll try to work up a simple example where there are dependent parameters but things aren't updating correctly when the bifurcation parameter changes. |
OK! |
Yeah, this is the kind of issue I was worried about. Thanks for the simple example. |
We need to check if it is actually working when one is using an initial condition as the bifurcation parameter. I suspect that it has no way to know it needs to update the conserved constant in this case (i.e. it is just changing that parameter in the underlying parameter vector), and hence will give incorrect results.
The text was updated successfully, but these errors were encountered: