-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
parameter as a function of other parameters #3309
Comments
do you need to do |
To add, the main purpose is to perform parameter estimation to determine |
In this case, |
The same for |
I think that parameter dependencies or equations involving parameters are what would you need to express that. See https://docs.sciml.ai/ModelingToolkit/stable/tutorials/initialization/#Initialization-of-parameters for more about this. The solution proposed above should be equivalent to parameter initialization if I understand correctly. |
this does work but only in initialization, then @mtkmodel CST_2 begin
@structural_parameters begin
NC = 1
end
@parameters begin
α = 0.5
Ve = 1.0
cin[1:NC] = [1.0 for i in 1:NC]
end
@components begin
T1 = CST(NC = NC, V = α*Ve)
T2 = CST(NC = NC, V = (1-α)*Ve)
end
@equations begin
T1.cin ~ cin
T2.cin ~ cin
end
end
@mtkbuild m = CST_2()
u0 = unknowns .=> 0.0
prob = ODEProblem(m, u0, (0.0, 5.0))
getter = getp(m, [m.T.V, m.C.V])
setter! = setp(m, [m.α, m.Ve])
solve(prob, Tsit5())
getter(prob) # [0.5, 0.5]
setter!(prob, [0.25, 1.0])
solve(prob, Tsit5())
getter!(prob) # [0.5, 0.5] This is because the expression provided is only valid in the initialization step, the parameter itself does not remain an expression dependent of other parameters, that's why it's not updated after several |
Question❓
I have a model of a continuously stirred tank (CST):
I also have a model of a Plugflow Device (PF) but it's a bit large and is not that relevant for the question. The important part is that also has a parameter
V
I wanted to simulate the hydrodynamic behaviour of a fluid in the tubes of an equipment by assuming that behaviour is a mix of CST and PF, in the sense that a part of the equipment volume behaves as CST and the rest as PF, so I did the following:
This approach does not work because the equations involving the parameters do not go to the$N$ variables and $N+2$ equations. How would I solve this without changing
observed
section, which leaves me withC.V
andT.V
to variables?The text was updated successfully, but these errors were encountered: