10 double eccentric_anomaly_equation(
double eccentric_anomaly,
11 void *orbital_phase_eccentricity)
13 double orbital_phase =
reinterpret_cast<double*
>(
14 orbital_phase_eccentricity
16 double eccentricity =
reinterpret_cast<double*
>(
17 orbital_phase_eccentricity
19 return (eccentric_anomaly
21 eccentricity * std::sin(eccentric_anomaly)
38 const gsl_root_fsolver_type *FsolverType;
39 gsl_root_fsolver *solver;
41 double lower_bound = 0.0, upper_bound = 2.0 * M_PI;
42 gsl_function Function;
43 orbital_phase -= 2.0 * M_PI * std::floor(orbital_phase / (2.0 * M_PI));
46 Function.function = &eccentric_anomaly_equation;
47 Function.params = params;
49 FsolverType = gsl_root_fsolver_brent;
50 solver = gsl_root_fsolver_alloc (FsolverType);
51 gsl_root_fsolver_set(solver, &Function, lower_bound, upper_bound);
54 std::cerr << std::setw(25) <<
"Iteartion" 55 << std::setw(25) <<
"LowerBound" 56 << std::setw(25) <<
"root" 57 << std::setw(25) <<
"UpperBound" 61 int status = GSL_CONTINUE;
62 for(
unsigned iter = 0; status == GSL_CONTINUE; ++iter) {
63 status = gsl_root_fsolver_iterate(solver);
64 root = gsl_root_fsolver_root(solver);
65 lower_bound = gsl_root_fsolver_x_lower(solver);
66 upper_bound = gsl_root_fsolver_x_upper(solver);
67 status = gsl_root_test_interval(lower_bound,
72 std::cerr << std::setw(25) << iter
73 << std::setw(25) << lower_bound
74 << std::setw(25) << root
75 << std::setw(25) << upper_bound
80 gsl_root_fsolver_free(solver);
82 assert(status == GSL_SUCCESS);
92 return Eigen::Vector3d(
98 std::sin(current_eccentric_anomaly)),
double reduced_mass() const
The reduced mass of the system in solar masses.
Orientations of zones of bodies in a binary system.
double orbital_energy() const
The magnitude of the orbital energy of the system in .
double __eccentricity
The eccentricity of the orbit.
const double solar_radius
Radius of the sun [m].
double eccentric_anomaly(double orbital_phase) const
double __primary_mass
The mass of the tidally perturbed object in solar masses.
double orbital_angmom() const
The magnitude of the orbital angular momentum of the system in .
const double solar_mass
Mass of the sun [kg].
double __secondary_mass
The mass of the perturber object in solar masses.
double orbital_period() const
The orbital period of the system in days.
Declare an interface for working with eccentric orbits.
Eigen::Vector3d secondary_position(double orbital_phase) const
Secondary position vector in a coordinate system centered on the primary, with and ...
const double G
Gravitational constant in SI.
double __semimajor
The semimajor axis of the orbit in solar radii.