Skip to content

Commit

Permalink
More API name changes. Mostly on python side.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Oct 31, 2023
1 parent 7ccf4e3 commit 58856d6
Show file tree
Hide file tree
Showing 57 changed files with 522 additions and 585 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ There are several papers describing the functionality of REBOUND.

5. Rein & Tamayo 2016 (Monthly Notices of the Royal Astronomical Society, Volume 459, Issue 3, p.2275-2285) develop the framework for second order variational equations. <https://ui.adsabs.harvard.edu/abs/2016MNRAS.459.2275R>

6. Rein & Tamayo 2017 (Monthly Notices of the Royal Astronomical Society, Volume 467, Issue 2, p.2377-2383) describes the Simulation Archive for exact reproducibility of N-body simulations. <https://ui.adsabs.harvard.edu/abs/2017MNRAS.467.2377R>
6. Rein & Tamayo 2017 (Monthly Notices of the Royal Astronomical Society, Volume 467, Issue 2, p.2377-2383) describes the Simulationarchive for exact reproducibility of N-body simulations. <https://ui.adsabs.harvard.edu/abs/2017MNRAS.467.2377R>

7. Rein & Tamayo 2018 (Monthly Notices of the Royal Astronomical Society, Volume 473, Issue 3, p.3351–3357) describes the integer based JANUS integrator. <https://ui.adsabs.harvard.edu/abs/2018MNRAS.473.3351R>

Expand Down
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ This changelog only includes the most important changes in recent updates. For a
* Various minor bug fixes. One related to exact_finish_time=1.

### Version 3.2.0
* Added real-time interactive 3D visualizations using WebGL for Jupyter notebooks. This is an early release. Not everything might be working yet and new feature will be added to the widget class. To try it out, simply run `sim.getWidget()` in a Jupyter notebook. Note that you need to have ipywidgets installed and enabled.
* Added real-time interactive 3D visualizations using WebGL for Jupyter notebooks. This is an early release. Not everything might be working yet and new feature will be added to the widget class. To try it out, simply run `sim.widget()` in a Jupyter notebook. Note that you need to have ipywidgets installed and enabled.
* Minor changes to the Visualization backend. This should not have any consequences for users.


Expand All @@ -377,7 +377,7 @@ This changelog only includes the most important changes in recent updates. For a
* Updated visualization. REBOUND now uses a modern version of OpenGL (3.3) that allows for custom shaders and therefore better looking visualizations. However, REBOUND now requires glfw3 to compile the visualization module. If you are on a Mac, then the easiest way to install the glfw3 library is with homebrew: `brew tap homebrew/versions && brew install glfw3`. If you are on Linux, you can install it with your package manager, for example with `sudo apt-get install libglfw3-dev`.

### Version 3.0.0
* Introducing the Simulation Archive. The Simulation Archive allows for exact (bit-by-bit) reproducibility in N-body simulations and a completely new way of analyzing simulations. See Rein&Tamayo (2017) for details.
* Introducing the Simulationarchive. The Simulationarchive allows for exact (bit-by-bit) reproducibility in N-body simulations and a completely new way of analyzing simulations. See Rein&Tamayo (2017) for details.
* The binary format has changed. Binary files created with an earlier version of REBOUND can not be loaded with this version. However, future binary files will be backwards compatible from this point forward.


Expand Down
4 changes: 2 additions & 2 deletions docs/binaryformat.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
REBOUND comes with its own binary format.
The binary format allows you to store a current simulation state to a file or to memory.
The binary format is also used when you make a copy of a simulation or when you compare two similations with each other.
The Simulation Archive is an extension of the binary format which allows you to store multiple snapshots of a simulation in one file.
The Simulationarchive is an extension of the binary format which allows you to store multiple snapshots of a simulation in one file.
This page explains the details of the binary format.
It is mainly intended for people who wish to extend the built-in REBOUND functionality.
You do not need to know those details if you're only working with binary files to save and load simulations.
Expand Down Expand Up @@ -43,7 +43,7 @@ You create a binary file if you save a simulation
```python
sim = rebound.Simulation()
// ... setup simulation ...
sim.save("snapshot.bin")
sim.save_to_file("snapshot.bin")
```
Such a binary file with one snapshot is simply a set of `reb_binaryfield`s followed by one `reb_simulationarchive_blob` at the end, for example:

