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

Dynamics for multis #947

Open
wants to merge 41 commits into
base: feature-multis
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
471538f
A version working for triple systems!
miroslavbroz Sep 15, 2024
bf5fd08
Triple systems with two if's.
miroslavbroz Sep 19, 2024
54cdb1c
Correction of nbody.py (pip3 install rebound).
miroslavbroz Sep 19, 2024
460a5e1
Correction of the Euler angle.
miroslavbroz Sep 19, 2024
beb6960
Correction of constraints <- double precision!
miroslavbroz Sep 22, 2024
05f7a8c
Epsilon parameter for integrators.
miroslavbroz Sep 26, 2024
7e535e3
A re-implementation of keplerian.py for triples!
miroslavbroz Sep 26, 2024
93ab3e7
Correction of constraints <- "%.17e" format.
miroslavbroz Sep 27, 2024
77e64d0
solRad units in Keplerian dynamics.
miroslavbroz Sep 29, 2024
a9d0399
Computation of the Euler angles.
miroslavbroz Sep 29, 2024
035ee7a
vgamma in Keplerian dynamics.
miroslavbroz Sep 29, 2024
39327b1
Correction of vgamma unit.
miroslavbroz Sep 29, 2024
bab6f58
dpdt, dperdt in Keplerian dynamics.
miroslavbroz Sep 29, 2024
0be34a1
Documentation of Keplerian dynamics.
miroslavbroz Sep 29, 2024
a7b8655
ltte in Keplerian dynamics.
miroslavbroz Sep 30, 2024
4b365b4
Rebuilt default binaries.
miroslavbroz Oct 1, 2024
dea000a
ASCII art.
miroslavbroz Oct 2, 2024
b3debd7
Pass roche **kwarg parameters.
miroslavbroz Oct 3, 2024
4b31a86
Don't reuse module variable (cape).
miroslavbroz Oct 4, 2024
5ba5500
Correction of Euler angles for triples.
miroslavbroz Oct 7, 2024
1dd0336
Introducing a "xyz" dynamics with a geometry layer.
miroslavbroz Oct 3, 2024
f07858d
The "xyz" dynamics with an inverse geometry layer.
miroslavbroz Oct 6, 2024
8322b86
Correction of orientation and Euler angles.
miroslavbroz Oct 6, 2024
41f8024
Reboundx support.
miroslavbroz Oct 6, 2024
7be6a57
Reboundx update.
miroslavbroz Oct 6, 2024
5a9da3a
Single star without ds, Fs.
miroslavbroz Oct 7, 2024
74b5234
The "xyz" dynamics documentation.
miroslavbroz Oct 7, 2024
e9e02a1
J2 = -C20 or oblateness.
miroslavbroz Oct 7, 2024
a8f894d
Rebuilt default binaries.
miroslavbroz Oct 7, 2024
71d6ca2
Merge branch 'feature-multis' into feature-multis
miroslavbroz Oct 7, 2024
b4b607c
Correction of J2 (requivs).
miroslavbroz Oct 8, 2024
4df00a1
Merge branch 'feature-multis' of github.com:miroslavbroz/phoebe2 into…
miroslavbroz Oct 8, 2024
d919127
Use 'gr_full' in reboundx.
miroslavbroz Oct 13, 2024
b5832f0
Correction of J2 = -C20 in reboundx.
miroslavbroz Oct 14, 2024
d41abe6
Consolidated to coord.py, orbel.py, geometry.py.
miroslavbroz Oct 14, 2024
c299719
Correction of import.
miroslavbroz Oct 14, 2024
de0daae
Test of geometry.
miroslavbroz Oct 14, 2024
b5e61b1
Generalisation of J2 = -C20 in reboundx.
miroslavbroz Oct 21, 2024
214b0fb
Round-offs in elements.
miroslavbroz Oct 22, 2024
c648a28
Mass constraint for multiples.
miroslavbroz Nov 7, 2024
c28e09e
Quadratic term in the mean anomaly.
miroslavbroz Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions phoebe/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,9 @@ def _compute_intrinsic_system_at_t0(self, b, compute,
if dynamics_method in ['nbody', 'rebound']:
t0, xs0, ys0, zs0, vxs0, vys0, vzs0, inst_ds0, inst_Fs0, ethetas0, elongans0, eincls0 = dynamics.nbody.dynamics_from_bundle(b, [t0], compute, return_roche_euler=True, **kwargs)

elif dynamics_method in ['xyz']:
t0, xs0, ys0, zs0, vxs0, vys0, vzs0, inst_ds0, inst_Fs0, ethetas0, elongans0, eincls0 = dynamics.xyz.dynamics_from_bundle(b, [t0], compute, return_roche_euler=True, **kwargs)

elif dynamics_method == 'bs':
# TODO: pass stepsize
# TODO: pass orbiterror
Expand Down Expand Up @@ -1027,6 +1030,9 @@ def _worker_setup(self, b, compute, times, infolists, **kwargs):
if dynamics_method in ['nbody', 'rebound']:
ts, xs, ys, zs, vxs, vys, vzs, inst_ds, inst_Fs, ethetas, elongans, eincls = dynamics.nbody.dynamics_from_bundle(b, times, compute, return_roche_euler=True, **kwargs)

elif dynamics_method in ['xyz']:
ts, xs, ys, zs, vxs, vys, vzs, inst_ds, inst_Fs, ethetas, elongans, eincls = dynamics.xyz.dynamics_from_bundle(b, times, compute, return_roche_euler=True, **kwargs)

elif dynamics_method == 'bs':
# if distortion_method == 'roche':
# raise ValueError("distortion_method '{}' not compatible with dynamics_method '{}'".format(distortion_method, dynamics_method))
Expand All @@ -1039,6 +1045,8 @@ def _worker_setup(self, b, compute, times, infolists, **kwargs):
elif dynamics_method=='keplerian':
# TODO: make sure that this takes systemic velocity and corrects positions and velocities (including ltte effects if enabled)
ts, xs, ys, zs, vxs, vys, vzs, ethetas, elongans, eincls = dynamics.keplerian.dynamics_from_bundle(b, times, compute, return_euler=True, **kwargs)
inst_ds = None
inst_Fs = None

else:
raise NotImplementedError
Expand All @@ -1054,6 +1062,8 @@ def _worker_setup(self, b, compute, times, infolists, **kwargs):
vxs, vys, vzs = [np.zeros(len(times))], [np.zeros(len(times))], [np.zeros(len(times))]
xs, ys, zs = [np.zeros(len(times))], [np.zeros(len(times))], [np.full(len(times), vgamma)]
ethetas, elongans, eincls = [np.zeros(len(times))], [np.full(len(times), long_an)], [np.full(len(times), incl)]
inst_ds = None
inst_Fs = None

for i,t in enumerate(times):
zs[0][i] = vgamma*(t-t0)
Expand All @@ -1065,7 +1075,8 @@ def _worker_setup(self, b, compute, times, infolists, **kwargs):
dynamics_method=dynamics_method,
ts=ts, xs=xs, ys=ys, zs=zs,
vxs=vxs, vys=vys, vzs=vzs,
ethetas=ethetas, elongans=elongans, eincls=eincls)
ethetas=ethetas, elongans=elongans, eincls=eincls,
inst_ds=inst_ds, inst_Fs=inst_Fs)

