Create a model
Purpose of the tutorial is to show the typical steps for building a model, running an experiment and reporting results using Modelon Impact.
Modelon Impact is a web-based modelling and simulation environment. Access and use of the tool is through the web browser.
About the tutorial🔗
Time to complete tutorial is approximately 20-30 minutes.
The tutorial shows how to build a small fluid system consisting of two open tanks connected by two pipes.
Going through the tutorial will teach the essential skills of working in Modelon Impact. The purpose is to show how Modelon Impact works using the Graphical User Interface and libraries.
You will learn how to:
- Create a new workspace
- Build a model by adding and connecting components
- Set component properties also known as component parameterization
- Set simulation settings also known as experiment settings
- Run a simulation also known as running an experiment
- Display results by plotting variables
- Add views and stickies for diagram animation and analysis
Models are built within a workspace. The workspace has to be created and named. A workspace is where a user keeps models, libraries and other resource files used for a particular project. One workspace can contain multiple models that use different libraries.
- A workspace is created and opened from the welcome page. Go to welcome page by clicking on Impact icon located on top left.
- Click the NEW button to create a new workspace and give it the name my_workspace. This will create a new workspace and open the workspace landing page.
- For Modelon Impact desktop application, the workspace is stored locally on your computer. Learn more.
Graphic: New workspace landing page
You are now ready to create your first model in your workspace!
Modelon Impact is a model centric tool. The model you build and work on is at the center of all operations performed such as experimenting and analyzing performance.
In Modelon Impact, a model is created by dragging components from a library (located in workspace browser to the left) into the model canvas. Connecting and parameterizing the components makes the system ready for simulation.
The aim is to build a model consisting of two tanks connected by pipes by using components from the Modelica Standard Library, also known as MSL.
Each tank is placed at different heights where the initial water level is lower in tank2. The expected result is to finish up with the same water level in both tanks.
Create a new model🔗
- Open the left sidebar, known as the Library Browser.
- Click on the + button in the top-right corner to open up the Create new class menu.
- Name the new model Tanks and press Create. By convention, class names should start with a upper-case letter.
Learn more about the Class specialization option
This creates a new empty model named Tanks within your Workspace library.
Right-click on a library package and choose "New model" is a quick way to create a new model.
The next step is to find specific components and place them on the canvas. You will only use components from the Modelica Standard Library.
You will use following model components:
- Modelica.Fluid.Vessels.OpenTank - Modelica.Fluid.Pipes.StaticPipe - Modelica.Fluid.System
- Find the components within the Modelica library folder. The Library filtering function can be used.
- Add them on the model canvas.
Graphic: Adding Components
- Select and rotate the pipe using the right top rotating mark.
Click on and choose Shortcuts & Controls showing how to efficiently navigate the canvas.
Connect the tank and pipe together with the left mouse button from the bottom of the tank to the top pipe opening.
Compatible connectors are highlighted when you start dragging the connection line.
Once a connection has been made, the shape of the connection line can be edited by dragging at either the line or the corner point.
Set component properties🔗
The next step is parameterization, that is to set the properties for the tank and the pipe. The component properties or parameters determine the size and properties of the model.
Click on the right gray column of the canvas to open up the properties panel.
Double-clicking on a component is an alternative to open up the properties panel.
Graphic: Setting Component Properties
Select the tank component and set its properties:
- height = 12 m (General Tab)
- crossArea = 1 m2 (General Tab)
- use_portsData = false (Uncheck the check-box) (General Tab)
- level_start = 8 m (Initialization Tab)
There is no need to adjust other parameters, except for the setting of the media.
You will now set the media
- Click on Medium in the General tab.
- Choose Modelica.Media.Water.ConstantPropertyLiquidWater from the drop-down list and click on .
Type LiquidWater in the Medium drop-down list to quickly find the ConstantPropertyLiquidWater class.
If the propagate button is missing, make sure you enable the automatic propagation in the settings.
Select pipe and set its parameters as shown below:
- length = 2 m
- diameter = 0.1 m
- height_ab = 2 m
You have created the first part of the model, a tank and a pipe with their sensible properties. We will create the second part by copying the first part.
- Select the tank and the pipe components by a left-click on the canvas.
Right-click and choose Copy. Note, you can also use the keyboard shortcut Ctrl+C.
Paste the selected components by right-clicking on the canvas and choose Paste. Note, you can also use the keyboard shortcut Ctrl+V.
Adjust the model layout and connect both pipes together as shown below.
This gives us the final model layout. The remaining step is to change the initial water level within the second tank and changing the tank height relative to the first one.
Select tank2 component and set its properties:
- level_start = 0.01 m (Initialization Tab)
Select pipe2 and set its properties:
- height_ab = -1 m
Now the model is ready for the 1st run!
You have now built the complete system model. But before you press the simulation button, you need to set-up a simulation setting.
- Switch to the Experimentation mode.
We are interested in analyzing the transient behavior (Dynamic Analysis) of the tanks.
Click on the Dynamic icon to activate Dynamic Analysis.
Set the simulation stop time to 100 seconds.
Learn more about the advanced simulations settings
The experiment is now configured and you are ready to run the simulation.
- Click the run button to start the simulation.
It may take several seconds before the simulation is started as the model is first compiled.
When the simulation has finished, the result mode is activated and a new result Result1 is visible in the Results browser. The variables in Results are accessed from the Variable browser under Calculated Values.
Hover the mouse over Result1 and click on ... to rename, delete, download the result file or show simulation and compilation log.
The next step is to visualize the result!
Modelon Impact include simple but powerful visualization features such as plots and stickies allowing you to inspect and analyze result in an intuitive way.
Results can be visualized using:
- Plots - standard way to visualize transient result
- Stickies - display variables and parameters values on the model canvas
- Built in model animation- display built-in model animation on the model canvas
Result can also be exported for post-processing in other tools.
We are interested in plotting the water level in the tanks. A plot is created by dragging a variable from the variable browser into the modeling canvas.
- Select tank1 and drag and drop fluidLevel variable on the canvas to create the Water Level plot.
- Click on the title of the plot and rename the plot to Water Level.
- Add the water level of tank2 to the same plot, by dragging and dropping tank2.fluidLevel to the Water Level plot.
Create a new plot (Pipe Flow) showing the mass flow through the pipe: pipe2.port_a.m_flow plot and place it next to the Water Level plot.
Analysis: Initially water is flowing from the tank with the higher water level to the lower tank. The water levels in both tanks will stabilize around an equilibrium point when the static pressure from the tanks including the pipe height are equal on both sides.
How can I change units?
See change units
Each plot can be exported to a .png image or .csv file.
It is also possible to create parametric plots where the independent variable is not 'time.' We will now create a plot for the level of fluid in tank2 as a function of the level of fluid in tank1.
- Create a new plot by dragging and dropping the variable tank2.level on to an empty portion of the canvas.
- Click on the title of the plot and rename it to Water Level (Parametric).
- Now drag the variable tank1.level on to the x-axis of the plot to make that the x-variable.
Graphic: X-Y Plot
A new plot is created if the variable is dragged to an empty space in the canvas. If dragged onto an existing plot the variable is added to the same plot. If dragged on to the x-axis of an existing plot, the selected variable is chosen as the independent variable; this will generate a parametric x-y plot. It’s also possible to drag variables between plots.
The Time Slider at the bottom of the canvas can also be used to show a line marker in each plot with time on the x-axis.
The tank model has built-in diagram animation that is useful to quickly get an overview of the system. A time slider will automatically appear at the modeling canvas after simulation.
Slide the time slider and check the model behavior from 0 sec to 100 sec. It is also possible to use keyboard arrows to move through time up and down.
The sticky represents a label connected to a specific component or model.
There are 2 types of stickies:
- Not Editable (Result Variables)
- Editable (Inputs)
Non-editable sticky can be created by clicking on the icon next to each variable.
Enable stickies for,
Moving the time slider will update the values in the stickies.
Go to the Modeling tab and select pipe. Orange points can be seen next to some variables. Moving mouse over these parameters gives us an information that changing these parameters would trigger model re-compilation.
Create an editable sticky for pipe.General.Geometry.diameter.
We have just prepared a good view example including 2 plots and several stickies. This view can be saved by hovering the mouse cursor over below the run button and saving it.
- Create a new view called Basic View. Refer to Views for more detailed information.
It is possible to re-run the model with the adjusted pipe diameter and compare the results with the 1st run.
- Change the diameter = 0.2 m in pipe and press the Run button.
Graphic: Compare Results
Increasing of one of the pipe diameter allowed to reach the same water level faster as expected.
Congratulations, you have modelled, simulated and analyzed your 1st model!