My model works as expected in OMEdit using DASSL, Euler and CVODE solvers. However after exporting it to a FMU, I get error messages and the simulation fails. I am using OMEdit v1.21.0 (64-bit).
My model is as follows:
model experiment
import Modelica.Units.Conversions.from_deg;
import Modelica.Units.Conversions.to_deg;
import Modelica.Constants.g_n;
import Modelica.Constants.pi;
import Modelica.Constants.small;
parameter Modelica.Units.SI.Length Lw =10;
parameter Modelica.Units.SI.Length B =3;
parameter Modelica.Units.SI.Angle beta=0.35 ;
parameter Modelica.Units.SI.Mass m =8000;
parameter Modelica.Units.SI.Length xG =3;
parameter Modelica.Units.SI.Length zG =1;
parameter Modelica.Units.SI.Length fG =0;
parameter Modelica.Units.SI.Angle eta =0;
parameter Real U =18;
parameter Real rho(unit = "kg/m3") = 1025;
parameter Modelica.Units.SI.KinematicViscosity nu = 1.19 * 10 ^ (-6) ;
parameter Modelica.Units.SI.Torque M = 0 ;
parameter Modelica.Units.SI.Angle betaM = 0.01 ;
//Unknowns
Real fnb ;
Real clb ;
Real cl0;
Real lam(start = 0.9, fixed = false) ;
Real cld ;
Modelica.Units.SI.Velocity UM ;
Real rn "Reynold's number";
Modelica.Units.SI.Length lm ;
Real cf ;
Modelica.Units.SI.Area Af ;
Modelica.Units.SI.Force Ff ;
Modelica.Units.SI.Force rT ;
Modelica.Units.SI.Force T ;
Modelica.Units.SI.Force Fn ;
Modelica.Units.SI.Length xP ;
Modelica.Units.SI.Length aN ;
Modelica.Units.SI.Length aF ;
Modelica.Units.SI.Angle tau(start = 0.069, fixed = false) ;
equation
fnb = U / (g_n * B) ^ 0.5;
clb = m * g_n / (0.5 * rho * U ^ 2 * B ^ 2);
clb = cl0 - 0.0065 * to_deg(beta) * cl0 ^ 0.60;
cl0 = to_deg(tau) ^ 1.1 * (0.012 * lam ^ (1 / 2) + 0.0055 * lam ^ (5 / 2) / fnb ^ 2);
cld = 0.012 * lam ^ (1 / 2) * to_deg(tau) ^ 1.1 - 0.0065 * to_deg(beta) * (0.012 * lam ^ (1 / 2) * to_deg(tau) ^ 1.1) ^ 0.6;
UM = U * (1 - cld / (lam * cos(tau)) ^ (1 / 2));
rn = lm * UM / nu;
lm = B * lam;
cf = 0.075 / (log10(rn) - 2) ^ 2;
Af = B ^ 2 * lam / cos(beta);
Ff = 0.5 * rho * UM ^ 2 * Af * (cf);
M = T * fG - Fn * aN - Ff * aF ;
0 = T * cos(eta) - m * g_n * sin(tau) - Ff;
rT = (m * g_n * tan(tau) + Ff / cos(tau));
0 = Fn * cos(eta) - m * g_n * cos(tau + eta) + Ff * sin(eta);
xP = lm * (0.75 - 1 / (5.21 * fnb ^ 2 / lam ^ 2 + 2.39));
aN = xG - xP;
aF = zG - 1 / 4 * B * tan(beta);
end experiment;
I have simulated the FMU in both OMEdit and FMPY with the same error messages:
assert | debug | Model error: Argument of log10(rn) was 0 should be > 0
stdout | warning | Non-Linear Solver try to handle a problem with a called assert.
assert | debug | Model error: Argument of log10(rn) was 0 should be > 0
assert | debug | Model error: Argument of log10(rn) was 0 should be > 0
assert | debug | Model error: Argument of log10(rn) was 0 should be > 0
assert | debug | Solving non-linear system 38 failed at time=0.
| | | | For more information please use -lv LOG_NLS.
I am thinking whether this could have something to do with initialization?
Any ideas?
========================================
Edit 20.4.2023:
I tried (log10(rn+1000)-2) to make sure it is a positive value from the beginning but now get this error:
assert | debug | hullResistance_12jac.c:274: Invalid root: (0)^(-0.5) assert | debug | hullResistance_12jac.c:274: Invalid root: (0)^(-0.5) assert | debug | hullResistance_12jac.c:274: Invalid root: (0)^(-0.5) assert | debug | Solving non-linear system 38 failed at time=0. | | | | For more information please use -lv LOG_NLS.
I did the FMU check as suggested and the model passes without errors.