Message Boards Message Boards

1
|
6160 Views
|
16 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Importing FMU to System Modeller

Posted 4 years ago

Hello, Use System Modeller a good deal yet need to use the Fluid Library too - this is not included in SM12.1 Modelica 3.2.3 yet is in most versions of 3.2.3.
The workaround seems to be to create a FMU in OMEdit Modelica and then export a FMU to System Modeller (Sim Center). Yet when I import even a simple model (Rotational, not even Fluid), I get the following:

*Error:  Assertion triggered during translation: "Imported FMU does not support the current platform (as determined by ModelicaServices.target=Default), supported platforms: x86_64-pc-win32"
Build finished at 19:56:20 (took 00:00).*

Is there a known method to allow importation of an FMU to SM?

Thanks for the help.

POSTED BY: Chris Benson
16 Replies
Posted 4 years ago

Thank you. This allows the full power of Mathematica to be easily applied to a external simulation.

I had assumed that the model would need to exist in SM, but almost all the functionally exist with just the imported .mat data file. I have never seen that advertised anywhere.

This has saved me hours.

Thanks again.

POSTED BY: Chris Benson

For example, being able to save a preset for a plot to meet a certain publication standard (colours, Labels, width, etc) would be great. For now, Sm-> Mathematica works.

Yes that would indeed be useful.

For now, working with Modelica Fluids, I do this: - design and edit in SM - to OMEdit for final edit and running the model - .mat to SM MC for an easy import/conversion to .csv - Import[] to Mathematica then to post-processing and plots .

Then you simplify the process by opening the mat file directly in Mathematica, note that it will take ownership of the file and will delete int when you quit so you probably want to wrap that function with something that makes a temporary copy of the original file.

SystemModelSimulationData["/path/to/matfile.mat"]

POSTED BY: Otto Tronarp
Posted 4 years ago

Good morning.

The saving of the line settings does help in a minor way. What I have ended up doing is just pulling the data to Mathematica where I can have width, dashing, filling, colour all saved. It works, but is two steps. In future SM, it would be great if something similar were possible. For example, being able to save a preset for a plot to meet a certain publication standard (colours, Labels, width, etc) would be great. For now, Sm-> Mathematica works.

For now, working with Modelica Fluids, I do this: - design and edit in SM - to OMEdit for final edit and running the model - .mat to SM MC for an easy import/conversion to .csv - Import[] to Mathematica then to post-processing and plots .

Eventually I will parse the .Mat directly in Mathematic. It works, but painful.

Again, thanks for the help.

Thanks for the help.

POSTED BY: Chris Benson

Thank you for that bit of knowledge - the MDI vs TDI displays. That goes a long way as it saves the plots. When working one type of model, it is helpful to see a parametric and a group y-time plots. - so for my mechanical models (rotational...), this is much better - being OMEdit, yet for Fluids... perhaps SM13.

Is the reason that you want the MDI that you want to see a parametric and a time plot at the same time? That's actually possible, but perhaps not that obvious. If you use the Plot > Plot Data Setup Dialog you can add a parametric plot to a X(T) plot window, see attached plot for an example.

On a side question, is it possible to save the plot settings - ie, the shading and line width, axis labels. While one can save the plot data selection, plot improvements beyond that do not save (at least with the knowledge I have).

No cosmetic changes are saved when saving as a model plot (Plot > Add Plot To Model), but there is a global setting for the the default line width.

Axis range, label and unit should be saved.

Otto

Attachment

Attachments:
POSTED BY: Otto Tronarp
Posted 4 years ago

Thank you for that bit of knowledge - the MDI vs TDI displays. That goes a long way as it saves the plots. When working one type of model, it is helpful to see a parametric and a group y-time plots. - so for my mechanical models (rotational...), this is much better - being OMEdit, yet for Fluids... perhaps SM13.

On a side question, is it possible to save the plot settings - ie, the shading and line width, axis labels. While one can save the plot data selection, plot improvements beyond that do not save (at least with the knowledge I have).

Thanks for the help.

POSTED BY: Chris Benson

Hi,

Ok then you have tried it at least.

This is unfortunate since the SM environment is much nicer to work in and the integration with Mathematica is great. Yet I must say that OMEdit is getting much better and has several advantages over SM: - being able to arrange and move plots around - while SM has a nice presentation, they are a fixed stack order, meaning if you want to change this, you must rebuild the work (yet OMEdit doesn't save plot settings, so each has its own issues).

Are you referring to the tabbed interface here? It is still possible to switch to an MDI interface SimulationCenter>Preferences>SimulationCenter (or Tools>Options>SimulationCenter if you are on Windows/Linux) and select MDI.

Thanks for the feedback.

Otto

POSTED BY: Otto Tronarp
Posted 4 years ago

Hi,

I have tried Fluid models in SM. For a long time did try building models in SM, yet past the basic editing, there were always errors that I believe had to do with the Flow connectors. I built the same models in OMEdit and they run. With those working models, I then try them in SM, but no luck. The models are not complicated: a sink and source (ideal gas), two valves, and a volumetric compressor. Even using only standard Modelica 3.2.3 elements, it does not work. I tried with with SM12 and SM12.1. Often they seem ok in SM yet fail in compiling in MC or fail the run.

This is unfortunate since the SM environment is much nicer to work in and the integration with Mathematica is great. Yet I must say that OMEdit is getting much better and has several advantages over SM: - being able to arrange and move plots around - while SM has a nice presentation, they are a fixed stack order, meaning if you want to change this, you must rebuild the work (yet OMEdit doesn't save plot settings, so each has its own issues)

- Optimaztion is much better in OMEdit: 
    1) It is easier to do parameter sweeps in OMEdit and appears to be faster than the SM->Mathematic path
   2) The OMOtim package of OMEdit allows system optimisation of the system - it is much faster than the parametric optimisation of SM->M.

