I have been attempting to simulate the below given nonlinear dynamic system in the Scilab\Xcos
[version, options] = getversion()
version =
"scilab-2024.1.0"
options = [1x7 string]
"VC++" "x64" "tk" "modelicac" "release" "May 23 2024" "09:52:14"
\begin{eqnarray}
\frac{\mathrm{d}\Phi_f}{\mathrm{d}t} &=& \frac{1}{1 + L_a(a + 3b\Phi^2_f)}\left[u - (R_a + R_f)\cdot i - K_e\cdot\Phi_f\cdot\omega\right] \\
\frac{\mathrm{d}\omega}{\mathrm{d}t} &=& \frac{1}{J}\left(K_m\cdot\Phi_f\cdot i - T_l\right)
\end{eqnarray}
where
i = a\cdot\Phi_f + b\cdot\Phi^3_f
The parameters numerical values are
\begin{eqnarray}
L_a &=& 2\cdot 10^{-3} \nonumber \\
R_a &=& 0.02112 \nonumber \\
R_f &=& 0.01015 \nonumber \\
K_e &=& 1.106 \nonumber \\
K_m &=& 1.137 \nonumber \\
J &=& 25 \nonumber \\
a &=& 10.23 \nonumber \\
b &=& 2.40 \nonumber
\end{eqnarray}
I have created the below given Xcos model
I have set the solver in following manner for the RK45 - Runge-Kutta 4(5) numerical method. As soon as I start the simulation I receive below given error message
Simulation problem:
at block #13 “77474b38:1969f4cb9a6:-7fc6” CVode: CVODES encountered an unrecognized error. Please report this to the Sundials developers at sundials-users@llnl.gov.
May I ask you for an advice why the simulation crash? Is it caused by the unsuitable numerical method or unsuitably assembled model?
Hello, and welcome to Scilab’s Disscourse,
Can you test your diagram with the default (and more versatile) solver (CVODE/BDF/Newton) ?
BTW, how are defined the inputs u, T_l and the initial conditions (0, I presume) in your equations above ?
S.
Thank you for your reaction. As far as the inputs. T_l = 0 and u is a step at time zero from initial value 0 to final value 463. As far as the initial conditions. Both of the integrators have zero initial condition. As far as the numerical method. I have chosen the CVODE/BDF/Newton and I have received following error message:
Simulation problem:
at block #13 “77474b38:1969f4cb9a6:-7fc6” CVode: At t = 0.0258593 and h = 9.95448e-38, the error test failed repeatedly or with |h| = hmin.
Why do you need to use Xcos ? For a simple system like yours it is way simpler to directly code in the Scilab language, so check your diagram because it seems that it does not correctly reproduce the two odes. Here is what I obtain with the following script:

function out=rhs(t,x)
Φ_f = x(1);
ω = x(2);
i = a*Φ_f+b*Φ_f^3;
dΦ_f_dt = (u-(R_a+R_f)*i-K_e*Φ_f*ω)/(1+L_a*(a+3*b*Φ_f^2));
dω_dt = (K_m*Φ_f*i-T_l)/J;
out = [dΦ_f_dt; dω_dt]
endfunction
L_a = 2e-3;
R_a = 0.02112;
R_f = 0.01015;
K_e = 1.106;
K_m = 1.137;
J = 25;
a = 10.23;
b = 2.40;
T_l = 0;
u = 463;
[t,x,info] = cvode(rhs,[0 1],[0;0])
Φ_f = x(1,:);
ω = x(2,:);
clf
plot(t,Φ_f,t,ω)
legend("Φ_f(t)","ω(t)",2)
xlabel("t")
Thank you very much for your effort. The reason why I need to use the Xcos is that I would like to test a control algorithm for the above given system. This task seems to me to be better realizable in the Xcos than in the Scilab language. You are correct. I have done a mistake in the diagram in the left most summing block (namely I have exchanged the signs in the last input). Thank you once more for your help.
You are right, to some extent, but learning how to do things in pure Scilab for simple systems and simple control schemes really helps to understand how Xcos works, because your diagram always results in a system of differential equations. The only thing I can say is that your diagram is not correct w.r.t. your equations and that it’s your job to investigate what’s wrong.
S.