We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug 🐞
If I have a stream connector for a concentration, sol[inlet.concentration] should work. It doesn't, but it works for sol.outlet.concentration.
stream
sol[inlet.concentration]
sol.outlet.concentration
Minimal Reproducible Example 👇
using ModelingToolkit, DifferentialEquations using ModelingToolkit: t_nounits as t, D_nounits as D @connector SolutionPin begin flow(t), [connect=Flow] conc(t), [connect=Stream] dummy(t) end @mtkmodel Source begin @components begin outlet = SolutionPin() end @equations begin outlet.flow ~ -10 outlet.conc ~ 0.3 end end @mtkmodel Tank begin @components begin inlet = SolutionPin() end @variables begin product_mass(t) = 0 conc(t) end @equations begin D(product_mass) ~ inlet.flow * instream(inlet.conc) conc ~ instream(inlet.conc) # obviously not physically correct end end @mtkmodel Room begin @components begin src = Source() tank = Tank() end @equations begin connect(src.outlet, tank.inlet) end end @mtkbuild room = Room() prob = ODEProblem(room, [], (0, 10.0), []) sol = solve(prob) sol[room.src.outlet.conc] # works sol[room.src.inlet.flow] # works sol[room.tank.inlet.conc] # ERROR: ArgumentError: tank₊inlet₊conc(t) is neither an observed nor an unknown sol[room.tank.conc] # works
Adding instream() does not work either (it shouldn't be required anyway).
instream()
The text was updated successfully, but these errors were encountered:
instream
The problem is that tank.inlet.conc is not present in the simplified system, so MTK doesn't know how to compute it.
tank.inlet.conc
julia> room Model room: Equations (1): 1 standard: see equations(room) Unknowns (1): see unknowns(room) tank₊product_mass(t) [defaults to 0] Observed (6): see observed(room) julia> observed(room) 6-element Vector{Equation}: src₊outlet₊flow(t) ~ -10.0 src₊outlet₊conc(t) ~ 0.3 tank₊inlet₊dummy(t) ~ -0.0 tank₊inlet₊flow(t) ~ -src₊outlet₊flow(t) tank₊conc(t) ~ src₊outlet₊conc(t) src₊outlet₊dummy(t) ~ tank₊inlet₊dummy(t) julia> equations(room) 1-element Vector{Equation}: Differential(t)(tank₊product_mass(t)) ~ tank₊inlet₊flow(t)*src₊outlet₊conc(t)
Sorry, something went wrong.
Seems like a stream connector bug?
Yeah likely. I'm looking into it.
AayushSabharwal
No branches or pull requests
Describe the bug 🐞
If I have a
stream
connector for a concentration,sol[inlet.concentration]
should work. It doesn't, but it works forsol.outlet.concentration
.Minimal Reproducible Example 👇
Adding
instream()
does not work either (it shouldn't be required anyway).The text was updated successfully, but these errors were encountered: