2

I'm trying to solve the code

model modelTest

// types
  type Mass = Real (unit = "Kg", min = 0);
  type Length = Real (unit = "m");
  type Area = Real (unit = "m2", min = 0);
  type Force = Real (unit = "Kg.m/s2");
  type Pressure = Real (unit = "Kg/m/s2");
  type Torque = Real (unit = "Kg.m2/s2");
  type Velocity = Real (unit = "m/s");
  type Time = Real (unit = "s");

// constants
  constant Real pi = 2 * Modelica.Math.asin(1.0);
  parameter Mass Mp = 0.01;
  parameter Length r1 = 0.010;
  parameter Integer n = 3;
  parameter Area A = 0.020 * 0.015;
  parameter Time Stepping = 0.1;
  parameter Real DutyCycle = 0.5;
  parameter Pressure Pin = 5000;
  parameter Real Js = 1;

// variables
  Length x[n];
  Velocity vx[n];
  Real theta;
  Real vt;
  Pressure P[n]; 

initial equation
  theta = 0;
  vt = 0;

algorithm
  for i in 1:n loop
    if noEvent((i - 1) * Stepping < mod(time, Stepping)) and noEvent(mod(time, Stepping) < (i - 1) * Stepping + Stepping * DutyCycle) then
      P[i] := Pin;
    else
      P[i] := 0;
    end if;
  end for;

equation
  vx = der(x);
  vt = der(theta);
  x = r1 * {sin(theta + (i -1) * 2 * pi / n) for i in 1:n};
  Js * der(theta) = r1 * sum((Mp * der(vx) + P * A) .* {cos(theta + (i -1) * 2 * pi / n) for i in 1:n});

annotation(
    experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-6, Interval = 0.01),
    __OpenModelica_simulationFlags(lv = "LOG_STATS", outputFormat = "mat", s = "dassl"));
end modelTest;

but the solver never finishes showing the error:

Failed to solve linear system of equations (no. 51) at time ... Residual norm is ...

The default linear solver fails, the fallback solver with total pivoting at time ... that might riase plv LOG_LS.

I would appreciate if you could help me know what is the problem and how I can solve it. Thanks for your support in advance.

P.S.1. I found this similar issue from 15 months ago.

P.S.2. There were several mistakes in the code. A modified version can be found here.

Community
  • 1
  • 1
Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193

0 Answers0