I'm trying to model a natural convection case using Modelica.Media package and I've set up a simple grid of 6x6 fixed-volume zones (code attached) which implements mass and energy conservation. Those zones are connected to a no-flow boundary condition model and communicate through a flow model.
But when simulating it, I got a set of non-linear equations during all the steps, related to the calculation of the state p, h, Xi of each zone (figure attached).
Do you know I can set it up to avoid that? Maybe a different set of initial conditions? Any help is much appreciated!
model Zone
replaceable package Medium = Modelica.Media.Interfaces.PartialMedium annotation(choicesAllMatching = true);
Medium.BaseProperties medium(p(start=101325, fixed=false),
T(start=293.15, fixed=false));
Test.Port portT(redeclare package Medium = Medium);
Test.Port portB(redeclare package Medium = Medium);
Test.Port portL(redeclare package Medium = Medium);
Test.Port portR(redeclare package Medium = Medium);
parameter Medium.AbsolutePressure P_ambient = 101325;
Medium.Temperature T_ambient = Units.Conversions.from_degC(20);
Medium.MassFraction X_ambient[Medium.nX] = Medium.X_default;
...
initial equation
medium.p = P_ambient;
medium.T = T_ambient;
medium.Xi = X_ambient[1:Medium.nXi];
equation
...
m = V * medium.d;
U = m * medium.u;
mXi = m * medium.Xi;
der(m) = portL.mf + portR.mf + portT.mf + portB.mf;
der(U) = portL.hf + portR.hf + portT.hf + portB.hf + portL.q + portR.q + portT.q + portB.q;
der(mXi) = portL.mXif + portR.mXif + portT.mXif + portB.mXif;
On the flow model, I`m using
portI.mf = mf;
portI.hf = semiLinear(portI.mf, portI.h, portJ.h);
portI.mXif = semiLinear(portI.mf, portI.Xi, portJ.Xi);
portI.q = q;
portI.mf + portJ.mf = 0;
portI.hf + portJ.hf = 0;
portI.q + portJ.q = 0;
portI.mXif + portJ.mXif = zeros(Medium.nXi);
Connector
Medium.Temperature T;
flow Units.HeatFlowRate q;
Medium.AbsolutePressure p;
flow Medium.MassFlowRate mf;
Medium.SpecificEnthalpy h;
flow Medium.EnthalpyFlowRate hf;
Medium.MassFraction Xi[Medium.nXi];
flow Medium.MassFlowRate mXif[Medium.nXi];
I've just found the problem, my set of equations was not complete and initialization was not helpful at all.