I do have great hope for SM13 with learning all the tricks of OMEdit and of course Fluids.

For now I am working OMEdit for my fluid projects an then -> .xls -> Mathematica for post-processing.

  • perhaps more than you asked, but for thought.
POSTED BY: Chris Benson

Hi Chris,

You are right I won't comment on release plans here.

I see from you old posts that you have tried to use Fluid in the past, have you tried i lately? Might be worth a shot, there is no particular Modelica construct that Fluid needs that SystemModeler doesn't support. It's more that in many cases the resulting equation systems require more symbolic processing to be easily solvable and that you can workaround to some extent while modeling.

Otto

POSTED BY: Otto Tronarp
Posted 4 years ago

Hi Otto,

Thank you for the help. In the longer term I will get OMEdit on my Mac side as it seems the solution. Yet due to some complexities (having openFoam CFD on my Mac side), the installation is problematic. I think I found a work around in the Windows environment.

I realise this is likely not for public consumption, but does it look like System Modeller might support fully Fluids in the next version - Spring 2021? I do have my hopes.

Chris

POSTED BY: Chris Benson

In most cases the FMU is a binary so it's tied to the OS it was built for. There are some support in the standard for source code FMUs but that's not supported by SystemModeler. However, what you could do is export it as a source code FMU from OpenModelica (if they support it) and then compile the binary manually on macOS so that you get binary FMU for macOS.

I thought the OpenModelica was available on macOS, so you shouldn't need to move to Windows.

Otto

POSTED BY: Otto Tronarp
Posted 4 years ago

Hi Otto,

I just want to confirm that both of these (System Modeller, OMEdit) running on one OS, namely Windows 10, that the FMU 32bit vs. 64bit is solved. I will have to purchase an additional Wolfram license and don't want to do so unless this is a path forward.

With this I will create Fluids models in SM for ease of editing and such, then move the .mo to OMEdit, create the run it, edit as required, then export the working model to FMU. Then open in SM on Windows.
- from what I understand of what you are saying this should work?

I then plan to call is as a model in Mathematica for optimisation and data work. Do you foresee this as also requiring a Windows version of Mathematica?

Thanks for the help.

Chris

POSTED BY: Chris Benson
Posted 4 years ago

We were posting at the same time...

I am confused why the same OS would be required? Are not all the files involved OS independent? This is possible, but a bit costly.

POSTED BY: Chris Benson
Posted 4 years ago

To add to the info: For both the imported FMU diagram view in System Modeller:

Imported FMU for model exchange FMI version: 2.0 Generation tool: OpenModelica Compiler OpenModelica v1.14.1 (64-bit) Targets: x86_64-pc-win32

This is true no matter which 64bit compiler I have selected. If seems System Modeller takes a 64bit FMU and makes a 32 bit FMU.

POSTED BY: Chris Benson

You need to generate the FMU on the same platform as you are running SystemModeler, so if you use SystemModeler on macOS you need to export the FMU on macOS as well.

Otto

POSTED BY: Otto Tronarp
Posted 4 years ago

Hi Otto, Thanks for the help.

I'm still not having any luck, so here is some more detail if this helps:

In Model Center I have two complier options:
GCC/G++ with x86_64 Glang++ 11.0.3 64bit with x86_64

I have imported the simple rotation model via System Modeller as both Model Exchange and Co_simulation.

As a .mo, both work fine in both OMEdit on W10 and System Modeller/Model Centre on my Mac.

I used the .mo in OMEdit to create a FMU:

*mingw32-make: Entering directory 'C:/Users/Chris/AppData/Local/Temp/OPENMO~1/OMEdit/Rotation' rm -f Rotation.fmutmp/sources/Rotation_init.xml cp -a "C:/Program Files/OpenModelica1.14.1-64bit//share/omc/runtime/c/fmi/buildproject/"* Rotation.fmutmp/sources cp -a Rotation_FMU.libs Rotation.fmutmp/sources/ mingw32-make: Leaving directory 'C:/Users/Chris/AppData/Local/Temp/OPENMO~1/OMEdit/Rotation' RESULT: 0* I then tried to simulate them both in Model Centre, and both resulted in:

Error: Assertion triggered during translation: "Imported FMU does not support the current platform (as determined by ModelicaServices.target=Default), supported platforms: x86_64-pc-win32"

While the link below gave great hope in being able to use SystemModeller for Fluids, I have run into this.

Any help is greatly appreciated.

Chris

POSTED BY: Chris Benson

Hi,

it looks like you are using a 64-bit FMU but building 32-bit simulations, you need to make them match. You can change to build 64-bit simulations by going to Options > Global > Compiler and select a 64-bit compiler configuration instead.

I hope that helps, Otto

POSTED BY: Otto Tronarp
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract