Engee documentation
Notebook

Car suspension simulation

This example will demonstrate the simulation of a simplified car suspension, which consists of independent front and rear vertical suspensions. The model includes the calculation of the body tilt.

The suspension scheme of the car model:

car.png

General view of the car suspension model:

suspension--1708522950414.png

The figure shows the simulated characteristics of a half-car. The front and rear suspensions are modeled as spring-damping systems. A more detailed model would include the tire model and the non-linearities of the damper, such as velocity-dependent damping (with more rebound damping than compression). The vehicle body has degrees of freedom of tilt and bounce. They are represented in the model by four states: vertical displacement, vertical velocity, angular displacement in pitch and angular velocity in pitch. A complete model with six degrees of freedom can be implemented using vector algebra blocks to perform axis transformations and force/displacement/velocity calculations. Equation block 1 describes the effect of the front suspension on rebound (i.e., the vertical degree of freedom).:

where:

Equation block 2 describes the pitching moments caused by suspension.

where:

Equation block 3 resolves the forces and moments that arise during the movement of a body, according to Newton's Second Law.:

where:

Loading and running the simulation

Enabling a backend method for displaying graphics:

In [ ]:
using Plots
gr();

Loading and launching the model:

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

try
    engee.run(m, verbose=true) # запуск модели
    catch err # в случае, если модель не загружена и engee.run() не выполняется, то будут выполнены две нижние строки после catch
        m = engee.load("/user/start/examples/controls/suspension/suspension.engee") # загрузка модели
        engee.run(m, verbose=true) # запуск модели
    end
Building...
Progress 100%
Out[0]:
Dict{String, DataFrames.DataFrame} with 6 entries:
  "Скорость изменения угла наклона" => 1001×2 DataFrame…
  "Торможение.1"                    => 1001×2 DataFrame…
  "Угол наклона"                    => 1001×2 DataFrame…
  "Усилие на задней оси"            => 1001×2 DataFrame…
  "Препятствие.1"                   => 1001×2 DataFrame…
  "Усилие на передней оси"          => 1001×2 DataFrame

Processing of results

Extracting data describing braking distance and sliding from the simout variable:

In [ ]:
sleep(5)
data = collect(simout)
Out[0]:
6-element Vector{WorkspaceArray}:
 WorkspaceArray("suspension/Торможение.1")
 WorkspaceArray("suspension/Препятствие.1")
 WorkspaceArray("suspension/Усилие на передней оси")
 WorkspaceArray("suspension/Скорость изменения угла наклона")
 WorkspaceArray("suspension/Усилие на задней оси")
 WorkspaceArray("suspension/Угол наклона")

Defining data from the model into the corresponding variables:

In [ ]:
stop_signal = collect(data[1])
barrier_signal = collect(data[2])
front_force = collect(data[3])
angle_speed = collect(data[4])
rear_force = collect(data[5])
angle = collect(data[6]);

Visualization of simulation results:

In [ ]:
p1 = plot(stop_signal[:,1], stop_signal[:,2], title="Сигнал торможения")
p2 = plot(barrier_signal[:,1], barrier_signal[:,2], title="Сигнал препятствия")
p3 = plot(front_force[:,1], front_force[:,2], title="Усилие на передней оси")
p4 = plot(angle_speed[:,1], angle_speed[:,2], title="Скорость изменения \n угла наклона")
p5 = plot(rear_force[:,1], rear_force[:,2], title="Усилие на задней оси")
p6 = plot(angle[:,1], angle[:,2], title="Угол наклона")
plot(p1, p2, p3, p4, p5, p6, layout=(3, 2), legend=false)
Out[0]:

Conclusion:

In this example, the simulation of a simplified car suspension was demonstrated. This model allows us to investigate the effects that occur during the operation of damping elements and suspension stiffness.