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

Question regarding initial conditions

Question regarding initial conditions

I am running the model:

Code:


model SMP

Real y(start=5);
Real y_dot(start=0);
Real omega_0=5.0;
Real delta=0.2;
equation
y_dot = der(y);
der(y_dot) + 2.0*delta*omega_0*der(y) + omega_0^2*y = 0;
end SMP;

The model runs and gives the results I expects, but I get the error:

Code:


"Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions("-d=initialization").

I am solving a second order ODE so I need to provide 2 initial conditions, which I believe I am doing with:

Code:


Real y(start=5);
Real y_dot(start=0);

Any reason why I am getting this error?

Re: Question regarding initial conditions

Are omega_0 and delta actually variables? They kinda look like parameters. What happens when you add the parameter keyword?

Re: Question regarding initial conditions

OK. The parameter keyword didn't matter (still probably, not a bad idea though).

Using initial equations instead of start values fixes the problem, though. Perhaps someone else can explain why this is:

Code:


model SMP
    Real y;
    Real y_dot;
    Real omega_0=5.0;
    Real delta=0.2;
initial equation
    y = 5;
    y_dot = 0;
equation
    y_dot = der(y);
    der(y_dot) + 2.0*delta*omega_0*der(y) + omega_0^2*y = 0;
end SMP;

Re: Question regarding initial conditions

Dave wrote:


Code:


Real y(start=5);
Real y_dot(start=0);

Any reason why I am getting this error?

Since without fixing the start value by the fixed attribute (fixed=true) this are just initial guess and not initial conditions.

watkipet wrote:


Are omega_0 and delta actually variables? They kinda look like parameters. What happens when you add the parameter keyword?

Yes, omega_0 and delta are variables, but are treated like parameters while the compile process. The difference is that this variable as parameters are changeable after the compile process.

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