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
  • » pierreD
  • » Profile

Posts

Posts

Sep-23-15 09:28:16
Modification on a generated modelica code representing a simple state machine diagrams

Hi,

I don't know if here is the right place to post this topic but, in the doubt, I prefer to report my issue here.
There are one reported issue and one question.

1.
I recently tried to use delayed transition with ModelicaML. So I built I pretty simple model from which I generated Modelica code.
http://image.noelshack.com/fichiers/2015/39/1442999141-capture-proto4-simpledelayedtransition.gif
However, when I tried to directly simulate this code (with Dymola 2016, JModelica 1.16 or OpenModelica 1.9.3), the simulation didn't work.
But, with some modifications on the Modelica code: mainly, it consisted in turning lines:

Code:

 when {Given.State.active, Given.State.selfTransitionActivated} then 

into

Code:

 when {pre(Given.State.active), Given.State.selfTransitionActivated} then 

Then, it eventually proved to work fine (at least with JModelica, I haven't tried with the two others yet).

Does some one have any explications?

2.
Does any one have hints about the modification of the generation template (how to process?) for test purposes?


Best regards,
Pierre

Sep-10-15 11:20:42
Unable to set the input parameters of my FMU

Fine, alright!

Sep-10-15 09:58:25
Unable to set the input parameters of my FMU

Hello,

I noticed the recent released of the latest OpenModelica version (1.9.3) which has a "further improved FMI 2.0 co-simulation support". I installed it and tried to export a Co-Sim FMU 2.0 but I obtained a Model-Exchange FMU 2.0. I looked for an answer in previous forum posts, documentation and papers (that are well detailed in some cases, thank you!) but I did not find answers that could solve my issue.

I am still a rookie with OpenModelica, so is it possible that I missed examples or tutorials?
I understood that your team is still working on FMI 2.0, but is an export of a co-simulation FMU 2.0 possible?
Is it the nature of the modelica model that determine the kind of the FMU between 'Model Exchange ' and 'Co-simulation' or is some special lines needed in the generation code?

Could someone help me on this?

Pierre

PS: I would like to give thanks to the OpenModelica team for its work and documentation.

Sep-09-15 08:35:02
Difficulties to execute a modelica code generated thanks to ModelicaML from a model containing a...

Hi,

I tried to look up the error messages origins. I identified the following errors:
- "Error: Internal error Inverse Algorithm needs to be solved for"
- "Error: No system for the symbolic initialization was generated."

However, I did not succeed in correcting them modifing the modelica code through a text editor.
Then, I decided to run the generated file in Dymola and everything worked fine.

As the message 'This has not been implemented yet.' may suggest, could these problems be related to the OpenModelica version?  I am using OMShell 1.1 connected to OpenModelica 1.9.2.

Thank you in advance for your help
Pierre

Sep-04-15 11:59:54
Difficulties to execute a modelica code generated thanks to ModelicaML from a model containing a...

Hi again!

I am starting using step by step the different functionalities of ModelicaML. So far, I suceeded in generating code, simulating and plotting it. Currently, I'd like to use state machine diagram in order to generate Modelica Code from it. However, whenever I put a state Machine Diagram in my model, I got error messages from the OpenModelicaShell.

Here is my model architecture and my steps:

1)  In Eclipse:
- New element > Simulation Model(s) > 'Essai'
- (in my model) New element > Variables (Primitive) > x (Type: ModelicaReal)
-  New Element > Equation Section > 'Mon_equation' >x=sin(time); (Equations)
- New Diagram >  State Machine Diagram > [and I build then the diagram]

http://image.noelshack.com/fichiers/2015/36/1441367638-temp-3.png

- I generate the modelica code

2) In a text editor, I open my modelica code and delete the line 'within ModelicaMLModel;' (because, I don't know how to simulate if I keep this line)

3) In the OpenModelicaShell, I enter:

>> loadFile("c:/Essai.mo")
true
>> simulate(Essai)
[error messages]

 Spoiler Show Spoiler Hide Spoiler
 
record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 10.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Essai', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "Simulation execution failed for model: Essai
assert            | debug   | No system for the symbolic initialization was generated.
assert            | info    | simulation terminated by an assertion at initialization
",
    timeFrontend = 0.06678928467165519,
    timeBackend = 0.01026345527154988,
    timeSimCode = 0.02004940572055946,
    timeTemplates = 0.1281593750043651,
    timeCompile = 5.100906749321492
