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 |
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).
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 ![]() |
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.
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 variablesimout
are read and to which the signal record is added.
The obtained result can be observed as a table in the command line.
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, theusing
keyword is used to import functions and types from packages. -
CSV.write("result.csv", result)
- performs writing data to a CSV format file. TheCSV.write
function takes two arguments: a file in CSV format "result.csv" and theresult
variable. As a result, the code takes theresult
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.
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:
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.