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  {
30  assert(entry != Evolve::Dissipation::ECCENTRICITY);
31  assert(entry != Evolve::Dissipation::SEMIMAJOR);
32  assert(top_zone_index < number_zones()-1);
33 
34  std::valarray<Eigen::Vector3d> &zone_torque=__torque[top_zone_index];
35  switch(entry) {
37  return zone_torque[0];
39  return zone_torque[(with_respect_to_top ? 1 : 2)];
41  return zone_torque[(with_respect_to_top ? 3 : 4)];
43  return zone_torque[(with_respect_to_top ? 5 : 6)];
45  return zone_torque[(with_respect_to_top ? 7 : 8)];
47  return zone_torque[(with_respect_to_top ? 9 : 10)];
48  default:
50  "Unsupported entry in "
51  "ExponentialDecayDiffRotBody::torque_entry"
52  );
53  }
54  }
55 
57  double age,
58  double companion_mass,
59  double semimajor,
60  double eccentricity,
61  const double *spin_angmom,
62  const double *inclination,
63  const double *periapsis,
64  bool locked_surface,
65  bool zero_outer_inclination,
66  bool zero_outer_periapsis)
67  {
68  if(age!=__current_age) {
69  __current_age=age;
70  reset_torque();
71  }
73  age,
74  companion_mass,
75  semimajor,
76  eccentricity,
77  spin_angmom,
78  inclination,
79  periapsis,
80  locked_surface,
81  zero_outer_inclination,
82  zero_outer_periapsis);
83  }
84 
86  unsigned top_zone_index,
87  Evolve::Dissipation::QuantityEntry entry,
88  bool with_respect_to_top
89  ) const
90  {
91  assert(top_zone_index<number_zones()-1);
92 
93  if(
97  || entry == Evolve::Dissipation::AGE
98  || entry == Evolve::Dissipation::RADIUS
99  )
100  return Eigen::Vector3d(0, 0, 0);
101  Eigen::Vector3d &result=torque_entry(top_zone_index,
102  entry,
103  with_respect_to_top);
104  if(!std::isnan(result[0])) return result;
105  const Evolve::DissipatingZone &zone1 = zone(top_zone_index),
106  &zone2 = zone(top_zone_index + 1);
107  double i1 = zone1.moment_of_inertia(),
108  i2 = zone2.moment_of_inertia();
109  if(i1 == 0 || i2 == 0) {
110  result.setZero();
111  return result;
112  }
113  if(
115  ||
117  )
118  result = zone_to_zone_transform(
119  zone2,
120  zone1,
121  Eigen::Vector3d(0, 0, zone2.spin_frequency()),
122  entry,
123  !with_respect_to_top
124  );
125  else if(
126  (
128  ||
130  )
131  &&
132  !with_respect_to_top
133  )
134  result = Eigen::Vector3d(
135  0,
136  0,
137  -(entry == Evolve::Dissipation::SPIN_ANGMOM ? 1.0 / i1 : 1.0)
138  );
139  else {
140  result = zone_to_zone_transform(zone2,
141  zone1,
142  Eigen::Vector3d(0, 0, 1));
143  if(entry == Evolve::Dissipation::SPIN_ANGMOM) result /= i2;
144  else if(entry != Evolve::Dissipation::SPIN_FREQUENCY)
145  result *= zone2.spin_frequency();
146  if(
148  ||
150  )
151  result[2] -= zone1.spin_frequency();
152  }
154  result *= i1 * i2;
155  else if(with_respect_to_top)
156  result *= i2 * (1 - i1 / (i1 + i2));
157  else result *= i1 * (1 - i2 / (i1 + i2));
158  result/=__timescale * (i1 + i2);
159  return result;
160  }
161 
162 }//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.