forked from AntefNava/rebound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrator.c
144 lines (137 loc) · 3.74 KB
/
integrator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* @file integrator.c
* @brief Integration schemes.
* @author Hanno Rein <[email protected]>
* @details This file implements the leap-frog integration scheme.
* This scheme is second order accurate, symplectic and well suited for
* non-rotating coordinate systems. Note that the scheme is formally only
* first order accurate when velocity dependent forces are present.
*
* @section LICENSE
* Copyright (c) 2015 Hanno Rein
*
* This file is part of rebound.
*
* rebound is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* rebound is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rebound. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include "rebound.h"
#include "gravity.h"
#include "output.h"
#include "integrator.h"
#include "integrator_whfast.h"
#include "integrator_ias15.h"
#include "integrator_leapfrog.h"
#include "integrator_sei.h"
#include "integrator_wh.h"
#include "integrator_hybrid.h"
void reb_integrator_part1(struct reb_simulation* r){
switch(r->integrator){
case REB_INTEGRATOR_IAS15:
reb_integrator_ias15_part1(r);
break;
case REB_INTEGRATOR_WH:
reb_integrator_wh_part1(r);
break;
case REB_INTEGRATOR_LEAPFROG:
reb_integrator_leapfrog_part1(r);
break;
case REB_INTEGRATOR_SEI:
reb_integrator_sei_part1(r);
break;
case REB_INTEGRATOR_WHFAST:
reb_integrator_whfast_part1(r);
break;
case REB_INTEGRATOR_HYBRID:
reb_integrator_hybrid_part1(r);
break;
default:
break;
}
}
void reb_integrator_part2(struct reb_simulation* r){
switch(r->integrator){
case REB_INTEGRATOR_IAS15:
reb_integrator_ias15_part2(r);
break;
case REB_INTEGRATOR_WH:
reb_integrator_wh_part2(r);
break;
case REB_INTEGRATOR_LEAPFROG:
reb_integrator_leapfrog_part2(r);
break;
case REB_INTEGRATOR_SEI:
reb_integrator_sei_part2(r);
break;
case REB_INTEGRATOR_WHFAST:
reb_integrator_whfast_part2(r);
break;
case REB_INTEGRATOR_HYBRID:
reb_integrator_hybrid_part2(r);
break;
default:
break;
}
}
void reb_integrator_synchronize(struct reb_simulation* r){
switch(r->integrator){
case REB_INTEGRATOR_IAS15:
reb_integrator_ias15_synchronize(r);
break;
case REB_INTEGRATOR_WH:
reb_integrator_wh_synchronize(r);
break;
case REB_INTEGRATOR_LEAPFROG:
reb_integrator_leapfrog_synchronize(r);
break;
case REB_INTEGRATOR_SEI:
reb_integrator_sei_synchronize(r);
break;
case REB_INTEGRATOR_WHFAST:
reb_integrator_whfast_synchronize(r);
break;
case REB_INTEGRATOR_HYBRID:
reb_integrator_hybrid_synchronize(r);
break;
default:
break;
}
}
void reb_integrator_reset(struct reb_simulation* r){
r->integrator = REB_INTEGRATOR_IAS15;
r->gravity_ignore_10 = 0;
reb_integrator_ias15_reset(r);
reb_integrator_wh_reset(r);
reb_integrator_leapfrog_reset(r);
reb_integrator_sei_reset(r);
reb_integrator_whfast_reset(r);
reb_integrator_hybrid_reset(r);
}
void reb_update_acceleration(struct reb_simulation* r){
// This should probably go elsewhere
PROFILING_STOP(PROFILING_CAT_INTEGRATOR)
PROFILING_START()
reb_calculate_acceleration(r);
if (r->N_var){
reb_calculate_acceleration_var(r);
}
if (r->additional_forces) r->additional_forces(r);
PROFILING_STOP(PROFILING_CAT_GRAVITY)
PROFILING_START()
}