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

initial condition for step function

initial condition for step function

I would like to ask a Modelica question about when function, and the following source code cannot be properly functioned. The variable Pstart_CONV is an initial condition for der(x_calc) in the if statement, and the Pstart_CONV value is given by x when the "when statement" becomes true. Because x is a step function, I want to assign an initial condition for der(x_calc) so x can be continued for the whole domain.

Thank you very much,

Source:

model Unnamed4
  Real  Pstart_CONV;

  Real P_crit_ratio;
  parameter Real P_crit_ratio_criteria = 2.00;

  Real x;
  Real x_calc(start=0);

equation
  P_crit_ratio = 10-time;

  when P_crit_ratio <= P_crit_ratio_criteria then
    Pstart_CONV = x;
  end when;

  if P_crit_ratio >= P_crit_ratio_criteria then
    x = time^2;
    x_calc = 0;
  else
    der(x_calc) = time * 5;
    x = x_calc + Pstart_CONV;
  end if;   
end Unnamed4;

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