def _run_single_time(self, b, i, time, infolist, **kwargs):
logger.debug("rank:{}/{} PhoebeBackend._run_single_time(i={}, time={}, infolist={}, **kwargs.keys={})".format(mpi.myrank, mpi.nprocs, i, time, infolist, kwargs.keys()))
Expand Down Expand Up @@ -1096,10 +1107,12 @@ def _run_single_time(self, b, i, time, infolist, **kwargs):
if True in [info['needs_mesh'] for info in infolist]:

if dynamics_method in ['nbody', 'rebound']:
di = dynamics.at_i(inst_ds, i)
Fi = dynamics.at_i(inst_Fs, i)
# by passing these along to update_positions, volume conservation will
# handle remeshing the stars
inst_ds = kwargs.get('inst_ds')
inst_Fs = kwargs.get('inst_Fs')
di = dynamics.at_i(inst_ds, i)
Fi = dynamics.at_i(inst_Fs, i)
else:
# then allow d to be determined from orbit and original sma
# and F to remain fixed
Expand Down
1 change: 1 addition & 0 deletions phoebe/dynamics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

from . import nbody as nbody
from . import keplerian as keplerian
from . import xyz as xyz
from phoebe import u


Expand Down
134 changes: 134 additions & 0 deletions phoebe/dynamics/coord.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@

