From 612dc16f5a8861fafbd944a7cdee7383056a65da Mon Sep 17 00:00:00 2001 From: Hanno Rein Date: Thu, 30 Jul 2015 09:57:19 -0400 Subject: [PATCH] Moving examples --- doc/index.rst | 1 + doc/librebound.rst | 2 +- doc/pythoninstall.rst | 87 ++++++++++++++ ipython_examples/AdvWHFast.ipynb | 25 ++-- ipython_examples/Churyumov-Gerasimenko.ipynb | 8 +- ipython_examples/Forces.ipynb | 6 +- ipython_examples/Horizons.ipynb | 17 +-- ipython_examples/Installation.ipynb | 114 ------------------- ipython_examples/Twitter.ipynb | 86 -------------- ipython_examples/Units.ipynb | 52 +++------ ipython_examples/WHFast.ipynb | 38 +++---- ipython_examples/index.ipynb | 55 --------- 12 files changed, 153 insertions(+), 338 deletions(-) create mode 100644 doc/pythoninstall.rst delete mode 100644 ipython_examples/Installation.ipynb delete mode 100644 ipython_examples/Twitter.ipynb delete mode 100644 ipython_examples/index.ipynb diff --git a/doc/index.rst b/doc/index.rst index 0f504a557..dc66812eb 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -103,6 +103,7 @@ Table of Contents :numbered: self + pythoninstall modules rebound librebound diff --git a/doc/librebound.rst b/doc/librebound.rst index 13bb9256d..2316c04b9 100644 --- a/doc/librebound.rst +++ b/doc/librebound.rst @@ -1,7 +1,7 @@ The C version of REBOUND ======================== -This section describes the C version of REBOUND. To learn how to install REBOUND for Python have a look at the iPython/Jupiter notebooks at https://github.com/hannorein/rebound/blob/master/ipython_examples/index.ipynb. Hint: It's super easy! +This section describes the C version of REBOUND. Installation ------------ diff --git a/doc/pythoninstall.rst b/doc/pythoninstall.rst new file mode 100644 index 000000000..eb96c4181 --- /dev/null +++ b/doc/pythoninstall.rst @@ -0,0 +1,87 @@ +Installing REBOUND (Python) +=========================== + +Installing REBOUND is very easy. Rebound does not depend on any libraries. However, you need to have python (version 2 or 3) and a C compiler installed. Most likely, you already have those on your system. + +If you don't, and aren't sure how to go about getting them, it is probably easiest to install either the Enthought or Anaconda python distributions (which are free and come with typically used libraries and an easy-to-use installer). For the C compiler on Mac, it's probably easiest to install Xcode from the App store. + +Create a virtual environment +---------------------------- + +Before you start, you can create a virtual environment to keep your python installation clean. This is recommended, but not necessary. You need to have [virtualenv](https://virtualenv.pypa.io/en/latest/) installed (if you use the Anaconda python distribution, you'll need to instead create a conda environment - see below). + +To create a virtual environment, simply open a terminal window, go to the folder where you want REBOUND to be installed (e.g. `/home/username/rebound/`) and enter:: + + virtualenv venv + +This creates a virtual environment named `venv`. To activate it, type:: + + source venv/bin/activate + +If you log out of your terminal or open a new one, you'll need to reactivate the virtual environment with the above command (if the environment is active you'll see its name in parentheses before the command prompt). + +If you use the Anaconda distribution, the above likely will not work. To create a conda environment run the following command:: + + conda create -n venv pip + source activate venv + + +Standard python installation using pip +-------------------------------------- + +Now you can install REBOUND using pip. All you have to do is type the following into a terminal window (if you created a virtual environment above you should first run the appropriate activate command depending on whether you used virtualenv or conda): + + pip install rebound + +The setup script will download the latest version of REBOUND from [PyPI](https://pypi.python.org/pypi) (the Python Package Index), compile the C code in the background and place all the files in their correct location. No other libraries are needed to start working with WHFast and REBOUND, but you might want to install numpy and matplotlib to be able to post-process your data and make plots. For analysis tools (and to run FourierSpectrum.ipynb) you might also want scipy. Installing those libraries is also very easy (but may need a few minutes). Depending on whether you use virtualenv or conda, use + + pip install numpy matplotlib scipy + +or + + conda install numpy matplotlib scipy + + +That's all there is to do! + + +Installing the development version directly from github +------------------------------------------------------- + +Instead of using pip to install the latest version of REBOUND from PyPI, you can also install REBOUND directly from github. This is useful if you want to make changes to REBOUND. + +First clone the repository (you might need to create a github account):: + + git clone git@github.com:hannorein/rebound.git + +If you already know that you might be contributing something to REBOUND, you can also first fork the repository on github and then clone your own repository. + +Next, create a virtual environment with the same commands as above:: + + virtualenv venv && source venv/bin/activate + +Now you can install rebound from source using:: + + pip install -e . + +You can modify the python module files in the directory `rebound/` and you'll see the changed the next time you run a python script (no need to reinstall the REBOUND package every time). + +If you install REBOUND directly from github, you can also run it without python. Have a look at the README file in the main directory and at the examples in the `examples/` directory for examples in C. These are much more diverse than the python examples (e.g. allow you to use a tree code for gravity calculations, use other boundary conditions, etc). + +Python Notebook +--------------- + + +The tutorials in python_tutorials were written using iPython/Jupyter notebooks. You can view them directly on GitHub. If you want to edit them or create your own notebook, you'll need to install iPython (make sure to activate the virtual environment first if you created one):: + + pip install "ipython[notebook]" + +or:: + + conda install ipython-notebook + +You can then open iPython notebooks in your browser by typing:: + + ipython notebook + +To create a new notebook select from the dropdown menu on the top right the item that says 'New'. Now you can interactively follow the commands in the tutorials or run your own! diff --git a/ipython_examples/AdvWHFast.ipynb b/ipython_examples/AdvWHFast.ipynb index f983b3df8..818742ea6 100644 --- a/ipython_examples/AdvWHFast.ipynb +++ b/ipython_examples/AdvWHFast.ipynb @@ -8,7 +8,7 @@ "\n", "There are several performance enhancements one can make to WHFast. However, each one has pitfalls that an inexperienced user can unwittingly fall into. We therefore chose safe default settings that make the integrator difficult to misuse. **This makes the default WHFast substantially slower and less accurate than it can be**. Here we describe how to alter the integrator settings to improve WHFast's performance.\n", "\n", - "## TL;DR\n", + "**TL;DR**\n", "\n", "As long as \n", "\n", @@ -24,7 +24,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## The Wisdom-Holman algorithm\n", + "**The Wisdom-Holman algorithm**\n", "\n", "In order to understand and apply the various integrator flags, we need to first understand the Wisdom-Holman scheme (see, e.g., Wisdom & Holman 1991, or Rein & Tamayo 2015 for more details).\n", "\n", @@ -41,7 +41,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Combining Kepler steps and synchronizing \n", + "**Combining Kepler steps and synchronizing**\n", "\n", "It turns out that Kepler steps take longer than interaction steps as long as you don't have many planets, so an obvious and important performance boost would be to combine adjacent Kepler half-steps into full ones, i.e.:\n", "\n", @@ -53,7 +53,7 @@ "\n", "We call this step of reinserting half-Kepler steps to obtain the physical state of the particles *synchronizing*. This must be done whenever the **actual** states of the particles are required, e.g., before every output, or if one wanted to use the particles' states to compute additional changes to the particle orbits between timesteps. It is also necessary to synchronize each timestep whenever the MEGNO chaos indicator is being computed.\n", "\n", - "## Conversions between Jacobi and Inertial Coordinates\n", + "**Conversions between Jacobi and Inertial Coordinates**\n", "\n", "It turns out that the most convenient coordinate system to work in for performing the Kepler steps is Jacobi coordinates (see, e.g., 9.5.4 of Murray & Dermott). WHFast therefore works in Jacobi coordinates, converting to inertial coordinates when it needs to (e.g. for output, and for doing the direct gravity calculation in the interaction step, which is most easily done in inertial coordinates).\n", "\n", @@ -61,7 +61,7 @@ "\n", "WHFast therefore stores the Jacobi coordinates internally throughout the time it is running, and only recalculates Jacobi coordinates from the inertial ones if told to do so. Since Jacobi coordinates reference particles to the center of mass of all the particles with indices lower than their own (typically all the particles interior to them), the main reason you would have to recalculate Jacobi coordinates is if between timesteps you choose to somehow change the particles' positions or velocities (give them kicks in addition to their mutual gravity), or change the particles' masses. \n", "\n", - "## Overriding the defaults\n", + "**Overriding the defaults**\n", "\n", "Let's begin by importing rebound, and defining a simple function to reset rebound and initialize a new simulation with a test case," ] @@ -205,7 +205,7 @@ "collapsed": true }, "source": [ - "## Modifying particles/forces\n", + "**Modifying particles/forces**\n", "\n", "Again, if performance is a factor in your simulations, you would not want to write a custom stepper in python that modifies the particles, since this will be very slow. You could either write a modified C version of `reb_integrate` in `src/librebound.c` (the flags are defined in `librebound.h`, and have the same name as the python ones, just without `sim.` in front), or you can use the REBOUNDXF library, which takes care of this for you and supports many typically used modifications. We again illustrate a simple scheme with python code:" ] @@ -266,7 +266,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Symplectic correctors\n", + "**Symplectic correctors**\n", + "\n", "Symplectic correctors make the Wisdom-Holman scheme higher order (without symplectic correctors it's second order). The great thing about them is that they only need to get applied when you synchronize. So if you just need to synchronize to output, and there are many timesteps between outputs, they represent a very small performance loss for a huge boost in accuracy (compare for example the green line (11th order corrector) to the red line (no corrector) in Fig. 4 of Rein & Tamayo 2015--beyond the right of the plot, where the round-off errors dominate, the two lines would rise in unison). We have implemented symplectic correctors up to order 11. You can set the order with (must be an odd number), e.g.," ] }, @@ -291,21 +292,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" + "pygments_lexer": "ipython2", + "version": "2.7.6" } }, "nbformat": 4, diff --git a/ipython_examples/Churyumov-Gerasimenko.ipynb b/ipython_examples/Churyumov-Gerasimenko.ipynb index b5a4dfb24..e02904080 100644 --- a/ipython_examples/Churyumov-Gerasimenko.ipynb +++ b/ipython_examples/Churyumov-Gerasimenko.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## NASA Horizons\n", + "**NASA Horizons**\n", "\n", "If you're interested in Solar System dynamics, you have probably heard of NASA Horizons. It's a large database of Solar System objects, their orbits and physical properties. It includes planets, moons, satellites, asteroids, comets and spacecrafts. With REBOUND, you can easily import data from NASA Horizons. As an example, let's pull in the present day positions of Jupiter, Saturn and the Sun:" ] @@ -119,7 +119,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Integration with IAS15\n", + "**Integration with IAS15**\n", + "\n", "We will integrate backwards in time for 70 years. Because we don't know what will happen yet (hint: a close encounter) we will use the IAS15 integrator. It is fast, accurate and has adaptive timesteps to capture any potential close encounters. \n", "\n", "To integrate backwards, we could set a negative timestep or multiply all velocities with $-1$. We'll choose the first option:" @@ -190,7 +191,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Visualization with matplotlib\n", + "**Visualization with matplotlib**\n", + "\n", "Let's plot the orbits of Jupiter (blue) and the comet (green) to get an idea of what was going on during our integration." ] }, diff --git a/ipython_examples/Forces.ipynb b/ipython_examples/Forces.ipynb index 3a8d7b650..a166175c3 100644 --- a/ipython_examples/Forces.ipynb +++ b/ipython_examples/Forces.ipynb @@ -9,7 +9,8 @@ "\n", "This tutorial gives you a very quick overview of how that works. \n", "\n", - "## Stark problem\n", + "**Stark problem**\n", + "\n", "We'll start be adding two particles, the Sun and an Earth-like planet to REBOUND." ] }, @@ -131,7 +132,8 @@ "source": [ "You can see that the eccentricity is oscillating between 0 and almost 1. \n", "\n", - "## Non-conservative forces\n", + "**Non-conservative forces**\n", + "\n", "The previous example assumed a conservative force, i.e. we could describe it as a potential as it is velocity independent. Now, let's assume we have a velocity dependent force. This could be a migration force in a protoplanetary disk or PR drag. We'll start from scratch and add the same two particles as before." ] }, diff --git a/ipython_examples/Horizons.ipynb b/ipython_examples/Horizons.ipynb index c0f0525d5..eee6da2ec 100644 --- a/ipython_examples/Horizons.ipynb +++ b/ipython_examples/Horizons.ipynb @@ -8,7 +8,8 @@ "\n", "REBOUND can add particles to simulations by obtaining ephemerides from NASA's powerful HORIZONS database. HORIZONS supports many different options, and we will certainly not try to cover everything here. This is meant to serve as an introduction to the basics, beyond what's in [Churyumov-Gerasimenko.ipynb](Churyumov-Gerasimenko.ipynb). If you catch any errors, or would either like to expand on this documentation or improve REBOUND's HORIZONS interface (`rebound/horizons.py`), please do fork the repository and send us a pull request.\n", "\n", - "## Adding particles\n", + "**Adding particles**\n", + "\n", "When we add particles by passing a string, REBOUND queries the HORIZONS database and takes the first dataset HORIZONS offers. For the Sun, moons, and small bodies, this will typically return the body itself. For planets, it will return the barycenter of the system (for moonless planets like Venus it will say barycenter but there is no distinction). In all cases, REBOUND will print out the name of the HORIZONS entry it's using.\n", "\n", "You can also add bodies using their integer NAIF IDs: [NAIF IDs](http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/MATLAB/req/naif_ids.html). Note that because of the number of small bodies (asteroids etc.) we have discovered, this convention only works for large objetcts. For small bodies, instead use \"NAME=name\" (see the SMALL BODIES section in the [HORIZONS Documentation](http://ssd.jpl.nasa.gov/?horizons_doc)):" @@ -78,7 +79,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Time\n", + "**Time**\n", "\n", "By default, REBOUND queries HORIZONS for objects' current positions. Specifically, it caches the current time the first time you call `rebound.add`, and gets the corresponding ephemeris. All subsequent calls to `rebound.add` will then use that initial cached time to make sure you get a synchronized set of ephemerides.\n", "\n", @@ -174,7 +175,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Reference Frame\n", + "**Reference Frame**\n", "\n", "REBOUND queries for particles' positions and velocities relative to the Sun:" ] @@ -218,21 +219,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" + "pygments_lexer": "ipython2", + "version": "2.7.6" } }, "nbformat": 4, diff --git a/ipython_examples/Installation.ipynb b/ipython_examples/Installation.ipynb deleted file mode 100644 index 212d4d25c..000000000 --- a/ipython_examples/Installation.ipynb +++ /dev/null @@ -1,114 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Installing REBOUND\n", - "\n", - "Installing REBOUND is very easy. Rebound does not depend on any libraries. However, you need to have python (version 2 or 3) and a C compiler installed. Most likely, you already have those on your system. \n", - "\n", - "If you don't, and aren't sure how to go about getting them, it is probably easiest to install either the Enthought or Anaconda python distributions (which are free and come with typically used libraries and an easy-to-use installer). For the C compiler on Mac, it's probably easiest to install Xcode from the App store.\n", - "\n", - "## Create a virtual environment\n", - "\n", - "Before you start, you can create a virtual environment to keep your python installation clean. This is recommended, but not necessary. You need to have [virtualenv](https://virtualenv.pypa.io/en/latest/) installed (if you use the Anaconda python distribution, you'll need to instead create a conda environment - see below).\n", - "\n", - "To create a virtual environment, simply open a terminal window, go to the folder where you want REBOUND to be installed (e.g. `/home/username/rebound/`) and enter:\n", - "\n", - " virtualenv venv\n", - "\n", - "This creates a virtual environment named `venv`. To activate it, type:\n", - "\n", - " source venv/bin/activate\n", - "\n", - "If you log out of your terminal or open a new one, you'll need to reactivate the virtual environment with the above command (if the environment is active you'll see its name in parentheses before the command prompt).\n", - "\n", - "If you use the Anaconda distribution, the above likely will not work. To create a conda environment run the following command:\n", - "\n", - " conda create -n venv pip\n", - " source activate venv\n", - "\n", - "\n", - "## Standard python installation using pip\n", - "\n", - "Now you can install REBOUND using pip. All you have to do is type the following into a terminal window (if you created a virtual environment above you should first run the appropriate activate command depending on whether you used virtualenv or conda):\n", - "\n", - " pip install rebound\n", - "\n", - "The setup script will download the latest version of REBOUND from [PyPI](https://pypi.python.org/pypi) (the Python Package Index), compile the C code in the background and place all the files in their correct location. No other libraries are needed to start working with WHFast and REBOUND, but you might want to install numpy and matplotlib to be able to post-process your data and make plots. For analysis tools (and to run FourierSpectrum.ipynb) you might also want scipy. Installing those libraries is also very easy (but may need a few minutes). Depending on whether you use virtualenv or conda, use\n", - "\n", - " pip install numpy matplotlib scipy\n", - " \n", - "or\n", - " \n", - " conda install numpy matplotlib scipy\n", - " \n", - "\n", - "That's all there is to do!\n", - "\n", - "\n", - "## Installing the development version directly from github\n", - "\n", - "Instead of using pip to install the latest version of REBOUND from PyPI, you can also install REBOUND directly from github. This is useful if you want to make changes to REBOUND.\n", - "\n", - "First clone the repository (you might need to create a github account):\n", - "\n", - " git clone git@github.com:hannorein/rebound.git\n", - "\n", - "If you already know that you might be contributing something to REBOUND, you can also first fork the repository on github and then clone your own repository.\n", - "\n", - "Next, create a virtual environment with the same commands as above:\n", - "\n", - " virtualenv venv && source venv/bin/activate\n", - "\n", - "Now you can install rebound from source using\n", - "\n", - " pip install -e .\n", - "\n", - "You can modify the python module files in the directory `rebound/` and you'll see the changed the next time you run a python script (no need to reinstall the REBOUND package every time).\n", - "\n", - "If you install REBOUND directly from github, you can also run it without python. Have a look at the README file in the main directory and at the examples in the `examples/` directory for examples in C. These are much more diverse than the python examples (e.g. allow you to use a tree code for gravity calculations, use other boundary conditions, etc).\n", - "\n", - "## iPython Notebook\n", - "\n", - "The tutorials in python_tutorials were written using iPython/Jupyter notebooks. You can view them directly on GitHub. If you want to edit them or create your own notebook, you'll need to install iPython (make sure to activate the virtual environment first if you created one)\n", - "\n", - " pip install \"ipython[notebook]\"\n", - "\n", - "or\n", - "\n", - " conda install ipython-notebook\n", - " \n", - "You can then open iPython notebooks in your browser by typing\n", - "\n", - " ipython notebook\n", - " \n", - "To create a new notebook select from the dropdown menu on the top right the item that says 'New'. Now you can interactively follow the commands in the tutorials or run your own!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/ipython_examples/Twitter.ipynb b/ipython_examples/Twitter.ipynb deleted file mode 100644 index af4b8c553..000000000 --- a/ipython_examples/Twitter.ipynb +++ /dev/null @@ -1,86 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "%matplotlib inline" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A complete N-body simulation and visualization in 140 characters\n", - "The following code is exactly 140 characters long and thus fits into one tweet. It integrates the motion of the Sun and Mars using the IAS15 integrator. " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Searching NASA Horizons for 'Sun'... Found: Sun (10).\n", - "Searching NASA Horizons for 'Mars'... Found: Mars Barycenter (4).\n" - ] - }, - { - "data": { - "text/plain": [ - "[]" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEACAYAAABfxaZOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHaxJREFUeJzt3XmYXFW97vHvSxg8CAoKgkCueI4goCiIJyJ4pJUpDAZR\nMOBVUBwAweEoyCCX5N7nOADOIh4uAgIqyAHBMAkRacQJRMIgk0TNuYAIKoMCDoS894+9o2Wo7nRV\nddeq4f08Tz2pYVftl031r1evvfZask1ERAyHFUoHiIiI7knRj4gYIin6ERFDJEU/ImKIpOhHRAyR\nFP2IiCHScdGXdJqk+yXdMsbrI5IekbSgvh3T6T4jIqI9K07CZ5wOfAE4c5xtrrY9axL2FRERHei4\npW/7GuCh5WymTvcTERGd60afvoFtJN0k6VJJm3VhnxER0cRkdO8szw3AdNuPS9oFuBDYuAv7jYiI\nZUx50bf9x4b7l0k6SdKzbD/YuJ2kTAIUEdEG2xPuQp/yoi9pHeAB25Y0A9CyBX+pVoJ3g6S5tueW\nztEomSauF3Ml08Qk08S12mDuuOhLOhvYDlhL0t3AHGAlANsnA3sBB0taDDwO7NPpPiMioj0dF33b\n+y7n9S8CX+x0PxER0blckTu+0dIBmhgtHaCJ0dIBxjBaOkATo6UDNDFaOkATo6UDNDFaOsBkUK8s\noiLJvdanHxExERKyKVJMW62d3RiyGRHRlyRWATYBNqcaav6s+rbmMvfXlFgCPAo81uTf3wN3Ntzu\nsvlTV/9jamnpR0QAEusD/wq8mKrIbw48H/glcAtVsf4d8GDD7aH634epustXA55e3xrvPwd4YX3b\nBPhn4D7+/kvgP2x+217u1mpnin5EDCWJfwJeDexc39YBrqUq8Etvd9r8ZQr2vSKwIdUvgBcCp9j8\nob3PStGPiGhKYlNgJlWR3xa4Cbgc+DZwg82TBeO1JUU/IqKBxJrAm4EDqFrzl1AV+u/aPFwy22RI\n0Y+IoSexArA9VaHfBbgMOA240mZJyWyTLaN3ImJoSWwAvBN4O9VJ19OAQ2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/Su\n0mEarGP7/vr+/cA6JcM0eK+qeZhOLfEn71L1SLEtqa4S74lj1ZDpx/VTxY6VpBUk3Uh1PK6yfSs9\ncJzGyAVlv1efoRqhuKThudLHqlkm08JxKl30e/ks8ra2twR2AQ6puzV6iqu+uV44hl8Cng9sAdwH\nfKpEiLob5Xzg/bb/2PhaqWNVZzqvzvQohY+V7SW2t6CaNuXVkl6zzOtFjlOTXCMUPFaSdgcesL2A\nMVrR3T5W42Rq6TiVLvr3AtMbHk+nau0XZ/u++t/fAhdQdUX1gvvr/mIkPRd4oHAebD/gGtWfnV0/\nVpJWoir4Z9m+sH666LFqyPTVpZl64VjVOR4BLqHqG+6Z71RDrpcXPlbbALPqc3tnA6+VdBZlj1Wz\nTGe2epxKF/2/XbwlaWWqi7fmFc6EpFUlrV7ffzqwE3DL+O/qmnnA/vX9/YELx9m2K+ov/1J70uVj\nJUnAqcBttj/b8FKxYzVWppLHStJaS//0l/RPwI7AAgp/p8bKtbS41rp6rGwfbXu67ecD+wDftf1W\nCh6rMTLt1+p3qu0rcieD7cWSll68NQ04tRdG7lD1011Q/dyyIvA121d0O4Sks4HtgLUk3Q0cC3wC\nOFfSO4BFVKNBSmaaA4xI2oLqT91fAQd2MxOwLfAW4GZJC+rnjqLssWqW6Wiq6cVLHavnAmdIWoGq\nwXeW7SvrfMW+U+PkOrPw96rR0m6coj9/DdSQ6XhJL2WCxykXZ0VEDJHS3TsREdFFKfoREUMkRT8i\nYoik6EdEDJEU/YiIIZKiHxExRFL0IyKGSIp+RMQQ+f/0qkxyqqu6jgAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "import rebound as r;s=r.Simulation();s.add([\"Sun\",\"Mars\"]);x=[]\n", - "while s.t<9:s.integrate(s.t+.1);x+=[s.particles[1].x]\n", - "import matplotlib.pyplot as m;m.plot(x)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/ipython_examples/Units.ipynb b/ipython_examples/Units.ipynb index b0ad998ec..a57f3d365 100644 --- a/ipython_examples/Units.ipynb +++ b/ipython_examples/Units.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Settings the units for a simulation" + "# Unit convenience functions" ] }, { @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": { "collapsed": false }, @@ -52,7 +52,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "G = 39.476926421373.\n" + "G = 39.4769264214.\n" ] } ], @@ -69,7 +69,7 @@ "\n", "As an aside, the reason why `G` differs from $4\\pi^2 \\approx 39.47841760435743$ is mostly that we follow the convention of defining a \"year\" as 365.25 days (a Julian year), whereas the Earth's sidereal orbital period is closer to 365.256 days (and at even finer level, Venus and Mercury modify the orbital period). `G` would only equal $4\\pi^2$ in units where a \"year\" was exactly equal to one orbital period at $1 AU$ around a $1 M_\\odot$ star.\n", "\n", - "##Adding particles\n", + "**Adding particles**\n", "\n", "If you use `sim.units` at all, you need to set the units before adding any particles. You can then add particles in any of the ways described in [WHFast.ipynb](WHFast.ipynb). You can also add particles drawing from the horizons database (see [Churyumov-Gerasimenko.ipynb](Churyumov-Gerasimenko.ipynb)). If you don't set the units ahead of time, HORIZONS will return initial conditions in units of AU, $M_\\odot$ and yrs/$2\\pi$, such that `G=1`. \n", "\n", @@ -87,23 +87,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Searching NASA Horizons for 'Earth'... " - ] - }, - { - "ename": "gaierror", - "evalue": "[Errno 8] nodename nor servname provided, or not known", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mgaierror\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Earth'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mps\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparticles\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmath\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"v = {0}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mps\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvx\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mps\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvy\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mps\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvz\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/Users/dtamayo/Documents/workspace/rebound/rebound/simulation.py\u001b[0m in \u001b[0;36madd\u001b[0;34m(self, particle, **kwargs)\u001b[0m\n\u001b[1;32m 376\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munits\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 377\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munits\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'AU'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'yr2pi'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Msun'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 378\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhorizons\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetParticle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mparticle\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 379\u001b[0m \u001b[0munits_convert_particle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparticles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'km'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m's'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'kg'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_units\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'length'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_units\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'time'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_units\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'mass'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 380\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/Users/dtamayo/Documents/workspace/rebound/rebound/horizons.py\u001b[0m in \u001b[0;36mgetParticle\u001b[0;34m(particle, m, x, y, z, vx, vy, vz, primary, a, anom, e, omega, inc, Omega, MEAN, date)\u001b[0m\n\u001b[1;32m 33\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[0mt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtelnetlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTelnet\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 35\u001b[0;31m \u001b[0mt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'horizons.jpl.nasa.gov'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m6775\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 36\u001b[0m expect = ( ( b'Horizons>', particle+'\\n' ),\n\u001b[1;32m 37\u001b[0m \u001b[0;34m(\u001b[0m \u001b[0;34mb'Continue.*:'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'y\\n'\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/Users/dtamayo/Documents/workspace/venv/lib/python3.4/telnetlib.py\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self, host, port, timeout)\u001b[0m\n\u001b[1;32m 235\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mport\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mport\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 236\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtimeout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 237\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msock\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msocket\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcreate_connection\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mport\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 238\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__del__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/Users/dtamayo/Documents/workspace/venv/lib/python3.4/socket.py\u001b[0m in \u001b[0;36mcreate_connection\u001b[0;34m(address, timeout, source_address)\u001b[0m\n\u001b[1;32m 492\u001b[0m \u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mport\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0maddress\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 493\u001b[0m \u001b[0merr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 494\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mres\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mgetaddrinfo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mport\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSOCK_STREAM\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 495\u001b[0m \u001b[0maf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msocktype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mproto\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcanonname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msa\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 496\u001b[0m \u001b[0msock\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/Users/dtamayo/Documents/workspace/venv/lib/python3.4/socket.py\u001b[0m in \u001b[0;36mgetaddrinfo\u001b[0;34m(host, port, family, type, proto, flags)\u001b[0m\n\u001b[1;32m 531\u001b[0m \u001b[0;31m# and socket type values to enum constants.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 532\u001b[0m \u001b[0maddrlist\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 533\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mres\u001b[0m \u001b[0;32min\u001b[0m \u001b[0m_socket\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetaddrinfo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhost\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mport\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfamily\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mproto\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mflags\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 534\u001b[0m \u001b[0maf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msocktype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mproto\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcanonname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msa\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 535\u001b[0m addrlist.append((_intenum_converter(af, AddressFamily),\n", - "\u001b[0;31mgaierror\u001b[0m: [Errno 8] nodename nor servname provided, or not known" + "Searching NASA Horizons for 'Earth'... Found: Earth-Moon Barycenter (3).\n", + "v = 6.18818201572\n" ] } ], @@ -125,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": { "collapsed": false }, @@ -135,14 +120,15 @@ "output_type": "stream", "text": [ "---------------------------------\n", - "Rebound version: \t2.0.0\n", + "REBOUND version: \t2.2.1\n", + "REBOUND built on: \tJul 29 2015 21:38:06\n", "Number of particles: \t2\n", "Selected integrator: \tias15\n", "Simulation time: \t0.000000\n", "Current timestep: \t0.001000\n", "---------------------------------\n", - "\n", - "\n", + "\n", + "\n", "---------------------------------\n" ] } @@ -168,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 5, "metadata": { "collapsed": false }, @@ -179,14 +165,15 @@ "text": [ "G = 1.0\n", "---------------------------------\n", - "Rebound version: \t2.0.0\n", + "REBOUND version: \t2.2.1\n", + "REBOUND built on: \tJul 29 2015 21:38:06\n", "Number of particles: \t2\n", "Selected integrator: \tias15\n", "Simulation time: \t0.000000\n", "Current timestep: \t0.001000\n", "---------------------------------\n", "\n", - "\n", + "\n", "---------------------------------\n" ] } @@ -205,15 +192,6 @@ "source": [ "The orbital speed of Earth is $\\sim 3\\times 10^4$ m/s, but since we didn't correctly set `G` ahead of time, we get $\\sim 3\\times 10^9$ m/s, so the Earth would fly off the Sun in this simulation." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/ipython_examples/WHFast.ipynb b/ipython_examples/WHFast.ipynb index 8ae4846ed..03968c709 100644 --- a/ipython_examples/WHFast.ipynb +++ b/ipython_examples/WHFast.ipynb @@ -15,7 +15,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## First WHFast integration\n", + "**First WHFast integration**\n", + "\n", "You can enter all the commands below into a file and execute it all at once, or open an interactive shell).\n", "\n", "First, we need to import the REBOUND module (make sure have have enabled the virtual environment if you used it to install REBOUND)." @@ -287,7 +288,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Visualization with matplotlib\n", + "**Visualization with matplotlib**\n", + "\n", "Instead of just printing boring numbers at the end of the simulation, let's visualize the orbit using matplotlib (you'll need to install numpy and matplotlib to run this example, see [Installation](Installation.ipynb)).\n", "\n", "We'll use the same particles as above. As the particles are already in memory, we don't need to add them again. Let us plot the position of the inner planet at 100 steps during its orbit. First, we'll import numpy and create an array of times for which we want to have an output (here, from $T_{\\rm orb}$ to $2 T_{\\rm orb}$ (we have already advanced the simulation time to $t=2\\pi$)." @@ -528,11 +530,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Speeding things up and extra accuracy\n", + "**Speeding things up and extra accuracy**\n", "\n", - "There are several performance enhancements one can make to WHFast. However, each one has pitfalls that an inexperienced user can unwittingly fall into. We therefore chose safe default settings that make the integrator difficult to misuse. **This makes the default WHFast substantially slower and less accurate than it can be**, so anyone looking to use it more seriously should check out its advanced settings in [Advanced Settings for WHFast](AdvWHFast.ipynb).\n", - "\n", - "## Common mistakes with WHFast\n", + "There are several performance enhancements one can make to WHFast. However, each one has pitfalls that an inexperienced user can unwittingly fall into. We therefore chose safe default settings that make the integrator difficult to misuse. **This makes the default WHFast substantially slower and less accurate than it can be**, so anyone looking to use it more seriously should check out its advanced settings in [Advanced Settings for WHFast](AdvWHFast.ipynb)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Common mistakes with WHFast**\n", "\n", "If you're getting odd output, check the following:\n", "\n", @@ -542,34 +549,25 @@ "\n", "3. If you're somehow modifying particles or adding forces, you should make sure to read [Advanced Settings for WHFast](AdvWHFast.ipynb)." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 2", "language": "python", - "name": "python3" + "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" + "pygments_lexer": "ipython2", + "version": "2.7.6" } }, "nbformat": 4, diff --git a/ipython_examples/index.ipynb b/ipython_examples/index.ipynb deleted file mode 100644 index 34176e36d..000000000 --- a/ipython_examples/index.ipynb +++ /dev/null @@ -1,55 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# REBOUND Tutorials\n", - "\n", - "## Basics\n", - "1. [Installing REBOUND](Installation.ipynb)\n", - "2. [The symplectic integrator WHFast](WHFast.ipynb)\n", - "3. [Using NASA Horizons and IAS15 to simulate a close encounter of Churyumov-Gerasimenko with Jupiter](Churyumov-Gerasimenko.ipynb)\n", - "4. [Test particles](Testparticles.ipynb)\n", - "5. [Setting the units for a simulation](Units.ipynb)\n", - "\n", - "## Modifying integrations\n", - "\n", - "1. [Assigning particles unique IDs and removing particles from the simulation](ParticleIDsAndRemoval.ipynb),\n", - "2. [Catching close encounters between planets using exceptions](CloseEncounters.ipynb)\n", - "3. [Setting up a box beyond which you remove particles from the simulation](EscapingParticles.ipynb)\n", - "4. [Checkpoints (save and load binary data)](Checkpoints.ipynb)\n", - "5. [Additional forces](Forces.ipynb)\n", - "\n", - "## Analysis tools\n", - "1. [Creating a stability map with the MEGNO chaos indicator and WHFast](Megno.ipynb)\n", - "2. [Fourier Analysis & Resonances with WHFast](FourierSpectrum.ipynb)\n", - "3. [Parallel computing using REBOUND and IPython/Jupyter](Parallel.ipynb)\n", - "\n", - "## Fun demonstrations\n", - "1. [A complete N-body simulation with visualization in 140 characters](Twitter.ipynb)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -}