Mechanical system with translational friction
This example shows a mass attached to a spring and a viscous damper. The mass is driven by an ideal source of velocity through the friction element. The motion profile of the velocity source is chosen in such a way that when plotting the dependence of the mass displacement on the displacement provided by the source, a typical hysteresis curve is obtained.
Model diagram:
Defining the function to load and run the model:
In [ ]:
function start_model_engee()
try
engee.close("mechanical_system_translational_friction", force=true) # closing the model
catch err # if there is no model to close and engee.close() is not executed, it will be loaded after catch.
m = engee.load("$(@__DIR__)/mechanical_system_translational_friction.engee") # loading the model
end;
try
engee.run(m) # launching the model
catch err # if the model is not loaded and engee.run() is not executed, the bottom two lines after catch will be executed.
m = engee.load("$(@__DIR__)/mechanical_system_translational_friction.engee") # loading the model
engee.run(m) # launching the model
end
end
Out[0]:
Launching the model:
In [ ]:
try
start_model_engee() # running the simulation using the special function implemented above
catch err
end;
Output of simulation results from the simout variable:
In [ ]:
res = collect(simout)
Out[0]:
Writing results to variables:
In [ ]:
P1 = collect(res[1]); # Moving the mass
P2 = collect(res[4]); # Moving the speed source
v1 = collect(res[2]); # Source speed
Simulation results:
In [ ]:
using Plots
plot(P1[:,1], P1[:,2], linewidth=3, xlabel= "Time, from", ylabel= "Displacement, m", legend=:bottomright, label="Weight")
plot!(P2[:,1], P2[:,2], linewidth=3, label="The speed source")
Out[0]:
In [ ]:
plot(v1[:,1], v1[:,2], linewidth=3, xlabel= "Time, from", ylabel= "Speed, m/s", legend=:bottomright, label="The speed source")
Out[0]:
In [ ]:
plot(P2[:,2], P1[:,2], linewidth=3, xlabel="Movement of the speed source, m", ylabel="Mass displacement, m", title="Displacement hysteresis curve", legend=false)
Out[0]:


