Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
Common.h File Reference

Functions and classes of general use for all unit tests. More...

#include "../Evolve/StopInformation.h"
#include "../Core/AstronomicalConstants.h"
#include <cpptest.h>
#include <valarray>
#include <sstream>
#include <cstdlib>
#include <string>
+ Include dependency graph for Common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool check_diff (double x, double y, double frac_tolerance, double abs_tolerance)
 Returns true iff \(|x-y|\leq\mathrm{abs\_tolerance} + \mathrm{frac\_tolerance}\cdot\max(|x|,|y|)\). More...
 
bool check_diff (std::valarray< double > x, std::valarray< double > y, std::valarray< double > frac_tolerance, std::valarray< double > abs_tolerance)
 Returns true iff \( \forall i\ |x_i-y_i|\leq \mathrm{abs\_tolerance}_i + \mathrm{frac\_tolerance}_i\cdot\max(|x_i|,|y_i|)\). More...
 
bool isEqual (double a, double b)
 
double getError (double predicted, double actual)
 
bool approxEqual (double predicted, double actual, double thres=0.02)
 
double orbital_angmom_from_freq (double m1, double m2, double freq, double e)
 The orbital angular momentum corresponding to the given frequency. More...
 
double uniform_rand (double min, double max)
 Generates a uniformly distributed random number. More...
 
std::ostream & operator<< (std::ostream &os, const std::valarray< std::valarray< double > > &poly_coef)
 Create a string with a description of the given stop info. More...
 
double rand_value (double min, double max)
 A uniform random real value in the given range. More...
 
int rand_value (int min, int max)
 A uniform integer value in the given range. More...
 
void rand_poly_coef (std::valarray< std::valarray< double > > &poly_coef, double max_mass=-1)
 Fills the given valarray with a random set of polynomial coefficients. More...
 
std::valarray< std::valarray< double > > rand_poly_coef (double max_mass=-1)
 Returns a random set of polynomial coefficients. More...
 
std::valarray< std::valarray< double > > offset_age (const std::valarray< std::valarray< double > > &poly_coef, double age_offset)
 Returns new polynomial coefficienst such that output polynomial(mass, age+age_offset)=input polynomial(mass, age) More...
 
unsigned next_binom_coef (unsigned n, unsigned m, unsigned nCm)
 Given n, m and (n)C(m) returns (n)C(m+1) More...
 
double lag_from_lgQ (double lgQ)
 Converts lg(Q) to a tidal phase lag. More...
 
double lag_from_lgQ (double lgQ, double mass_ratio)
 Transform Penev et. al 2012 lg(Q*) to phase lag. More...
 

Variables

const double MIN_STELLAR_MASS = 0.4
 The lowest stellar mass to use in tests in \(M_\odot\). More...
 
const double MAX_LOW_MASS = 1.075
 The boundary between high and low mass stars in \(M_\odot\). More...
 
const double MAX_STELLAR_MASS = 1.3
 The highest stellar mass to use in tests in \(M_\odot\). More...
 
const double MIN_AGE = 1e-7
 Most tests start at this age in Gyr. More...
 
const double MAX_AGE = 10.0
 Most tests end at this age in Gyr. More...
 
const double MIN_PLANET_MASS = 10
 The lower limit of the mass of random planets. More...
 
const double MAX_PLANET_MASS = 80
 The upper limit of the mass of random planets. More...
 
const double MIN_PLANET_RADIUS = 5
 The lower limit of the radius of random planets. More...
 
const double MAX_PLANET_RADIUS = 15
 The upper limit of the radius of random planets. More...
 

Detailed Description

Functions and classes of general use for all unit tests.

Definition in file Common.h.

Function Documentation

◆ approxEqual()

bool approxEqual ( double  predicted,
double  actual,
double  thres = 0.02 
)
Todo:
Get rid of this function and use check_diff instead.

Definition at line 33 of file Common.cpp.

◆ check_diff() [1/2]

bool check_diff ( double  x,
double  y,
double  frac_tolerance,
double  abs_tolerance 
)

Returns true iff \(|x-y|\leq\mathrm{abs\_tolerance} + \mathrm{frac\_tolerance}\cdot\max(|x|,|y|)\).

Definition at line 3 of file Common.cpp.

◆ check_diff() [2/2]

bool check_diff ( std::valarray< double >  x,
std::valarray< double >  y,
std::valarray< double >  frac_tolerance,
std::valarray< double >  abs_tolerance 
)

Returns true iff \( \forall i\ |x_i-y_i|\leq \mathrm{abs\_tolerance}_i + \mathrm{frac\_tolerance}_i\cdot\max(|x_i|,|y_i|)\).

Definition at line 11 of file Common.cpp.

◆ getError()

