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

VanDerPol Model Example

VanDerPol Model Example

Hi everyone!

I am new in OpenModelica. I am trying to run the VanDerPol example from OMNotebook, but I do not get the correct output.

>>setCommandLineOptions("+d=initialization");

>> simulate(VanDerPol, startTime=0, stopTime=25)
record SimulationResult
    resultFile = "",
    messages = "Simulation failed for model: VanDerPol
Warning: Assuming fixed start value for the following 2 variables:
         x:VARIABLE(start = 1.0 ) .VanDerPol, .Real type: Real
         y:VARIABLE(start = 1.0 ) .VanDerPol, .Real type: Real
"
end SimulationResult;

I have read in the forum about the +d=initialization parameter, so I executed the setCommandLineOptions. Why the example does not run properly?

Greetings!

Re: VanDerPol Model Example

Hi,

I pressume that your code look like this:

class VanDerPol
  Real x(start = 1);
  Real y(start = 1);
  parameter Real lambda = 0.3;
  equation
  der(x) = y;
  der(y) = -x + lambda*(1-x*x)*y;
  end VanDerPol;

When using the command : setCommandLineOptions("+d=initialization"), what you are telling the compiler is show me more detailed warnings, this command does not get rid of them.  Now the problem with your code is that you are "suggesting" the compiler to start x and y at 1, however you are not forcing it.  In order to do so, the right code is:

class VanDerPol
  Real x(start = 1, fixed=true);
  Real y(start = 1, fixed=true);
  parameter Real lambda = 0.3;
  equation
  der(x) = y;
  der(y) = -x + lambda*(1-x*x)*y;
  end VanDerPol;

There are 0 guests and 0 other users also viewing this topic