Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. restart:
  2. with(linalg):
  3. with(DEtools):
  4.  
  5. x2(t):=cos(t):
  6. y2(t):=sin(t):
  7.  
  8. Position := [x(t), y(t), z(t)]:
  9. #Soleil:=[1,2,0]:
  10. Soleil:=[x2(t),y2(t),0]:
  11.  
  12. r := sqrt(x(t)^2 + y(t)^2 + z(t)^2 + 0.001):
  13. r2:= sqrt((x2(t)-x(t))^2 + (y2(t)-y(t))^2 + (0)^2 + 0.001):
  14.  
  15. Vitesse := [(D(x))(t), (D(y))(t), (D(z))(t)]:
  16.  
  17. CouplageGravitation := 1.0:
  18. CouplageGravitation2 := 0.005:
  19.  
  20. ForceGravitationnelle := -CouplageGravitation*Position/r^3:
  21. ForceGravitationnelle2:= -CouplageGravitation2*Soleil/(r2)^3:
  22.  
  23.  
  24. Force := ForceGravitationnelle + ForceGravitationnelle2:
  25.  
  26. Fx := innerprod([1, 0, 0], Force);
  27. Fy := innerprod([0, 1, 0], Force);
  28. Fz := innerprod([0, 0, 1], Force);
  29.  
  30. TempsInitial := 0:
  31. TempsFinal := 250:
  32.  
  33. eq1 := (D(D(x)))(t) = Fx;
  34. eq2 := (D(D(y)))(t) = Fy;
  35. eq3 := (D(D(z)))(t) = Fz;
  36.   /                                                                          
  37. - |         /      2                       2         2                       2
  38.   \1.0 x(t) \cos(t)  - 2 cos(t) x(t) + x(t)  + sin(t)  - 2 sin(t) y(t) + y(t)
  39.  
  40.                                                                 (3/2)\//
  41.           \                      /    2       2       2        \     | |
  42.    + 0.001/^(3/2) + 0.005 cos(t) \x(t)  + y(t)  + z(t)  + 0.001/     / \
  43.  
  44.                                  (3/2)                                
  45.   /    2       2       2        \      /      2                       2
  46.   \x(t)  + y(t)  + z(t)  + 0.001/      \cos(t)  - 2 cos(t) x(t) + x(t)
  47.  
  48.                                                    \
  49.            2                       2        \      |
  50.    + sin(t)  - 2 sin(t) y(t) + y(t)  + 0.001/^(3/2)/
  51.   /                                                                          
  52. - |         /      2                       2         2                       2
  53.   \1.0 y(t) \cos(t)  - 2 cos(t) x(t) + x(t)  + sin(t)  - 2 sin(t) y(t) + y(t)
  54.  
  55.                                                                 (3/2)\//
  56.           \                      /    2       2       2        \     | |
  57.    + 0.001/^(3/2) + 0.005 sin(t) \x(t)  + y(t)  + z(t)  + 0.001/     / \
  58.  
  59.                                  (3/2)                                
  60.   /    2       2       2        \      /      2                       2
  61.   \x(t)  + y(t)  + z(t)  + 0.001/      \cos(t)  - 2 cos(t) x(t) + x(t)
  62.  
  63.                                                    \
  64.            2                       2        \      |
  65.    + sin(t)  - 2 sin(t) y(t) + y(t)  + 0.001/^(3/2)/
  66.                                    1.0 z(t)              
  67.                    - ------------------------------------
  68.                                                     (3/2)
  69.                      /    2       2       2        \    
  70.                      \x(t)  + y(t)  + z(t)  + 0.001/    
  71.                       /                                                  
  72.    @@(D, 2)(x)(t) = - |         /      2                       2         2
  73.                       \1.0 x(t) \cos(t)  - 2 cos(t) x(t) + x(t)  + sin(t)
  74.  
  75.                             2        \      
  76.       - 2 sin(t) y(t) + y(t)  + 0.001/^(3/2)
  77.  
  78.                                                     (3/2)\//
  79.                      /    2       2       2        \     | |
  80.       + 0.005 cos(t) \x(t)  + y(t)  + z(t)  + 0.001/     / \
  81.  
  82.                                     (3/2)                                
  83.      /    2       2       2        \      /      2                       2
  84.      \x(t)  + y(t)  + z(t)  + 0.001/      \cos(t)  - 2 cos(t) x(t) + x(t)
  85.  
  86.                                                       \
  87.               2                       2        \      |
  88.       + sin(t)  - 2 sin(t) y(t) + y(t)  + 0.001/^(3/2)/
  89.                       /                                                  
  90.    @@(D, 2)(y)(t) = - |         /      2                       2         2
  91.                       \1.0 y(t) \cos(t)  - 2 cos(t) x(t) + x(t)  + sin(t)
  92.  
  93.                             2        \      
  94.       - 2 sin(t) y(t) + y(t)  + 0.001/^(3/2)
  95.  
  96.                                                     (3/2)\//
  97.                      /    2       2       2        \     | |
  98.       + 0.005 sin(t) \x(t)  + y(t)  + z(t)  + 0.001/     / \
  99.  
  100.                                     (3/2)                                
  101.      /    2       2       2        \      /      2                       2
  102.      \x(t)  + y(t)  + z(t)  + 0.001/      \cos(t)  - 2 cos(t) x(t) + x(t)
  103.  
  104.                                                       \
  105.               2                       2        \      |
  106.       + sin(t)  - 2 sin(t) y(t) + y(t)  + 0.001/^(3/2)/
  107.                                             1.0 z(t)              
  108.            @@(D, 2)(z)(t) = - ------------------------------------
  109.                                                              (3/2)
  110.                               /    2       2       2        \    
  111.                               \x(t)  + y(t)  + z(t)  + 0.001/    
  112. x0 := 2.0:
  113. y0 := 0.1:
  114. z0 := 1.0:
  115. Vx0 := -0.5:
  116. Vy0 := 0.0:
  117. Vz0 := 0.0:
  118.  
  119. ConditionsInitiales := x(0) = x0, y(0) = y0, z(0) = z0, D(x)(0) = Vx0, D(y)(0) = Vy0, D(z)(0) = Vz0 ;
  120. Trajectoire := dsolve({eq1, eq2, eq3, ConditionsInitiales}, {x(t), y(t), z(t)}, numeric, range = TempsInitial..TempsFinal, maxfun=0);
  121. x(0) = 2.0, y(0) = 0.1, z(0) = 1.0, D(x)(0) = -0.5, D(y)(0) = 0., D(z)(0) = 0.
  122. proc(x_rkf45)  ...  end;
  123. plots[odeplot](Trajectoire, [x(t), y(t), z(t)], TempsInitial..TempsFinal, numpoints = 1000, axes = boxed, scaling = constrained);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement