Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
StellarEvolution::Interpolator Class Reference

A class that interpolates among stellar evolution tracks. More...

#include <Interpolator.h>

+ Inheritance diagram for StellarEvolution::Interpolator:
+ Collaboration diagram for StellarEvolution::Interpolator:

Public Member Functions

 Interpolator ()
 Construct an object that can be set to interpolate between tabulated evolution tracks. More...
 
 Interpolator (const std::valarray< double > &tabulated_masses, const std::valarray< double > &tabulated_feh, const std::list< std::valarray< double > > &tabulated_ages, const std::vector< std::list< std::valarray< double > > > &tabulated_quantities, const std::vector< double > &smoothing, const std::vector< int > &nodes, const std::vector< bool > &vs_log_age, const std::vector< bool > &log_quantity, unsigned num_threads)
 Creates a fully functional stellar evolution interpolator. More...
 
void create_from (const std::valarray< double > &tabulated_masses, const std::valarray< double > &tabulated_feh, const std::list< std::valarray< double > > &tabulated_ages, const std::vector< std::list< std::valarray< double > > > &tabulated_quantities, const std::vector< double > &smoothing, const std::vector< int > &nodes, const std::vector< bool > &vs_log_age, const std::vector< bool > &log_quantity, unsigned num_threads)
 Fully setup an object created by the default constructor. More...
 
virtual EvolvingStellarQuantityoperator() (QuantityID quantity, double mass, double feh) const
 Return a single quantity interpolation to a given mass and [Fe/H]. More...
 
virtual double core_formation_age () const
 The age at which the core begins to form in Gyr. More...
 
virtual void save_state (const std::string &filename="../interp_state_data") const
 Serializes the interpolation state to file. More...
 
virtual void load_state (const std::string &filename="../interp_state_data")
 Loads data from serialization. More...
 
void delete_tracks ()
 Free all evolution tracks, rendering all created quantities unuseable! More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int)
 Serialize the current interpolation. More...
 
int find_first_core_index (const std::valarray< double > &core_mass) const
 Return the index of the first non-zero value in the argument. More...
 
void perform_queued_interpolations (InterpolationQueue &interpolation_queue, unsigned num_threads=1)
 Perform all queued interpolations. More...
 

Private Attributes

std::valarray< double > __track_masses
 
std::valarray< double > __track_feh
 The stellar [Fe/H] values for which evolution tracks are available. More...
 
std::vector< std::vector< const OneArgumentDiffFunction * > > __interpolated_quantities
 The interpolated stellar evolution quantities for each track. More...
 
std::vector< bool > __vs_log_age
 Was the interpolation of the corresponding quantity vs. log(age)? More...
 
std::vector< bool > __log_quantity
 Was the interpolation of the log(corresponding quantity)? More...
 
double __core_formation
 The age at which the core starts forming in Gyr. More...
 

Friends

class boost::serialization::access
 

Detailed Description

A class that interpolates among stellar evolution tracks.

Uses a set of pre-computed evolution tracks to generate inrpolating functions that represents reasonably well the evolution of various properties of an arbitrary mass star as a function of age.

At present the only implementing class is MESA::Interpolator based on a set of MESA tracks.

Definition at line 42 of file Interpolator.h.

Constructor & Destructor Documentation

◆ Interpolator() [1/2]

StellarEvolution::Interpolator::Interpolator ( )
inline

Construct an object that can be set to interpolate between tabulated evolution tracks.

Definition at line 96 of file Interpolator.h.

◆ Interpolator() [2/2]

StellarEvolution::Interpolator::Interpolator ( const std::valarray< double > &  tabulated_masses,
const std::valarray< double > &  tabulated_feh,
const std::list< std::valarray< double > > &  tabulated_ages,
const std::vector< std::list< std::valarray< double > > > &  tabulated_quantities,
const std::vector< double > &  smoothing,
const std::vector< int > &  nodes,
const std::vector< bool > &  vs_log_age,
const std::vector< bool > &  log_quantity,
unsigned  num_threads 
)
inline

Creates a fully functional stellar evolution interpolator.

Parameters
tabulated_massesThe stellar masses (in \(M_\odot\)) for which evolution tracks are tabulated.
tabulated_fehThe stellar [Fe/H] for which evolution tracks are tabulated.
tabulated_agesA set of ages for each track in Gyr on the grid defined by track_masses and track_feh. The mass index varies faster.
tabulated_quantitiesA set of stellar quantities for each age of each track. See StellarEvolution::QuantityID for the list, order and units of the quantities.
smoothingHow much to smooth each quantity when fitting. Use NaN for no smoothing. Corresponds entry by entry with tabulated_quantities.
nodesHow many nodes to use when smoothing each quantity (ignored if the corresponding smoothing entry is NaN - no smoothing). Corresponds entry by entry with tabulated_quantities and smoothing.
vs_log_ageShould interpolation be done vs. log(age) instead of age for each quantity?
log_quantityShould interpolation be done of log(quantity) instead of quantity for each quantity?
num_threadsThe number of simultaneosly running threads to use for the interpolation.

Definition at line 104 of file Interpolator.h.

Member Function Documentation

◆ core_formation_age()

virtual double StellarEvolution::Interpolator::core_formation_age ( ) const
inlinevirtual

The age at which the core begins to form in Gyr.

Reimplemented in StellarEvolution::MockStellarEvolution.

Definition at line 219 of file Interpolator.h.

◆ create_from()

void StellarEvolution::Interpolator::create_from ( const std::valarray< double > &  tabulated_masses,
const std::valarray< double > &  tabulated_feh,
const std::list< std::valarray< double > > &  tabulated_ages,
const std::vector< std::list< std::valarray< double > > > &  tabulated_quantities,
const std::vector< double > &  smoothing,
const std::vector< int > &  nodes,
const std::vector< bool > &  vs_log_age,
const std::vector< bool > &  log_quantity,
unsigned  num_threads 
)

