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

+d=initialization

+d=initialization

Hi Guys,

I am a beginner that just started using OpenModelica.  When I try and run the examples given in the user guide (like Hello World) in OMN, I get the warning: "Warning: The initial conditions are not fully specified. Use +d=initialization for more information".

I have changed the setting in OME by going Tools->Options->Simulation->OMC Flags and typing in it +d=initialization.  However I still keep getting the warning and I am not sure why.

Could you please give me a hand with this?

Regards

Malen

Re: +d=initialization

OMNotebook and OMEdit settings are not linked together in any way.

You can use setCommandLineOptions("+d=initialization") in an OMNotebook cell and evaluate that.

Re: +d=initialization

Hi,

Thanks for the reply.

Managed to sort out the problem

Regards

Re: +d=initialization

Hi Sjoelund.se,

Further to my inquire about the +d=initialization, I wanted to ask regarding the rule that: "The number of variables inside a class should be equall to the number of functions".

I start with defining a class record:

record  CelestialBody
  constant Real g = 6.672e-11;
  parameter Real radius;
  parameter String name;
  parameter Real mass;
  end CelestialBody;

than I define another class:

class Rocket "rocket class"
  parameter String name;
  Real mass(start=1038.358);
  Real altitude(start=59404);
  Real velocity(start= -2003);
  Real acceleration;
  Real thrust; //Thrust force on rocket
  Real gravity; //Gravity forcefield
  parameter Real massLossRate=0.000277;
  equation (thrust-mass*gravity)/mass = acceleration;
  der (mass) = -massLossRate*abs(thrust);
  der (altitude) = velocity;
  der (velocity) = acceleration;
  end Rocket;

and at the end:

class MoonLanding
  parameter Real force1 = 36350;
  parameter Real force2 = 1308;
  protected
  parameter Real thrustEndTime = 210;
  parameter Real thrustDecreaseTime = 43.2;
  public
  Rocket apollo(name="apollo13");
  CelestialBody moon(name="moon",mass=7.372e22,radius=1.738e6);
  equation
apollo.thrust = if (time < thrustDecreaseTime) then force1
                else if (time < thrustEndTime) then force2
                else 0;
apollo.gravity=moon.g*moon.mass/(apollo.altitude+moon.radius)^2;
end MoonLanding;

I simulate the last class and everything is fine.  Nonetheless the number of eqautions in class MoonLanding is not eqaul to the number of variables.  Also in class Rocket the same is true however the code complies and gives me the desired result.  I am not sure how this follows the rule that I mentioned at the beginning?

Regards

Malen

Re: +d=initialization

Yes, to pass balanced model checking (which OpenModelica does not yet perform), I believe some of the variables in Rocket would have to be marked "input".

Re: +d=initialization

Thanks for the reply.  But is it possible to use "input" inside a "class" because from my understanding "inputs" and "outputs" are only used inside a "function".

Also I wanted to ask, I am having problems with new files that I open in OMN.  For some odd reason when I try to input "New Cells", the programe freezez.  I close the file, saving my work, but when I open it it shows only empty cells with no code written in them. 

Regards

Malen

Re: +d=initialization

https://trac.openmodelica.org/OpenModelica/newticket select component OMNotebook.

And yes, models can have inputs. Blocks are specialized models that have only input/output public variables. (As opposed to models, which are more generic)

Re: +d=initialization

Thanks for the help.

Re: +d=initialization

Hi sjoelund.se

I have this simple piece of code:

class HelloWorld
  Real x(start=1);
  equation
  der(x)=-x;
  end HelloWorld;

try and simulate it and I get :

record SimulationResult
    resultFile = "HelloWorld_res.mat",
    messages = ""
end SimulationResult;
OMC-ERROR:
"Warning: Assuming fixed start value for the following 1 variables:
         x:VARIABLE(start = 1.0 ) .HelloWorld, .Real type: Real

I managed to get rid of the warning by using:

Real x(start=1, fixed=true);

However I do not understand why this happens.  Why when I use the "fixed=true" command I do not get a warning?  And also I used the command "setCommandLineOptions("+d=initialization") but I do not understand what it performs? 

Regards

Malen

Re: +d=initialization

By default, fixed=false. This means you need to add an initial equation in order for the initial conditions to be fully specified.
Fixed=true means "use the start-value as initial condition".

setCommandLineOptions("+d=initialization") just adds more details to the warnings. Some working models have several thousand underspecified initial conditions, so they are hidden by default. It's good to fully specify the initial conditions since otherwise we might find another valid (unexpected) solution.

Re: +d=initialization

Thanks for the reply.

Regarding the question that I had before about the number of equations not being equal to the number of variables in the "MoonLanding" example, I think that there is no need to mark some of the values in class "Rocket" as inputs. 

My understanding is that the whole system has 6 variables overall (all of them contained in the class "Rocket") and 6 equations overall ( 4 of them in class "Rocket" and 2 of them in class "MoonLanding") .  Is this the case?

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