Skip to content

Commit 3e8bbf6

Browse files
Merge pull request #121 from hannorein/matthewholman-main
Stop simulation on error.
2 parents 684c1aa + 63bee43 commit 3e8bbf6

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/forces.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,20 @@ void assist_additional_forces(struct reb_simulation* sim){
7171
// We might consider adding the heliocenter.
7272

7373
if(geo == 1){
74-
// geocentric
75-
// Get mass, position, velocity, and acceleration of the Earth for later use.
76-
// The offset position is used to adjust the particle positions.
77-
int flag = assist_all_ephem(ephem, assist->ephem_cache, ASSIST_BODY_EARTH, t, &GM, &xo, &yo, &zo, &vxo, &vyo, &vzo, &axo, &ayo, &azo);
78-
if(flag != ASSIST_SUCCESS){
79-
reb_simulation_error(sim, assist_error_messages[flag]);
80-
}
74+
// geocentric
75+
// Get mass, position, velocity, and acceleration of the Earth for later use.
76+
// The offset position is used to adjust the particle positions.
77+
int flag = assist_all_ephem(ephem, assist->ephem_cache, ASSIST_BODY_EARTH, t, &GM, &xo, &yo, &zo, &vxo, &vyo, &vzo, &axo, &ayo, &azo);
78+
if(flag != ASSIST_SUCCESS){
79+
reb_simulation_error(sim, assist_error_messages[flag]);
80+
sim->status = REB_STATUS_GENERIC_ERROR;
81+
return;
82+
}
8183
}else{
82-
// barycentric
83-
xo = 0.0; yo = 0.0; zo = 0.0;
84-
vxo = 0.0; vyo = 0.0; vzo = 0.0;
85-
axo = 0.0; ayo = 0.0; azo = 0.0;
84+
// barycentric
85+
xo = 0.0; yo = 0.0; zo = 0.0;
86+
vxo = 0.0; vyo = 0.0; vzo = 0.0;
87+
axo = 0.0; ayo = 0.0; azo = 0.0;
8688
}
8789

8890
// TODO: eliminate the output files after testing
@@ -315,6 +317,8 @@ static void assist_additional_force_direct(struct reb_simulation* sim, double xo
315317

316318
if(flag != ASSIST_SUCCESS){
317319
reb_simulation_error(sim, assist_error_messages[flag]);
320+
sim->status = REB_STATUS_GENERIC_ERROR;
321+
return;
318322
}
319323

320324
// Loop over test particles
@@ -359,6 +363,8 @@ static void assist_additional_force_direct(struct reb_simulation* sim, double xo
359363

360364
if(flag != ASSIST_SUCCESS){
361365
reb_simulation_error(sim, assist_error_messages[flag]);
366+
sim->status = REB_STATUS_GENERIC_ERROR;
367+
return;
362368
}
363369

364370
// Skip remainder of calculation if variational particles are not used

0 commit comments

Comments
 (0)