end SimulationResult;
"[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:6364:9-6364:54:writable] Error: Internal error Inverse Algorithm needs to be solved for {StateMachine0.Region0.negatif.timeAtActivation,StateMachine0.Region0.le_debut.active,StateMachine0.Region0.positif.active,$whenCondition4,$whenCondition5,StateMachine0.Region0.positif.timeAtActivation,$whenCondition1,$whenCondition10,$whenCondition9,StateMachine0.active,StateMachine0.Region0.nul.timeAtActivation,$whenCondition6,$whenCondition7,StateMachine0.timeAtActivation,$whenCondition2,StateMachine0.startBehaviour,StateMachine0.Region0.le_debut.timeAtActivation,StateMachine0.Region0.nul.active,StateMachine0.Region0.negatif.active,$whenCondition8,$whenCondition3,StateMachine0.Region0.numberOfActiveStates} in
algorithm
  StateMachine0.startBehaviour := true;
  if StateMachine0.startBehaviour then
    StateMachine0.active := true;
    StateMachine0.Region0.le_debut.active := true;
  end if;
  $whenCondition1 := StateMachine0.active;
  $whenCondition2 := StateMachine0.selfTransitionActivated;
  if StateMachine0.active then
    StateMachine0.stime := time - StateMachine0.timeAtActivation;
  end if;
  if not StateMachine0.active then
    StateMachine0.stime := 0.0;
  end if;
  $whenCondition3 := StateMachine0.Region0.le_debut.active;
  $whenCondition4 := StateMachine0.Region0.le_debut.selfTransitionActivated;
  if StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.le_debut.stime := time - StateMachine0.Region0.le_debut.timeAtActivation;
  end if;
  if not StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.le_debut.stime := 0.0;
  end if;
  $whenCondition5 := StateMachine0.Region0.nul.active;
  $whenCondition6 := StateMachine0.Region0.nul.selfTransitionActivated;
  $whenCondition7 := StateMachine0.Region0.positif.active;
  $whenCondition8 := StateMachine0.Region0.positif.selfTransitionActivated;
  $whenCondition9 := StateMachine0.Region0.negatif.active;
  $whenCondition10 := StateMachine0.Region0.negatif.selfTransitionActivated;
  if StateMachine0.Region0.nul.active then
    StateMachine0.Region0.nul.stime := time - StateMachine0.Region0.nul.timeAtActivation;
  end if;
  if not StateMachine0.Region0.nul.active then
    StateMachine0.Region0.nul.stime := 0.0;
  end if;
  if StateMachine0.Region0.positif.active then
    StateMachine0.Region0.positif.stime := time - StateMachine0.Region0.positif.timeAtActivation;
  end if;
  if not StateMachine0.Region0.positif.active then
    StateMachine0.Region0.positif.stime := 0.0;
  end if;
  if StateMachine0.Region0.negatif.active then
    StateMachine0.Region0.negatif.stime := time - StateMachine0.Region0.negatif.timeAtActivation;
  end if;
  if not StateMachine0.Region0.negatif.active then
    StateMachine0.Region0.negatif.stime := 0.0;
  end if;
  if StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.le_debut.active := false;
    StateMachine0.Region0.nul.active := true;
  end if;
  if StateMachine0.active then
    if $PRE.StateMachine0.Region0.nul.active then
      if x > 0.0 then
        StateMachine0.Region0.nul.active := false;
        StateMachine0.Region0.positif.active := true;
      end if;
    elseif $PRE.StateMachine0.Region0.positif.active then
      if x < 0.0 then
        StateMachine0.Region0.positif.active := false;
        StateMachine0.Region0.negatif.active := true;
      end if;
    elseif $PRE.StateMachine0.Region0.negatif.active then
      if x > 0.0 then
        StateMachine0.Region0.negatif.active := false;
        StateMachine0.Region0.positif.active := true;
      end if;
    end if;
  end if;
  if not StateMachine0.active then
    StateMachine0.Region0.le_debut.active := false;
    StateMachine0.Region0.nul.active := false;
    StateMachine0.Region0.positif.active := false;
    StateMachine0.Region0.negatif.active := false;
  end if;
  StateMachine0.Region0.numberOfActiveStates := 0;
  if StateMachine0.Region0.nul.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.Region0.positif.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.Region0.negatif.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.Region0.le_debut.active then
    StateMachine0.Region0.numberOfActiveStates := 1 + StateMachine0.Region0.numberOfActiveStates;
  end if;
  if StateMachine0.active then
    assert(not StateMachine0.Region0.numberOfActiveStates < 1, "StateMachine0.Region0 has no active states although the parent state is active!");
    assert(not StateMachine0.Region0.numberOfActiveStates > 1, "StateMachine0.Region0 has multiple active states which are mutually exclusive!");
  end if;
  if not StateMachine0.active then
    assert(StateMachine0.Region0.numberOfActiveStates == 0, "StateMachine0.Region0 has active states although the parent state is not active!");
  end if;
