Sorry, this is my first time working with modelingtoolkit.jl and controlsystemsmtk.jl. I am studying the issue you linked.
In the meantime here is all the code relevant to the model here:
Components:
# Capacitors
@named Ci = Capacitor(C=3)
@named Ce = Capacitor(C=1)
@named Ch = Capacitor(C=2)
# Resistances
@named Rih = Resistor(R=0.1)
@named Rie = Resistor(R=0.5)
@named Rea = Resistor(R=3)
# Current sources
@named Φhp_c = Current()
@named Φcv_c = Current()
@named Ta_in = Constant(k=Tambient)
@named Ta = Voltage()
@named gnd = Ground()
Some dummy input signals:
hp_in_val = 100*randn(10)
Φhp(t) = max(t >= 10 ? hp_in_val[end] : hp_in_val[Int(floor(t)) + 1], 0)
@register_symbolic Φhp(t)
@named Φhp_ctrl = TimeVaryingFunction(Φhp)
cv_in_val = 500*randn(10)
Φcv(t) = max(t >= 10 ? cv_in_val[end] : cv_in_val[Int(floor(t)) + 1], 0)
@register_symbolic Φcv(t)
@named Φcv_ctrl = TimeVaryingFunction(Φcv)
Connections:
eqs = [
# Ci -> Rih, Rie
connect(Ci.p, Rie.p),
connect(Ci.p, Rih.p),
# heat sources
# Φh, Φcv -> Ch
connect(Φhp_c.n, Ch.p),
connect(Φcv_c.n, Ch.p),
# Ch -> Rih
connect(Ch.p, Rih.n),
# Ce -> Rie, Rea
connect(Ce.p, Rie.n),
connect(Ce.p, Rea.p),
# Ta -> Rea
connect(Ta.p, Rea.n),
# input to source connections
connect(Ta_in.output, Ta.V),
connect(Φcv_ctrl.output, Φcv_c.I),
connect(Φhp_ctrl.output, Φhp_c.I),
# ground connections
connect(gnd.g, Ci.n),
connect(gnd.g, Ce.n),
connect(gnd.g, Ch.n),
connect(gnd.g, Φhp_c.p),
connect(gnd.g, Φcv_c.p),
connect(gnd.g, Ta.n),
];
components = [
Ci, Ce, Ch,
Rih, Rie, Rea,
Ta_in, Ta,
Φhp_c, Φcv_c,
Φhp_ctrl, Φcv_ctrl,
gnd,
];
Problem definition:
@named model = ODESystem(eqs, t, systems = components)
print(equations(model))
sys = structural_simplify(model, allow_parameter=true)
prob = ODEProblem(sys, Pair[], (0, 10.0))
Try to find the state-space model:
using ControlSystemsMTK, ControlSystemsBase, RobustAndOptimalControl
# inputs = Φhp, Φcv
# outputs = Ci.v, Ce.v, Ch.v
RobustAndOptimalControl.named_ss(model, [Φhp_ctrl.output.u, Φcv_ctrl.output.u], [Ci.v, Ce.v, Ch.v])