Faculté des

Sciences

Appliquées

 

Mécanique Rationnelle

2e candidature 2005-2006

Séminaire Matlab du 5/10/2012

 

1.

Une table est animée d’un mouvement d’oscillation A.sin(wt). Une balle est initialement au repos sur la table. Le coefficient de restitution est a. Le coefficient de restitution est défini par la relation :
 ou  est la vitesse après impact et  la vitesse avant impact dans le système de référence de la table en mouvement.

 

On demande

 

3. De modéliser par Matlab le mouvement de la table et de la balle pour les conditions initiales trouvées en 2.

 

Le cœur du code

La modélisation des équations par Runge Kutta

La condition de stop de l’intégration

La modélisation temps réel

La modélisation avec simulation du mouvement

 

 

Le cœur du code

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 

clear

 

 

global A omega ydot_initial y_initial g

options = odeset('Events','event_rebond','RelTol',1e-10);

omega=1;g=10;alpha=0.9;

t_max1=(pi/2+0*pi)/omega;

t_max2=(pi/2+2*pi)/omega;

ydot_initial=(alpha*g*t_max1-g*(t_max2-t_max1)/2)/alpha;

y_initial=A*sin(omega*t_max1)+g*t_max1^2/2-ydot_initial*t_max1;

 

% Cosmétique Graphe

 

 

for A=1:2:12 % on teste différentes valeurs de A amplitude de vibration table

figure

subplot(2,1,1); title(['A.\omega.\omega/g =',num2str(A*omega*omega/g)]);subplot(2,1,2);

  for i=1:35 % Nombre de rebonds

    if i==1

      t_initial=0;y_0=y_initial;  ydot_0=ydot_initial;

    else

      ydot_0 =-alpha*y(end,2)+(1+alpha)*A*omega*cos(omega*t(end));

      y_0=A*sin(omega*t(end)); 

      t_initial=t(end);

    end

   

    [t,y] = ode45(@rebond_eq,[t_initial:0.15:t_initial+100],[y_0 ydot_0],options);   

    % début du dessin

 

    subplot(2,1,2);plot(y(:,1),y(:,2));hold on;grid on

    subplot(2,1,1);plot(t(:),y(:,1),'r-');hold on;plot(t(:),A*sin(omega*t(:)));hold on;grid on ;

   

 

  end

  end

hold off;

 

­­­   Retour haut de la page  ­­­

 

La modélisation de l’arrêt de l’intégration

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 

function [value,isterminal,direction] = event_rebond(t,y)

global A omega ydot_initial y_initial

value = y(1)-A*sin(omega*t);

isterminal = 1;   % Stop the integration

direction = 0;   % Negative direction only

 

­­­   Retour haut de la page  ­­­

 

La modélisation de l’équation du mouvement

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 

function z = rebond_eq(t,y);

global A omega ydot_initial y_initial g

z=zeros(2,1);

z(1) = y(2);

z(2) = -g;

 

­­­   Retour haut de la page  ­­­

 

Version complète avec animation quasi temps réel

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

 

clear

% mov = avifile('c:\test3.avi','Compression','None','Quality',100,'fps',25)

global A omega ydot_initial y_initial g

omega=1;g=10;alpha=0.9;

t_max1=(pi/2+0*pi)/omega;

t_max2=(pi/2+2*pi)/omega;

ydot_initial=(alpha*g*t_max1-g*(t_max2-t_max1)/2)/alpha;

y_initial=A*sin(omega*t_max1)+g*t_max1^2/2-ydot_initial*t_max1;

t_initial=0;

 

% Cosmétique Graphe

figure('NumberTitle','on','Name','Séminaire du 5/10/2012 - Projet Table Vibrante','Renderer','OpenGL','Color','w','Position',[100 100 500 500])

subplot(2,1,1);

title(['A.\omega.\omega/g =',num2str(A*omega*omega/g)]);

xlabel('Temps (s)');ylabel('y (m)');axis([0 200 -30 100])

subplot(2,1,2);

title('Visualisation du mouvement');

xlabel('Temps (s)');ylabel('y (m)');

% Fin Cosmétique Graphe

 

 

for A=5:2:5 % on teste différentes valeurs de A amplitude de vibration table

  for i=1:35 % Nombre de rebonds

    if i>1

      ydot_initial =-alpha*y(end,2)+(1+alpha)*A*omega*cos(omega*t(end));

      y_initial=A*sin(omega*t(end));

      t_initial=t(end);

    end

  options = odeset('Events','event_rebond','RelTol',1e-10);

  [t,y] = ode45(@rebond_eq,[t_initial:0.15:t_initial+100],[y_initial ydot_initial],options);

 

    % début du dessin

  for j=2:1:max(size(t))

    subplot(2,1,1);

    line(t(j-1:j),y(j-1:j,1))

    line(t(j-1:j),A*sin(omega*t(j-1:j)),'Color','r')

    subplot(2,1,2,'replace');axis([-50 50 -10 100]);

    line(0,y(j),'Color','b','Marker','.','MarkerSize',5);

    line([-20 20],[A*sin(omega*t(j)) A*sin(omega*t(j))],'Color','r','LineWidth',2);

    drawnow;

    % F = getframe(gcf);

    % mov = addframe(mov,F);

    end

  hold off;

  end

end

%mov = close(mov);

­­­   Retour haut de la page  ­­­

 

 

 

 

 

Depuis le 06.02.2005, vous êtes le visiteur