Book a Demo

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - fishy

Pages: [1]
1
General Board / Re: Modelica Library integration with EA/SysML/SysPhS
« 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

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

2
Thanks - I did that also, but I hope posting on the forum is a good way for the dev team to discuss requirements/fixes with a wider group?

4
This relates to an obervation first made a few years ago...

https://sparxsystems.com/forums/smf/index.php/topic,48010.0.html

  • EA doesn't correctly declare Modelica parameters from SysML parameters that are typed as vectors using mutiplicty.
  • EA appears to ignore the stereotyping of parameters using SysPhS <<MultidimensionalElement>> when declaring Modelica parameters
  • There are inconsistencies in the syntax EA uses for Modelica parameters declared in blocks, and those declared for Operations stereotyped <<SimFunction>>.   It's actually slightly closer to correct for SimFunctions, but still doesn't work

This was last tested by me, using EA 17.1.1713

Please post here if you'd like me to expand with more detail.

5
I suspect, based on my own testing, that this is due several a bugs in how EA writes Modelica code...

To understand what's happening, you really need to take a look at the Modelica code generatedby EA when you press 'Solve' or 'Validate' in the 'Configure SysML Simulation' window.

In SysML, the natural way to work with vector quantities (1-d arrays) is to declare multiplicity on a parameter.
In EA, this means setting 'Property > Multiplicity > Upper bound' to a value greater than 1 (or potentially *) for an aribtrary upper bound.

But if you do this, EA messes up the syntax for Modelica definitions...

In your example, the correct definition for your 'ChooseVector' <<constraint>> would be:

    class ChooseVector;
        Real pX[3];
        Real pY[3];
        Real p[3];
        equation
            p = if (Type==X1) then pX else pY;
    end ChooseVector;


However, if you specify SysML multiplicity on the parameter, EA instead generates this:

    class ChooseVector;
        RealU005B3U005D pX;
        RealU005B3U005D pY;
        RealU005B3U005D p;
        equation
            p = if (Type==X1) then pX else pY;
    end ChooseVector;


...it's messing up in two ways:
  • It substitutes Unicode codes rather than using an ASCII square bracket ( U005B = [, in unicode)
  • It uses SysML notation, by putting the dimension next to the type definition (Real in this case), rather than matching the Modelica syntax and placing the dimension next to the variable.

If instead you take your appoach, of using the SysPhS stereotypes, by setting:
  • MultidimensionalElement.dimension = 3
  • Part.Lower Value = 3
  • Part.Upper Value = 3

...then EA just ignores these settings and produces...

    class ChooseVector;
        Real pX;
        Real pY;
        Real p;
        equation
            p = if (Type==X1) then pX else pY;
    end ChooseVector;


Which is why you see the error you do:  Modelica thinks pX, pY and p are single-valued parameters and can't assign a three valued vector.

6
General Board / Re: SimFunction
« on: January 12, 2026, 10:41:24 pm »
It appears that you can do this by manually defining a new stereotype:   Press the 'New...' button in the Stereotype window, and simply type SimFunction.
This then blows through nicely into the SysMLSimConfiguration screen...

7
General Board / Re: SimFunction
« on: January 12, 2026, 10:29:19 pm »
I am facing exactly the same problem in EA 17.1.   My aim is to write a funtion that will be interpreted by OpenModelica.   How do I apply the <<SimFunction>> stereotype?

8
I have noticed that when I have ports with multiple flow properties or complex structures - e.g. those typed with blocks containing multiple/nested properties (such as SysPhS interfaceBlocks) - the shapes that represent those properties do not always retain their position and dimensions on a Parametric diagram when the diagram is closed and re-opened.
Since it can take a lot of time to lay out a parametric diagram neatly, it's extremely frustrating to close the diagram, re-open it and then find that several things have moved or re-sized!
The underlying issue has something to do with the relative sizes of the shapes and the text they contain.   It appeas that a shape will re-size if the manually set size doesn't allow a sufficient margin around the text.   The same appears to be true of shapes containing other shapes - e.g. a block type containing properties, which itself is contained within a port on the boundary/frame of a parametric diagram:  if there is insufficient margin between a shape and the boundaries of the shapes it contains, then the containing shape may re-size or relocate.

As a supplementary observation, it's really frustrating that the resizing behaviour of ports and the shapes they contain is different:
  • the outer boundary of the port shape exhibits horizontal and vertical symmetry.   When you resize it, it's anchored in place by it's centre
  • any shapes (flow properties/type blocks) contained within the port do not anchor in the same way, meaning that they have to be manually positioned in the horizontal centre of the port.

9
General Board / Re: Modelica Library integration with EA/SysML/SysPhS
« 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.
  • For blocks, stereotype them as ModelicaBlock and set the ModelicaBlock.Name property to the full classpath of the Modelica element you want to 'wrap'.   For example:  Modelica.Fluids.Pipes.StaticPipe for a block that calculates flow through a pipe
  • For properties, stereotype them as ModelicaParameter.   Use the ModelicaParameter.Name property to match the name of the parameter instance within the Modelica block - for example length or diameter as constant properties of the pipe.   That allows you to set a completely arbitrary name as the SysML parameter name if you want to - e.g. use d for diameter, or L for length.   If you don't use ModelicaParameter.Name, or don't apply the ModelicaParameter stereotyope, then the SysML name field must match the Modelica instance name exactly.
  • For ports, similar to parameters, use ModelicaPort and ModelicaPort.Name to match the interface name used by the Modelica block - e.g. port_a or port_b on a pipe.

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.

10
General Board / Modelica Library integration with EA/SysML/SysPhS
« 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,

Pages: [1]