Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to attach reboundx.Extras instance to simulation before setting params. #112

Closed
AstroEloy opened this issue Sep 28, 2023 · 8 comments
Closed

Comments

@AstroEloy
Copy link

AstroEloy commented Sep 28, 2023

Now when I try to use reboundx in Python I get this error (with any of the examples):

"Need to attach reboundx.Extras instance to simulation before setting params."

It does not happen in reboundx-3.9.0

@dtamayo
Copy link
Owner

dtamayo commented Oct 6, 2023

Hi Eloy,

Apologies for the slow response. I'm not able to reproduce this issue. Usually when you get errors like this, versions/installations have got mixed up. The first thing to try is to reinstall. If you make a new virtualenv or conda environment and you pip install reboundx, do you get this same error?

@AstroEloy
Copy link
Author

From a clean installation in a new environment in MacOS with pip, I got the same error.

@hannorein
Copy link
Collaborator

Everything works fine when I try this:

rein@m1air:~ # mkdir eloytest
rein@m1air:~ # cd eloytest
rein@m1air:~/eloytest # python3 -m venv venv
rein@m1air:~/eloytest # source venv/bin/activate
rein@m1air:~/eloytest # pip install reboundx                                                                        eloytest|
Collecting reboundx
  Using cached reboundx-3.10.1.tar.gz (90 kB)
  Preparing metadata (setup.py) ... done
Collecting rebound>=3.23.0
  Using cached rebound-3.28.3-cp310-cp310-macosx_11_0_arm64.whl (221 kB)
Collecting numpy
  Using cached numpy-1.26.0-cp310-cp310-macosx_11_0_arm64.whl (14.0 MB)
Using legacy 'setup.py install' for reboundx, since package 'wheel' is not installed.
Installing collected packages: rebound, numpy, reboundx
  Running setup.py install for reboundx ... done
Successfully installed numpy-1.26.0 rebound-3.28.3 reboundx-3.10.1
WARNING: You are using pip version 22.0.4; however, version 23.2.1 is available.
You should consider upgrading via the '/Users/rein/eloytest/venv/bin/python3 -m pip install --upgrade pip' command.
rein@m1air:~/eloytest # python                                                                                      eloytest|
Python 3.10.5 (v3.10.5:f377153967, Jun  6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import reboundx
>>> import rebound
>>> sim = rebound.Simulation()
>>> sim.add(m=1.)
>>> sim.add(a=1.)
>>> rebx = reboundx.Extras(sim)
>>> mm = rebx.load_operator("modify_mass")
>>> rebx.add_operator(mm)
>>> sim.particles[0].params["tau_mass"] = -1000
>>> gr = rebx.load_force("gr")
>>> rebx.add_force(gr)
>>> gr.params['c'] = 1.e4 # set speed of light
>>> sim.integrate(100.)

What version of MacOS and Python do you use?

@AstroEloy
Copy link
Author

I am using Python 3.11.5 on macOS Monterey

@AstroEloy
Copy link
Author

AstroEloy commented Oct 6, 2023

Ok, I tried and the error does not happen in Python 3.9. It should be the Python version

@hannorein
Copy link
Collaborator

I've tried it with python 3.11 and still see no problems. I'm not sure why it doesn't work on your side. My only guess is that you might have (accidentally) changed something in your python 3.11 installation.

@AstroEloy
Copy link
Author

It looks like... But it is strange that reboundx version 3.9 does not give me this problem. Thank you for the help!

@dtamayo
Copy link
Owner

dtamayo commented Oct 6, 2023

I also just tried a clean install with python 3.11 and it worked fine for me. It's so tricky to debug these kind of problems! I'll close this for now, but please feel free to open a new one if you run into more problems. Thanks Hanno.

@dtamayo dtamayo closed this as completed Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants