Skip to content

Commit e0295d9

Browse files
committed
Sources complètes + doc
0 parents  commit e0295d9

File tree

10 files changed

+1914
-0
lines changed

10 files changed

+1914
-0
lines changed

Euler.ml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
(*
2+
Two-Body-Problem
3+
Copyright (C) 2010-2011 Florian Lefèvre
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU Affero General Public License as
7+
published by the Free Software Foundation, either version 3 of the
8+
License, or (at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU Affero General Public License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*)
18+
#open "float";;
19+
20+
(*Création d'une matrice de taille adaptée*)
21+
let create_vect xo xf dx = make_matrix (int_of_float((xf-xo)/dx + 1./dx + dx)) 2 0.;;
22+
23+
(*Euler 1 - récursive*)
24+
25+
let rec euler1 f' yo xo xf dx =
26+
let y1 = yo + f'(xo,yo) * dx in
27+
match xo with
28+
|xo when xo < xf -> (xo,yo)::(euler1 f' y1 (xo + dx) xf dx);
29+
|_ -> []
30+
;;
31+
32+
(*Euler 1 - itérative*)
33+
34+
let euler1 f' yo xo xf dx =
35+
let i = ref xo and ii = ref 0
36+
and vect = (create_vect xo xf dx) in
37+
let y = ref yo in
38+
while !i <= xf do
39+
(vect.(!ii).(0) <- !i);
40+
(vect.(!ii).(1) <- !y);
41+
y := !y + f'(!i,!y) * dx;
42+
i := !i + dx;
43+
incr ii;
44+
done;
45+
vect;;
46+
47+
(*Euler 2*)
48+
49+
let euler2 f'' y'o yo xo xf dx =
50+
let y'' = ref (f''(xo,yo,y'o)) and y' = ref y'o and y = ref yo in
51+
let i = ref xo and ii = ref 0
52+
and vect = (create_vect xo xf dx) in
53+
while !i <= xf do
54+
(vect.(!ii).(0) <- !i);
55+
(vect.(!ii).(1) <- !y);
56+
y := !y + dx * ( !y' + ( !y'' * dx));
57+
y' := !y' + !y'' * dx;
58+
y'' := f''(!i,!y,!y');
59+
i := !i + dx;
60+
incr ii;
61+
done;
62+
vect;;
63+
64+
(*
65+
- Version finale (Copie de Méthode d'Euler 8.ml)
66+
*)
67+

Exemples.ml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
(*
2+
Two-Body-Problem
3+
Copyright (C) 2010-2011 Florian Lefèvre
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU Affero General Public License as
7+
published by the Free Software Foundation, either version 3 of the
8+
License, or (at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU Affero General Public License for more details.
14+
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*)
18+
19+
include "SystemeNonPerturbe.ml";;
20+
21+
(*Exemple 1*)
22+
(*Deux masses sans vitesse initiale en interaction gravitationnelle*)
23+
24+
let A = {masse = 5e12; rayon = 5; coord_x = 250. ; coord_y = 200.; vitesse_x = 0.; vitesse_y = 0.};;
25+
let B = {masse = 1e13; rayon = 7; coord_x = 50.; coord_y = 300.; vitesse_x = 0.; vitesse_y = 0.};;
26+
27+
solve A B 0.001;;
28+
29+
(*Exemple 2*)
30+
(*Cas d'une masse négligeable devant la seconde*)
31+
32+
let A = {masse = 1e17; rayon = 25; coord_x = 300. ; coord_y = 200.; vitesse_x = 0.; vitesse_y = 0.};;
33+
let B = {masse = 300.; rayon = 3; coord_x = 450.; coord_y = 200.; vitesse_x = 0.; vitesse_y = 200.};;
34+
35+
solve A B 0.0001;;
36+
37+
(*Exemple 3*)
38+
(*Deux masses égales en interaction*)
39+
40+
let A = {masse = 3e18; rayon = 5; coord_x = 150.; coord_y = 200.; vitesse_x = 0.; vitesse_y = -500. };;
41+
let B = {masse = 3e18; rayon = 5; coord_x = 400.; coord_y = 200.; vitesse_x = 0.; vitesse_y = 500.};;
42+
43+
solve A B 0.0001;;
44+
45+
(*Exemple 3 bis*)
46+
(*Deux masses égales en interaction sur une orbite circulaire*)
47+
48+
let A = {masse = 3e18; rayon = 5; coord_x = 100.; coord_y = 200.; vitesse_x = 0.; vitesse_y = -500. };;
49+
let B = {masse = 3e18; rayon = 5; coord_x = 500.; coord_y = 200.; vitesse_x = 0.; vitesse_y = 500.};;
50+
51+
solve A B 0.0001;;
52+
53+
(*Exemple 4*)
54+
(*Centre de masse en Mouvement Rectiligne Uniforme*)
55+
56+
let A = {masse = 1e17; rayon = 25; coord_x = 0. ; coord_y = 0.; vitesse_x = 25.; vitesse_y = 25.};;
57+
let B = {masse = 300.; rayon = 3; coord_x = 150.; coord_y = 0.; vitesse_x = 0.; vitesse_y = 250.};;
58+
59+
solve A B 0.0001;;
60+
61+
62+
(*Simulation Terre-Lune*)
63+
(*
64+
- Données :
65+
- Masse de la Terre : ~ 5,9736 x 10 ^ 24 Kg.
66+
- Masse de la Lune : ~ 7,3477 x 10 ^ 22 Kg.
67+
- Distance Terre-Lune : ~ 384 400 Km.
68+
- Vitesse orbitale de la Lune : 1,022 Km/s.
69+
- Donnée de vérification de la simulation :
70+
- Vitesse de libération : 2,38 km/s
71+
- Période de révolution : 27,321582 Jours (Soit ~ 2 360 584 s).
72+
*)
73+
74+
let Terre = {masse = 5.9736e24; rayon = 6000000; coord_x = 0.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 0.};;
75+
let Lune = {masse = 7.3477e22; rayon = 1737400; coord_x = 384.4e6; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 1.022e3};;
76+
77+
solve Terre Lune 1.;;
78+
79+
(***************************)
80+
(*Première vitesse cosmique*)
81+
82+
(*Echec de lancement*)
83+
84+
let Terre = {masse = 5.9736e24; rayon = 6378000; coord_x = 0.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 0.};;
85+
let Sat = {masse = 1e3; rayon = 1; coord_x = 6378100.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 7.900e3};;
86+
87+
solve Terre Sat 0.001;;
88+
89+
(*Mise en orbite correct*)
90+
let Terre = {masse = 5.9736e24; rayon = 6378000; coord_x = 0.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 0.};;
91+
let Sat = {masse = 1e3; rayon = 1; coord_x = 6378100.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 7.950e3};;
92+
93+
solve Terre Sat 0.001;;
94+
95+
(*Deuxième vitesse cosmique*)
96+
97+
(*Echec de libération*)
98+
99+
let Terre = {masse = 5.9736e24; rayon = 6378000; coord_x = 0.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 0.};;
100+
let Sat = {masse = 1e3; rayon = 1; coord_x = 6378100.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 11.100e3};;
101+
102+
solve Terre Sat 0.001;;
103+
104+
(*Le satellite échappe à l'attraction de la Terre*)
105+
let Terre = {masse = 5.9736e24; rayon = 6378000; coord_x = 0.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 0.};;
106+
let Sat = {masse = 1e6; rayon = 1; coord_x = 6378100.; coord_y = 500000.; vitesse_x = 0.; vitesse_y = 11.300e3};;
107+
108+
solve Terre Sat 0.001;;
109+
110+
111+
112+

0 commit comments

Comments
 (0)