Skip to content

Commit

Permalink
rebound.c/h
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed May 30, 2016
1 parent 00cb6df commit 7529d69
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 56 deletions.
105 changes: 52 additions & 53 deletions src/rebound.c
Expand Up @@ -205,27 +205,26 @@ void reb_free_simulation(struct reb_simulation* const r){

void reb_free_pointers(struct reb_simulation* const r){
reb_tree_delete(r);
free(r->gravity_cs);
free(r->collisions);
free(r->gravity_cs );
free(r->collisions );
reb_integrator_wh_reset(r);
reb_integrator_whfast_reset(r);
reb_integrator_ias15_reset(r);
reb_integrator_hybarid_reset(r);
free(r->particles);
free(r->particles );
}

void reb_reset_temporary_pointers(struct reb_simulation* const r){
// Note: this will not clear the particle array.
r->gravity_cs_allocatedN = 0;
r->gravity_cs = NULL;
r->gravity_cs_allocatedN = 0;
r->gravity_cs = NULL;
r->collisions_allocatedN = 0;
r->collisions = NULL;
r->collisions = NULL;
// ********** WHFAST
r->ri_whfast.allocated_N = 0;
r->ri_whfast.eta = NULL;
r->ri_whfast.p_j = NULL;
// ********** IAS15
r->ri_ias15.allocatedN = 0;
r->ri_ias15.allocatedN = 0;
set_dp7_null(&(r->ri_ias15.g));
set_dp7_null(&(r->ri_ias15.b));
set_dp7_null(&(r->ri_ias15.csb));
Expand All @@ -236,13 +235,13 @@ void reb_reset_temporary_pointers(struct reb_simulation* const r){
r->ri_ias15.x0 = NULL;
r->ri_ias15.v0 = NULL;
r->ri_ias15.a0 = NULL;
r->ri_ias15.csx = NULL;
r->ri_ias15.csv = NULL;
r->ri_ias15.csa0 = NULL;
r->ri_ias15.csx = NULL;
r->ri_ias15.csv = NULL;
r->ri_ias15.csa0 = NULL;
r->ri_ias15.at = NULL;
// ********** WH
r->ri_wh.allocatedN = 0;
r->ri_wh.eta = NULL;
r->ri_wh.eta = NULL;
// ********** HYBARID
r->ri_hybarid.global_index_from_mini_index = NULL;
r->ri_hybarid.global_index_from_mini_index_N = 0;
Expand Down Expand Up @@ -280,49 +279,49 @@ void reb_init_simulation(struct reb_simulation* r){
reb_tools_init_srand();
reb_reset_temporary_pointers(r);
reb_reset_function_pointers(r);
r->t = 0;
r->G = 1;
r->softening = 0;
r->dt = 0.001;
r->t = 0;
r->G = 1;
r->softening = 0;
r->dt = 0.001;
r->dt_last_done = 0.;
r->root_size = -1;
r->root_nx = 1;
r->root_ny = 1;
r->root_nz = 1;
r->root_n = 1;
r->nghostx = 0;
r->nghosty = 0;
r->nghostz = 0;
r->N = 0;
r->allocatedN = 0;
r->N_active = -1;
r->testparticle_type = 0;
r->N_var = 0;
r->var_config_N = 0;
r->var_config = NULL;
r->exit_min_distance = 0;
r->exit_max_distance = 0;
r->max_radius[0] = 0.;
r->max_radius[1] = 0.;
r->status = REB_RUNNING;
r->exact_finish_time = 1;
r->root_size = -1;
r->root_nx = 1;
r->root_ny = 1;
r->root_nz = 1;
r->root_n = 1;
r->nghostx = 0;
r->nghosty = 0;
r->nghostz = 0;
r->N = 0;
r->allocatedN = 0;
r->N_active = -1;
r->testparticle_type = 0;
r->N_var = 0;
r->var_config_N = 0;
r->var_config = NULL;
r->exit_min_distance = 0;
r->exit_max_distance = 0;
r->max_radius[0] = 0.;
r->max_radius[1] = 0.;
r->status = REB_RUNNING;
r->exact_finish_time = 1;
r->force_is_velocity_dependent = 0;
r->gravity_ignore_10 = 0;
r->calculate_megno = 0;
r->output_timing_last = -1;
r->calculate_megno = 0;
r->output_timing_last = -1;

r->minimum_collision_velocity = 0;
r->collisions_plog = 0;
r->collisions_Nlog = 0;
r->collisions_plog = 0;
r->collisions_Nlog = 0;

// Default modules
r->integrator = REB_INTEGRATOR_IAS15;
r->boundary = REB_BOUNDARY_NONE;
r->gravity = REB_GRAVITY_BASIC;
r->collision = REB_COLLISION_NONE;
// Integrators


// Integrators
// ********** WHFAST
// the defaults below are chosen to safeguard the user against spurious results, but
// will be slower and less accurate
Expand All @@ -335,23 +334,23 @@ void reb_init_simulation(struct reb_simulation* r){

// ********** IAS15
r->ri_ias15.epsilon = 1e-9;
r->ri_ias15.min_dt = 0;
r->ri_ias15.epsilon_global = 1;
r->ri_ias15.min_dt = 0;
r->ri_ias15.epsilon_global = 1;
r->ri_ias15.iterations_max_exceeded = 0;

// ********** SEI
r->ri_sei.OMEGA = 1;
r->ri_sei.OMEGAZ = -1;
r->ri_sei.lastdt = 0;

r->ri_sei.OMEGA = 1;
r->ri_sei.OMEGAZ = -1;
r->ri_sei.lastdt = 0;
// ********** HYBARID
r->ri_hybarid.mini = NULL;
r->ri_hybarid.mini = NULL;
r->ri_hybarid.global = NULL;
r->ri_hybarid.switch_ratio = 0.;
r->ri_hybarid.CE_radius = 0.;
r->ri_hybarid.mini_active = 0;
r->ri_hybarid.timestep_too_large_warning = 0;

// Tree parameters. Will not be used unless gravity or collision search makes use of tree.
r->tree_needs_update= 0;
r->tree_root = NULL;
Expand Down
6 changes: 3 additions & 3 deletions src/rebound.h
Expand Up @@ -498,9 +498,9 @@ struct reb_simulation {
REB_INTEGRATOR_WHFAST = 1, ///< WHFast integrator, symplectic, 2nd order, up to 11th order correctors
REB_INTEGRATOR_SEI = 2, ///< SEI integrator for shearing sheet simulations, symplectic, needs OMEGA variable
REB_INTEGRATOR_WH = 3, ///< WH integrator (based on swifter), WHFast is recommended, this integrator is in REBOUND for comparison tests only
REB_INTEGRATOR_LEAPFROG = 4, ///< LEAPFROG integrator, simple, 2nd order, symplectic
REB_INTEGRATOR_HYBARID = 5, ///< HYBARID Integrator for close encounters (experimental)
REB_INTEGRATOR_NONE = 6, ///< Do not integrate anything
REB_INTEGRATOR_LEAPFROG = 4, ///< LEAPFROG integrator, simple, 2nd order, symplectic
REB_INTEGRATOR_HYBARID = 5, ///< HYBARID Integrator for close encounters (experimental)
REB_INTEGRATOR_NONE = 6, ///< Do not integrate anything
} integrator;

/**
Expand Down

0 comments on commit 7529d69

Please sign in to comment.