Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
DiskBinarySystem.cpp
1 #define BUILDING_LIBRARY
2 #include "DiskBinarySystem.h"
3 
4 namespace Evolve {
5 
7  {
8  unsigned nzones = primary().number_zones();
9  std::valarray<double> angmom(nzones),
10  zeros(0.0, nzones - 1);
11  for(unsigned zone_ind = 0; zone_ind < nzones; ++zone_ind)
12  angmom[zone_ind] = primary().zone(zone_ind).angular_momentum();
13  configure(false,
14  age(),
15  Core::NaN,
16  Core::NaN,
17  &(angmom[0]),
18  &(zeros[0]),
19  &(zeros[0]),
20  Core::SINGLE);
21  }
22 
24  {
25 #ifndef NDEBUG
26  std::cerr << "Adding secondary" << std::endl;
27 #endif
28  unsigned nzones = primary().number_zones() + secondary().number_zones();
29  std::valarray<double> angmom(nzones),
30  inclination(nzones),
31  periapsis(nzones - 1);
32  unsigned zone_ind = 0;
33  for(short body_ind = 0; body_ind < 2; ++body_ind) {
34  const DissipatingBody &body = (body_ind == 0
35  ? primary()
36  : secondary());
37  for(
38  unsigned body_zone_ind = 0;
39  body_zone_ind < body.number_zones();
40  ++body_zone_ind
41  ) {
42  const DissipatingZone &zone = body.zone(body_zone_ind);
43  angmom[zone_ind] = zone.angular_momentum();
44  assert(zone.inclination() == 0);
45  assert(zone.periapsis() == 0);
46  inclination[zone_ind] = __initial_inclination;
47  if(zone_ind) periapsis[zone_ind - 1] = 0;
48  ++zone_ind;
49  }
50  }
51  configure(true,
52  age(),
55  &(angmom[0]),
56  &(inclination[0]),
57  &(periapsis[0]),
58  Core::BINARY);
59  if(
60  semimajor() * (1.0 - eccentricity())
61  <
63  )
65  }
66 
68  DissipatingBody &body2, double initial_semimajor,
69  double initial_eccentricity, double initial_inclination,
70  double disk_lock_frequency, double disk_dissipation_age,
71  double secondary_formation_age) :
72  BinarySystem(body1, body2),
73  __initial_semimajor(initial_semimajor),
74  __initial_eccentricity(initial_eccentricity),
75  __initial_inclination(initial_inclination),
76  __disk_lock_frequency(disk_lock_frequency),
77  __disk_dissipation_age(disk_dissipation_age),
78  __secondary_formation_age(secondary_formation_age)
79  {
80  if(initial_eccentricity<0 || initial_eccentricity>1) {
81  std::ostringstream msg;
82  msg << "Invalid initial eccentricity: " << initial_eccentricity
83  << " encountered in DiskBinarySystem constructor!";
84  throw Core::Error::BadFunctionArguments(msg.str());
85  }
86  if(__initial_inclination<0 || __initial_inclination>M_PI) {
87  std::ostringstream msg;
88  msg << "Invalid initial inclination: " << initial_eccentricity
89  << " encountered in DiskBinarySystem constructor, must be "
90  "between 0 and pi!";
91  throw Core::Error::BadFunctionArguments(msg.str());
92  }
94  std::ostringstream msg;
95  msg << "Forming the secondary (at age= " << secondary_formation_age
96  << ") before the disk dissipates (at age="
97  << disk_dissipation_age << ") is not supported at this time.";
98  throw Core::Error::BadFunctionArguments(msg.str());
99  }
101  }
102 
104  {
105  if(age == __disk_dissipation_age)
107  if(age == __secondary_formation_age)
108  add_secondary();
110  }
111 
113  {
114  double result;
116  result = __disk_dissipation_age;
117  else if(age() < __secondary_formation_age)
118  result = __secondary_formation_age;
119  else result = Core::Inf;
120  return std::min(result, BinarySystem::next_stop_age());
121  }
122 
123 } //End Evolve namespace.
Function arguments do not satisfy some requirement.
Definition: Error.h:73
double angular_momentum() const
The angular momentum of the given zone 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.
virtual double minimum_separation(bool deriv=false) const
Smallest semimajor axis at which the secondary can survive for the latest system configuration.
double __initial_inclination
Inclination between surface zone of primary and initial orbit.
double __disk_dissipation_age
Age when disk dissipates.
double periapsis(bool evolution_rate=false) const
The argument of periapsis of this zone minus the reference zone&#39;s.
virtual const DissipatingZone & zone(unsigned zone_index) const =0
A modifiable reference to one of the body&#39;s zones.
double __secondary_formation_age
Age when the secondary forms.
virtual double next_stop_age() const
The next age when the evolution needs to be stopped for a system change.
Orientations of zones of bodies in a binary system.
double __initial_semimajor
The semimajor axis of the orbit at which the secondary forms.
double age() const
Returns the present age of the system in Gyr.
Definition: BinarySystem.h:833
A layer of a system body for which the tidal bulge is not exactly in phase with the tidal potential...
DiskBinarySystem(DissipatingBody &body1, DissipatingBody &body2, double initial_semimajor, double initial_eccentricity, double initial_inclination, double disk_lock_frequency, double disk_dissipation_age, double secondary_formation_age)
Create the system.
const DissipatingBody & secondary() const
Returns the secondary body in the system (const).
Definition: BinarySystem.h:839
virtual void reached_critical_age(double age)
Change the system as necessary at the given age.
virtual void reached_critical_age(double age)
Change the system as necessary at the given age.
virtual void secondary_died()
Update the system to account for the death of the secondary.
Declares a class of binary systems which start with a disk-locked star which is then released and at ...
void add_secondary()
Adds the secondary to the system in its initial orbit.
virtual double next_stop_age() const
The next age when the evolution needs to be stopped for a system change.
double inclination(bool evolution_rate=false) const
The angle between the angular momenta of the zone and the orbit.
double semimajor() const
The current semimajor axis of the system.
Definition: BinarySystem.h:852
void release_surface_spin()
Releases the surface spin of the star when the disk dissipates.
void set_surface_lock_frequency(double frequency)
Sets the frequency at which the surface is locked (if any).
double eccentricity() const
The current eccentricity of the system.
Definition: BinarySystem.h:855
double disk_dissipation_age()
The age when the disk dissipates.
virtual int configure(bool initialize, double age, double semimajor, double eccentricity, const double *spin_angmom, const double *inclination, const double *periapsis, Core::EvolModeType evolution_mode)
Sets the current state of the system.
Describes a system of two bodies orbiting each other.
Definition: BinarySystem.h:56
double __disk_lock_frequency
Frequency of the surface spin of the primary when disk is present.
double __initial_eccentricity
The eccentricity of the orbit at which the secondary forms.
virtual unsigned number_zones() const =0
The number of zones the body consists of.