double getError ( double  predicted,
double  actual 
)
Todo:
Get rid of this function and use check_diff instead.

Definition at line 27 of file Common.cpp.

◆ isEqual()

bool isEqual ( double  a,
double  b 
)
Todo:
Get rid of this function and use check_diff instead.

Definition at line 23 of file Common.cpp.

◆ lag_from_lgQ() [1/2]

double lag_from_lgQ ( double  lgQ)

Converts lg(Q) to a tidal phase lag.

Definition at line 17 of file CInterface.cpp.

◆ lag_from_lgQ() [2/2]

double lag_from_lgQ ( double  lgQ,
double  mass_ratio 
)

Transform Penev et. al 2012 lg(Q*) to phase lag.

Parameters
lgQThe old-style quality factor (log10)
mass_ratioThe planet to star mass ratio

Definition at line 145 of file Common.cpp.

◆ next_binom_coef()

unsigned next_binom_coef ( unsigned  n,
unsigned  m,
unsigned  nCm 
)

Given n, m and (n)C(m) returns (n)C(m+1)

Definition at line 134 of file Common.cpp.

◆ offset_age()

std::valarray< std::valarray<double> > offset_age ( const std::valarray< std::valarray< double > > &  poly_coef,
double  age_offset 
)

Returns new polynomial coefficienst such that output polynomial(mass, age+age_offset)=input polynomial(mass, age)

Returns new polynomial coefficienst such that output polynomial(age+age_offset)=input polynomial(age)

Returns new polynomial coefficienst such that output polynomial(mass, age+age_offset)=input polynomial(mass, age)

Definition at line 115 of file Common.cpp.

◆ operator<<()

std::ostream& operator<< ( std::ostream &  os,
const std::valarray< std::valarray< double > > &  poly_coef 
)

Create a string with a description of the given stop info.

Outputs the mass and age polynomial defined by the given polynomial coefficients array

Definition at line 71 of file Common.cpp.

◆ orbital_angmom_from_freq()

double orbital_angmom_from_freq ( double  m1,
double  m2,
double  freq,
double  e 
)

The orbital angular momentum corresponding to the given frequency.

Definition at line 39 of file Common.cpp.

◆ rand_poly_coef() [1/2]

void rand_poly_coef ( std::valarray< std::valarray< double > > &  poly_coef,
double  max_mass = -1 
)

Fills the given valarray with a random set of polynomial coefficients.

Definition at line 90 of file Common.cpp.

◆ rand_poly_coef() [2/2]

std::valarray< std::valarray<double> > rand_poly_coef ( double  max_mass = -1)

Returns a random set of polynomial coefficients.

Definition at line 108 of file Common.cpp.

◆ rand_value() [1/2]

double rand_value ( double  min,
double  max 
)

A uniform random real value in the given range.

Definition at line 61 of file Common.cpp.

◆ rand_value() [2/2]

int rand_value ( int  min,
int  max 
)

A uniform integer value in the given range.

Definition at line 66 of file Common.cpp.

◆ uniform_rand()

double uniform_rand ( double  min,
double  max 
)

Generates a uniformly distributed random number.

Seeding the random number generator is the caller's responsibility.

Definition at line 49 of file Common.cpp.

Variable Documentation

◆ MAX_AGE

const double MAX_AGE = 10.0

Most tests end at this age in Gyr.

Definition at line 57 of file Common.h.

◆ MAX_LOW_MASS

const double MAX_LOW_MASS = 1.075

The boundary between high and low mass stars in \(M_\odot\).

Definition at line 48 of file Common.h.

◆ MAX_PLANET_MASS

const double MAX_PLANET_MASS = 80

The upper limit of the mass of random planets.

Definition at line 63 of file Common.h.

◆ MAX_PLANET_RADIUS

const double MAX_PLANET_RADIUS = 15

The upper limit of the radius of random planets.

Definition at line 69 of file Common.h.

◆ MAX_STELLAR_MASS

const double MAX_STELLAR_MASS = 1.3

The highest stellar mass to use in tests in \(M_\odot\).

Definition at line 51 of file Common.h.

◆ MIN_AGE

const double MIN_AGE = 1e-7

Most tests start at this age in Gyr.

Definition at line 54 of file Common.h.

◆ MIN_PLANET_MASS

const double MIN_PLANET_MASS = 10

The lower limit of the mass of random planets.

Definition at line 60 of file Common.h.

◆ MIN_PLANET_RADIUS

const double MIN_PLANET_RADIUS = 5

The lower limit of the radius of random planets.

Definition at line 66 of file Common.h.

◆ MIN_STELLAR_MASS

const double MIN_STELLAR_MASS = 0.4

The lowest stellar mass to use in tests in \(M_\odot\).

Definition at line 45 of file Common.h.