Skip to content

Commit

Permalink
Calculates pericenter passage time for particles not in a simulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Aug 26, 2024
1 parent a7efb21 commit 1cf7d63
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,12 +1166,11 @@ struct reb_orbit reb_orbit_from_particle_err(double G, struct reb_particle p, st
}
}

if (p.sim == NULL){ // if particle isn't in simulation yet, can't get time. You can still manually apply the equation below using o.M and o.n
o.T = nan("");
}
else{
o.T = p.sim->t - o.M/fabs(o.n); // time of pericenter passage (M = n(t-T). Works for hyperbolic with fabs and n defined as above).
double t0 = 0.0;
if (p.sim != NULL){ // if particle isn't in simulation yet, can't get time.
t0 = p.sim->t;
}
o.T = t0 - o.M/fabs(o.n); // time of pericenter passage (M = n(t-T). Works for hyperbolic orbits using fabs and n as defined above).

// move some of the angles into [0,2pi) range
o.f = reb_mod2pi(o.f);
Expand Down

0 comments on commit 1cf7d63

Please sign in to comment.