Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
TidalPotentialTerms.cpp
Go to the documentation of this file.
1 
8 #include "TidalPotentialTerms.h"
9 
10 namespace Evolve {
11 
13 
14  const double TidalPotentialTerms::__Umm_coef[][3]={
15  {
16  std::sqrt(3.0 * M_PI / 10.0) / 4.0,
17  -std::sqrt(6.0 * M_PI / 5.0) / 4.0,
18  std::sqrt(3.0 * M_PI / 10.0) / 4.0
19  },
20  {
21  -std::sqrt(3.0 * M_PI / 10.0) / 2.0,
22  -std::sqrt(6.0 * M_PI / 5.0) / 2.0,
23  std::sqrt(3.0 * M_PI / 10.0) / 2.0
24  },
25  {
26  3.0 * std::sqrt(M_PI / 5.0) / 4.0,
27  -std::sqrt(M_PI / 5.0) / 2.0,
28  3.0 * std::sqrt(M_PI / 5.0) / 4.0
29  },
30  {
31  -std::sqrt(3.0 * M_PI / 10.0) / 2.0,
32  std::sqrt(6.0 * M_PI / 5.0) / 2.0,
33  std::sqrt(3.0 * M_PI / 10.0) / 2.0
34  },
35  {
36  std::sqrt(3.0 * M_PI / 10.0) / 4.0,
37  -std::sqrt(6.0 * M_PI / 5.0) / 4.0,
38  std::sqrt(3.0 * M_PI / 10.0) / 4.0
39  }
40  };
41 
42  void TidalPotentialTerms::configure(double inclination,
43  double arg_of_periapsis)
44  {
45  __arg_of_periapsis = arg_of_periapsis;
46 
47  if(__Ummp_inclination == inclination)
48  return;
49 
50  __Ummp_inclination = inclination;
51 
52  double c = std::cos(__Ummp_inclination),
53  s = std::sin(__Ummp_inclination),
54  s2 = std::pow(s, 2),
55  sc = s * c,
56  cp1 = c + 1.0,
57  cm1 = c - 1.0;
58 
59  __Ummp[0][0] = __Umm_coef[0][0] * std::pow(cp1, 2);
60  __Ummp_deriv[0][0] = -__Umm_coef[0][0] * 2.0 * s * cp1;
61 
62  __Ummp[1][0] = __Umm_coef[1][0] * s * cp1;
63  __Ummp_deriv[1][0] = __Umm_coef[1][0] * (cp1 + 2.0 * s2);
64 
65  __Ummp[2][0] = __Umm_coef[2][0] * s2;
66  __Ummp_deriv[2][0] = __Umm_coef[2][0] * 2.0 * sc;
67 
68  __Ummp[3][0] = -__Umm_coef[3][0] * s * cm1;
69  __Ummp_deriv[3][0] = -__Umm_coef[3][0] * (c * cm1 - s2);
70 
71  __Ummp[4][0] = __Umm_coef[4][0] * std::pow(cm1, 2);
72  __Ummp_deriv[4][0] = -__Umm_coef[4][0] * 2.0 * s * cm1;
73 
74 
75 
76  __Ummp[0][1] = __Umm_coef[0][1] * s2;
77  __Ummp_deriv[0][1] = __Umm_coef[0][1] * 2.0 * sc;
78 
79  __Ummp[1][1] = __Umm_coef[1][1] * sc;
80  __Ummp_deriv[1][1] = __Umm_coef[1][1] * (1.0 - 2.0 * s2);
81 
82  __Ummp[2][1] = __Umm_coef[2][1] * (2.0 - 3.0 * s2);
83  __Ummp_deriv[2][1] = -__Umm_coef[2][1] * 6.0 * sc;
84 
85  __Ummp[3][1] = __Umm_coef[3][1] * sc;
86  __Ummp_deriv[3][1] = __Umm_coef[3][1] * (1.0 - 2.0 * s2);
87 
88  __Ummp[4][1] = __Umm_coef[4][1] * s2;
89  __Ummp_deriv[4][1] = __Umm_coef[4][1] * 2.0 * sc;
90 
91 
92 
93  __Ummp[0][2] = __Umm_coef[0][2] * std::pow(cm1, 2);
94  __Ummp_deriv[0][2] = -__Umm_coef[0][2] * 2.0 * cm1 * s;
95 
96  __Ummp[1][2] = -__Umm_coef[1][2] * s * cm1;
97  __Ummp_deriv[1][2] = -__Umm_coef[1][2] * (c * cm1 - s2);
98 
99  __Ummp[2][2] = __Umm_coef[2][2] * s2;
100  __Ummp_deriv[2][2] = __Umm_coef[2][2] * 2.0 * sc;
101 
102  __Ummp[3][2] = __Umm_coef[3][2] * s * cp1;
103  __Ummp_deriv[3][2] = __Umm_coef[3][2] * (c * cp1 - s2);
104 
105  __Ummp[4][2] = __Umm_coef[4][2] * std::pow(cp1, 2);
106  __Ummp_deriv[4][2] = -__Umm_coef[4][2] * 2.0 * cp1 * s;
107  }
108 
109  TidalPotentialTerms::TidalPotentialTerms() :
110  __Ummp_inclination(Core::NaN),
111  __Ummp(5),
112  __Ummp_deriv(5)
113  {
114  for(int i = 0; i < 5; ++i) {
115  __Ummp[i].resize(3);
116  __Ummp_deriv[i].resize(3);
117  }
118  }
119 
121  int max_mp
122  )
123  {
124  std::pair<double, double> result(Core::Inf, Core::Inf);
125  for(int m=-2; m<=2; m+=2) {
126 
127  std::pair<double, double> m_range = __pms.get_expansion_range(
128  m,
129  max_mp
130  );
131  result.first = std::min(result.first, m_range.first);
132  result.second = std::min(result.second, m_range.second);
133  }
134  return result;
135  }
136 
138  double e,
139  int m,
140  int mp,
141  std::complex<double> &no_deriv,
142  std::complex<double> &inclination_deriv,
143  std::complex<double> &eccentricity_deriv
144  ) const
145  {
146  no_deriv = inclination_deriv = eccentricity_deriv = 0;
147  double singularity_factor = std::pow(1.0 - e*e, -1.5);
148  for(int i = 0; i < 3; ++i) {
149  int s = 2 * (i - 1);
150  double pms = __pms(s, mp, e, false) * singularity_factor;
151  std::complex<double> periapsis_factor(
152  std::cos(s * __arg_of_periapsis),
153  -std::sin(s * __arg_of_periapsis)
154  );
155  no_deriv += pms * __Ummp[m+2][i] * periapsis_factor;
156  inclination_deriv += (pms
157  *
158  __Ummp_deriv[m+2][i]
159  *
160  periapsis_factor);
161  eccentricity_deriv += (
162  __pms(s, mp, e, true)
163  *
164  __Ummp[m+2][i]
165  *
166  periapsis_factor
167  );
168  assert(!std::isnan(no_deriv.real()));
169  assert(!std::isnan(inclination_deriv.real()));
170 // assert(!std::isnan(eccentricity_deriv.real()));
171  }
172  }
173 
175  double e,
176  int m,
177  int mp,
178  double &no_deriv,
179  double &inclination_deriv,
180  double &eccentricity_deriv
181  ) const
182  {
183  std::complex<double> complex_no_deriv,
184  complex_inclination_deriv,
185  complex_eccentricity_deriv;
186  operator()(e,
187  m,
188  mp,
189  complex_no_deriv,
190  complex_inclination_deriv,
191  complex_eccentricity_deriv);
192  no_deriv = complex_no_deriv.real();
193  inclination_deriv = complex_inclination_deriv.real();
194  eccentricity_deriv = complex_eccentricity_deriv.real();
195  }
196 } //End Evolve namespace.
std::valarray< std::valarray< double > > __Ummp
The quantities defined in Lai (2012).
double __Ummp_inclination
The inclination with which __Ummp was last filled.
double __arg_of_periapsis
The argument of periaspsis set by the last call to configure().
static EccentricityExpansionCoefficients __pms
The eccentricity expansion of .
Orientations of zones of bodies in a binary system.
void configure(double inclination, double arg_of_periapsis=0)
Set the inclination relative to the orbit.
Declare an interface for evaluating the expansion of the tidal potential.
struct LIB_PUBLIC EccentricityExpansionCoefficients
Opaque struct to cast to/from Evolve::EccentricityExpansionCoefficients.
Definition: CInterface.h:44
static const double __Umm_coef[][3]
The constant coefficiients in of Lai (2012).
std::valarray< std::valarray< double > > __Ummp_deriv
The derivatives of the quantities w.r.t. the inclination.
static std::pair< double, double > get_expansion_range(int max_mp)
Return the range of eccentricities (min, max) over which an expansion going up to given max m&#39; is val...
void operator()(double e, int m, int mp, std::complex< double > &no_deriv, std::complex< double > &inclination_deriv, std::complex< double > &eccentricity_deriv) const
Calculates (see documentation) and its derivatives w.r.t. e and .
std::pair< double, double > get_expansion_range(int m, int max_s) const
Return the range of eccentricities (min, max) over which an expansion going up to given max s is vali...