A class that interpolates among stellar evolution tracks. More...
#include <Interpolator.h>
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 EvolvingStellarQuantity * | operator() (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 |
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.
|
inline |
Construct an object that can be set to interpolate between tabulated evolution tracks.
Definition at line 96 of file Interpolator.h.
|
inline |
Creates a fully functional stellar evolution interpolator.
tabulated_masses | The stellar masses (in \(M_\odot\)) for which evolution tracks are tabulated. |
tabulated_feh | The stellar [Fe/H] for which evolution tracks are tabulated. |
tabulated_ages | A set of ages for each track in Gyr on the grid defined by track_masses and track_feh . The mass index varies faster. |
tabulated_quantities | A set of stellar quantities for each age of each track. See StellarEvolution::QuantityID for the list, order and units of the quantities. |
smoothing | How much to smooth each quantity when fitting. Use NaN for no smoothing. Corresponds entry by entry with tabulated_quantities . |
nodes | How 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_age | Should interpolation be done vs. log(age) instead of age for each quantity? |
log_quantity | Should interpolation be done of log(quantity) instead of quantity for each quantity? |
num_threads | The number of simultaneosly running threads to use for the interpolation. |
Definition at line 104 of file Interpolator.h.
|
inlinevirtual |
The age at which the core begins to form in Gyr.
Reimplemented in StellarEvolution::MockStellarEvolution.
Definition at line 219 of file Interpolator.h.
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.
tabulated_masses | The stellar masses (in \(M_\odot\)) for which evolution tracks are tabulated. |
tabulated_feh | The stellar [Fe/H] values for which evolution tracks are tabulated. |
tabulated_ages | A set of ages for each track in Gyr on the grid defined by track_masses and track_feh . The mass index varies faster. |
tabulated_quantities | A set of stellar quantities for each age of each track. See StellarEvolution::QuantityID for the list, order and units of the quantities. |
smoothing | How much to smooth each quantity when fitting. Use NaN for no smoothing. Corresponds entry by entry with tabulated_quantities . |
nodes | How 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_age | Should interpolation be done vs. log(age) instead of age for each quantity? |
log_quantity | Should interpolation be done of log(quantity) instead of quantity for each quantity? |
num_threads | The number of simultaneosly running threads to use for the interpolation. |
Definition at line 47 of file Interpolator.cpp.
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.
|
private |
Return the index of the first non-zero value in the argument.
Definition at line 15 of file Interpolator.cpp.
|
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:
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.
filename | The name of a file previously created using save_state() |
Definition at line 236 of file Interpolator.cpp.
|
virtual |
Return a single quantity interpolation to a given mass and [Fe/H].
The result must be destroyed when it becomes obsolete.
quantity | The quantity for which to set-up the interpolation. |
mass | The stellar mass to which to interpolate in \(M_\odot\). |
feh | The stellar [Fe/H] to which to interpolate. |
Reimplemented in StellarEvolution::MockStellarEvolution.
Definition at line 199 of file Interpolator.cpp.
|
private |
Perform all queued interpolations.
interpolation_queue | The queue of pending interpolations to calculate. |
num_threads | The number of threads to use for simultaneous processing |
Definition at line 28 of file Interpolator.cpp.
|
virtual |
Serializes the interpolation state to file.
Only call this on objects initialized with the default constructor.
filename | The name of the file to save the state to. |
Definition at line 248 of file Interpolator.cpp.
|
private |
Serialize the current interpolation.
ar | The archive to serialize to. |
int | Version number. Ignored! |
Definition at line 270 of file Interpolator.h.
|
private |
The age at which the core starts forming in Gyr.
Definition at line 78 of file Interpolator.h.
|
private |
The interpolated stellar evolution quantities for each track.
See ::QuantityID for the order.
Definition at line 69 of file Interpolator.h.
|
private |
Was the interpolation of the log(corresponding quantity)?
Definition at line 75 of file Interpolator.h.
|
private |
The stellar [Fe/H] values for which evolution tracks are available.
Definition at line 58 of file Interpolator.h.
|
private |
The stellar masses for which evolution tracks are available in \(M_\odot\)
Definition at line 58 of file Interpolator.h.
|
private |
Was the interpolation of the corresponding quantity vs. log(age)?
Definition at line 72 of file Interpolator.h.