Expand Down
2 changes: 1 addition & 1 deletion docs/collisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ You can set this pointer to a function that should be called when a collision oc

### Halt

This function resolves a collision by simply halting the integration and setting the `status` flag in the simulation to `REB_EXIT_COLLISION`.
This function resolves a collision by simply halting the integration and setting the `status` flag in the simulation to `REB_STATUS_COLLISION`.
In python this will raise the `Collision` exception.
This is the default.
It can also be set manually using the following syntax:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ There are several papers describing the functionality of REBOUND.

5. Rein & Tamayo 2016 (Monthly Notices of the Royal Astronomical Society, Volume 459, Issue 3, p.2275-2285) develop the framework for second order variational equations. <https://ui.adsabs.harvard.edu/abs/2016MNRAS.459.2275R>

6. Rein & Tamayo 2017 (Monthly Notices of the Royal Astronomical Society, Volume 467, Issue 2, p.2377-2383) describes the Simulation Archive for exact reproducibility of N-body simulations. <https://ui.adsabs.harvard.edu/abs/2017MNRAS.467.2377R>
6. Rein & Tamayo 2017 (Monthly Notices of the Royal Astronomical Society, Volume 467, Issue 2, p.2377-2383) describes the Simulationarchive for exact reproducibility of N-body simulations. <https://ui.adsabs.harvard.edu/abs/2017MNRAS.467.2377R>

7. Rein & Tamayo 2018 (Monthly Notices of the Royal Astronomical Society, Volume 473, Issue 3, p.3351–3357) describes the integer based JANUS integrator. <https://ui.adsabs.harvard.edu/abs/2018MNRAS.473.3351R>

Expand Down
2 changes: 1 addition & 1 deletion docs/orbitalelements.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The following function allows you to calculate the orbital elements of a particl
sim = rebound.Simulation()
sim.add(m=1) # star
sim.add(a=1, e=0.1) # planet
o = sim.particles[1].calculate_orbit(primary=sim.particles[0])
o = sim.particles[1].orbit(primary=sim.particles[0])
print(o.a, o.e)
```
If `primary` is not given, Jacobi coordinates are used.
Expand Down
28 changes: 14 additions & 14 deletions docs/simulationarchive.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Simulation Archive
# Simulationarchive

The concepts behind the Simulationarchive are described in detail in [Rein & Tamayo 2017](https://ui.adsabs.harvard.edu/abs/2017MNRAS.467.2377R/abstract).
Further examples of how to work with the Simulationarchive are provided in an [iPython](ipython_examples/Simulationarchive.ipynb) and [C example](c_examples/simulationarchive.md).

## Creating Simulation Archive snapshots
## Creating Simulationarchive snapshots

The following code shows how to manually append a Simulation Archive snapshot to a file.
The following code shows how to manually append a Simulationarchive snapshot to a file.
If the file does not exist yet, the function outputs a new binary file.
If the file already exists, the function will append a Simulation Archive snapshot to the existing file.
If the file already exists, the function will append a Simulationarchive snapshot to the existing file.

=== "C"
```c
Expand All @@ -20,15 +20,15 @@ If the file already exists, the function will append a Simulation Archive snapsh
```python
sim = rebound.Simulation()
# ... work on simulation ...
sim.simulationarchive_snapshot("archive.bin")
sim.save_to_file("archive.bin")
```
You can pass the optional argument `delete_file=True` to delete the file if it already exists.
By default, the function appends a snapshot to existing files.

Instead of manually outputting each snapshot, you can also automate this process as shown below.

### Regular time intervals
The following code automatically creates a Simulation Archive snapshot at regular intervals.
The following code automatically creates a Simulationarchive snapshot at regular intervals.
=== "C"
```c
struct reb_simulation* r = reb_simulation_create();
Expand All @@ -40,11 +40,11 @@ The following code automatically creates a Simulation Archive snapshot at regula
```python
sim = rebound.Simulation()
# ... work on simulation ...
sim.automateSimulationarchive("archive.bin", interval=10.)
sim.save_to_file("archive.bin", interval=10.)
```

### Regular number of timesteps
The following code automatically creates a Simulation Archive snapshot after a fixed number of timesteps.
The following code automatically creates a Simulationarchive snapshot after a fixed number of timesteps.
=== "C"
```c
struct reb_simulation* r = reb_simulation_create();
Expand All @@ -56,7 +56,7 @@ The following code automatically creates a Simulation Archive snapshot after a f
```python
sim = rebound.Simulation()
# ... work on simulation ...
sim.automateSimulationarchive("archive.bin", step=100)
sim.save_to_file("archive.bin", step=100)
```
!!! Info
This method is in general more reliable than the interval method.
Expand All @@ -66,7 +66,7 @@ The following code automatically creates a Simulation Archive snapshot after a f


