Compiling and Updating a Project to Add a Modelica Model and Component
Once the entity description and all architecture descriptions of a model are completed, the model is ready to be compiled and added to the Twin Builder project as a component.
You can update a project to both compile your Modelica model and create a component as follows:
- Select Modelica Model Editor > Compile & Update Project.
-
After model compilation, select the model interfaces you want to expose in Twin Builder. See Selecting Component Interface.
Note:Select the Don't show interface selection during compilation check box to skip this step in future compilations. To reenable this step, open the Options dialog box, select Model Editor > Modelica > General, and select the Show model interfaces dialog during compilation check box.
- The Import Components dialog box appears listing
all of the models in the current Modelica Model project on the Models tab.
Note:
Select the Don't show again and update component everytime check box to skip this step in future compilations. To reenable this step, open the Options dialog box, select Model Editor > Modelica > General, and select the Show update component dialog after compilation check box.
- See Importing and Updating Twin Builder Models and Components for detailed
information on settings you can make in this dialog box. When finished,
Twin Builder compiles the Modelica model source code.
- If the compiler detects an error or issues a warning, it is displayed in the Message Manager pane and will identify the line number of the statement that caused the error or warning. Press Ctrl+G to open the Go To Line dialog box to go to the line.
- If the compilation of the Modelica Model succeeds, a message appears in the Message Manager pane indicating that the project update was successful.
- A component for each model appears in the Project Manager Component Definitions folder. The new models also appear in the list of Project Components from which they can be placed onto a schematic for simulation.
Use External Solver
You can select this option under Modelica Model editor or from the Modelica ribbon. When selected, the compiled model uses an external solver during co-simulation; the following properties are added to the created component:
-
_cs_solver – Solver used in Co-Simulation. 0 - CVode, 1 – fixed step-size explicit Euler.
-
_cs_rel_tol – relative tolerance when CVode is used.
-
_cs_step_size – step size for Explicit Euler.
The above three properties control the usage of the external solver for the model.
Initialization of Input Values
Initial values of inputs can be specified using two ways:
- Input pin values at time=0 by setting UseStartValueInitialization to “false”.
- Corresponding _start parameters by setting UseStartValueInitialization to “true”.
The first option is the default option and is appropriate if the source of the input is from constant blocks, FML_INIT block, timer function components, and so on. However, if the input is connected to a quantity that depends on other components, it could lead to initialization failure due to improper initial values. Specifying the initial conditions for the inputs (the second option) is always the preferred way to initialize the model. The start parameters have the same name of the input plus _start suffix.