Engee documentation
Notebook

Mechanical system with rigid progressive motion limiter

This example shows two masses connected by a rigid limiter. Mass 1 is driven by an ideal source of velocity. When the direction of the input velocity changes, Mass 2 does not move until Mass 1 reaches the other end of the gap modelled by the progressive rigid stop.

Schematic of the model:

mechanical_system_translational_hardstop_1733299118648.png

Define the function to load and run the model:

In [ ]:
function start_model_engee()
    try
        engee.close("mechanical_system_translational_hardstop", force=true) # закрытие модели 
        catch err # в случае, если нет модели, которую нужно закрыть и engee.close() не выполняется, то будет выполнена её загрузка после catch
            m = engee.load("$(@__DIR__)/mechanical_system_translational_hardstop.engee") # загрузка модели
        end;

    try
        engee.run(m) # запуск модели
        catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
            m = engee.load("$(@__DIR__)/mechanical_system_translational_hardstop.engee") # загрузка модели
            engee.run(m) # запуск модели
        end
end
Out[0]:
start_model_engee (generic function with 1 method)

Running the model:

In [ ]:
try
    start_model_engee() # запуск симуляции с помощью специальной функции, реализованной выше
    catch err
    end;

Output the results of the simulation from the simout variable:

In [ ]:
res = collect(simout)
Out[0]:
10-element Vector{WorkspaceArray}:
 WorkspaceArray("Mass 1.flange.F")
 WorkspaceArray("Mass 2.flange.v")
 WorkspaceArray("Mass 2.F")
 WorkspaceArray("Mass 2.flange.F")
 WorkspaceArray("Mass 2.v")
 WorkspaceArray("Mass 1.flange.v")
 WorkspaceArray("mechanical_system_translational_hardstop/SysOutput")
 WorkspaceArray("Mass 1.F")
 WorkspaceArray("mechanical_system_translational_hardstop/Ideal Translational Motion Sensor.2")
 WorkspaceArray("Mass 1.v")

Writing results to variables:

In [ ]:
P1 = collect(res[9]); # Перемещение массы 1
P2 = collect(res[7]); # Перемещение массы 2
v1 = collect(res[10]); # Скорость массы 1
v2 = collect(res[5]); # Скорость массы 2

Simulation results:

In [ ]:
using Plots
plot(P1[:,1], P1[:,2], linewidth=3, xlabel= "Время, с", ylabel= "Перемещение, м", legend=:bottomright, label="Масса 1")
plot!(P2[:,1], P2[:,2], linewidth=3, label="Масса 2")
Out[0]:
In [ ]:
using Plots
plot(v1[:,1], v1[:,2], linewidth=3, xlabel= "Время, с", ylabel= "Скорость, м/с", legend=:bottomright, label="Масса 1")
plot!(v2[:,1], v2[:,2], linewidth=3, label="Масса 2")
Out[0]: