Comments (5)
from reboundx.
Hi Dan,
thanks you very much for the explanation!, now it's clear =)
Cheers,
Mileva
from reboundx.
Hi again,
sorry for re-open when was already closed =(
As I mentioned, I'm learning about how to implement my own effects. Just for learn, I try to implement a linear mass loss/growth, based in the e-folding code already available. I followed all the steps, which I think that are ok. Everything compile correctly. However, when I call from my python code, the integration never starts =(
This is the C code for the effect (copy from modify_mass.c and change a couple of things):
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "rebound.h"
#include "reboundx.h"
void rebx_modify_mass_linear(struct reb_simulation* const sim, struct rebx_effect* const effect, const double dt, enum rebx_timing timing){
const int _N_real = sim->N - sim->N_var;
for(int i=0; i<_N_real; i++){
struct reb_particle* const p = &sim->particles[i];
const double* const M_dot = rebx_get_param_check(p, "M_dot", REBX_TYPE_DOUBLE);
const double* const initial_mass = rebx_get_param_check(p, "initial_mass", REBX_TYPE_DOUBLE);
if (M_dot != NULL){
p->m += *initial_mass + (*M_dot*dt);
}
}
reb_move_to_com(sim);
}
I have defined M_dot
in units of M_sun/year, i.e., the rate of mass loss. And Mo
the initial mass of
the star in M_sun. So, what I think is doing is:
m = Mo + M_dot*dt
Thus, in principle, just a linear (and simple) equation.
From python, I call doing:
Mo = 3.04
rebx = reboundx.Extras(sim)
mass_effect_linear = rebx.add("modify_mass_linear")
ps[0].params["M_dot"] = -1.e-5
ps[0].params["initial_mass"] = Mo
Nout = 1e5
mass = np.zeros(Nout)
years=1e5
times = np.linspace(0., years, Nout)
time_step = np.zeros((0,Nout))
semimayor = np.zeros((2,Nout))
ecc = np.zeros((2,Nout))
sim.integrator = "ias15"
#sim.integrator = "whfast"
for i, timex in enumerate(times):
sim.integrate(timex)
mass[i] = sim.particles[0].m
semimayor[0][i] = sim.particles[1].a
semimayor[1][i] = sim.particles[2].a
ecc[0][i] = sim.particles[1].e
ecc[1][i] = sim.particles[2].e
time_step = np.append(time_step,sim.dt)
print i
So, any advice what I'm doing wrong and why the integration never starts.. :/
Thanks a lot for the help!
Cheers,
Mileva
from reboundx.
Hi Mileva,
what do you mean it doesn't start? What error do you get in the notebook and/or in the terminal from which you launched the notebook?
Also, I know it's just a test, but I think your equation updating the masses will always update to the same value assuming a constant timestep. I think you want p->m += M_dotdt;
from reboundx.
Hi Dan,
yes, with your advice works perfect. Thanks!
When I said "the integration never starts" I mean, that, as you can see in the code:
for i, timex in enumerate(times):
sim.integrate(timex)
mass[i] = sim.particles[0].m
semimayor[0][i] = sim.particles[1].a
semimayor[1][i] = sim.particles[2].a
ecc[0][i] = sim.particles[1].e
ecc[1][i] = sim.particles[2].e
time_step = np.append(time_step,sim.dt)
print i
I inserted a "print i" at the end, in order to follow what is going on. However, in this case, never start to count, doesn't print anything. With your correction yes, it prints =)
Thanks!
Best,
Mileva
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
- Getting warning/error with additional forces HOT 9
- Trouble Installing reboundx HOT 1
- Could not install reboundx due to 'wheels error' HOT 3
- reboundx install failed on my Macbook HOT 6
- "OSError: librebound.cpython-37m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory" when importing reboundx on Google Colab 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.