from numpy import zeros

def coord_j2b(mass, rj, vj):
"""
Converts from Jacobi to barycentric coordinates.

Rewritten from swift/coord/coord_j2b.f.

Reference: Levison, H.F., Duncan, M.J., The long-term dynamical behavior of short-period comets. Icarus 108, 18-36, 1994.

"""

nbod = len(mass)
eta = zeros((nbod))
rb = zeros((nbod, 3))
vb = zeros((nbod, 3))

# First compute auxiliary variables, then the barycentric positions
eta[0] = mass[0]
for i in range(1,nbod):
eta[i] = eta[i-1] + mass[i]

i = nbod-1
mtot = eta[i]
rb[i] = eta[i-1]*rj[i]/mtot
vb[i] = eta[i-1]*vj[i]/mtot

capr = mass[i]*rj[i]/mtot
capv = mass[i]*vj[i]/mtot

for i in range(nbod-2,0,-1):
rat = eta[i-1]/eta[i]
rb[i] = rat*rj[i] - capr
vb[i] = rat*vj[i] - capv

rat2 = mass[i]/eta[i]
capr += rat2*rj[i]
capv += rat2*vj[i]

# Now compute the Sun's barycentric position
rtmp = zeros((3))
vtmp = zeros((3))

for i in range(1,nbod):
rtmp += mass[i]*rb[i]
vtmp += mass[i]*vb[i]

rb[0] = -rtmp/mass[0]
vb[0] = -vtmp/mass[0]

return rb, vb


def coord_b2j(mass, rb, vb):
"""
Converts from barycentric to Jacobi coordinates.

Rewritten from swift/coord/coord_b2j.f.

Reference: Levison, H.F., Duncan, M.J., The long-term dynamical behavior of short-period comets. Icarus 108, 18-36, 1994.

"""

nbod = len(mass)
eta = zeros((nbod))
rj = zeros((nbod, 3))
vj = zeros((nbod, 3))

# First compute auxiliary variables, then the Jacobi positions
eta[0] = mass[0]
for i in range(1,nbod):
eta[i] = eta[i-1] + mass[i]

sumr = mass[0]*rb[0]
sumv = mass[0]*vb[0]
capr = rb[0]
capv = vb[0]

for i in range(1, nbod-1):
rj[i] = rb[i] - capr
vj[i] = vb[i] - capv

sumr += mass[i]*rb[i]
sumv += mass[i]*vb[i]
capr = sumr/eta[i]
capv = sumv/eta[i]

rj[nbod-1] = rb[nbod-1] - capr
vj[nbod-1] = vb[nbod-1] - capv

return rj, vj


def coord_h2j(mass, rh, vh):
"""
Converts from heliocentric to Jacobi coordinates.

Rewritten from swift/coord/coord_h2j.f.

Reference: Levison, H.F., Duncan, M.J., The long-term dynamical behavior of short-period comets. Icarus 108, 18-36, 1994.

"""

nbod = len(mass)
eta = zeros((nbod))
rj = zeros((nbod, 3))
vj = zeros((nbod, 3))

eta[0] = mass[0]
for i in range(1,nbod):
eta[i] = eta[i-1] + mass[i]

rj[1] = rh[1]
vj[1] = vh[1]

sumr = mass[1]*rh[1]
sumv = mass[1]*vh[1]
capr = sumr/eta[1]
capv = sumv/eta[1]

for i in range(2,nbod):
rj[i] = rh[i] - capr
vj[i] = vh[i] - capv

if i < nbod-1:
sumr += mass[i]*rh[i]
sumv += mass[i]*vh[i]
capr = sumr/eta[i]
capv = sumv/eta[i]

return rj, vj


Loading
Loading