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 
12  EccentricityExpansionCoefficients TidalPotentialTerms::__pms;
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  __e_order(0),
111  __Ummp_inclination(Core::NaN),
112  __Ummp(5),
113  __Ummp_deriv(5)
114  {
115  for(int i = 0; i < 5; ++i) {
116  __Ummp[i].resize(3);
117  __Ummp_deriv[i].resize(3);
118  }
119  }
120 
122  double e,
123  int m,
124  int mp,
125  std::complex<double> &no_deriv,
126  std::complex<double> &inclination_deriv,
127  std::complex<double> &eccentricity_deriv,
128  std::complex<double> &highest_e_order_term
129  ) const
130  {
131  no_deriv = inclination_deriv = eccentricity_deriv = 0;
132  for(int i = 0; i < 3; ++i) {
133  int s = 2 * (i - 1);
134  std::pair<double, double> pms = __pms(s, mp, e, __e_order, false);
135  std::complex<double> periapsis_factor(
136  std::cos(s * __arg_of_periapsis),
137  -std::sin(s * __arg_of_periapsis)
138  );
139  no_deriv += pms.first * __Ummp[m+2][i] * periapsis_factor;
140  inclination_deriv += (pms.first
141  *
142  __Ummp_deriv[m+2][i]
143  *
144  periapsis_factor);
145  eccentricity_deriv += (
146  __pms(s, mp, e, __e_order, true).first
147  *
148  __Ummp[m+2][i]
149  *
150  periapsis_factor
151  );
152  highest_e_order_term += (pms.second
153  *
154  __Ummp[m+2][i]
155  *
156  periapsis_factor);
157  assert(!std::isnan(no_deriv.real()));
158  assert(!std::isnan(inclination_deriv.real()));
159  assert(!std::isnan(eccentricity_deriv.real()));
160  assert(!std::isnan(highest_e_order_term.real()));
161  }
162  }
163 
165  int m,
166  int mp,
167  double &no_deriv,
168  double &inclination_deriv,
169  double &eccentricity_deriv,
170  double &highest_e_order_term) const
171  {
172  std::complex<double> complex_no_deriv,
173  complex_inclination_deriv,
174  complex_eccentricity_deriv,
175  complex_highest_e_order_term;
176  operator()(e,
177  m,
178  mp,
179  complex_no_deriv,
180  complex_inclination_deriv,
181  complex_eccentricity_deriv,
182  complex_highest_e_order_term);
183  no_deriv = complex_no_deriv.real();
184  inclination_deriv = complex_inclination_deriv.real();
185  eccentricity_deriv = complex_eccentricity_deriv.real();
186  highest_e_order_term = complex_highest_e_order_term.real();
187  }
188 } //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.
void operator()(double e, int m, int mp, std::complex< double > &no_deriv, std::complex< double > &inclination_deriv, std::complex< double > &eccentricity_deriv, std::complex< double > &highest_e_order_term) const
Calculates (see documentation) and its derivatives w.r.t. e and .
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.
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.
unsigned __e_order
The expansion order in eccentricity to use.