ModelicaSpecification icon indicating copy to clipboard operation
ModelicaSpecification copied to clipboard

First Base Modelica test cases

Open casella opened this issue 1 year ago • 2 comments

This ticket contains seven test case of Base Modelica flat output obtained with OpenModelica. They are meant to support a first round of discussion about the forthcoming standard and its implementation.

Four tests are taken from the Modelica Standard Library version 4.0.0, two are taken from the ScalableTestSuite library, version 2.2.0, and one is taken from the PowerGrids library 1.0.3 (note that it still uses MSL 3.2.3). A .txt extension was added to allow uploading on github's issue tracker system.

Model Base Modelica code Purpose Issues
Modelica.Mechanics.Rotational.Examples.First First.mo Very simple 1D mechanical model None
Modelica.Blocks.Examples.PID_Controller PID_Controller.mo Simple model with blocks and mechanical components None
Modelica.Electrical.Analog.Examples.CauerLowPassAnalog CauerLowPassAnalog.mo.txt Simple electrical circuit None
Modelica.Fluid.Examples.Tanks.ThreeTanks ThreeTanks.mo Simple Fluid system, includes non-trivial functions of the IF97 water model and non-trivial stream connections PositiveMax() function definition must be added to flat model
ScalableTestSuite.Electrical.TransmissionLine.ScaledExperiments.TransmissionLineModelica_N_10 TransmissionLineModelica_N_10.mo Electrical circuit with arrays of interconnected components - scalar version None
ScalableTestSuite.Electrical.TransmissionLine.ScaledExperiments.TransmissionLineModelica_N_10 TransmissionLineModelica_N_10_array.mo Electrical circuit with arrays of interconnected components - array version None
PowerGrids.Electrical.Test.OneBusTransmissionLineShuntOneLoad Model using Complex array operator records, flat output contains records and functions from operator record definitions Base Modelica output currently broken, will provide ASAP
PowerGrids.Electrical.Test.OneBusTransmissionLineShuntOneLoad Model using Complex array operator records, flat output with inlined operator record functions Base Modelica output currently broken, will provide ASAP

One potentially interesting use of Base Modelica is the export of obfuscated models. This is more high-level than FMI, with IP protection provided by obfuscation. As a first example, consider the obfuscated version of the PID_Controller model: PID_Controller_obfuscated.mo.txt. This is currently still not fully working (i.e. we can't import it back to OMC) for technical reasons, but it already gives you an impression of what can be achieved.

One could also selectively obfuscate some parts of the flat model, i.e. those belonging to protected components, or those belonging to encrypted libraries. We have already implemented this feature, so I can provide more examples if needed.

casella avatar May 13 '24 21:05 casella

As noted at the meeting I don't think we should focus on obfuscating models.

  • One reason (as noted at the meeting) is that you often want to use them as sub-components, keeping parameters and connectors that are compatible with other Modelica models (already supported by Dymola as "File/Save/Encrypted Total Model"; except the exporter have to use some extra steps to find the non-encrypted obfuscated model - like: PID.tmp.mo.txt ). The use as a sub-component conflicts with the current goals of Base Modelica.
  • Another is that obfuscation seems tangential to the main purpose.

Obviously tools can still create obfuscated Base Modelica models. Obfuscating the parts coming from encrypted libraries might be necessary for Base Modelica, but I only see it as a limitation - not as a use-case in itself (i.e., the actual use-case is that you want to analyze the model in some way and the obfuscation only ensures that you don't see more than necessary).

HansOlsson avatar May 14 '24 12:05 HansOlsson

PR #3506 adds the experiment annotation to Base Modelica. Once accepted, I will update the Base Modelica code files.

casella avatar May 14 '24 20:05 casella

I just added and updated these tests (and a few others) to the BaseModelica_CrossCheck repo. We continue the work from there.

casella avatar Jul 01 '24 15:07 casella