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

Change parameter (beta, mass) during integration run #28

Closed
hippke opened this issue May 24, 2018 · 1 comment
Closed

Change parameter (beta, mass) during integration run #28

hippke opened this issue May 24, 2018 · 1 comment

Comments

@hippke
Copy link

hippke commented May 24, 2018

As a user, I like to change certain values during the course of the integration, using feedback from the integration. Consider a light sail in form of a reflective sphere which may change its reflectivity (the beta value). When it gets closer to the star, it increases reflectivity, and vice versa. If beta can be adjusted during the run, depending on the distance between two objects, interesting trajectories can be simulated.

One may take this further and also modify parameters such as the mass of a body. This is already possible using a given (set once and forget) function, as shown in the example "ModifyMass.ipynb". However, it appears not to be possible to change mass or luminosity depending on external conditions.

@dtamayo
Copy link
Owner

dtamayo commented May 24, 2018

It depends on whether the timescale on which you change the strength of radiation pressure is long compared to the dynamical timescale. It sounds like this is not your case, but for completeness, in this case, you could simply update beta between a grid of times. If the grid is fine on the timescale you want to vary beta you’ll capture the right behavior, and if it’s coarse on the scale of the integrator timestep, you won’t lose any performance. For example to vary beta linearly from 0 to 1 over 1e4 time units:

t_vary = 1e4
Ntimes = 1000
times = np.linspace(0, t_vary, Ntimes)
for time in times:
	sim.integrate(time)
	sim.particles[1].params[‘beta’] = time/t_vary

If on the other hand you need to vary it on orbital timescales, you would need to write your own custom function. You can follow the example here: https://github.com/dtamayo/reboundx/blob/master/ipython_examples/Custom_Effects.ipynb, where you would write a function like starkForce, that in addition to adding the appropriate acceleration (you could translate the implementation in src/radiation_forces.c) updates the beta parameter of the particles. You can also add new parameters to the particles that control how the effect varies with time to each particle and access them in that function.

When you do this, it means that this function you write will be called in Python every timestep from C, which will slow things down by a factor of a couple to a few. For presumably short integration timescales for light sails the performance might not be an issue you care about. If you need to squeeze out extra performance, you could write your custom effect in C that updates particle accelerations, and then REBOUNDx will automatically take care of all the interface so that it’s accessible from Python. A tutorial on how to do that is here: http://reboundx.readthedocs.io/en/latest/add_effect.html

Hope that helps!

@dtamayo dtamayo closed this as completed May 24, 2018
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

2 participants