-
Notifications
You must be signed in to change notification settings - Fork 82
Conversion Scripts
For instance, a model in AixLib is renamed from AixLib.Fluid.HeatExchangers.HeaterCooler_T
to AixLib.Fluid.HeatExchangers.Heater_T
, then in another model the path to this model remains AixLib.Fluid.HeatExchangers.HeaterCooler_T
.
So, when renaming such a model, a conversion script should be created in ./AixLib/Resources/Scripts
and should be named like ConvertAixLib_from_<x.y.z>_to_<x.y.z+1>.mos
, where <x.y.z> denotes the version number still with the old model path and z+1
with the new model path.
The content must look like
convertClass("AixLib.Fluid.HeatExchangers.HeaterCooler_T", "AixLib.Fluid.HeatExchangers.Heater_T");
Now append the list of conversion scripts in the main package.mo
file of AixLib
appropriately like in this example:
annotation(..., version = "0.5.2", conversion(from(
version="0.3.2",script="modelica://AixLib/Resources/Scripts/ConvertAixLib_from_0.3.2_to_0.4.mos",
version="0.5.0",script="modelica://AixLib/Resources/Scripts/ConvertAixLib_from_0.5.0_to_0.5.1.mos",
version="0.5.1",script="modelica://AixLib/Resources/Scripts/ConvertAixLib_from_0.5.1_to_0.5.2.mos")),...
If now another library is opened, while the AixLib is already loaded, AixLib's conversion script(s) is automatically executed depending on the AixLib version in the uses()
anotation of the other library's package.mo
file.
If any change is made that makes AixLib incompatible in terms of a class name or a parameter name, it is necessary to create a conversion script, add it to the conversion()
list and to increase AixLib's version number in the annotation()
of AixLib's package.mo
file.
The 3 possible commands are:
convertClass ("oldClass", "newClass");
convertElement ("oldClass", "oldElement", "newElement");
convertModifiers("oldClass", oldParameterBindings, newParameterBindings);
There are many options to create enhanced script, e.g. use array notation with curled brackets. For challenging conversions have a look at Dymola's user manuals.
You can find one advanced example in ConvertAixLib_from_0.5.0_to_0.5.1.mos:
convertModifiers("AixLib.Fluid.FixedResistances.HydraulicResistance", {"D"}, {"diameter=%D%"});
Hereby an older parameter name D
will be renamed in all models to the new parameter name diameter
for the model AixLib.Fluid.FixedResistances.HydraulicResistance
. Furthermore, the old parameter values will be applied to the new parameter.
- Getting started
-
Modeling and simulation guide
- Modelica guidelines
- How to Modelica
- Important tools around AixLib
- Move from HeatPump to ModularReversible
-
Contribution guide
- Git Workflow
- Structure of Repository
- Behind the Scenes
- Contribute to AixLib
- Testing and model quality management
- Requirements
- Test Management
- Continuous Integration