Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
EvolvingStellarZone.cpp
Go to the documentation of this file.
1 
8 #define BUILDING_LIBRARY
9 #include "EvolvingStellarZone.h"
10 
11 namespace Star {
12 
14  {
15  for(size_t i=0; i<__current_age_quantities.size(); ++i)
17  delete __current_age_quantities[i];
19  }
20  }
21 
23  unsigned deriv_order) const
24  {
25  assert(quantity < __evolving_quantities.size());
26 
27  if(__current_age_quantities[quantity]==NULL) {
28  __current_age_quantities[quantity] =
29  __evolving_quantities[quantity]->deriv(__current_age);
30  }
31  return __current_age_quantities[quantity]->order(deriv_order);
32  }
33 
34  double EvolvingStellarZone::any_age_quantity(size_t quantity,
35  double age,
36  unsigned deriv_order) const
37  {
38  if(deriv_order == 0)
39  return (*(__evolving_quantities[quantity]))(age);
40  else {
42  *deriv = __evolving_quantities[quantity]->deriv(age);
43  double result = deriv->order(deriv_order);
44  delete deriv;
45  return result;
46  }
47  }
48 
49  void EvolvingStellarZone::configure(bool initialize,
50  double age,
51  double orbital_frequency,
52  double eccentricity,
53  double orbital_angmom,
54  double spin,
55  double inclination,
56  double periapsis,
57  bool spin_is_frequency)
58  {
59  if(__current_age != age) {
60  __current_age = age;
62  }
63  BrokenPowerlawPhaseLagZone::configure(initialize,
64  age,
65  orbital_frequency,
66  eccentricity,
67  orbital_angmom,
68  spin,
69  inclination,
70  periapsis,
71  spin_is_frequency);
72  }
73 
75  {
77 
78  for(size_t i = 0; i < __evolving_quantities.size(); ++i)
80  }
81 
83  {
84 #ifndef NDEBUG
85  std::cerr << "Adjusting zone quantity interpolation per age = "
86  << age
87  << std::endl;
88 #endif
89  for(size_t i = 0; i < __evolving_quantities.size(); ++i) {
90 #ifndef NDEBUG
91  std::cerr << "Quantity " << i << " next discontinuity at: "
92  << __evolving_quantities[i]->next_discontinuity();
93 #endif
94 
95  while(__evolving_quantities[i]->next_discontinuity() <= age) {
96  __evolving_quantities[i]->enable_next_interpolation_region();
97 #ifndef NDEBUG
98  std::cerr << ", switching to next region up to t = "
99  << __evolving_quantities[i]->next_discontinuity();
100 #endif
101  }
102 #ifndef NDEBUG
103  std::cerr << std::endl;
104 #endif
105  }
106  }
107 
109  {
110  double result = Core::Inf;
111  for(size_t i = 0; i < __evolving_quantities.size(); ++i)
112  result = std::min(
113  result,
114  __evolving_quantities[i]->next_discontinuity()
115  );
116  return result;
117  }
118 
120  {
121  double result = -Core::Inf;
122  for(
123  std::vector<
125  >::const_iterator quantity_iter = __evolving_quantities.begin();
126  quantity_iter != __evolving_quantities.end();
127  ++quantity_iter
128  )
129  result = std::max(result, (*quantity_iter)->range_low());
130  return result;
131  }
132 
134  {
135  for(
136  std::vector<
138  >::const_iterator quantity_iter = __evolving_quantities.begin();
139  quantity_iter != __evolving_quantities.end();
140  ++quantity_iter
141  )
142  (*quantity_iter)->select_interpolation_region(age);
143  }
144 
145 }//End Star namespace.
std::vector< const Core::FunctionDerivatives *> __current_age_quantities
Pre-computed values and derivatives for quantities which only depend on age at the current age...
double periapsis(bool evolution_rate=false) const
The argument of periapsis of this zone minus the reference zone&#39;s.
double __current_age
The age for the last configure() call.
A class for stellar properties that depend on age.
virtual double order(unsigned deriv_order=1) const =0
Derivative of the given order of the function with respect to its argument.
Declares a base class for all stellar zones.
virtual void select_interpolation_region(double age) const
Prepare the zone quantities for interpolation around the given age.
double current_age_quantity(size_t quantity, unsigned deriv_order=0) const
The current age value of the given quantity (or its derivative).
double next_stop_age() const
The next age when the evolution needs to be stopped for a change in one of the bodies.
const std::vector< const StellarEvolution::EvolvingStellarQuantity *> __evolving_quantities
The quantities describing the stellar zone.
void reached_critical_age(double age)
Change the body as necessary at the given age.
~EvolvingStellarZone()
Delete any dynamically allocated memory.
A class representing arbitrary order derivatives of a function.
Definition: Functions.h:66
double any_age_quantity(size_t quantity, double age, unsigned deriv_order=0) const
The value of the given quantity (or its derivative) at an arbitrary age.
double inclination(bool evolution_rate=false) const
The angle between the angular momenta of the zone and the orbit.
void reset_current_quantities()
Forgets any previously calculated quantities for the current age.
virtual void configure(bool initialize, double age, double orbital_frequency, double eccentricity, double orbital_angmom, double spin, double inclination, double periapsis, bool spin_is_frequency)
Defines the current orbit, triggering re-calculation of all quantities.
double min_interp_age() const
The minimum age at wich zone quantities can be querried.