Advertisement
luizaspan

Colisão unidimensional /não acabado nem testado

May 14th, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. // método de euler para EDOs:
  2. // f(x+dx) = f(x) + dxF(f,x) (+ condição inicial)
  3.  
  4. // EDO Colisão unidimensional
  5.  
  6. #include <stdio.h>
  7.  
  8. #define dt 0.01
  9.  
  10. #define v01 10
  11. #define v02 -15
  12. #define m1 3
  13. #define m2 4
  14.  
  15. int main(void)
  16. {
  17.   int i;
  18.   double t,x1,x2,v1,v2;
  19.  
  20.   x1=20;
  21.   x2=35;
  22.  
  23.   for (i=0;i<=10000;i+=2)
  24.     {
  25.       t=++i*dt;
  26.       x1+=v01*dt;
  27.       x2+=v02*dt;
  28.       v1=v01;
  29.       v2=v02;
  30.  
  31.       if (x2==x1)
  32.     {
  33.       v1=((m1-m2)/(m1+m2))*v01+(2*m2/(m1+m2))*v02;
  34.       v2=(2*m1/(m1+m2))*v01-((m1-m2)/(m1+m2))*v02;
  35.     }
  36.  
  37.       printf("%lf\t %lf\t %lf\t %lf\t %lf\n",t,x1,x2,v1,v2);
  38.     }
  39.  
  40.   return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement