Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
SumQuantity.h
Go to the documentation of this file.
1 
9 #ifndef __SUM_QUANTITY_H
10 #define __SUM_QUANTITY_H
11 
12 #include "../Core/SharedLibraryExportMacros.h"
14 
15 namespace StellarEvolution {
16 
21  class LIB_LOCAL SumQuantity : public EvolvingStellarQuantity {
22  private:
25 
27  bool destroy_qs;
28  public:
31  EvolvingStellarQuantity *quantity2,
32  bool delete_inputs=false)
33  : q1(quantity1), q2(quantity2), destroy_qs(delete_inputs) {}
34 
36  virtual void select_interpolation_region(double age) const
37  {
38  q1->select_interpolation_region(age);
39  q2->select_interpolation_region(age);
40  }
41 
43  double operator()(double age) const
44  {return (*q1)(age)+(*q2)(age);}
45 
47  const FunctionDerivatives *deriv(double age) const
48  {return new SumDerivatives(q1->deriv(age), q2->deriv(age), true);}
49 
51  double range_high() const
52  {return std::min(q1->range_high(), q2->range_high());}
53 
55  double range_low() const
56  {return std::max(q1->range_low(), q2->range_low());}
57 
59  double next_discontinuity() const
60  {return std::min(q1->next_discontinuity(), q2->next_discontinuity());}
61 
64  {
65  if(q1->next_discontinuity() == q2->next_discontinuity()) {
66  q1->enable_next_interpolation_region();
67  q2->enable_next_interpolation_region();
68  } else if(q1->next_discontinuity() < q2->next_discontinuity())
69  q1->enable_next_interpolation_region();
70  else
71  q2->enable_next_interpolation_region();
72  }
73 
76  {
78  "Called EvolvingStellarQuantity::crossings, which are ill "
79  "defined."
80  );
81  }
82 
85  {if(destroy_qs) {delete q1; delete q2;}}
86  }; //End SumQuantity declaration.
87 
88 
89 } //End StellarEvolution namespace.
90 
91 #endif
double range_low() const
The smallest age for which the quantity can be interpolated.
Definition: SumQuantity.h:55
EvolvingStellarQuantity * q1
This quantity will be q1+q2.
Definition: SumQuantity.h:24
brief The smallest age for which the quantity can be interpolated in virtual Gyr double range_low() const
The upper end of the range over which the function is defined.
InterpSolutionIterator crossings(double=0) const
An iterator over the ages where the quantity takes the given y value.
Definition: SumQuantity.h:75
Declares a class implementing the intepolation of a single stellar quantity from stellar evolution tr...
The largest age for which the quantity can be interpolated in virtual Gyr double range_high() const
The lower end of the range over which the function is defined.
double range_high() const
The largest age for which the quantity can be interpolated.
Definition: SumQuantity.h:51
void enable_next_interpolation_region() const
See EvolvingStellarQuantity::enable_next_interpolation_region.
Definition: SumQuantity.h:63
Any runtime error.
Definition: Error.h:61
A class for stellar properties that depend on age.
An iterator over a set of solutions to an interpolating function.
bool destroy_qs
Whether to destroy the input quantities on destruction.
Definition: SumQuantity.h:27
double operator()(double age) const
Return the value the quantity takes at the given age.
Definition: SumQuantity.h:43
double next_discontinuity() const
See EvolvingStellarQuantity::next_discontinuity.
Definition: SumQuantity.h:59
A class representing arbitrary order derivatives of a function.
Definition: Functions.h:66
Return the age derivative of the quantity at the given age in virtual Gyr const FunctionDerivatives * deriv(double age) const
Returns a pointer to the derivative of the function.
virtual void select_interpolation_region(double age) const
See EvolvingStellarQuantity::select_interpolation_region.
Definition: SumQuantity.h:36
A clas for stellar quantities that are the sum of two other quantities.
Definition: SumQuantity.h:21
const FunctionDerivatives * deriv(double age) const
Return the age derivative of the quantity at the given age.
Definition: SumQuantity.h:47
SumQuantity(EvolvingStellarQuantity *quantity1, EvolvingStellarQuantity *quantity2, bool delete_inputs=false)
Create a quantity that is (*quantity1)-(*quantity2)
Definition: SumQuantity.h:30
Derivative class for a quantity that is the sum of two other quantities.