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

Problems with the simulation.

Problems with the simulation.

Hello friends, good day. I'm doing an algorithm but it's not working well. Annex my code. I am evaluating two functions (V1, V2), each time they go through zero a pulse is activated, when both pulses coincide (either 0 or 1) a third pulse is activated which determines the state of a variable (Cvar). That variable (Cvar) must modify the function V1. The problem is that my code is not running.
Can you help me please? Could you tell me where my mistake is? Thank you. Have a nice day.



model practica
  Real V1;
  Real V2;
  Real u;
  Real u1;
  Real Cvar;
  Real y;
  Real y1;
  Real y2;
  Real y3;
  Boolean cross1;
  Boolean cross2;
  parameter Real Cp = 2;
  parameter Real Cs = -2;
  equation
  V1 = 5 * sin(60 * time)* Cvar;
  V2 = 5 * sin(100 * time);
  cross1 = V1 < 0.0;
  cross2 = V2 < 0.0;
  u = if cross1 == true then 1 else 0;
  u1 = if cross2 == true then 1 else 0;
  y = (-1 * u) + (-1 * u1) + 1;
  y1 = u * (-u1) * (u1 * (-u)) + 1;
  y2 = y + y1;
  y3 = y2 + y1 - 2.5;
  if y3>0 then
  Cvar = Cp;
  else
  Cvar = Cs;
  end if;
end practica;

Edited by: Damian - Oct-02-18 16:01:54
There are 0 guests and 0 other users also viewing this topic
You are here: