I am curious about the expected behavior of MTK when composing large models from sub-models. I’m hoping to better identify and understand which sub-models I’ve designed poorly.
Sometimes when I make an ODESystem, I can structural_simplify() the system, I can solve() the ODEProblem with the structural_simplified system, but cannot solve() it with the original system. Is this acceptable, or is it indicative of a poorly designed MTK ODESystem? Should a correctly defined MTK ODESystem always be solvable in an ODEProblem prior to structural simplification, or are there some ODESystems that must be structural_simplified?
The states and equations of a structurally_simplified ODESystem must be equal. Is that also true for a well designed system before it is strucuturally_simplified? Is that only true if you want to solve an ODEProblem with it? Does that change for a DAE?
If I create an ODESystem that has input states defined, but not connected to anything, can I make this ODESystem, structural_simplify the system, create an ODEProblem of the structural_simplified system and solve the ODEProblem without making those connections first?
Great, thanks for the response Chris! So for example, if I have a sub-model with 9 states, 3 are input, 3 are output, and 3 are internal with initial conditions supplied, sounds like the right way to unit test this model is to provide the input connections to constants (or steps or some other source) first. I wasn’t sure if supplying initial conditions to those inputs would be sufficient to make the sub-model run standalone.
Follow up question:
If all inputs are provided, and both the input subsystem and the subsystem being tested are defined well, 1. Should the combined system be solvable prior to structural_simplification?
2. Should the states and equations for the combined system be equal prior to structural_simplification?
Of course I plan to structural_simplify all of my models. Just trying to see if I can use the pre-simplified model to determine if it’s been poorly defined. I have made systems to test these ideas but sometimes feel like I’m just getting lucky when it works without really understanding why. Just trying to gain that understanding and intuition about MTK systems.
Actually another follow up question:
3. Do MTK models need to be structurally_simplified, can any well defined model be ran without structural_simplification?
Again, I think SS is one of the coolest features of MTK and plan to use it, and I don’t have a good use case for this scenario. Just curious.
Kind of but not really. The main thing is numerical difficulties. If your DAE has index > 1 then most ODE solvers cannot solve it because of numerical issues. Thus one of the biggest reasons for structural simplification is that it performs an index reduction which removes Jacobian singularities and thus makes it easier to simulate. So in theory any system can be solved before simplification, but in practice there’s a large class of models which cannot due to this index phenomena.