Analysis of the spring damping system
The schematic of the system is shown in the figure below.

The implementation will include three subsystems:
- mass-1, spring-1, damper-1.
- spring-2, dumper-2.
- mass-2, spring-3, damper-3.
The figure below shows the top level of the implemented system.

Also shown below is the content of all subsystems of the model in their chronological order. The first one is Mass_1 Spring_1 Damper_1.

The second is Spring_2 Damper_2.

And the third is Mass_2 Spring_3 Damper_3.

Now let's move on to the declaration of parameters of these systems.
# Определение масс тел
m1 = 20;
m2 = 10;
# Расчёт обратной дроби от массы тел
invm1 = 1/m1;
invm2 = 1/m2;
# Определение коэффициентов гашения демпферов
d1 = 0.5;
d2 = 0.2;
d3 = 2;
# Коэффициенты упругости пружин
k1 = 5;
k2 = 3;
k3 = 2;
# Начальные состояния интеграторов для первой и третьей подсистем
init_integrator_1 = 0.0001;
init_integrator_3 = 0;
# Входные силы воздействия
F1 = 20;
F2 = 40;
Let's run the model with our parameters.
function run_model( name_model, path_to_folder )
Path = path_to_folder * "/" * name_model * ".engee"
if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
model = engee.open( name_model ) # Открыть модель
model_output = engee.run( model, verbose=true ); # Запустить модель
else
model = engee.load( Path, force=true ) # Загрузить модель
model_output = engee.run( model, verbose=true ); # Запустить модель
engee.close( name_model, force=true ); # Закрыть модель
end
return model_output
end
run_model( "PowerAnalysis", @__DIR__ )
In this demonstration, the output signals describing the oscillatory processes of the masses are not logged via To Workspace, but via bus logging. Therefore, when we run the model, we see that several variables have been created with the name of the subsystem and the name of the output port, which are stored in the simout structure. If more than four signals are logged during the simulation, all their names can be viewed by hovering the cursor over the simout variable.
# Считывание из simout залогированных сигналов
X1 = simout["PowerAnalysis/Mass_1_Spring_1_Damper_1.X1"];
X1 = collect(X1);
X2 = simout["PowerAnalysis/Mass_2_Spring_3_Damper_3.X2"];
X2 = collect(X2);
X1[1:3,:]
As we see the data read field, from simout we get a DataFrames structure containing time stamp and data fields. We get a similar structure when reading WorkspaceArray.
Now let's construct a comparative graph of the oscillations of the two bodies from our model. In this case, we get the acceleration from the sum of the impact forces with respect to the mass of the body.
Then we calculate the velocity by integration. And at the expense of the second integration we obtain displacement, which in turn we log.
using Plots # Подключения библиотеки построения графиков
plotly()
plot(X1.time,X1.value) # Первое тело
plot!(X2.time,X2.value) # Второе тело
As we can see from the graph, the oscillations of the first body are more intense than the second. This is primarily due to the fact that the mass of the first body is twice the mass of the second body.
Also during the simulation we logged the capacities of dampers and springs. Let's analyse these data.
The power is calculated through the product of force over velocities.
# Демпфер
Fd2x1d = simout["PowerAnalysis/Mass_1_Spring_1_Damper_1/Product.1"];
Fd2x1d = collect(Fd2x1d);
Let's draw a graph.
plot( Fd2x1d.time, Fd2x1d.value )
In these two graphs we see the power drops for the first spring and the first damper.
Conclusion
In this demonstration, we have analysed the behaviour of the damper system and also looked at the different possibilities of logging signals from models in Engee.