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

OpenModelica: Translation Warning

OpenModelica: Translation Warning

  I have posted related questions in StackOverFlow and Wolfram SystemMdeler forum but nobody has answered me yet. The issue is That I want to run this code but I get the warning below:
Translation Warning [multibody_Coulomb_static_friction: 43:3-47:9]: In component , in relation V1 == V2, == on Real numbers is only allowed inside functions.

I would appreciate if you could help me know why this is happening and how I can solve this

Re: OpenModelica: Translation Warning

Modelica Specification says that comparing 2 real numbers for equality is not a good idea as they will seldom be really equal (that's why you get a warning if you don't use it inside functions).
You can introduce an epsilon in the comparison to make it more robust and use =< >= instead of ==.
See for example this:
https://github.com/modelica/Modelica-Co … ce/Util.mo

Edited by: adrpo - Jul-24-17 23:06:40

Re: OpenModelica: Translation Warning

Thanks for the reply. here some questions:



1. the function you linked to seems to offer a way to compare two real numbers and if they are within a threshold they can be considered as equal. here is what I do not understand:
 
1.1. the diff < absTol part is clear but what is the diff <= max(abs(b), abs(a)) * relTol does and why should we have it?

1.2. can you give an example of how I should use this function and how to call it?

2. why my simulation is so slow? does it have anything with the waring and will using your solutions help accelerating?

3. Is this warning the same reason I can't run my code in Wolfram SystemModeler? please see this post in their forum.

4. int function what is the := operand called and what does it do?

I would appreciate if you could help me with these questions.

Edited by: foadsf - Jul-24-17 23:33:50
There are 0 guests and 0 other users also viewing this topic
You are here: