Engee documentation

Software processing of simulation results in Engee

In this article, we will explain how to save simulation results using the 'simout` variable. Consider working with a variable based on a simple example — the output of a sine wave using a block Sine Wave.

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

simout open 1 en

The simout variable in Engee: integration and interaction

Create a model using 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 signal line context menu. (see Recording signals in Engee).

simout 1

In this example, all the parameters (solver and block parameters Sine Wave) — remain By default. The sinusoidal signal simulation graph will be displayed in the window signal visualizations graphs icon 1.

Enable signal recording signal logging 1 when connecting blocks on those pins for which you want to get information.

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

simout 2 en

The 'simout` variable generates DataFrame – a data structure represented as a table. The cells of this table are automatically filled with data from the simulation results. 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 (in this example, result) and save the simulation results by entering the following code into the command line:

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

Where:

  • 'result` is the name of the variable in which the simulation data is stored (can be renamed).

  • `newmodel_1' is the name of the current model.

  • `Sin Wave' is the name of the block that outputs the data.

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

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

simout 4 en

Next, write down the data about the simulation in a CSV file. Save the data inside the result variable to the result.csv CSV file using the following commands:

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

Where:

  • using CSV' – 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) – writes data to a CSV file. The 'CSV.write` function takes two arguments: the CSV file "result.csv" and the variable result. As a result, the code takes the variable result and writes its contents to the file "result.csv" in CSV format.

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

simout 5 en

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

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

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

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

The resulting graph will match the one that was received earlier in the window Charts:

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 the safety of simulation data in a convenient and universal CSV format.