16 std::cout << std::setw(25) <<
"phase" 17 << std::setw(25) <<
"x" 18 << std::setw(25) <<
"y" 19 << std::setw(25) <<
"z" 21 for(
double phase = 0.0; phase < 4.0 * M_PI; phase += 0.001 * M_PI) {
23 std::cout << std::setw(25) << phase
24 << std::setw(25) << secondary_position[0]
25 << std::setw(25) << secondary_position[1]
26 << std::setw(25) << secondary_position[2]
33 double secondary_mass,
37 double arg_of_periapsis,
38 const Eigen::Vector3d &position,
54 approx_potential.set_eccentricity_order(e_order);
58 std::ostringstream Uexact_label, Uapprox_label;
59 Uexact_label <<
"Uexact(" 60 <<
"x=" << position[0]
61 <<
", y=" << position[1]
62 <<
", z=" << position[2]
64 Uapprox_label <<
"Uapprox(" 65 <<
"x=" << position[0]
66 <<
", y=" << position[1]
67 <<
", z=" << position[2]
69 std::cout << std::setw(35) <<
"time/Porb" 70 << std::setw(35) << Uexact_label.str()
71 << std::setw(35) << Uapprox_label.str()
75 time < 5.0 * orbital_period;
76 time += 0.01 * orbital_period
78 std::cout << std::setw(35) << time/orbital_period
79 << std::setw(35) << exact_potential(position, time)
80 << std::setw(35) << approx_potential(position, time)
87 const Eigen::Vector3d &position,
91 const double safety = 1.1;
119 const Eigen::Vector3d &position
124 exact_potential.
orbit());
126 std::ostringstream message_start;
131 <<
"; inclination = " << exact_potential.
inclination()
133 <<
"; U(x = " << position[0]
134 <<
", y = " << position[1]
135 <<
", z = " << position[2];
139 time < 5.0 * orbital_period;
140 time += 0.03 * M_PI * orbital_period
142 double expected = exact_potential(position, time);
143 double got = approx_potential(position, time);
145 std::ostringstream message;
146 message << message_start.str()
148 <<
" = " << time / orbital_period
149 <<
" Porb): expected " << expected
151 <<
"; difference " << got - expected
152 <<
" > " << abs_tolerance;
159 message.str().c_str()
166 double secondary_mass,
170 double arg_of_periapsis,
186 approx_potential.set_eccentricity_order(e_order);
188 double test_offsets[]= {-0.01, -0.001, 0.0, 0.001, 0.01};
189 unsigned num_offsets =
sizeof(test_offsets) /
sizeof(
double);
190 for(
unsigned z_index = 0; z_index < num_offsets; ++z_index)
191 for(
unsigned y_index = 0; y_index < num_offsets; ++y_index)
192 for(
unsigned x_index = 0; x_index < num_offsets; ++x_index) {
195 Eigen::Vector3d(test_offsets[x_index],
196 test_offsets[y_index],
197 test_offsets[z_index]));
203 double test_angles[] = {-M_PI/2, -1.0, -0.1, 0.0, 0.1, 1.0, M_PI/2};
204 unsigned num_angles =
sizeof(test_angles) /
sizeof(
double);
210 unsigned e_order = 0;
211 if(e > 0.05) e_order = 10;
212 if(e > 0.25) e_order = 20;
213 if(e > 0.45) e_order = 35;
214 std::cout <<
"Eccentricity : " << e << std::endl;
217 unsigned inclination_i = 0;
218 inclination_i < num_angles;
222 unsigned periapsis_i = 0;
223 periapsis_i < num_angles;
230 test_angles[inclination_i],
231 2.0 * test_angles[periapsis_i],
Basic description of two bodies in an eccentric orbit.
void test_single_point(TidalPotentialExpansion &approx_potential, const TidalPotential &exact_potential, const Eigen::Vector3d &position)
Test the expansion for a given system at a given position, sampling time.
test_GravitationalPotential()
Create the test suite.
Unit tests that check the expansion of the gravitational potential vs. analytic expressions.
void print_tidal_potential(double primary_mass, double secondary_mass, double semimajor, double eccentricity, double inclination, double arg_of_periapsis, const Eigen::Vector3d &position, unsigned e_order) const
Print to stdout the value of the tidal potential without an approximation and using the expansion as ...
double inclination() const
See __inclination attribute.
void test_expansion()
Test the expansion of the potential for multiple system configurations, locations and times...
Evaluate the tidal potential using the expansion.
double arg_of_periapsis() const
The argument of periapsis of the system.
double eccentricity() const
The semimajor axis of the system.
double semimajor() const
The semimajor axis of the system.
Orientations of zones of bodies in a binary system.
double abs_expected_precision(const Eigen::Vector3d &position, const EccentricOrbit &orbit) const
const double solar_radius
Radius of the sun [m].
double primary_mass() const
The semimajor axis of the system.
void test_system(double primary_mass, double secondary_mass, double semimajor, double eccentricity, double inclination, double arg_of_periapsis, unsigned e_order=0)
Test the expansion for a given system, sampling positions and times.
bool check_diff(double x, double y, double frac_tolerance, double abs_tolerance)
Returns true iff .
const double solar_mass
Mass of the sun [kg].
Calculate the tidal potential over one component of an eccentric binary.
const EccentricOrbit & orbit() const
An unmutable reference to the binary orbit.
void print_orbit(const EccentricOrbit &orbit) const
Print to stdout the location of the secondary relative to the primary as a function of time for the g...
double orbital_period() const
The orbital period of the system in days.
Eigen::Vector3d secondary_position(double orbital_phase) const
Secondary position vector in a coordinate system centered on the primary, with and ...
double secondary_mass() const
The semimajor axis of the system.
const double G
Gravitational constant in SI.