Description
First, thanks for the great ecosystem! ModelingToolkit really looks promising.
I think I run into a limitation with the current design of CellMLToolkit. From my understanding it simply parses the cellml document and directly parses and simplifies everything, followed by constructing the ODESystem. This fails if the cellml description is incomplete. However, I think it is a valid use case to connect the missing variables manually. To give a very simple example, let us consider a forced van der Pol oscillator.
<?xml version='1.0' encoding='UTF-8'?>
<model name="forced_oscillator" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
<units name="m_per_s">
<unit units="meter"/>
<unit exponent="-1" units="second"/>
</units>
<component name="system">
<variable initial_value="0.0" name="time" units="second"/>
<variable initial_value="1.0" name="mu" units="dimensionless"/>
<variable name="f" public_interface="in" units="meter"/>
<variable initial_value="0.0" name="x" public_interface="out" units="meter"/>
<variable initial_value="0.0" name="v" public_interface="out" units="m_per_s"/>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>time</ci>
</bvar>
<ci>x</ci>
</apply>
<ci>v</ci>
</apply>
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>time</ci>
</bvar>
<ci>v</ci>
</apply>
<apply>
<plus/>
<apply>
<minus/>
<apply>
<times/>
<ci>mu</ci>
<apply>
<minus/>
<cn cellml:units="dimensionless">1</cn>
<apply>
<times/>
<ci>x</ci>
<ci>x</ci>
</apply>
</apply>
<ci>v</ci>
</apply>
<ci>x</ci>
</apply>
<ci>f</ci>
</apply>
</apply>
</math>
</component>
</model>
Parsing this model fails, because f is not connected to anything:
using CellMLToolkit
ml = CellModel("forced_oscillator.cellml")
ERROR: value of system₊f is not found
However, it would be nice to have access to a partially parsed model, such that one could connect the missing components via ModelingToolkit.jl either directly by connecting the partial model with other partial models from other CellML files. To give a rough sketch on what I have in mind:
using ModelingToolkit, CellMLToolkit
mlc = CellModelComponent("forced_oscillator.cellml")
eqs = [
0 ~ mlcsys.system₊f - sin(mlc.sys.system₊xˍtimetime)
]
ml = finalize(mlc, eqs)