Skip to content

This lab focuses on creating physical models using SysPhS and simulating their behavior using OpenModelica. In this laboratory, the vehicle speed control loop of the ACC is modeled. The control and vehicle models are simplified for better understanding.

Useful links

Note: knowledge of the SysPhS specification is not needed to complete this lab.

Preliminary steps

The following steps will show you how to install OpenModelica and configure it in Enterprise Architect.

  1. Install OpenModelica
    • Download installer for Windows: https://openmodelica.org/download/download-windows/
    • Download installer for Linux: https://openmodelica.org/download/download-linux
  2. Change perspective to "Simulation/SysML with Modelica" alt text
  3. In the Simulate tab, open "Modelica/Simulink / SysMLSim Configuration Manager" (Note: a model must be opened in EA to open the Configuration Manager. The solver setup will be global; any model can be opened for this step.) alt text
  4. In the SysMLSim Configuration Manager, configure the simulation solver alt text
  5. Select the location of "omc.exe" (on Linux, the omc binary) alt text
  6. Make sure that in the Portal>Window menu you opened the "Features" and "Properties" windows: https://ftsrg-rete.github.io/remo-lecture-notes/general-modeling-guide/#ablakok-beallitasa

Try out the simulation

The following steps will show you how you can create an example SysPhS model using an EA model pattern and how you can run simulations in EA.

  1. On the "Start Page" Create the "Two tanks" test models from pattern and explore the models alt text
  2. Click on the "TankPI" SysMLSimulationConfiguration and run the simulation to check if the OpenModelica is installed and configured properly alt text
  3. After the simulation finished, you should see the time plot of the water levels in the tanks and the water flow alt text

Create a structural model

This part of this document presents the preliminary structural modeling steps, which are required for the simulation.

  1. Create "Primitive Value Type Library" using modeling pattern: alt text
  2. Create packages for the Value Types, Components, Interfaces, and Constraint blocks: alt text
  3. Create value types to model the physical quantities in the system: alt text
  4. Create interface blocks to model the interactions between the components, because of the simulation, the direction of the flow properties shall be set to "none": alt text
  5. Create the structural composition model of the vehicle with ACC, similarly to laboratory 4: alt text
  6. Create the internal block diagram of the system context (which is modeled by the "Vehicle with ACC" block): alt text

Check: Take a screenshot of your IBD, and put it into your documentation.

Create the physical model

This section presents the physical modeling of the ACC and its environment using parametric diagrams and constraint blocks.

Modeling the Human-Machine Interface

The HMI sends a speed request to the ACC. Within the control loop, the speed request behaves as a reference signal. During the simulation, we assume that the reference signal does not change. Thus, we define a constant value property called "reference speed" and set its initial value to "30.0". alt text

Modeling the Speed Sensor

The Speed Sensor measures the speed of the vehicle and sends it to the ACC. The physical characteristics of the sensor are simple: its output equals its input. alt text alt text

Modeling the Vehicle Propulsion and Dynamics

The speed of the vehicle is dependent on two forces: * : the accelerating force created by the engine, and * : the decelerating force created by the friction of the wheels and the mechanical components.

Thus, the acceleration of the vehicle can be defined by the following equation:

The accelerating force of the engine is defined by the following equation if the speed of vehicle is not zero: .

If is smaller than we assume that the vehicle is accelerated by a constant force: .

The decelerating force is speed-dependent and can be calculated by the following equation: , where is the damping coefficient and

To model the engine and the vehicle, we define separate constraint blocks for the engine, the braking force, and the vehicle dynamics.

alt text

Within the engine characteristics, we define an operation to model the nonlinearity of engine acceleration near small speeds: alt text alt text

We define the overall physical characteristics of the vehicle using a parametric diagram:

alt text

Check: Take a screenshot of your parametric diagram, and put it into your documentation.

Modeling the ACC

Within the ACC, we define a simple P controller. The P controller contains three parts: 1. Error calculation: First, the controller calculates the difference between the reference speed and the speed measurement. 2. Control calculation: Thereafter, the P controller multiplies the error with a predefined gain, which is in this case . The result of the multiplication will show what fraction of the maximal motor performance is required. 3. Power actuation request calculation: Finally, the ACC ensures that the control value cannot be greater than and multiples the control value with the maximal power to calculate the engine performance request.

For better transparency, it is advantageous to model the three steps separately using three constraint blocks: alt text

Note: If you use the built-in Real type from the drop-down menu instead of the Real valuetype defined in the Primitive Value Types Library, then the property will appear in the paramaters compartment instead of the values compartment. The simulation should still work.

Within the "Power Request Calculation", an operation shall be defined to ensure that ACC does not want to request more power than the maximal engine performance, which is . alt text alt text

The overall behavior of the ACC can be defined using a parametric diagram, where binding connectors connect the parameters of the constraint parameters and the flow properties of the ACC: alt text

Check: Take a screenshot of your parametric diagram, and put it into your documentation.

After you have created all model elements, the BDD of the system context will look similar to this: alt text

Simulation of system behavior

After you have created the detailed model of the ACC and the vehicle, you can simulate the differential equations using OpenModelica.

  1. Ensure that you have defined the initial value for every value property, where it is important. Defining the initial value is especially important for constant value properties. If you do not specify an initial value, then zero will be the default initial value. alt text
  2. Using the "Simulation" toolbox, create a SysMLSimConfiguration artifact: alt text
  3. Double click on the simulation artifact, and the SysML Configuration Manager will automatically appear. In the configuration manager, select the package where the models are stored: alt text
  4. Set the block of the system context ("Vehicle with ACC") as "SysMLSimModel": alt text
  5. Set all constant value properties of the blocks as "SimConstant", to denote for the simulator that their value cannot change: alt text alt text
  6. Set how long you want to run the simulation and select which value properties shall appear in the simulation plot: alt text
  7. Validate the model to find possible errors. The errors will appear in the "System Output" window. Check: After correcting any errors, take a screenshot of your simulation configuration and put it into your documentation. (Note: The summary at the end of the validation result might say that there are more than zero errors even though it lists only warnings. Eliminating explicitly stated errors in the list is enough, but make sure that you get zero errors in the logs of the next step.)
  8. If there is no validation error, then run the simulator by clicking on the large "Solve" button. After a few seconds, the time-series plot of the selected value properties will appear: alt text
  9. Run the simulation multiple times with different gain values in the control loop, with different reference speed requests in the HMI, and with different initial vehicle speed values. Take a screenshot of the generated plots with each setup, and put it into your documentation.

Overall, your documentation should contain a screenshot (or a diagram export) for each of the following: - the IBD - the Parametric Diagram of the vehicle dynamics - the ACC's Parametric Diagram - the simulation configuration - the generated plots for at least two setups (different gain values, reference speeds, initial speed values).