dtamayo / reboundx

A library for adding additional forces to the REBOUND N-body integration package
GNU General Public License v3.0
80 stars 61 forks source link

modify_mass module error #20

Closed MilevaE closed 7 years ago

MilevaE commented 7 years ago

Hi all,

I'm interested to use the Reboundx module "modify_mass". Just to check if works in my computer I copied the ipython example and run:

import rebound
import reboundx
import numpy as np
sim = rebound.Simulation()
sim.G = 4*np.pi**2 # use units of AU, yrs and solar masses

M0 = 1. # initial mass of star
sim.add(m=M0)
sim.add(a=1.)
sim.add(a=2.)
sim.add(a=3.)
sim.move_to_com()
ps = sim.particles

rebx = reboundx.Extras(sim)
mass_effect = rebx.add("modify_mass")

ps[0].params["tau_mass"] = -1.e4

Nout = 1000
mass = np.zeros(Nout)
times = np.linspace(0., 1.e4, Nout)

for i, time in enumerate(times):
    sim.integrate(time)
    mass[i] = sim.particles[0].m

unfortunately I obtain a strange error, and I am bit lost =(

here is the error:


Traceback (most recent call last):
  File "mas.py", line 18, in <module>
    ps[0].params["tau_mass"] = -1.e4
  File "/home/mileva/reboundx/reboundx/__init__.py", line 35, in params
    params = Params(self)
  File "/home/mileva/reboundx/reboundx/params.py", line 13, in __init__
    raise AttributeError("Need to attach reboundx.Extras instance to simulation before setting particle params.")
AttributeError: Need to attach reboundx.Extras instance to simulation before setting particle params.
*** glibc detected *** python: double free or corruption (out): 0x00007f89ce9cddd0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7da26)[0x7f89d00a0a26]
/usr/local/lib/python2.7/dist-packages/rebound/../librebound.so(reb_integrator_whfasthelio_reset+0x47)[0x7f89cf2c5eb7]
/usr/local/lib/python2.7/dist-packages/rebound/../librebound.so(reb_free_pointers+0xc3)[0x7f89cf2bc633]
/usr/lib/python2.7/lib-dynload/_ctypes.so(ffi_call_unix64+0x4c)[0x7f89cf51eea4]
/usr/lib/python2.7/lib-dynload/_ctypes.so(ffi_call+0x1e5)[0x7f89cf51e8c5]
/usr/lib/python2.7/lib-dynload/_ctypes.so(_ctypes_callproc+0x4d2)[0x7f89cf50f2c2]
/usr/lib/python2.7/lib-dynload/_ctypes.so(+0xbaa2)[0x7f89cf50faa2]
python(PyObject_Call+0x36)[0x4e9f36]
python(PyEval_EvalFrameEx+0x86a)[0x49846a]
python(PyEval_EvalCodeEx+0x1a0)[0x49f1c0]
python[0x4a8960]
python(PyObject_Call+0x36)[0x4e9f36]
python[0x4ec11a]
python(PyObject_Call+0x36)[0x4e9f36]
python(PyEval_CallObjectWithKeywords+0x36)[0x4ea396]
python[0x460bb5]
python[0x460f6e]
python[0x57cbd5]
python(PyDict_SetItem+0x49)[0x4faf79]
python(_PyModule_Clear+0x149)[0x561619]
python(PyImport_Cleanup+0x4bd)[0x507d8d]
python(Py_Finalize+0x12f)[0x4aedff]
python(Py_Main+0x3ce)[0x4aa72e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f89d00447ed]
python[0x41b9b1]
======= Memory map: ========
00400000-00671000 r-xp 00000000 08:11 5901780                            /usr/bin/python2.7
00870000-00871000 r--p 00270000 08:11 5901780                            /usr/bin/python2.7
00871000-008da000 rw-p 00271000 08:11 5901780                            /usr/bin/python2.7
008da000-008ec000 rw-p 00000000 00:00 0 
020a7000-02cb8000 rw-p 00000000 00:00 0                                  [heap]
7f89cb60d000-7f89cb6ef000 r-xp 00000000 08:11 5906044                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f89cb6ef000-7f89cb8ee000 ---p 000e2000 08:11 5906044                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f89cb8ee000-7f89cb8f6000 r--p 000e1000 08:11 5906044                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f89cb8f6000-7f89cb8f8000 rw-p 000e9000 08:11 5906044                    /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f89cb8f8000-7f89cb90d000 rw-p 00000000 00:00 0 
7f89cb90d000-7f89cba2e000 r-xp 00000000 08:11 5898405                    /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12.0
7f89cba2e000-7f89cbc2e000 ---p 00121000 08:11 5898405                    /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12.0
7f89cbc2e000-7f89cbc32000 r--p 00121000 08:11 5898405                    /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12.0
7f89cbc32000-7f89cbc33000 rw-p 00125000 08:11 5898405                    /usr/lib/x86_64-linux-gnu/libapt-pkg.so.4.12.0
7f89cbc33000-7f89cbc34000 rw-p 00000000 00:00 0 
7f89cbc34000-7f89cbc7e000 r-xp 00000000 08:11 6030924                    /usr/lib/python2.7/dist-packages/apt_pkg.so
7f89cbc7e000-7f89cbe7e000 ---p 0004a000 08:11 6030924                    /usr/lib/python2.7/dist-packages/apt_pkg.so
7f89cbe7e000-7f89cbe80000 r--p 0004a000 08:11 6030924                    /usr/lib/python2.7/dist-packages/apt_pkg.so
7f89cbe80000-7f89cbe89000 rw-p 0004c000 08:11 6030924                    /usr/lib/python2.7/dist-packages/apt_pkg.so
7f89cbe89000-7f89cbeb0000 r-xp 00000000 08:11 3673679                    /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7f89cbeb0000-7f89cc0b0000 ---p 00027000 08:11 3673679                    /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7f89cc0b0000-7f89cc0b2000 r--p 00027000 08:11 3673679                    /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7f89cc0b2000-7f89cc0b3000 rw-p 00029000 08:11 3673679                    /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7f89cc0b3000-7f89cc0c1000 r-xp 00000000 08:11 6034455                    /usr/lib/python2.7/lib-dynload/pyexpat.so
7f89cc0c1000-7f89cc2c0000 ---p 0000e000 08:11 6034455                    /usr/lib/python2.7/lib-dynload/pyexpat.so
7f89cc2c0000-7f89cc2c1000 r--p 0000d000 08:11 6034455                    /usr/lib/python2.7/lib-dynload/pyexpat.so
7f89cc2c1000-7f89cc2c3000 rw-p 0000e000 08:11 6034455                    /usr/lib/python2.7/lib-dynload/pyexpat.so
7f89cc2c3000-7f89cc348000 r-xp 00000000 08:11 6305700                    /usr/local/lib/python2.7/dist-packages/numpy/random/mtrand.so
7f89cc348000-7f89cc547000 ---p 00085000 08:11 6305700                    /usr/local/lib/python2.7/dist-packages/numpy/random/mtrand.so
7f89cc547000-7f89cc548000 r--p 00084000 08:11 6305700                    /usr/local/lib/python2.7/dist-packages/numpy/random/mtrand.so
7f89cc548000-7f89cc567000 rw-p 00085000 08:11 6305700                    /usr/local/lib/python2.7/dist-packages/numpy/random/mtrand.so
7f89cc567000-7f89cc568000 rw-p 00000000 00:00 0 
7f89cc568000-7f89cc571000 r-xp 00000000 08:11 6305710                    /usr/local/lib/python2.7/dist-packages/numpy/fft/fftpack_lite.so
7f89cc571000-7f89cc770000 ---p 00009000 08:11 6305710                    /usr/local/lib/python2.7/dist-packages/numpy/fft/fftpack_lite.so
7f89cc770000-7f89cc771000 r--p 00008000 08:11 6305710                    /usr/local/lib/python2.7/dist-packages/numpy/fft/fftpack_lite.so
7f89cc771000-7f89cc772000 rw-p 00009000 08:11 6305710                    /usr/local/lib/python2.7/dist-packages/numpy/fft/fftpack_lite.so
7f89cc772000-7f89cc773000 r-xp 00000000 08:11 6034429                    /usr/lib/python2.7/lib-dynload/future_builtins.so
7f89cc773000-7f89cc972000 ---p 00001000 08:11 6034429                    /usr/lib/python2.7/lib-dynload/future_builtins.so
7f89cc972000-7f89cc973000 r--p 00000000 08:11 6034429                    /usr/lib/python2.7/lib-dynload/future_builtins.so
7f89cc973000-7f89cc974000 rw-p 00001000 08:11 6034429                    /usr/lib/python2.7/lib-dynload/future_builtins.so
7f89cc974000-7f89cc993000 r-xp 00000000 08:11 6034447                    /usr/lib/python2.7/lib-dynload/_io.so
7f89cc993000-7f89ccb92000 ---p 0001f000 08:11 6034447                    /usr/lib/python2.7/lib-dynload/_io.so
7f89ccb92000-7f89ccb93000 r--p 0001e000 08:11 6034447                    /usr/lib/python2.7/lib-dynload/_io.so
7f89ccb93000-7f89ccb9c000 rw-p 0001f000 08:11 6034447                    /usr/lib/python2.7/lib-dynload/_io.so
7f89ccb9c000-7f89ccbbf000 r-xp 00000000 08:11 6307744                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/_umath_linalg.so
7f89ccbbf000-7f89ccdbe000 ---p 00023000 08:11 6307744                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/_umath_linalg.so
7f89ccdbe000-7f89ccdbf000 r--p 00022000 08:11 6307744                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/_umath_linalg.so
7f89ccdbf000-7f89ccdc0000 rw-p 00023000 08:11 6307744                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/_umath_linalg.so
7f89ccdc0000-7f89ccdf5000 r-xp 00000000 08:11 5905988                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f89ccdf5000-7f89ccff4000 ---p 00035000 08:11 5905988                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f89ccff4000-7f89ccff5000 r--p 00034000 08:11 5905988                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f89ccff5000-7f89ccff6000 rw-p 00035000 08:11 5905988                    /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7f89ccff6000-7f89cd10a000 r-xp 00000000 08:11 5909188                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f89cd10a000-7f89cd30a000 ---p 00114000 08:11 5909188                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f89cd30a000-7f89cd30b000 r--p 00114000 08:11 5909188                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f89cd30b000-7f89cd30d000 rw-p 00115000 08:11 5909188                    /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7f89cd30d000-7f89cd3a6000 r-xp 00000000 08:11 7344892                    /usr/lib/libblas/libblas.so.3gf.0
7f89cd3a6000-7f89cd5a5000 ---p 00099000 08:11 7344892                    /usr/lib/libblas/libblas.so.3gf.0
7f89cd5a5000-7f89cd5a6000 r--p 00098000 08:11 7344892                    /usr/lib/libblas/libblas.so.3gf.0
7f89cd5a6000-7f89cd5a7000 rw-p 00099000 08:11 7344892                    /usr/lib/libblas/libblas.so.3gf.0
7f89cd5a7000-7f89cde8c000 r-xp 00000000 08:11 7344908                    /usr/lib/lapack/liblapack.so.3gf.0
7f89cde8c000-7f89ce08b000 ---p 008e5000 08:11 7344908                    /usr/lib/lapack/liblapack.so.3gf.0
7f89ce08b000-7f89ce08c000 r--p 008e4000 08:11 7344908                    /usr/lib/lapack/liblapack.so.3gf.0
7f89ce08c000-7f89ce090000 rw-p 008e5000 08:11 7344908                    /usr/lib/lapack/liblapack.so.3gf.0
7f89ce090000-7f89ce19d000 rw-p 00000000 00:00 0 
7f89ce19d000-7f89ce1a0000 r-xp 00000000 08:11 6307743                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/lapack_lite.so
7f89ce1a0000-7f89ce39f000 ---p 00003000 08:11 6307743                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/lapack_lite.so
7f89ce39f000-7f89ce3a0000 r--p 00002000 08:11 6307743                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/lapack_lite.so
7f89ce3a0000-7f89ce3a1000 rw-p 00003000 08:11 6307743                    /usr/local/lib/python2.7/dist-packages/numpy/linalg/lapack_lite.so
7f89ce3a1000-7f89ce43f000 r-xp 00000000 08:11 6307712                    /usr/local/lib/python2.7/dist-packages/numpy/core/umath.so
7f89ce43f000-7f89ce63f000 ---p 0009e000 08:11 6307712                    /usr/local/lib/python2.7/dist-packages/numpy/core/umath.so
7f89ce63f000-7f89ce640000 r--p 0009e000 08:11 6307712                    /usr/local/lib/python2.7/dist-packages/numpy/core/umath.so
7f89ce640000-7f89ce646000 rw-p 0009f000 08:11 6307712                    /usr/local/lib/python2.7/dist-packages/numpy/core/umath.so
7f89ce646000-7f89ce648000 rw-p 00000000 00:00 0 
7f89ce648000-7f89ce7a6000 r-xp 00000000 08:11 6307713                    /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so
7f89ce7a6000-7f89ce9a6000 ---p 0015e000 08:11 6307713                    /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.soAbortado (`core' generado)

Any suggestion about what I'm doing wrong?

thanks in advance to all!

all the best,

Mileva

dtamayo commented 7 years ago

I just tried your code and it works fine with the latest version. Try upgrading to the latest version of REBOUND and REBOUNDx

MilevaE commented 7 years ago

Thanks for your fast answer! I can't upgrade REBOUND and REBOUNDX. The problem is that my operative system is ubuntu 12.04, and I should upgrade first this, but if I do I will loss all my licenses, and current configuration =( Bad news for me

Thanks anyway!

Cheers,

Mileva

hannorein commented 7 years ago

Hi Mileva. I typically install python packages in a virtualenv. That way I can easily upgrade them without risking to destroy my system wide python installation. It's pretty straightforward (google can tell you more):

virtualenv venv
source venv/bin/activate
pip install rebound reboundx
MilevaE commented 7 years ago

Very useful tip! Thanks Hanno!