Engee documentation

Software processing of simulation results in Engee

In this article we will tell you how to save simulation results using the simout variable. Let’s consider working with the variable on the basis of a simple example - output of a sinusoid using the block Sine Wave.

By default, the simout variable is not created after the model simulation is completed. To make it appear, tick the checkbox Save simulation results to workspace in the settings window debug article icon 1:

simout open 1

Variable simout in Engee: integration and interaction

Create a model using the blocks Sine Wave and Terminator. To do this, place them on the workspace, connect them with a signal line and enable signal recording using the context menu of the signal line. (see in Recording signals in Engee).

simout 1

In this example all parameters (solver and block parameters Sine Wave) remain by default. The graph of the sinusoidal signal simulation will be displayed in graph window.

Enable recording of signal logging 1 signals when connecting blocks on the pins for which information is required.

If the circuit is assembled correctly, the simulation result will be displayed on the graph. After the simulation is finished, the variable simout will be automatically created in the Engee workspace.

simout 2

The simout variable forms DataFrame - a data structure represented as a table. Cells of this table are automatically filled with simulation results data. For convenience, save the table in CSV format (named result.csv in the example).

The simout variable can be accessed via the collect command. The command collects data from the simout variable and saves it to a new variable. To execute the command, create a variable (result in this example) and save the simulation results by entering the following code on the command line:

result = collect(simout["newmodel_1/Sine Wave.1"])

Where:

  • result is the name of the variable into which the simulation data is saved (can be renamed).

  • newmodel_1 - name of the current model.

  • Sin Wave - name of the block that outputs the data.

  • 1 - number of the port, from the output of which the values for the variable simout are read and to which the signal record is added.

The obtained result can be observed as a table in the command line.

simout 4

Next, record the simulation data into a CSV file. Save the data inside the result variable to the CSV file result.csv using the following commands:

using CSV
CSV.write("result.csv", result)

where:

  • using CSV is a string indicating that the code will use functionality from the CSV library. In Julia, the using keyword is used to import functions and types from packages.

  • CSV.write("result.csv", result) - performs writing data to a CSV format file. The CSV.write function takes two arguments: a file in CSV format "result.csv" and the result variable. As a result, the code takes the result variable and writes its contents to the file "result.csv" in CSV format.

The results obtained are saved in the "result.csv" file, which is displayed in the file browser.

simout 5

The resulting CSV file contains numerical results of the Sine Wave block with the specified parameters (by default in this example). The results are presented in the form of columns time and value, where to each moment of time corresponds the simulation value of the block Sine Wave.

A CSV file with the simulation results can also be retrieved using the To CSV block.

You can make sure that the data is saved in the simout variable visually by displaying the graph in the command line or script editor:

using Plots
plot(result.time, result.value)

The resulting graph will coincide with the one obtained earlier in the graph window:

simout graph result

Thus, the article demonstrates how easy it is to save simulation results using the simout variable and a few lines of code. This approach is easy to use and ensures that the simulation data is saved in a convenient and versatile CSV format.