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
  • Index
  • » Users
  • » merywery
  • » Profile

Posts

Posts

Thanks for your reply!

Well, now I have the total model and I am able to modify it, but some new if-statements have appear. For example:
   
        if initType == .Modelica.Blocks.Types.Init.SteadyState then
          der(y) = 0;
        elseif initType == .Modelica.Blocks.Types.Init.InitialState or initType == .Modelica.Blocks.Types.Init.InitialOutput then
          y = y_start;
        end if;

Which seems difficult to translate into an if-expression, since the variable is written as "y" and "der(y)".

Another example is that now I have obtained nested if-statements.

My questions:
1- It is possible to write an if-expression from an if-statement like the one I showed you?
1- It is possible to build nested if-expressions?

And last, I translated one if-statement to an if-expression, and opened it with OMShell, but then I am not  able to instantiate the model and save it. Could you please shed some light on hpw to do it?

Many thanks!


Hi all,

I am working with a simple model of an electrical battery using phasors. The model works perfectly. I want to use the model for linking it with an optimisation software. To do so, I need the equations comming from the instantiation process which I can obtain without problem.

Here my doubt: When I instantiate the model, the model calls the atan3 function from the Modelica library, which contains the followinf if-else loop:

  if y0 == 0 then
    // For the default (y0 = 0), exactly the same result as with atan2(..) is returned
    y := w;
  else
    y := w + pi2*integer((pi+y0-w)/pi2);
  end if


When I try to run the optimisation process, an error comes up telling that I should use the if-expression instead of the if-else function.

My question is:

Can I do something simple to obtain the equations of the instantiated model with the if-else expression?
Can I call another version of the atan3 (own created) containing the if-else expression?

Thanks for your support!


Hi all,

I am trying to import an FMU from TRNSYS in the OMSimulator tool. However, once I insert it I get the following error:

[3] 08:16:21 Scripting Error
[fmiLogger] module FMI2XML: Start attribute is required for this causality, variability and initial combination

It seems that it is caused by the absence of starting values. I have checked the existing documentation (link) but I am not able to find the command line of OMSimulator.

On the other hand, in that link I have not found any function or method to provide initial values to different variables. I only see this one (which maybe is also useful, I don't know...):
-ignoreInitialUnknowns=<bool>  Ignore the initial unknowns from the modelDescription.xml

I would appreciate I you can guide me on how to find the command line and which methods should I use for runing my simulation.

Thanks!

Hi,

I am starting to use OpenModelica so I am trying to get all the information I can from the forums, but I am not able to solve my problem (very basic, I guess) at all.

I just want to run the simulation of the GTUnit from the ThermoPowerLibrary. Since it is a partial class, I run the simulation and I get the following errors:


[1] 14:27:33 Translation Error
[ThermoPower.Gas: 3270:5-3393:19]: Illegal to instantiate partial class GTunitBase.

[2] 14:27:33 Translation Error
Error occurred while flattening model GTUnitBase_prueba

[3] 14:32:20 Translation Error
[ThermoPower.Gas: 3281:7-3281:78]: Exhaust is partial, name lookup is not allowed in partial classes.

[4] 14:32:20 Translation Error
[ThermoPower.Gas: 3282:7-3282:71]: Air is partial, name lookup is not allowed in partial classes.

So OK, I know that I have to redeclare something, but what? I see that I cannot just rewrite the library file so I have duplicated the GTUnitBase inside my own model and then tried to include in some lines redeclare package Medium = Medium as I have seen in other topics, but a lot of errors appear as well.

Anyway, I cannot figure out how to solve this I would appreciate if someone can orient me on what I should include and where.

You can find attached my model.

Thanks!


GTUnitBase-prueba.mo

  • Index
  • » Users
  • » merywery
  • » Profile
You are here: