Modeling and Simulation: Car Suspension Damping System using Runge Kutta ODE45

Post Reply
Joseph Bundala
Expert Member
Reactions: 23
Posts: 55
Joined: 7 years ago
Has thanked: 14 times
Been thanked: 28 times
Contact:

#1

Hello Guys.

I will try to show how we can solve an Ordinary Differential Equation using Matlab solver ODE45. However, with this problem i will use GNU Octave environment to solve. First, i will model a car suspension damping system equations then solve it.

In my previous post analogies-between-elements-in-electrica ... stems-5072, I modeled Mass, Spring, Damper System with its Electric circuit equivalent. So, in this figure a mechanical damper is presented and i will model and solve it at one initial condition as well as different initial conditions for displacements and velocity.

Image

Balance of forces in Mass, spring, damper system:





ODE45 format:

  1. [t,x] = ode45(@FunctionName,  tspan,  [xInitial; xdotInitial])
  2. FunctionName = [x(2), RightHandSideofAFunction]


Where

m-mass
D-Damping Ratio
K-Spring constant
F-Force

Let

then and

Replace the balance of Force equation with these new parameters and make the subject;





This plot shows that the Suspension system overshoots [Displacement and Velocity ] initially and becomes stable after some time on different initial conditions [from -1 to 1] , I think with the Phase Plane we might have a limit circle if i extend the initial conditions for displacement. This system has local equilibrium point as seen in the Phase Plane plot.



Asymptotically Stable System

Simulations.JPG
Simulations.JPG (37.54 KiB) Viewed 3684 times
Simulations.JPG
Simulations.JPG (37.54 KiB) Viewed 3684 times

What determines the quality of the systems, is it mass, Force, Damping Coefficient, or Spring Constant. I will modify the code to plot for different Damping coefficient and i will see the differences.



Global Stable system

Capture.JPG
Capture.JPG (44.72 KiB) Viewed 3684 times
Capture.JPG
Capture.JPG (44.72 KiB) Viewed 3684 times

So, in choosing the type of material to make a suspension system, the parameters above are taken into account to have a durable "shokapu"

@Admin please help me to put the codes below in a good listing, its .m file

  1. function  kkoo = damper(t,x)
  2.         m = 1;  %mass
  3.         F  = 10; %Force
  4.         D = 0.01;  %Damping Coefficient
  5.         K  = 10;  %Spring Constant
  6.        
  7.         tzr     = x(2);    %let  xdot    =x(2)
  8.         suka = 1/m.*(F - D*x(2)-K*x(1)); % Right hand side of the ODE
  9.         kkoo = [tzr; suka];
  10.        
  11.  endfunction
  12.  
  13. function venom
  14.  
  15.   t =  0:0.1:20;
  16.  
  17.    initial_x     = 0; % different initial condition, you can put any range say [-1:1]
  18.   initial_xdot  = 0;
  19.  
  20.   for j = 1:length(initial_x)
  21.       for k = 1:length(initial_xdot)
  22.         cond3 = initial_xdot(k);
  23.         cond2 = initial_x(j);
  24.         [t,x] = ode45(@damper, t , [cond2 cond3] );          
  25.        
  26.         figure 1    
  27.        
  28.         h(1) = subplot(2,2,1);
  29.         h(2) = subplot(2,2,2) ;
  30.         h(3) = subplot(2,2,[3 4]);
  31.        
  32.         set(h(1),'NextPlot','add');
  33.         set(h(2),'NextPlot','add');
  34.         set(h(3),'NextPlot','add');
  35.        
  36.         grid on        
  37.         plot(h(1),t,x(:,1));        
  38.         xlabel('Time t');
  39.         ylabel('Displacement x');
  40.         title('Car suspension model displacement');      
  41.        
  42.         grid on  
  43.         plot(h(2),t,x(:,2));        
  44.         xlabel('Time t');
  45.         ylabel('Velocity-xdot');
  46.         title('Car suspension model Velocity');
  47.        
  48.        grid on        
  49.         plot(h(3),x(:,1),x(:,2));        
  50.         xlabel('Displacement x');
  51.         ylabel('Velocity-xdot');
  52.         title('Car suspension model Phase Plane');
  53.        
  54.         endfor
  55.   endfor
  56.  
  57. endfunction

2 Image
Last edited by Joseph Bundala on Sat May 26, 2018 11:54 am, edited 1 time in total.
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#2

Great you mentioned Octave ( matlab-octave-69/
). GNU Octave is software featuring a high-level programming language, primarily intended for numerical computations. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly compatible with MATLAB. It may also be used as a batch-oriented language. Since it is part of the GNU Project, it is free software under the terms of the GNU General Public License.

Octave is one of the major free alternatives to MATLAB, others being Scilab and FreeMat. Scilab, however, puts less emphasis on (bidirectional) syntactic compatibility with MATLAB than Octave does, see more https://en.wikipedia.org/wiki/GNU_Octave

Together with SageMath:

SageMath is a free open-source mathematics software system licensed under the GPL. It builds on top of many existing open-source packages: NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R and many more. Access their combined power through a common, Python-based language or directly via interfaces or wrappers, see more http://www.sagemath.org/,

these are very powerful tools for solving mathematics and science problems. SageMath however intends to replace MATLAB, MAPLE, Magma and Mathematica altogether, see https://en.wikipedia.org/wiki/SageMath

In mathematics and sciences, we have the floor to do whatever we want. :sunglasses: :) :D
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Joseph Bundala
Expert Member
Reactions: 23
Posts: 55
Joined: 7 years ago
Has thanked: 14 times
Been thanked: 28 times
Contact:

#3

Sure @Eli , with these powerful tools it has became so easy to visualize and analyze real life mathematical problems.

I will check out on SageMath as well and hope to model another physical problem with it.
1
1 Image
User avatar
Robot
Super Administrator
Senior Expert Member
Reactions: 24
Posts: 124
Joined: 7 years ago
Has thanked: 7 times
Been thanked: 7 times

#4

Great post @Simulink, keep it up, this is how we make a difference :writing_hand: :+1: . Checkout our Instagram page https://www.instagram.com/the_home_of_c ... _thinkers/ to follow up some of the exciting graphics from this forum.
0
Joseph Bundala
Expert Member
Reactions: 23
Posts: 55
Joined: 7 years ago
Has thanked: 14 times
Been thanked: 28 times
Contact:

#5

Hi guys,

I had to revisit this thread that i wrote two years ago. I have seen there are a lot of changes in this forum and that's a very good step for sharing edu materials.

By then, the modeling and simulation of the mechanical damper was done in Octave. However, the mathematical model can be built in Simulink very easily. The model was run from multiple initial conditions for which one can study the stability of a control system.
  1. a = -1:0.5:1;
  2. b = -1:0.5:1;
  3. %hold on
  4. for i=1:length(a)
  5.   for j = 1:length(b)
  6.       init1 = a(i);
  7.       init2 = b(j);
  8.       sim('damper.slx');
  9.       plot(x,'LineWidth',2)
  10.       hold all
  11.   end    
  12. end
  13.  

damper.png
The animation was done in R and the following packages were used in this case

gganimate
gifski
damper.gif
damper.gif (179.48 KiB) Viewed 2394 times
damper.gif
damper.gif (179.48 KiB) Viewed 2394 times
Change the parameters of a control system and observe any behavioral change in simulation.
1
1 Image
Post Reply

Return to “Mechanical Engineering”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests