From 15becb24a4a07c02061226988ac167c9e235bb1f Mon Sep 17 00:00:00 2001 From: Hanno Rein Date: Wed, 1 Jan 2025 17:40:18 -0500 Subject: [PATCH] Renamed python functions of Simulation to be consistent with C: integrator_reset -> reset_integrator integrator_synchronize -> synchronize tree_update -> update_tree --- examples/outer_solar_system/problem.c | 4 ++-- ipython_examples/AdvWHFast.ipynb | 8 ++++---- rebound/simulation.py | 6 +++--- rebound/simulationarchive.py | 4 ++-- rebound/tests/test_shearingsheet.py | 2 +- src/particle.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/outer_solar_system/problem.c b/examples/outer_solar_system/problem.c index 11b8ca227..5882aa010 100644 --- a/examples/outer_solar_system/problem.c +++ b/examples/outer_solar_system/problem.c @@ -12,7 +12,7 @@ * * The example also works with the WHFAST symplectic integrator. We turn * off safe-mode to allow fast and accurate simulations with the symplectic - * corrector. If an output is required, you need to call ireb_simulation_synchronize() + * corrector. If an output is required, you need to call reb_simulation_synchronize() * before accessing the particle structure. */ #include @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) { const double k = 0.01720209895; // Gaussian constant r->dt = 40; // in days r->G = k * k; // These are the same units as used by the mercury6 code. - r->ri_whfast.safe_mode = 0; // Turn of safe mode. Need to call integrator_synchronize() before outputs. + r->ri_whfast.safe_mode = 0; // Turn of safe mode. Need to call reb_simulation_synchronize() before outputs. r->ri_whfast.corrector = 11; // Turn on symplectic correctors (11th order). // Setup callbacks: diff --git a/ipython_examples/AdvWHFast.ipynb b/ipython_examples/AdvWHFast.ipynb index 5fe09a73f..d29ae810c 100644 --- a/ipython_examples/AdvWHFast.ipynb +++ b/ipython_examples/AdvWHFast.ipynb @@ -226,7 +226,7 @@ "editable": true }, "source": [ - "REBOUND will synchronize every timestep even if you set `sim.ri_whfast.safe_mode = 0` and never explicitly call `sim.integrator_synchronize()`." + "REBOUND will synchronize every timestep even if you set `sim.ri_whfast.safe_mode = 0` and never explicitly call `sim.synchronize()`." ] }, { @@ -259,7 +259,7 @@ " sim.step()\n", " sim.particles[1].m += 1.e-10\n", " sim.ri_whfast.recalculate_coordinates_this_timestep = 1\n", - " sim.integrator_synchronize()" + " sim.synchronize()" ] }, { @@ -291,7 +291,7 @@ " sim.step()\n", " sim.particles[1].vx += 1.e-10*sim.dt\n", " sim.ri_whfast.recalculate_coordinates_this_timestep = 1\n", - " sim.integrator_synchronize()" + " sim.synchronize()" ] }, { @@ -301,7 +301,7 @@ "editable": true }, "source": [ - "This would not give accurate results, because the `sim.particles[1].vx` we access after `sim.step()` isn't a physical velocity (it's missing a half-Kepler step). It's basically at an intermediate point in the calculation. In order to make this work, one would call `sim.integrator_synchronize()` between `sim.step()` and accessing `sim.particles[1].vx`, to ensure the velocity is physical." + "This would not give accurate results, because the `sim.particles[1].vx` we access after `sim.step()` isn't a physical velocity (it's missing a half-Kepler step). It's basically at an intermediate point in the calculation. In order to make this work, one would call `sim.synchronize()` between `sim.step()` and accessing `sim.particles[1].vx`, to ensure the velocity is physical." ] }, { diff --git a/rebound/simulation.py b/rebound/simulation.py index 1d173343f..b6727992a 100644 --- a/rebound/simulation.py +++ b/rebound/simulation.py @@ -1412,20 +1412,20 @@ def stop(self): """ clibrebound.reb_simulation_stop(byref(self)) - def integrator_reset(self): + def reset_integrator(self): """ Call this function to reset temporary integrator variables """ clibrebound.reb_simulation_reset_integrator(byref(self)) - def integrator_synchronize(self): + def synchronize(self): """ Call this function if safe-mode is disabled and you need to synchronize particle positions and velocities between timesteps. """ clibrebound.reb_simulation_synchronize(byref(self)) self.process_messages() - def tree_update(self): + def update_tree(self): """ Call this function to update the tree structure manually after removing particles. """ diff --git a/rebound/simulationarchive.py b/rebound/simulationarchive.py index db90704cd..b1bbbb3e4 100644 --- a/rebound/simulationarchive.py +++ b/rebound/simulationarchive.py @@ -149,7 +149,7 @@ def __getitem__(self, key): if self.process_warnings: warnings.warn(message, RuntimeWarning) if sim.ri_eos.is_synchronized==0 or sim.ri_mercurius.is_synchronized==0 or sim.ri_whfast.is_synchronized==0 or sim.ri_mercurius.is_synchronized==0: - warnings.warn("The simulation might not be synchronized. You can manually synchronize it by calling sim.integrator_synchronize().", RuntimeWarning) + warnings.warn("The simulation might not be synchronized. You can manually synchronize it by calling sim.synchronize().", RuntimeWarning) return sim @@ -241,7 +241,7 @@ def getSimulation(self, t, mode='snapshot', keep_unsynchronized=1): keep_unsynchronized = 0 sim.ri_whfast.keep_unsynchronized = keep_unsynchronized sim.ri_saba.keep_unsynchronized = keep_unsynchronized - sim.integrator_synchronize() + sim.synchronize() return sim else: if mode=='exact': diff --git a/rebound/tests/test_shearingsheet.py b/rebound/tests/test_shearingsheet.py index 76e27dbb2..6f0831916 100644 --- a/rebound/tests/test_shearingsheet.py +++ b/rebound/tests/test_shearingsheet.py @@ -56,7 +56,7 @@ def powerlaw(slope, min_v, max_v): self.assertGreater(sim.collisions_log_n,1000) Nbefore = sim.N sim.remove(0,keep_sorted=0) - sim.tree_update() + sim.update_tree() self.assertEqual(Nbefore-1,sim.N) with self.assertRaises(RuntimeError): sim.remove(0,keep_sorted=1) diff --git a/src/particle.c b/src/particle.c index 28b08a9e4..6cb28c751 100644 --- a/src/particle.c +++ b/src/particle.c @@ -404,7 +404,7 @@ int reb_simulation_remove_particle(struct reb_simulation* const r, int index, in } }else{ if (r->tree_root){ - // Just flag particle, will be removed in tree_update. + // Just flag particle, will be removed in update_tree. r->particles[index].y = nan(""); if(r->free_particle_ap){ r->free_particle_ap(&r->particles[index]);