### Regular wall-time intervals
The following code automatically creates a Simulation Archive snapshot after a fixed wall-time.
The following code automatically creates a Simulationarchive snapshot after a fixed wall-time.
This is particularly useful for creating restart files when running long simulations.
The wall-time is given in seconds.
=== "C"
Expand All @@ -80,14 +80,14 @@ The wall-time is given in seconds.
```python
sim = rebound.Simulation()
# ... work on simulation ...
sim.automateSimulationarchive("archive.bin", walltime=120) # 2 minutes
sim.save_to_file("archive.bin", walltime=120) # 2 minutes
```

## Reading Simulation Archives
## Reading Simulationarchives

### Reading one snapshot
The following example shows how to read in a specific snapshot of a Simulation Archive.
If you pass a negative number for the snapshot, it will wrap around to the end of the Simulation Archive.
The following example shows how to read in a specific snapshot of a Simulationarchive.
If you pass a negative number for the snapshot, it will wrap around to the end of the Simulationarchive.
For example, the last snapshot in the file would have the index `-1`, the second to last `-2`, and so on.
=== "C"
```c
Expand Down
6 changes: 3 additions & 3 deletions docs/simulationbinaryfiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ Below is an example on how to work with binary files.
sim = rebound.Simulation()
// ... setup simulation ...
sim.integrate(10)
sim.save("snapshot.bin")
sim.save_to_file("snapshot.bin")
sim = None # Remove reference, allow python to release memory

sim2 = rebound.Simulation("snapshot.bin")
sim2.integrate(2) # continue integration
sim2 = None
```

Rather than using one file for one snapshot of a simulation, you can also use a [Simulation Archive](simulationarchive.md).
A Simulation Archive is a collection of simulation snapshots stored in one binary file.
Rather than using one file for one snapshot of a simulation, you can also use a [Simulationarchive](simulationarchive.md).
A Simulationarchive is a collection of simulation snapshots stored in one binary file.



2 changes: 1 addition & 1 deletion docs/simulationdiagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ The return value is particle object with mass, position, and velocity reflecting
```python
sim = rebound.Simulation()
# ... setup simulation ...
com = sim.calculate_com()
com = sim.com()
```

10 changes: 5 additions & 5 deletions examples/simulationarchive/problem.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Simulation Archive
* Simulationarchive
*
* This example shows how to use the Simulation Archive.
* This example shows how to use the Simulationarchive.
* We integrate a two planet system forward in time using
* the WHFast integrator. The simulation can be interrupted
* at any time. On the next run, the program will try to reload
* the latest data from the Simulation Archive.
* the latest data from the Simulationarchive.
*/

