Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
ExponentialDecayDiffRotBody.cpp
Go to the documentation of this file.
1 
8 #define BUILDING_LIBRARY
10 
11 namespace Star {
12 
14  {
15  if(__torque.size()!=number_zones()-1)
16  __torque.resize(number_zones()-1);
17  for(unsigned i=0; i<number_zones()-1; ++i)
18  __torque[i].resize(11, Eigen::Vector3d(Core::NaN,
19  Core::NaN,
20  Core::NaN));
21  }
22 
24  unsigned top_zone_index,
25  Evolve::Dissipation::QuantityEntry entry,
26  bool with_respect_to_top
27  ) const
28  {
29  assert(entry != Evolve::Dissipation::EXPANSION_ERROR);
31  assert(entry != Evolve::Dissipation::ECCENTRICITY);
32  assert(entry != Evolve::Dissipation::SEMIMAJOR);
33  assert(top_zone_index < number_zones()-1);
34 
35  std::valarray<Eigen::Vector3d> &zone_torque=__torque[top_zone_index];
36  switch(entry) {
38  return zone_torque[0];
40  return zone_torque[(with_respect_to_top ? 1 : 2)];
42  return zone_torque[(with_respect_to_top ? 3 : 4)];
44  return zone_torque[(with_respect_to_top ? 5 : 6)];
46  return zone_torque[(with_respect_to_top ? 7 : 8)];
48  return zone_torque[(with_respect_to_top ? 9 : 10)];
49  default:
51  "Unsupported entry in "
52  "ExponentialDecayDiffRotBody::torque_entry"
53  );
54  }
55  }
56 
58  double age,
59  double companion_mass,
60  double semimajor,
61  double eccentricity,
62  const double *spin_angmom,
63  const double *inclination,
64  const double *periapsis,
65  bool locked_surface,
66  bool zero_outer_inclination,
67  bool zero_outer_periapsis)
68  {
69  if(age!=__current_age) {
70  __current_age=age;
71  reset_torque();
72  }
74  age,
75  companion_mass,
76  semimajor,
77  eccentricity,
78  spin_angmom,
79  inclination,
80  periapsis,
81  locked_surface,
82  zero_outer_inclination,
83  zero_outer_periapsis);
84  }
85 
87  unsigned top_zone_index,
88  Evolve::Dissipation::QuantityEntry entry,
89  bool with_respect_to_top
90  ) const
91  {
92  assert(top_zone_index<number_zones()-1);
93 
94  if(
98  || entry == Evolve::Dissipation::AGE
99  || entry == Evolve::Dissipation::RADIUS
101  )
102  return Eigen::Vector3d(0, 0, 0);
103  Eigen::Vector3d &result=torque_entry(top_zone_index,
104  entry,
105  with_respect_to_top);
106  if(!std::isnan(result[0])) return result;
107  const Evolve::DissipatingZone &zone1 = zone(top_zone_index),
108  &zone2 = zone(top_zone_index + 1);
109  double i1 = zone1.moment_of_inertia(),
110  i2 = zone2.moment_of_inertia();
111  if(i1 == 0 || i2 == 0) {
112  result.setZero();
113  return result;
114  }
115  if(
117  ||
119  )
120  result = zone_to_zone_transform(
121  zone2,
122  zone1,
123  Eigen::Vector3d(0, 0, zone2.spin_frequency()),
124  entry,
125  !with_respect_to_top
126  );
127  else if(
128  (
130  ||
132  )
133  &&
134  !with_respect_to_top
135  )
136  result = Eigen::Vector3d(
137  0,
138  0,
139  -(entry == Evolve::Dissipation::SPIN_ANGMOM ? 1.0 / i1 : 1.0)
140  );
141  else {
142  result = zone_to_zone_transform(zone2,
143  zone1,
144  Eigen::Vector3d(0, 0, 1));
145  if(entry == Evolve::Dissipation::SPIN_ANGMOM) result /= i2;
146  else if(entry != Evolve::Dissipation::SPIN_FREQUENCY)
147  result *= zone2.spin_frequency();
148  if(
150  ||
152  )
153  result[2] -= zone1.spin_frequency();
154  }
156  result *= i1 * i2;
157  else if(with_respect_to_top)
158  result *= i2 * (1 - i1 / (i1 + i2));
159  else result *= i1 * (1 - i2 / (i1 + i2));
160  result/=__timescale * (i1 + i2);
161  return result;
162  }
163 
164 }//End Star namespace.
std::valarray< std::valarray< Eigen::Vector3d > > __torque
The coupling torque and its nonzero entries.
Function arguments do not satisfy some requirement.
Definition: Error.h:73
RADIUS
The derivative w.r.t. the radius of the body in .
Declares a DissipatingBody with exponentially decaying differential rotation coupling.
SPIN_FREQUENCY
The derivative w.r.t. the spin frequency of a dissipating zone.
Eigen::Vector3d angular_momentum_coupling(unsigned top_zone_index, Evolve::Dissipation::QuantityEntry entry=Evolve::Dissipation::NO_DERIV, bool with_respect_to_top=false) const
See DissipatingBody::angular_momentum_coupling().
virtual const DissipatingZone & zone(unsigned zone_index) const =0
A modifiable reference to one of the body&#39;s zones.
SEMIMAJOR
The derivative w.r.t. the semimajor axis in AU.
MOMENT_OF_INERTIA
virtual double moment_of_inertia(int deriv_order=0) const =0
Moment of inertia of the zone or its age derivative at the age of last configure() call...
virtual void configure(bool initialize, double age, double companion_mass, double semimajor, double eccentricity, const double *spin_angmom, const double *inclination=NULL, const double *periapsis=NULL, bool locked_surface=false, bool zero_outer_inclination=false, bool zero_outer_periapsis=false)
Defines the orbit this body is in.
A layer of a system body for which the tidal bulge is not exactly in phase with the tidal potential...
void reset_torque()
Resets __torque to all undefined (correcting the size if necessary).
virtual void configure(bool initialize, double age, double companion_mass, double semimajor, double eccentricity, const double *spin_angmom, const double *inclination=NULL, const double *periapsis=NULL, bool locked_surface=false, bool zero_outer_inclination=false, bool zero_outer_periapsis=false)
See DissipatingBody::configure().
Eigen::Vector3d & torque_entry(unsigned top_zone_index, Evolve::Dissipation::QuantityEntry entry, bool wih_respect_to_top) const
Returns the entry in __torque that corresponds to the given quantity entry.
double __timescale
The timescale for the differential rotation torque.
ECCENTRICITY
The derivative w.r.t. the eccentricity.
AGE
The derivative w.r.t. age, excluding the dependence through the body&#39;s radius and the moments of iner...
double __current_age
The age for which the last conigure() was called.
NO_DERIV
The quantity itself, undifferentiated.
ORBITAL_FREQUENCY
The derivative w.r.t. the orbital frequency.
SPIN_ANGMOM
The derivative w.r.t. the spin angular momentum in .
double spin_frequency() const
The spin frequency of the given zone.
virtual unsigned number_zones() const =0
The number of zones the body consists of.