1 #define BUILDING_LIBRARY 10 assert(std::abs(msign) < 2);
12 return (epower - s + 2 * std::min(msign, s - msign)) / 2;
22 std::pair<double, double> result(0.0, 0.0);
24 double e2 = std::pow(e, 2);
25 int min_n = std::max(1, -s - 1),
27 e_pow_ind = s + 2 * min_n - (deriv ? 1 : 0);
28 assert(e_pow_ind + (deriv ? 1 : 0) >= 0);
29 double e_pow = (e_pow_ind < 0 ? 0.0 : std::pow(e, e_pow_ind)),
30 coef = (deriv ? s + 2 * min_n : 1);
41 result.first += result.second;
55 std::pair<double, double> result(0.0, 0.0);
57 double e2 = std::pow(e, 2);
58 int min_n = std::max(0, -s),
60 e_pow_ind = s + 2 * min_n - (deriv ? 1 : 0);
61 assert(e_pow_ind + (deriv ? 1 : 0) >= 0);
62 double e_pow = (e_pow_ind < 0 ? 0.0 : std::pow(e, e_pow_ind)),
63 coef = (deriv ? s + 2 * min_n : 1);
69 result.second = coef *
__alpha[alpha_ind1][alpha_ind2] * e_pow;
70 result.first += result.second;
84 std::pair<double, double> result(0.0, 0.0);
86 double e2 = std::pow(e, 2);
87 int min_n = std::max(-1, -s + 1),
89 e_pow_ind = s + 2 * min_n - (deriv ? 1 : 0);
90 assert(e_pow_ind + (deriv ? 1 : 0) >= 0);
91 double e_pow = (e_pow_ind < 0 ? 0.0 : std::pow(e, e_pow_ind)),
92 coef = (deriv ? s + 2 * min_n : 1);
98 result.second = coef *
__gamma_plus[gamma_ind1][gamma_ind2] * e_pow;
99 result.first += result.second;
107 const std::string &tabulated_pms_fname,
111 std::ifstream tabulated_coef(tabulated_pms_fname.c_str());
113 "Unable to open eccentricity expansion file: " 120 if(max_e_power >= 0) {
121 if(__max_e_power<static_cast<unsigned>(max_e_power)) {
122 std::ostringstream msg;
123 msg <<
"Eccentricity expansion file '" 124 << tabulated_pms_fname
125 <<
"' stops at lower eccentricity power (" 127 <<
") than requested (" 129 <<
") in EccentricityExpansionCoefficients::read()!";
135 __alpha.resize(2 * __max_e_power + 1);
144 for(
int s = -epower - 2; s <= epower-2; s += 2) {
146 assert(s + static_cast<int>(__max_e_power) + 2 >= 0);
150 if(destination.size() == 0)
151 destination.resize(
inner_index(-1, s, __max_e_power)
156 <static_cast<int>(destination.size()));
162 for(
int s = -epower; s <= epower; s += 2) {
163 assert(s + static_cast<int>(__max_e_power) >= 0);
164 assert(s + __max_e_power <
__alpha.size());
166 if(destination.size() == 0)
167 destination.resize(
inner_index(0, s, __max_e_power) + 1);
170 <static_cast<int>(destination.size()));
171 tabulated_coef >> destination[
inner_index(0, s, epower)];
173 for(
int s = -epower + 2; s <= epower + 2; s += 2) {
175 assert(s + static_cast<int>(__max_e_power) - 2 >= 0);
179 if(destination.size() == 0)
180 destination.resize(
inner_index(1, s, __max_e_power)
185 <static_cast<int>(destination.size()));
186 tabulated_coef >> destination[
inner_index(1, s, epower)];
203 "Attempting to evaluate Pms before reading in eccentricity " 204 "expansion coefficients!" 207 std::pair<double, double> zero(0.0, 0.0);
210 s < -static_cast<int>(max_e_power) + m
212 s > static_cast<int>(max_e_power) + m
217 case -2 :
return (s == 0 ? zero :
p_m2s(e, s, max_e_power, deriv));
218 case 0 :
return p_0s(e, s, max_e_power, deriv);
219 case 2 :
return (s == 0 ? zero :
p_p2s(e, s, max_e_power, deriv));
221 "Asking for p_{m,s} with m other than +-2 and 0" Function arguments do not satisfy some requirement.
std::vector< std::vector< double > > __gamma_minus
The expansion coefficients of ( in the [documentation]{InclinationEccentricity_pms1}).
int inner_index(int msign, int s, int epower) const
The inner index in the __alpha/gamma_plus/gamma_minus arrays.
Declares a class which provides the [ coefficients]{InclinationEccentricity_pms1}.
void read(const std::string &tabulated_pms_fname="", int max_e_power=-1)
Reads in tabulated expansion coefficients, making this object useable.
Orientations of zones of bodies in a binary system.
bool __useable
Is the object ready to be used?
std::pair< double, double > p_0s(double e, int s, unsigned max_e_power, bool deriv) const
std::vector< std::vector< double > > __gamma_plus
The expansion coefficients of ( in the [documentation]{InclinationEccentricity_pms1}).
unsigned __max_e_power
Maximum eccentricity power with all necessary coefficients known.
std::pair< double, double > operator()(int m, int s, double e, unsigned max_e_power, bool deriv) const
Taylor series approximation of and the contribution of the highest power eccentricity terms...
unsigned max_e_power() const
Maximum eccentricity power with all necessary coefficients known.
std::vector< std::vector< double > > __alpha
The expansion coefficients of ( along with the s factior in the [documentation]{InclinationEccentri...
std::pair< double, double > p_p2s(double e, int s, unsigned max_e_power, bool deriv) const
std::pair< double, double > p_m2s(double e, int s, unsigned max_e_power, bool deriv) const