Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
ExpectedEvolutionMode.h
Go to the documentation of this file.
1 
9 #ifndef __EXPECTED_EVOLUTION_MODE_H
10 #define __EXPECTED_EVOLUTION_MODE_H
11 
12 #include "../shared/Common.h"
13 #include <list>
14 
15 namespace Evolve {
16 
21  template<typename MODE_TYPE>
23  private:
25  std::list<double> __age_breaks;
26 
28  std::list<MODE_TYPE> __expected_mode;
29 
32  public:
34  ExpectedEvolutionMode(double break_precision = 1e-5) :
35  __break_precision(break_precision)
36  {}
37 
39  void add_break(double age, MODE_TYPE mode)
40  {__age_breaks.push_back(age); __expected_mode.push_back(mode);}
41 
43  bool near_break(double age) const
44  {
45  for(
46  std::list<double>::const_iterator
47  break_i = __age_breaks.begin();
48  break_i != __age_breaks.end();
49  ++break_i
50  )
51  if(check_diff(age, *break_i, 0.0, __break_precision))
52  return true;
53  return false;
54  }
55 
57  MODE_TYPE operator()(double age) const
58  {
59  typename std::list<MODE_TYPE>::const_iterator
60  mode_i = __expected_mode.begin();
61  for(
62  std::list<double>::const_iterator age_i = __age_breaks.begin();
63  age_i != __age_breaks.end();
64  age_i++
65  ) {
66  std::list<double>::const_iterator next_age_i=age_i;
67  ++next_age_i;
68  if(
69  *age_i <= age
70  &&
71  (next_age_i == __age_breaks.end() || *next_age_i > age)
72  )
73  return *mode_i;
74  ++mode_i;
75  }
76  std::ostringstream msg;
77  msg << "Age "
78  << age
79  << " outside the range for which expected evolution modes "
80  << "are defined.";
81  throw Core::Error::BadFunctionArguments(msg.str());
82  }
83  };
84 
85 
86 
87 }//End Evolve namespace.
88 
89 #endif
double __break_precision
The precision with which breaks should be detected.
Function arguments do not satisfy some requirement.
Definition: Error.h:73
MODE_TYPE operator()(double age) const
The evolution mode that corresponds to the given age.
Orientations of zones of bodies in a binary system.
bool check_diff(double x, double y, double frac_tolerance, double abs_tolerance)
Returns true iff .
Definition: Common.cpp:3
ExpectedEvolutionMode(double break_precision=1e-5)
Create.
bool near_break(double age) const
Is the given age close to a break (hence ambigous mode).
std::list< double > __age_breaks
The ages at which evolution mode changes occur.
std::list< MODE_TYPE > __expected_mode
The evolution modes that apply between consecutive __age_breaks.
void add_break(double age, MODE_TYPE mode)
Add an evolution mode that applies up to the given age.
Some evolution mode that changes at specified ages.