- Index
- » Developer
- » OpenModelica development
- » divide by zero
divide by zero
divide by zero
Hi,
Trying to simulate a model which worked perfectly using Dymola, I got the error:
Divide by zero
:
equation
der(H3) = omega;
der(H2) = Vx * Modelica.Math.sin(theta)+ X * Modelica.Math.cos(theta) * omega;
der(H1) = Vx* Modelica.Math.cos(theta)+ X * Modelica.Math.sin(theta) * omega;
Vx = Y * omega;
Vy = - omega * X ;
der(theta) = (-Vx) / X;
der(X) = Modelica.Math.cos(theta) * Vx- Modelica.Math.sin(theta) * Vy;
der(Y) = Modelica.Math.sin(theta) * Vx+ Modelica.Math.cos(theta) * Vy;
(-Modelica.Math.sin(theta) * der(X)) + X * der(theta) = 0;
Re: divide by zero
Well, you should try to find out, which variable becomes zeros. The only division in the above model is der(theta) = (-Vx) / X, but that doesn't necessarily mean, that it's that one, since the equations are getting rearranged in the order the computer needs them. You can try to do something like this:
der(thetha) = -(Vx) / (max(1e-5, abs(X))* sign(X))
At least for my calculations this often works well. I can't tell you why Dymola is handling this well why OM doesn't, though.
- Index
- » Developer
- » OpenModelica development
- » divide by zero