Fully setup an object created by the default constructor.

Parameters
tabulated_massesThe stellar masses (in \(M_\odot\)) for which evolution tracks are tabulated.
tabulated_fehThe stellar [Fe/H] values for which evolution tracks are tabulated.
tabulated_agesA set of ages for each track in Gyr on the grid defined by track_masses and track_feh. The mass index varies faster.
tabulated_quantitiesA set of stellar quantities for each age of each track. See StellarEvolution::QuantityID for the list, order and units of the quantities.
smoothingHow much to smooth each quantity when fitting. Use NaN for no smoothing. Corresponds entry by entry with tabulated_quantities.
nodesHow many nodes to use when smoothing each quantity (ignored if the corresponding smoothing entry is NaN - no smoothing). Corresponds entry by entry with tabulated_quantities and smoothing.
vs_log_ageShould interpolation be done vs. log(age) instead of age for each quantity?
log_quantityShould interpolation be done of log(quantity) instead of quantity for each quantity?
num_threadsThe number of simultaneosly running threads to use for the interpolation.

Definition at line 47 of file Interpolator.cpp.

◆ delete_tracks()

void StellarEvolution::Interpolator::delete_tracks ( )

Free all evolution tracks, rendering all created quantities unuseable!

Essentially an only explicitly called destructor. The reason for requiring explicit destruction is that generated quantities cannot be used after this method is invoked, and not invoking it simply causes a benign memory leak.

Definition at line 217 of file Interpolator.cpp.

◆ find_first_core_index()

int StellarEvolution::Interpolator::find_first_core_index ( const std::valarray< double > &  core_mass) const
private

Return the index of the first non-zero value in the argument.

Definition at line 15 of file Interpolator.cpp.

◆ load_state()

void StellarEvolution::Interpolator::load_state ( const std::string &  filename = "../interp_state_data")
virtual

Loads data from serialization.

Only call this on objects NOT initialized using the default constructor (otherwise it has no data to save). Serializes state to file.

Recursively saves data of YRECEvolution and every class it depends on:

  • StellarEvolution
  • InterpolatingFunctionALGLIB
  • OneArgumentDiffFunction,
  • OneArgumentFunction
  • spline1dinterpolant
  • _spline1dinterpolant_owner.

In _spline1dinterpolant_owner, serialize() serializes everything EXCEPT p_struct->x.data and p_struct->y.data, because those are just copies of the original data on which the spline was based and are not necessary for evaluating the spline.

Parameters
filenameThe name of a file previously created using save_state()

Definition at line 236 of file Interpolator.cpp.

◆ operator()()

EvolvingStellarQuantity * StellarEvolution::Interpolator::operator() ( QuantityID  quantity,
double  mass,
double  feh 
) const
virtual

Return a single quantity interpolation to a given mass and [Fe/H].

The result must be destroyed when it becomes obsolete.

Parameters
quantityThe quantity for which to set-up the interpolation.
massThe stellar mass to which to interpolate in \(M_\odot\).
fehThe stellar [Fe/H] to which to interpolate.

Reimplemented in StellarEvolution::MockStellarEvolution.

Definition at line 199 of file Interpolator.cpp.

◆ perform_queued_interpolations()

void StellarEvolution::Interpolator::perform_queued_interpolations ( InterpolationQueue interpolation_queue,
unsigned  num_threads = 1 
)
private

Perform all queued interpolations.

Parameters
interpolation_queueThe queue of pending interpolations to calculate.
num_threadsThe number of threads to use for simultaneous processing

Definition at line 28 of file Interpolator.cpp.

◆ save_state()

void StellarEvolution::Interpolator::save_state ( const std::string &  filename = "../interp_state_data") const
virtual

Serializes the interpolation state to file.

Only call this on objects initialized with the default constructor.

Parameters
filenameThe name of the file to save the state to.

Definition at line 248 of file Interpolator.cpp.

◆ serialize()

template<class Archive >
void StellarEvolution::Interpolator::serialize ( Archive &  ar,
const unsigned  int 
)
private

Serialize the current interpolation.

Parameters
arThe archive to serialize to.
intVersion number. Ignored!

Definition at line 270 of file Interpolator.h.

Member Data Documentation

◆ __core_formation

double StellarEvolution::Interpolator::__core_formation
private

The age at which the core starts forming in Gyr.

Definition at line 78 of file Interpolator.h.

◆ __interpolated_quantities

std::vector< std::vector<const OneArgumentDiffFunction*> > StellarEvolution::Interpolator::__interpolated_quantities
private

The interpolated stellar evolution quantities for each track.

See ::QuantityID for the order.

Definition at line 69 of file Interpolator.h.

◆ __log_quantity

std::vector<bool> StellarEvolution::Interpolator::__log_quantity
private

Was the interpolation of the log(corresponding quantity)?

Definition at line 75 of file Interpolator.h.

◆ __track_feh

std::valarray<double> StellarEvolution::Interpolator::__track_feh
private

The stellar [Fe/H] values for which evolution tracks are available.

Definition at line 58 of file Interpolator.h.

◆ __track_masses

std::valarray<double> StellarEvolution::Interpolator::__track_masses
private

The stellar masses for which evolution tracks are available in \(M_\odot\)

Definition at line 58 of file Interpolator.h.

◆ __vs_log_age

std::vector<bool> StellarEvolution::Interpolator::__vs_log_age
private

Was the interpolation of the corresponding quantity vs. log(age)?

Definition at line 72 of file Interpolator.h.


The documentation for this class was generated from the following files: