Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
BreakLockCondition.cpp
1 #define BUILDING_LIBRARY
2 #include "BreakLockCondition.h"
3 #include "BinarySystem.h"
4 
5 namespace Evolve {
6 
7  std::valarray<double> BreakLockCondition::operator()(
8 #ifndef NDEBUG
9  Core::EvolModeType evol_mode,
10  const std::valarray<double> &orbit,
11 #else
13  const std::valarray<double> &,
14 #endif
15  const std::valarray<double> &derivatives,
16  std::valarray<double> &stop_deriv) const
17  {
18 #ifndef NDEBUG
19  assert(evol_mode==Core::BINARY);
20  assert(orbit.size()==1 + 3*__system.number_zones() -
22  assert(orbit.size()==derivatives.size());
24  assert(std::pow(__system.semimajor(), 6.5)==orbit[0]);
25  else assert(__system.semimajor()==orbit[0]);
26 #endif
30  +
33  false)
34  *__system.primary().radius(1)
35  +
38  true)
40  unsigned deriv_zone_ind=0,
41  unlocked_zone_ind=0,
42  num_zones=__system.number_zones();
43  unsigned inclination_offset=2,
44  periapsis_offset=inclination_offset+num_zones-1,
45  angmom_offset=periapsis_offset+num_zones;
46  for(int body_ind=0; body_ind<2; ++body_ind) {
47  const DissipatingBody &body=(body_ind==0 ? __system.primary()
48  : __system.secondary());
49  for(unsigned zone_ind=0; zone_ind<body.number_zones(); ++zone_ind) {
50  double dangmom_dt;
51  const DissipatingZone &zone=body.zone(zone_ind);
52  if(!zone.locked())
53  dangmom_dt=derivatives[angmom_offset+unlocked_zone_ind++];
54  else {
55  double dworb_dt=Core::orbital_angular_velocity(
56  __system.primary().mass(),
58  true)
59  *derivatives[0];
60  dangmom_dt=zone.moment_of_inertia(1)*zone.spin_frequency()
61  +
62  zone.moment_of_inertia()
63  *zone.lock_held().spin(dworb_dt);
64  }
65  dfrac_dt+=__system.above_lock_fraction(
67  deriv_zone_ind)*zone.moment_of_inertia(1)
68  +
71  deriv_zone_ind)
72  *derivatives[inclination_offset+deriv_zone_ind]
73  +
76  deriv_zone_ind)
77  *derivatives[inclination_offset+deriv_zone_ind]
78  *dangmom_dt;
79  if(deriv_zone_ind)
80  dfrac_dt+=__system.above_lock_fraction(
82  deriv_zone_ind)
83  *derivatives[periapsis_offset+deriv_zone_ind];
84  ++deriv_zone_ind;
85  }
86 
87  }
88  dfrac_dt=Core::NaN;
89  stop_deriv.resize(2, dfrac_dt);
90  std::valarray<double> result(2);
91  result[0]=frac;
92  result[1]=frac-1.0;
93  return result;
94  }
95 
97  short deriv_sign,
98  unsigned
99 #ifndef NDEBUG
100  index
101 #endif
102  )
103  {
104 #ifndef NDEBUG
105  if(index==0) assert(deriv_sign == -1);
106  else {
107  assert(index == 1);
108  assert(deriv_sign == 1);
109  }
110 #endif
112  }
113 
114  std::string BreakLockCondition::describe(int ) const
115  {
116  std::ostringstream description;
117  description << "Locked zone #"
119  << " exiting its current lock";
120  return description.str();
121  }
122 
123 }//End Evolve namespace.
std::valarray< double > operator()(Core::EvolModeType evol_mode, const std::valarray< double > &orbit, const std::valarray< double > &derivatives, std::valarray< double > &stop_deriv) const
How far away from breaking the lock the system is.
RADIUS
The derivative w.r.t. the radius of the body in .
const DissipatingBody & primary() const
Returns the primary body in the system (const).
Definition: BinarySystem.h:836
A base class for any body contributing to tidal dissipation.
Declares a class for a stopping condition monitoring when a locked zone loses the lock...
void reached(short deriv_sign, unsigned index=0)
See StoppingCondition::reached().
virtual const DissipatingZone & zone(unsigned zone_index) const =0
A modifiable reference to one of the body&#39;s zones.
MOMENT_OF_INERTIA
double above_lock_fraction(unsigned locked_zone_index, Dissipation::QuantityEntry entry=Dissipation::NO_DERIV, unsigned deriv_zone_index=0, bool secondary_radius=false)
The fraction of an infinitesimal timestep that a zone spends spinning faster than the lock it is in...
Orientations of zones of bodies in a binary system.
double spin(double orbital_frequency) const
Spin frequency at exactly the lock that corresponds to the given orbital frequency.
unsigned __locked_zone_index
The index within the list of locked zones of the checked zone.
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...
double mass() const
The mass of the body (constant with age).
double radius(int deriv_order=0) const
The current radius or its derivative with age of the body.
A layer of a system body for which the tidal bulge is not exactly in phase with the tidal potential...
unsigned number_locked_zones() const
How many zones on either body are currently locked.
Definition: BinarySystem.h:848
const DissipatingBody & secondary() const
Returns the secondary body in the system (const).
Definition: BinarySystem.h:839
BinarySystem & __system
The binary system this condition is attached to.
AGE
The derivative w.r.t. age, excluding the dependence through the body&#39;s radius and the moments of iner...
Defines the BinarySystem class.
virtual bool locked(int orbital_frequency_multiplier, int spin_frequency_multiplier) const
Should return true iff the given term is presently locked.
const SpinOrbitLockInfo & lock_held() const
The currntly held lock.
EvolModeType
The various evolution modes.
Definition: Common.h:42
double semimajor() const
The current semimajor axis of the system.
Definition: BinarySystem.h:852
SPIN_ANGMOM
The derivative w.r.t. the spin angular momentum in .
virtual std::string describe(int index=0) const
See StoppingCondition::describe().
unsigned number_zones() const
The total number of zones in both system bodies.
Definition: BinarySystem.h:842
virtual void release_lock(unsigned locked_zone_index, short direction)
Releases the lock to one of the locked zones.
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.