Modelling vehicle braking
This example will demonstrate the modelling of vehicle braking.
The car movement and its inertia are described by the Car block. The left port of this block receives the resultant force from the two pairs of wheels connected to the braking mechanism. The right port receives the air resistance force described by the subsystem of the same name.
Schematic diagram of the model:

Define the function to load and run the model:
In [ ]:
function start_model_engee()
try
engee.close("braking_distance", force=true) # закрытие модели
catch err # в случае, если нет модели, которую нужно закрыть и engee.close() не выполняется, то будет выполнена её загрузка после catch
m = engee.load("$(@__DIR__)/braking_distance.engee") # загрузка модели
end;
try
engee.run(m) # запуск модели
catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
m = engee.load("$(@__DIR__)/braking_distance.engee") # загрузка модели
engee.run(m) # запуск модели
end
end
Out[0]:
Running the simulation
In [ ]:
try
start_model_engee() # запуск симуляции с помощью специальной функции, реализованной выше
catch err
end;
Write from simout to variables the velocity, displacement and force signals:
In [ ]:
t = simout["braking_distance/Скорость в км/ч"].time[:]
distance = simout["braking_distance/Перемещение в км"].value[:]
speed = simout["braking_distance/Скорость в км/ч"].value[:]
forces_left = simout["braking_distance/Сила со стороны трансмиссии"].value[:]
forces_right = simout["braking_distance/Сила сопротивления воздуха"].value[:];
Visualising simulation results
In [ ]:
using Plots
In [ ]:
plot(t, forces_left, label="Усилие от трансмиссии, Н", linewidth=2)
plot!(t, forces_right, label="Сопротивление воздуха, Н", linewidth=2)
plot!(t, (forces_left+forces_right), label="Сумма сил, Н", linewidth=2, title="Силы, действующие на автомобиль")
Out[0]:
In [ ]:
plot(t, speed, label="Скорость, км/ч", linewidth=2)
plot!(t, distance*1000, label="Перемещение, м", linewidth=2)
Out[0]:
Defining a function to calculate the braking distance of a car and applying it to displacement data:
In [ ]:
function braking_distance(distance, t)
index = findfirst(x -> x < 0.00001, distance)
if index != nothing
return println("Тормозной путь: ", round(maximum(distance)*1000, digits=2), " м")
end
end
braking_distance(distance, t)
Conclusions:
This example demonstrated the modelling of vehicle braking. Using the function braking_distance
, the braking distance for a car with an initial speed of 100 km/h was calculated.