#include <stdio.h>
Expand All @@ -29,7 +29,7 @@ int main(int argc, char* argv[]) {
reb_simulationarchive_free(sa);
// Check if we were successful
if (r==NULL){
printf("No simulation archive found. Creating new simulation.\n");
printf("No simulationarchive found. Creating new simulation.\n");
r= reb_simulation_create();
reb_simulation_add_fmt(r, "m", 1.0); // star
reb_simulation_add_fmt(r, "m a e", 1e-3, 1.0, 0.01); // planet 1
Expand All @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) {
r->ri_whfast.corrector = 5;
r->integrator = REB_INTEGRATOR_WHFAST;
}else{
printf("Found simulation archive. Loaded snapshot at t=%.16f.\n",r->t);
printf("Found simulationarchive. Loaded snapshot at t=%.16f.\n",r->t);
}

// Automatically create a snapshot every 100 time units
Expand Down
18 changes: 9 additions & 9 deletions examples/variational_equations/problem.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) {

// Instead of shifting the initial x coordinate, we can also use variational equations.
r = create_sim();
var_i = reb_simulation_add_var_1st_order(r, -1); // The -1 means we vary a particle which is not a testparticle and therefore can influence other particles
var_i = reb_simulation_add_variation_1st_order(r, -1); // The -1 means we vary a particle which is not a testparticle and therefore can influence other particles

// By default all components of variational particles are initialized to zero.
// We are interested in shifting the planet's x coordinates and thus initialize the x coordinate of the variational particle to 1.
Expand All @@ -58,8 +58,8 @@ int main(int argc, char* argv[]) {

// Better yet, we can use second order variational particles.
r = create_sim();
var_i = reb_simulation_add_var_1st_order(r, -1);
var_ii = reb_simulation_add_var_2nd_order(r, -1, var_i, var_i);
var_i = reb_simulation_add_variation_1st_order(r, -1);
var_ii = reb_simulation_add_variation_2nd_order(r, -1, var_i, var_i);
r->particles[var_i+1].x = 1.;
reb_simulation_integrate(r,100.);
printf("Position of testparticle at t=100 using 2nd order var. eqs.: %.8f %.8f\n",r->particles[2].x+DeltaX*r->particles[var_i+2].x+DeltaX*DeltaX/2.*r->particles[var_ii+2].x,r->particles[2].y+DeltaX*r->particles[var_i+2].y+DeltaX*DeltaX/2.*r->particles[var_ii+2].y);
Expand All @@ -75,15 +75,15 @@ int main(int argc, char* argv[]) {
reb_simulation_free(r);

r = create_sim();
var_i = reb_simulation_add_var_1st_order(r, 2); // The 2 corresponds to the index of the testparticle that we vary.
var_i = reb_simulation_add_variation_1st_order(r, 2); // The 2 corresponds to the index of the testparticle that we vary.
r->particles[var_i].x = 1.;
reb_simulation_integrate(r,100.);
printf("Position of testparticle at t=100 using 1st order var. eqs.: %.8f %.8f\n",r->particles[2].x+DeltaX*r->particles[var_i].x,r->particles[2].y+DeltaX*r->particles[var_i].y);
reb_simulation_free(r);

r = create_sim();
var_i = reb_simulation_add_var_1st_order(r, 2);
var_ii = reb_simulation_add_var_2nd_order(r, 2, var_i, var_i);
var_i = reb_simulation_add_variation_1st_order(r, 2);
var_ii = reb_simulation_add_variation_2nd_order(r, 2, var_i, var_i);
r->particles[var_i].x = 1.;
reb_simulation_integrate(r,100.);
printf("Position of testparticle at t=100 using 2nd order var. eqs.: %.8f %.8f\n",r->particles[2].x+DeltaX*r->particles[var_i].x+DeltaX*DeltaX/2.*r->particles[var_ii].x,r->particles[2].y+DeltaX*r->particles[var_i].y+DeltaX*DeltaX/2.*r->particles[var_ii].y);
Expand All @@ -99,16 +99,16 @@ int main(int argc, char* argv[]) {
reb_simulation_free(r);

r = create_sim();
var_i = reb_simulation_add_var_1st_order(r, 2);
var_i = reb_simulation_add_variation_1st_order(r, 2);
// The function that sets up the variational particle gets the same orbital parameters as the original particle.
r->particles[var_i] = reb_particle_derivative_a(1.,r->particles[0],r->particles[2]);
reb_simulation_integrate(r,100.);
printf("Position of testparticle at t=100 using 1st order var. eqs.: %.8f %.8f\n",r->particles[2].x+DeltaX*r->particles[var_i].x,r->particles[2].y+DeltaX*r->particles[var_i].y);
reb_simulation_free(r);

r = create_sim();
var_i = reb_simulation_add_var_1st_order(r, 2);
var_ii = reb_simulation_add_var_2nd_order(r, 2, var_i, var_i);
var_i = reb_simulation_add_variation_1st_order(r, 2);
var_ii = reb_simulation_add_variation_2nd_order(r, 2, var_i, var_i);
// first derivative with respect to a
r->particles[var_i] = reb_particle_derivative_a(1.,r->particles[0],r->particles[2]);
// second derivative with respect to a
Expand Down
2 changes: 1 addition & 1 deletion ipython_examples/Checkpoints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"sim.add(m=1e-6, a=1.)\n",
"sim.add(a=2.)\n",
"sim.integrator = \"whfast\"\n",
"sim.save(\"checkpoint.bin\")\n",
"sim.save_to_file(\"checkpoint.bin\")\n",
"sim.status()"
]
},
Expand Down
Loading

0 comments on commit 58856d6

Please sign in to comment.