Engee documentation
Notebook

Analysis of the spring damping system

The schematic of the system is shown in the figure below.

image.png

The implementation will include three subsystems:

  1. mass-1, spring-1, damper-1.
  2. spring-2, dumper-2.
  3. mass-2, spring-3, dumper-3.

The figure below shows the top level of the implemented system.

image_6.png

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.

image_3.png

The second is Spring_2 Damper_2.

image_4.png

And the third is Mass_2 Spring_3 Damper_3.

image_5.png

Now let's move on to the declaration of parameters of these systems.

In [ ]:
# Определение масс тел
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.

In [ ]:
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
Out[0]:
run_model (generic function with 1 method)
In [ ]:
run_model( "PowerAnalysis", @__DIR__ )
Building...
Progress 0%
Progress 0%
Progress 5%
Progress 10%
Progress 15%
Progress 20%
Progress 25%
Progress 30%
Progress 35%
Progress 40%
Progress 45%
Progress 50%
Progress 55%
Progress 60%
Progress 65%
Progress 70%
Progress 75%
Progress 80%
Progress 85%
Progress 90%
Progress 95%
Progress 100%
Out[0]:
Dict{String, DataFrame} with 4 entries:
  "Mass_1_Spring_1_Damper_1.X1" => 10001×2 DataFrame…
  "Mass_2_Spring_3_Damper_3.X2" => 10001×2 DataFrame…
  "Product-1.1"                 => 20002×2 DataFrame…
  "Product.1"                   => 20002×2 DataFrame

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. image.png

In [ ]:
# Считывание из 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);
In [ ]:
X1[1:3,:]
Out[0]:

3 rows × 2 columns

timevalue
AnyAny
10.00.0001
20.010.000200998
30.020.000501961

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.

In [ ]:
using Plots # Подключения библиотеки построения графиков
plotly()
Out[0]:
Plots.PlotlyBackend()
In [ ]:
plot(X1.time,X1.value) # Первое тело
plot!(X2.time,X2.value) # Второе тело
Out[0]:

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.

In [ ]:
# Демпфер
Fd2x1d = simout["PowerAnalysis/Mass_1_Spring_1_Damper_1/Product.1"];
Fd2x1d = collect(Fd2x1d);

Let's draw a graph.

In [ ]:
plot( Fd2x1d.time, Fd2x1d.value )
Out[0]:

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.

Blocks used in example