Engee documentation
Notebook

Mechanical system with progressive friction

This example shows a mass attached to a spring and a viscous damper. The mass is driven by an ideal velocity source through a friction element. The motion profile of the velocity source is chosen so that a typical hysteresis curve is obtained when plotting the displacement of the mass against the displacement provided by the source.

Schematic of the model:

mechanical_system_translational_friction_modified_1734611281730.png

Define the function to load and run the model:

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

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

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]:
4-element Vector{WorkspaceArray}:
 WorkspaceArray("mechanical_system_translational_friction/Перемещение массы")
 WorkspaceArray("mechanical_system_translational_friction/Скорость источника")
 WorkspaceArray("mechanical_system_translational_friction/Ideal Translational Motion Sensor-1.1")
 WorkspaceArray("mechanical_system_translational_friction/Перемещение источника")

Writing results to variables:

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

Simulation results:

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