Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

What means "generate_ode_system2_nonlinear_residuals failed"

What means "generate_ode_system2_nonlinear_residuals failed"

I am trying to continue working on a model which worked fine in RC1 but fails now in 1.5.0.svn.r5385-2 (RC3).

Code:


$ cat /tmp/error.log
Opening a socket on port 29500
generate_ode_system2_nonlinear_residuals failed

Here is the model...

Code:

model TestControlBrushedDC0 "Closed loop with an external controller" 

  import Modelica.Electrical.Analog;
  import Modelica.Mechanics.Rotational;
  OpenRobotica.Machines.BrushedDC dcm;
  Analog.Basic.Ground gnd;
  Analog.Sources.SignalVoltage vsource;
  Rotational.Fixed fixed;
  Rotational.Sensors.SpeedSensor speedSensor;
  OpenRobotica.Interfaces.Fifos.FifoRealArray myFifo;
                                               //(Nout=3);
equation
  //vsource.v = if time < 0.5 then 0 else 10; //Hier Controller-Modell aufrufen
  connect(myFifo.varin[1], vsource.v);
  connect(myFifo.varout[1], speedSensor.w);
  connect(gnd.p, vsource.n);
  connect(vsource.p, dcm.pin_p);
  connect(vsource.n, dcm.pin_n);
  connect(dcm.pin_n, gnd.p);
  connect(fixed.flange_b, dcm.support);
  connect(dcm.flange, speedSensor.flange_a);
initial equation
  dcm.phiMechanical = 0;
end TestControlBrushedDC0;

The problem should be somewhere inside this, i guess.

Code:

block FifoRealArray "Read and write real array to fifo" 

  function openFifoOutWrp
  input String fifoName;
  input Integer dummy;  // force execution order in equation sections
  output Integer fd;
  algorithm
    fd :=openFifoOut(fifoName);
  end openFifoOutWrp;
 
  function openFifoInWrp
  input String fifoName;
  input Integer dummy;  // force execution order in equation sections
  output Integer fd;
  algorithm
    fd :=openFifoIn(fifoName);
  end openFifoInWrp;
 
  parameter String FifoName="ModelicaFifo";
  parameter Integer Nin=1 "Number of inputs from fifo";
  parameter Integer Nout=1 "Number of outputs to fifo";
  parameter Real CompTime=1e-12 "Computation time of controller";
  parameter Boolean IsServer=true
    "Indicates if model creates the fifo and opens for writing first";
  //output Real varin[Nin]; //[Nin];
  //input Real varout[Nout];
  Modelica.Blocks.Interfaces.RealInput varout[Nout]
    "Connector of Real vector to be send to fifo";
  Modelica.Blocks.Interfaces.BooleanInput interrupt=false
    "Send to and recieve from fifo when interrupt/event becomes true";
  Modelica.Blocks.Interfaces.RealOutput varin[Nin]
    "Connector of Real vector, recieved from fifo";
protected
  discrete Real dvarout[Nout];
  discrete Real dvarin[Nin];
  discrete Real nextWriteEvent(start=0);
  discrete Real nextReadEvent(start=0);
  //discrete Integer nextReadEvent(start=0);
  discrete Integer fd_in; // File descriptor
  discrete Integer fd_out;
  discrete Integer retval;
  discrete Integer numwritten[Nout];
  discrete Integer timewritten;
equation
  when (time >= nextWriteEvent or interrupt) then
    for i in 1:Nout loop //index auch uebergeben
      dvarout[i] = varout[i];
      numwritten[i] = fifoOutReal(fd_out, dvarout[i], i, Nout+1); //write2fifo
    end for;
    if interrupt then
      timewritten = fifoOutReal(fd_out, time, 0, Nout+1);  // send SimTime
    else
      timewritten = fifoOutReal(fd_out, nextWriteEvent, 0, Nout+1);  // send SimTime==nextWriteEvent
    end if;
    nextReadEvent = time + CompTime;
  end when;
 
  when (time > nextReadEvent) then
  //when (nextReadEvent >= 1) then //!!! change() geht in OM nur mit Real
    for i in 1:Nin loop
      dvarin[i] = fifoInReal(fd_in, i, Nin+1);
      varin[i] = dvarin[i];
    end for;
    nextWriteEvent = fifoInReal(fd_in, 0, Nin+1);
  end when;
 
  when initial() then
        retval = createFifo(FifoName);
        fd_out = openFifoOutWrp(FifoName, retval);
        fd_in = openFifoInWrp(FifoName, fd_out);
  end when;
  when terminal() then
    // end of sim
  end when;
end FifoRealArray;

As i said, it worked fine in OM RC1. I have no idea how to debug this now.

Cheers,
Joerg

There are 0 guests and 0 other users also viewing this topic
You are here: