Skip to content

Commit e97cae5

Browse files
committed
reimplemented other than bs ode integration
1 parent b33f192 commit e97cae5

3 files changed

Lines changed: 27 additions & 41 deletions

File tree

rebound/simulation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,6 @@ class ServerData(Structure):
14621462
("_odes", POINTER(POINTER(ODE))),
14631463
("_N_odes", c_size_t),
14641464
("_N_allocated_odes", c_size_t),
1465-
("_odes_warnings", c_int),
14661465
("_additional_forces", CFUNCTYPE(None,POINTER(Simulation))),
14671466
("_pre_timestep_modifications", CFUNCTYPE(None,POINTER(Simulation))),
14681467
("_post_timestep_modifications", CFUNCTYPE(None,POINTER(Simulation))),

src/rebound.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ struct reb_simulation {
629629
struct reb_ode** odes; // all ode sets (includes nbody if BS is set as integrator)
630630
size_t N_odes; // number of ode sets
631631
size_t N_allocated_odes;
632-
int ode_warnings;
633632

634633
// Callback functions
635634
void (*additional_forces) (struct reb_simulation* const r); // Implement any additional (non-gravitational) forces here.

src/simulation.c

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,9 @@ static int reb_check_exit(struct reb_simulation* const r, const double tmax, dou
354354
}
355355
}
356356
#ifndef MPI
357-
if (!r->N){
358-
if (!r->N_odes){
359-
reb_simulation_warning(r,"No particles found. Will exit.");
360-
r->status = REB_STATUS_NO_PARTICLES; // Exit now.
361-
}else{
362-
if (strcmp(r->integrator.name, "bs")!=0){
363-
reb_simulation_warning(r,"No particles found. Will exit. Use BS integrator to integrate user-defined ODEs without any particles present.");
364-
r->status = REB_STATUS_NO_PARTICLES; // Exit now.
365-
}
366-
}
357+
if (!r->N && !r->N_odes){
358+
reb_simulation_warning(r,"No particles in simulation. Will exit.");
359+
r->status = REB_STATUS_NO_PARTICLES; // Exit now.
367360
}
368361
#else
369362
int status_max = 0;
@@ -535,35 +528,30 @@ static void reb_simulation_step(struct reb_simulation* const r){
535528

536529
// Integrate other ODEs
537530
if (r->N_odes && strcmp(r->integrator.name, "bs")!=0){
538-
// TODO: Reimplement
539-
//if (r->ode_warnings==0 && (!r->ri_whfast.safe_mode || !r->ri_saba.safe_mode || !r->ri_eos.safe_mode || !r->ri_mercurius.safe_mode)){
540-
// reb_simulation_warning(r, "Safe mode should be enabled when custom ODEs are being used.");
541-
// r->ode_warnings = 1;
542-
//}
543-
544-
// double dt = r->dt_last_done;
545-
// double t = r->t - r->dt_last_done; // Note: floating point inaccuracy
546-
// double forward = (dt>0.) ? 1. : -1.;
547-
// r->ri_bs.first_or_last_step = 1;
548-
// while(t*forward < r->t*forward && fabs((r->t - t)/(fabs(r->t)+1e-16))>1e-15){
549-
// if (reb_sigint > 1){
550-
// r->status = REB_STATUS_SIGINT;
551-
// return;
552-
// }
553-
// if (r->ri_bs.dt_proposed !=0.){
554-
// double max_dt = fabs(r->t - t);
555-
// dt = fabs(r->ri_bs.dt_proposed);
556-
// if (dt > max_dt){ // Don't overshoot N-body timestep
557-
// dt = max_dt;
558-
// r->ri_bs.first_or_last_step = 1;
559-
// }
560-
// dt *= forward;
561-
// }
562-
// int success = reb_integrator_bs_step_odes(r, dt);
563-
// if (success){
564-
// t += dt;
565-
// }
566-
// }
531+
double dt = r->dt_last_done;
532+
double t = r->t - r->dt_last_done; // Note: floating point inaccuracy
533+
double forward = (dt>0.) ? 1. : -1.;
534+
struct reb_integrator_bs_state* bs = reb_integrator_bs.create();
535+
while(t*forward < r->t*forward && fabs((r->t - t)/(fabs(r->t)+1e-16))>1e-15){
536+
if (reb_sigint > 1){
537+
r->status = REB_STATUS_SIGINT;
538+
return;
539+
}
540+
if (bs->dt_proposed !=0.){
541+
double max_dt = fabs(r->t - t);
542+
dt = fabs(bs->dt_proposed);
543+
if (dt > max_dt){ // Don't overshoot N-body timestep
544+
dt = max_dt;
545+
bs->first_or_last_step = 1;
546+
}
547+
dt *= forward;
548+
}
549+
int success = reb_integrator_bs_step_odes(r, bs, dt);
550+
if (success){
551+
t += dt;
552+
}
553+
}
554+
reb_integrator_bs.free(bs);
567555
}
568556

569557
PROFILING_STOP(PROFILING_CAT_INTEGRATOR);

0 commit comments

Comments
 (0)