Comments (9)
Brilliant, that worked perfectly. Thank you for your time on this!
from reboundx.
Hi Ian, sorry this fell through the cracks. Are you at DDA? If so feel free to find me anytime. I think I might be able to help faster if we could try things out together on your laptop.
from reboundx.
No worries at all, that sounds great, I'll try to find you today.
from reboundx.
Hello,
I am also running into this situation. I was running my code just fine on my local environment and then when I created a new environment and installed the packages on that computer, my simulations stop running when I try to add radiation forces but run just fine if I take that part out. Same error message, it complains that I "need to attach reboundx.Extras instance to simulation before setting params" even though I definitely have. How do you resolve this?
Thanks,
Tammy
from reboundx.
Hi Tammy,
Sorry, we sorted this out in person and forgot to close the issue, but it would be good to have a solution here. Could you try making a new environment and doing
pip install reboundx --no-binary :all: --no-cache-dir
from reboundx.
I tried doing that, still getting the same error. My environment is Python 3.9.7, rebound version 4.3.2, reboundx version 4.1.0. This is to match my local environment which is successfully running simulations. The code for adding the extra forces is below and the error I'm getting is "AttributeError: Need to attach reboundx.Extras instance to simulation before setting params." which makes no sense because I clearly have...
# Add radiation forces #print("adding radiation forces") rebx = reboundx.Extras(sim) rf = rebx.load_force("radiation_forces") rebx.add_force(rf) rf.params["c"] = rbxConstants.C Q_pr = 1 # valid for meteoroid size >> wavelength of radiation # meteoroid radius should be in m, density should be in kg/m^3 ps["Meteoroid"].params["beta"] = rebx.rad_calc_beta( 6.6743e-11, 3.0e8, msun, lum_sol, r, rho, Q_pr )
from reboundx.
Hm, I just ran the command above with python 3.9.7 and I can't reproduce the error on my macbook pro. What commands did you run? Did you make a new environment? You didn't seem to install the latest versions of rebound and reboundx. Do you need those specific ones?
from reboundx.
I did make a new environment. The problem I have is when I install the latest versions for rebound/reboundx, I don't hit the "need to attach reboundx.Extras" error but it doesn't run my simulation (gets stuck on the first sim.integrate(time) run, doesn't throw error but gets held up forever) unless I remove the lines where I've added the radiation forces, in which case it runs just fine. The versions I mentioned earlier are the ones I have in the environment locally where everything works fine so I've been trying to duplicate that environment on this new computer.
The commands I ran are below:
conda create -n tamayo-test python==3.9.7
conda activate tamayo-test
(tamayo-test)$ pip install rebound==4.3.2
Collecting rebound==4.3.2
Downloading rebound-4.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (10 kB)
Downloading rebound-4.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (744 kB)
Installing collected packages: rebound
Successfully installed rebound-4.3.2
(tamayo-test)$ pip install reboundx --no-binary :all: --no-cache-dir
Collecting reboundx
Downloading reboundx-4.1.0.tar.gz (91 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: rebound>=4.0.0 in /home/tdo47/.conda/envs/tamayo-test/lib/python3.9/site-packages (from reboundx) (4.3.2)
Building wheels for collected packages: reboundx
Building wheel for reboundx (pyproject.toml) ... done
Created wheel for reboundx: filename=reboundx-4.1.0-cp39-cp39-linux_x86_64.whl size=79758 sha256=a44d0dcdec27bac26eb71264917b81297796d9d2b52c15ed78b2151e4d6603f5
Stored in directory: /tmp/pip-ephem-wheel-cache-_yxqjj8e/wheels/89/ea/22/1f8131ed9b9d9615287b303fb5a32e1bae2162630fbfa3d180
Successfully built reboundx
Installing collected packages: reboundx
Successfully installed reboundx-4.1.0
(tamayo-test)$ python test_sim.py
Searching NASA Horizons for 'Sun'...
Found: Sun (10)
Searching NASA Horizons for 'Mercury'...
Found: Mercury Barycenter (199) (chosen from query 'Mercury')
Searching NASA Horizons for 'Venus'...
Found: Venus Barycenter (299) (chosen from query 'Venus')
Searching NASA Horizons for 'Earth'...
Found: Earth-Moon Barycenter (3) (chosen from query 'Earth')
Searching NASA Horizons for 'Luna'...
Found: Moon (301) (chosen from query 'Luna')
Searching NASA Horizons for 'Mars'...
Found: Mars Barycenter (4) (chosen from query 'Mars')
Searching NASA Horizons for 'Jupiter'...
Found: Jupiter Barycenter (5) (chosen from query 'Jupiter')
Searching NASA Horizons for 'Saturn'...
Found: Saturn Barycenter (6) (chosen from query 'Saturn')
Searching NASA Horizons for 'Uranus'...
Found: Uranus Barycenter (7) (chosen from query 'Uranus')
Searching NASA Horizons for 'Neptune'...
Found: Neptune Barycenter (8) (chosen from query 'Neptune')
Searching NASA Horizons for 'C/2014 Q2'...
Found: Lovejoy (C/2014 Q2)
/home/tdo47/.conda/envs/tamayo-test/lib/python3.9/site-packages/rebound/horizons.py:167: RuntimeWarning: Warning: Mass cannot be retrieved from NASA HORIZONS. Set to 0.
warnings.warn("Warning: Mass cannot be retrieved from NASA HORIZONS. Set to 0.", RuntimeWarning)
/home/tdo47/.conda/envs/tamayo-test/lib/python3.9/site-packages/rebound/simulation.py:254: RuntimeWarning: REBOUNDx overwrites sim->additional_forces, sim->pre_timestep_modifications and sim->post_timestep_modifications whenever forces or operators that use them get added. If you want to use REBOUNDx together with your own custom functions that use these callbacks, you should add them through REBOUNDx. See https://github.com/dtamayo/reboundx/blob/master/ipython_examples/Custom_Effects.ipynb for a tutorial.
warnings.warn(msg[1:], RuntimeWarning)
Traceback (most recent call last):
File "/home/tdo47/msc-uwo/test_sim.py", line 13, in
ps[3].params["J2"] = 1.0826157e-3
File "/home/tdo47/.conda/envs/tamayo-test/lib/python3.9/site-packages/reboundx/init.py", line 40, in params
params = Params(self)
File "/home/tdo47/.conda/envs/tamayo-test/lib/python3.9/site-packages/reboundx/params.py", line 25, in init
raise AttributeError("Need to attach reboundx.Extras instance to simulation before setting params.")
AttributeError: Need to attach reboundx.Extras instance to simulation before setting params.
And here is the code I used for the test simulation: test_sim.txt
from reboundx.
Thanks for all the testing @tamidodo . I think the issue was compatibility issues with versions of REBOUND in the installation wheels. I think REBOUNDx 4.2.0 should resolve your issues. Could you let me know?
from reboundx.
Related Issues (20)
- Problem with the example: full version of yarkovsky_effect: Python 2.7 HOT 8
- Yarkovsky effect in Reboundx : question about the 'k' coefficient HOT 2
- Question additional forces HOT 5
- Signed int HOT 2
- Radiation forces blocked by particles HOT 3
- Need to attach reboundx.Extras instance to simulation before setting params. HOT 8
- Failed building editable for reboundx HOT 6
- Cannot reproduce the plot in InnerDiskEdge.ipynb HOT 1
- Trouble implementing new effect
- Extras not attatching to sim for Rebound 4.3.2 HOT 7
- "Process finished with exit code 139" when running example code HOT 4
- Error with setting gr.params in GR notebook HOT 12
- ReboundX - installing problem with Python HOT 1
- Trouble Installing reboundx HOT 1
- Could not install reboundx due to 'wheels error' HOT 3
- Happy Birthday! 🥳 HOT 1
- Difficulties to simulate the evolution of the Earth-Moon system + Sun HOT 6
- REBOUNDx error: Force 'type_I_migration' not found in REBOUNDx library. HOT 5
- Setting beta via sim.particles[i].beta does not work? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reboundx.