Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: fishy on November 20, 2025, 01:51:24 am

Title: Modelica Library integration with EA/SysML/SysPhS
Post by: fishy on November 20, 2025, 01:51:24 am
Hi,
I am modeling a system that involves flows of multicomponent liquids.   I have managed to build and simulate simple models for single component fluid flow using the SysPhS library to generate blocks representing tanks, pipes, motors and pumps and SysMLSim Configurations to drive OpenModelica.
However, there is already a large library of active and passive components in the OpenModelica library.   I am trying to understand how to build blocks that can leverage that library, rather than re-create all the complex parametric models they contain from scratch in EA.   Really I just want SysML blocks that 'wrap' Modelica blocks, reproduce the properties/parameters and ports, but leave the underlying maths/parametrics to Modelica.
There are some simple examples on Sparx's website and YouTube showing how to use ModelicaBlocks from the SysPhS library as "pointers" Modelica Library items, but this looks at an electronics example using JK FlipFlops, and stops short of explaining how to setup all the constants, variables and ports defined on more sophisticated, non-electrical Library components, where some of the interfaces may be more complex than the templates available in the SysPhS library.   Has anyone done this, or can point me to a tutorial...?   I am particularly interested in Fluid components in the first instance.
Thanks,
Title: Re: Modelica Library integration with EA/SysML/SysPhS
Post by: fishy on November 28, 2025, 02:00:37 am
An update on what I'm learning by experimentation:
Analogues of the Modelica block structures need to be set up in EA:   Blocks, contianing properties to represent Modelica parameters, and ports.

One clear problem arises, which I can't see a workaround for:  If you stereotype a propery as both ModelicaParameter and PhSVariable, the SysMLSimConfiguration ignores this, and lists the property as a PhSConstant.   This means that the property then isn't available to choose as a plottable value, and as a consequence I can't see a way to extract varibles calculated by Modelica (e.g. flow through a pipe, or water level in a tank) and plot it from EA.

Another clear problem is the setting of typed Modelica properties via SysML parameters - e.g. specifying a Medium used in a flow calculation, such as water.   There isn't any easy way to do this as Modelica requires you to redeclare types that don't match the base class that a block is expecting.   For example, Modelica.Fluid.Vessels.OpenTank expects a Medium of type Modelica.Media.Interfaces.PartialMedum.   But the modelica object Modelica.Media.Water.StandardWater isn't of this type.   Setting Medium = 'redeclare package Medium = Modelica.Media.Water.StandardWater' as the EA initial value doesn't work - you still get the error:

Quote
Error: component tank1 contains the definition of a partial class Medium. (Expression: Modelica.Fluid.Vessels.OpenTank tank1(T_ambient=20,crossArea=1,height=3,p_ambient=101325) annotation(Documentation(info = ""), Placement(visible = true, transformation( origin = {-357, 30}, extent = {{0, 0}, { 152, 141}})));  ")"
Please redeclare it to any package compatible with Modelica.Media.Interfaces.PartialMedium.
Title: Re: Modelica Library integration with EA/SysML/SysPhS
Post by: fishy on January 16, 2026, 01:16:42 am
One additional obstacle to widely leveraging the Modelica Standard Library is that (as of 17.1.1715) EA's Modelica code generation doesn't correctly declare multi-dimensional parameters - an issue described in this bug...

https://sparxsystems.com/forums/smf/index.php/topic,49209.0.html (https://sparxsystems.com/forums/smf/index.php/topic,49209.0.html)

...many Modelica Library functions and blocks rely on the passing of multi-dimensional structures.