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

plot error and warnings

plot error and warnings

Hello,
i'm create a model using blocks selfmade. For each block the user will provide the parameters required. If the user will not put in all the parameters( for example he will leave an empty box) i want to stamp an error or warning (and if possibile stop the initialization of the simulation). How can i do ?

Edited by: Ingrasciotta - Jul-02-19 15:07:08

Re: plot error and warnings

ModelicaSpec

On Page 97, section 8.3.7 there are explainations on asset funtion. Maybe it might help you.

Cheers
A

Re: plot error and warnings

I have seen it. I want to print an error when these two parameter are false or true both of them at the same time.

I try to use an auxiliary boolean parameter n :

parameter Boolean n = false;

equation

if Step ==false and Ramp == false then
n = true;
elseif Step == true and Ramp ==true then
n = true;
else
n = false;
end if;

assert(n,"message",level = AssertionLevel.error)


But it still not working. Can you help me? 

Re: plot error and warnings

Ingrasciotta wrote:

I want to print an error when these two parameter are false or true both of them at the same time.

I try to use an auxiliary boolean parameter n

you can compare both parameters directly as the condition of assertion.

assert is triggered (e.g. the simulation is stopped) when the condition is not fulfilled(i.e. condition = false). In your case it should be


Code:



mode foo
  parameter Boolean p1 = true;
  parameter Boolean p2 = true;
  Boolean n;
equation
  if p1 == p2 then
    n = false;
  else
    n = true;
  end if;
  assert(n,"Assertion Test" ,level = AssertionLevel.error);
  //or
  // assert(p1<>p2,"p1 can not be identical to p2", level = AssertionLevel.error); // this will also abort the simulation like above assertion
end foo;

so when both p1 and p2 have the same value, n would be false and thus the assertion triggered.

hope it helps you a little bit to understand OM

cheers
A


Edited by: Arinomo23 - Jul-10-19 19:38:01

Re: plot error and warnings

Problem solved! Thanks you so much!

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