This has not been implemented yet.
[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:6369:7-6369:88:writable] Error: Internal error function createSingleAlgorithmCode failed
[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:3915:9-3915:50:writable] Error: Internal error function createOdeSystem failed for component Algorithm 14 {11, 7, 20, 44, 41, 18, 45, 38, 37, 35, 25, 42, 39, 33, 46, 29, 5, 27, 13, 40, 43, 1}
[c:/dev/OpenModelica/Compiler/SimCode/SimCodeUtil.mo:2600:9-2600:54:writable] Error: Internal error function createEquationsForSystem1 failed for component Algorithm 14 {11, 7, 20, 44, 41, 18, 45, 38, 37, 35, 25, 42, 39, 33, 46, 29, 5, 27, 13, 40, 43, 1}
Error: No system for the symbolic initialization was generated.
"
I managed to simulate and plot my model without the state diagram but my objective is to use state diagram.
Does anyone know a solution to this problem?

Thank you,
Pierre

Hi,

I recently suceeded in running a modelicaml code-generation from different little models. Now, I try to simulate the 'Two Controlled Tanks Model'. I followed the tutorial 'ModelicaML Tutorial, MODPROD 2011, W. Shamai' (which is by the way well-detailled). Everything but the final step gone well during the tutorial.

This is the process I followed:
> click on my model containing the connection diagram > Simulation > Simulation with OMC
Then I entered the parameters as below:
http://image.noelshack.com/fichiers/2015/36/1441272284-temp.png

After that, I obtain a message error: "Simulation Results Plot Error", "Could not open the file [...]ModelicaMLModel.Design.TanksConnectedPI_res.mat"
And later, an empty window:
http://image.noelshack.com/fichiers/2015/36/1441272356-temp-2.png

I understood that this is related to a 'ReadMatlab4' exception but I don't know why I got this exception. What was wrong in my method?


Thanks in advance,
Pierre

Hi,

I worked on a Acceleo 2.x version. However, I tried on two other computers and it worked well. It must be an access error or another issue. I'll look after it.

Thank you for your help.

It worked! Thank you a lot for this help.

Thanks for your quick answer!

My precise approach was:

-> in the windows text editor, enter the following commands:

Code:

loadModel(Modelica); 

loadFile("C:/OpenModelica1.9.2/share/doc/omc/testmodels/dcmotor.mo");
simulate(dcmotor,startTime=0.0,stopTime=10.0);
plot({load.w,load.phi})

-> save as: "myScript.mos" in C:\OpenModelica1.9.2\bin
->  run the windows cmd.exe
-> check the %OPENMODELICAHOME% path
----> execute > echo %OPENMODELICAHOME%
-----> obtain: C:\OpenModelica1.9.2\-> try to run the script:
----> execute >%OPENMODELICAHOME%\bin\omc myScript.mos
----> obtain:
"File does not exist: myScript.mos
# Error encountered! Existing...
# Please check the error message and the flags.

Excution failed!"

Hi,

I do have the same problem. Does any one could help us on this? I tried to right some command lines (from the user guide to be sure of their quality) in a basic text editor and then save the file as a <*.mos> flie. I saved it in different sub-folders of %OPENMODELICAHOME% folder and tried to run the command:
[ > %OPENMODELICAHOME%\bin\omc myScript.mos ] in the Windows command shell. However, I obtained an error message.

So, I would like to know what is the right process to generate a .mos file and execute it.

Thanks in advance,
Pierre.

Hi!

Thank you for such a quick answer!

I've already tried to generate code from other models (empty model, model with one package, model with one package and a class: different little combinaitions). However, I still obtain the same error log that refers to the template error. Despite the fact I used the working package, could this be related to any Acceleo compatibility issue? or the template .mt file?

Thanks in advance

Hello,

I'm quite new in this community and I would like to try the functionalities offered by ModelicaML. I constated some dependancies issues so I downloaded a working Windows package, http://www.ida.liu.se/labs/pelab/modeli … clipse.zip and tried to launched the code generation of the Two Tanks example project 'modelicaml.example.twotankssystem.tutorial_v05'. Yet, I didn't manage to obtain the Modelica source code from the example.

I got two errors:
- first, when I open the 'Two Tanks' model, this message appears: "Some local profiles have changed. Select the ones you want to re-apply:".
- secondly, when I launch the generation ('Generate Modelica code (from sub-tree)", the return is a errors.log file containing:

"Compilation error in the file : C:\Users\Pierre\Documents\Logiciels\Eclipse-ModelicaML-2\eclipse\configuration\org.eclipse.osgi\bundles\2699\1\.cp\ModelicaML2Modelica_v04.mt
The template contains errors. : --%> is required to close <%--"

I tried to figure out where the error comes from, I followed multiples tutorials and read some previous discussions from this forum but nothing came out.

Please, let me know how to handle this problem, which seems to be a rookie mistake,

Thanks,
Pierre

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