dtamayo / spock

🖖 A package to determine whether planetary orbital configurations will live long and prosper
GNU General Public License v3.0
63 stars 15 forks source link

Simulations stuck in Jupyter Notebooks #17

Closed Rob685 closed 3 years ago

Rob685 commented 3 years ago

The rebound.Simulation() method gets stuck when it's ran in an Jupyter Notebook cell. I find that it works on the IPython console. If I run the following code in the IPython console, then it works, but the same code does not run in a notebook cell nor in Spyder.



In [2]: model = FeatureClassifier()

In [3]: sim = rebound.Simulation()
   ...: sim.add(m=1.)
   ...: sim.add(m=1.e-4, P=1., e=0.03, l=0.3)
   ...: sim.add(m=1.e-4, P=1.4, e=0.03, l=2.8)
   ...: sim.add(m=1.e-4, P=2, e=0.03, l=4.2)
   ...: sim.add(m=1.e-4, P=3.5, e=0.03, l=2.1)
   ...: sim.move_to_com()
   ...: fig = rebound.OrbitPlot(sim)

In [4]: model.predict_stable(sim)
Out[4]: 0.005517447```
dtamayo commented 3 years ago

Hi Rob, this sounds like an issue with SPOCK rather than REBOUND. I think most likely is an issue with the versions of different libraries SPOCK needs. The easiest way to avoid version problems that are a pain to resolve is to

a) get the free anaconda distribution of python https://www.anaconda.com/products/individual b) Run the create_env.sh in the SPOCK root directory passing it the name you want for the environment, e.g.

$ ./create_env.sh spock
$ conda activate spock
$ jupyter notebook

The script will create a new conda environment named spock, and install the same versions of the supporting libraries that we used. Then whenever you want to use spock you activate the environment, and launch a Jupyter notebook with the environment activated. If you haven't used conda environments before you can easily find how to use them.

Let us know if that works!

dtamayo commented 3 years ago

For anyone else looking at this issue, this means that instead of pip install spock, you would clone Spock's git repository directly

git clone https://github.com/dtamayo/spock

The create_env.sh shell script is then in the root spock directory

Rob685 commented 3 years ago

Great! Thanks, this worked. I needed to install spock by running $ pip install -e . in the spock root directory before opening the jupyter notebooks.