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) {
22 Eigen::Matrix<long double, 3, 1> secondary_position =
24 std::cout << std::setw(25) << phase
25 << std::setw(25) << secondary_position[0]
26 << std::setw(25) << secondary_position[1]
27 << std::setw(25) << secondary_position[2]
34 double secondary_mass,
38 double arg_of_periapsis,
39 const Eigen::Matrix<long double, 3, 1> &position,
40 unsigned expansion_order
57 std::ostringstream Uexact_label, Uapprox_label;
58 Uexact_label <<
"Uexact(" 59 <<
"x=" << position[0]
60 <<
", y=" << position[1]
61 <<
", z=" << position[2]
63 Uapprox_label <<
"Uapprox(" 64 <<
"x=" << position[0]
65 <<
", y=" << position[1]
66 <<
", z=" << position[2]
68 std::cout << std::setw(35) <<
"time/Porb" 69 << std::setw(35) << Uexact_label.str()
70 << std::setw(35) << Uapprox_label.str()
74 time < 5.0 * orbital_period;
75 time += 0.01 * orbital_period
77 std::cout << std::setw(35) << time/orbital_period
78 << std::setw(35) << exact_potential(position, time)
79 << std::setw(35) << approx_potential(position,
88 const Eigen::Matrix<long double, 3, 1> &position,
90 double expansion_precision
93 const double safety = 3.0;
95 double scaled_distance = (
114 std::pow(scaled_distance, 2)
116 (safety * scaled_distance + expansion_precision)
123 const Eigen::Matrix<long double, 3, 1> &position
129 exact_potential.
orbit(),
134 unsigned expansion_order =
137 std::ostringstream message_start;
138 message_start.setf(std::ios_base::scientific);
139 message_start.precision(16);
143 <<
"; e = " << eccentricity
144 <<
"; inclination = " << exact_potential.
inclination()
146 <<
"; U(x = " << position[0]
147 <<
", y = " << position[1]
148 <<
", z = " << position[2];
152 time < 5.0 * orbital_period;
153 time += 0.03 * M_PI * orbital_period
155 double expected = exact_potential(position, time);
156 double got = approx_potential(position, time, expansion_order);
158 std::ostringstream message;
159 message.precision(16);
160 message.setf(std::ios_base::scientific);
161 message << message_start.str()
163 <<
" = " << time / orbital_period
164 <<
" Porb): expected " << expected
166 <<
"; difference " << got - expected
167 <<
" > " << abs_tolerance;
170 std::cerr << message.str() << std::endl;
178 message.str().c_str()
185 double secondary_mass,
189 double arg_of_periapsis
205 long double test_offsets[]= {-0.01,
212 unsigned num_offsets =
sizeof(test_offsets) /
sizeof(
long double);
213 typedef long double ldbl;
214 for(
unsigned z_index = 0; z_index < num_offsets; ++z_index)
215 for(
unsigned y_index = 0; y_index < num_offsets; ++y_index)
216 for(
unsigned x_index = 0; x_index < num_offsets; ++x_index) {
220 Eigen::Matrix<ldbl, 3, 1> (test_offsets[x_index],
221 test_offsets[y_index],
222 test_offsets[z_index])
229 double test_angles[] = {-M_PI/2, -1.0, -0.1, 0.0, 0.1, 1.0, M_PI/2};
230 unsigned num_angles =
sizeof(test_angles) /
sizeof(
double);
236 std::cout <<
"Eccentricity : " << e << std::endl;
239 unsigned inclination_i = 0;
240 inclination_i < num_angles;
244 unsigned periapsis_i = 0;
245 periapsis_i < num_angles;
252 test_angles[inclination_i],
253 2.0 * test_angles[periapsis_i]);
double get_expansion_precision() const
Return the expansion precision target for the expansion terms.
Basic description of two bodies in an eccentric orbit.
test_GravitationalPotential()
Create the test suite.
Unit tests that check the expansion of the gravitational potential vs. analytic expressions.
double inclination() const
See __inclination attribute.
void test_expansion()
Test the expansion of the potential for multiple system configurations, locations and times...
void print_tidal_potential(double primary_mass, double secondary_mass, double semimajor, double eccentricity, double inclination, double arg_of_periapsis, const Eigen::Matrix< long double, 3, 1 > &position, unsigned expansion_order) const
Print to stdout the value of the tidal potential without an approximation and using the expansion as ...
void test_system(double primary_mass, double secondary_mass, double semimajor, double eccentricity, double inclination, double arg_of_periapsis)
Test the expansion for a given system, sampling positions 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.
const double solar_radius
Radius of the sun [m].
void test_single_point(TidalPotentialExpansion &approx_potential, const TidalPotential &exact_potential, const Eigen::Matrix< long double, 3, 1 > &position)
Test the expansion for a given system at a given position, sampling time.
double abs_precision(const Eigen::Matrix< long double, 3, 1 > &position, const EccentricOrbit &orbit, double expansion_precision) const
double primary_mass() const
The semimajor axis of the system.
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].
static unsigned required_expansion_order(double e)
The maximum orbital frequency multiplier to include in the potential Fourier expansion in order to ac...
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...
Eigen::Matrix< long double, 3, 1 > secondary_position(double orbital_phase) const
Secondary position vector in a coordinate system centered on the primary, with and ...
double orbital_period() const
The orbital period of the system in days.
double secondary_mass() const
The semimajor axis of the system.
const double G
Gravitational constant in SI.