@@ -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