dtamayo / reboundx

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

Adding custom operator and force without overwriting #40

Closed lenunez13 closed 4 years ago

lenunez13 commented 4 years ago

Hello. I am trying to incorporate both GR and my custom operator. Although I am adding the force and operator through REBOUNDx (as instructed in Custom_Effects.ipynb), the results indicate that the first function is still overwritten. Is there a problem with how I am calling the functions? Thanks!

if gr == True:
    rebx = reboundx.Extras(sim)
    gr = rebx.load_force("gr")
    gr.force_type = "pos"
    rebx.add_force(gr)
    gr.params["c"] = constants.C  

if tides == True:
    rebx = reboundx.Extras(sim)
    mod = rebx.load_operator("modify_orbits_direct2")
    mod.operator_type = "updater"
    rebx.add_operator(mod)
    tau = 5e4
    ps[1].params["tau_e"] = tau
dtamayo commented 4 years ago

Hi Luis,

I think the issue is that if both are True you are creating a new Extras instance. rebx = reboundx.Extras(sim) should be outside the if blocks

lenunez13 commented 4 years ago

That worked. Thanks!