8 #define BUILDING_LIBRARY 67 (*actual_interpolator)(
89 actual_quantity->select_interpolation_region(age);
90 return (*actual_quantity)(age);
103 for(
unsigned i = 0; i < nvalues; ++i) {
109 actual_quantity->next_discontinuity() < age[i]
111 actual_quantity->select_interpolation_region(age[i]);
112 result[i] = (*actual_quantity)(age[i]);
117 double age,
double *result)
123 actual_quantity->select_interpolation_region(age);
126 for(
unsigned order = 0; order < 3; ++order)
127 result[order] = deriv->
order(order);
142 for(
unsigned i = 0; i < nvalues; ++i) {
148 actual_quantity->next_discontinuity() < age[i]
150 actual_quantity->select_interpolation_region(age[i]);
152 *deriv = actual_quantity->
deriv(age[i]);
153 for(
unsigned order = 0; order < 3; ++order)
154 result[order * nvalues + i] = deriv->
order(order);
184 actual_quantity->select_interpolation_region(age);
185 *range_min = actual_quantity->previous_discontinuity();
186 *range_max = actual_quantity->next_discontinuity();
195 )->save_state(filename);
211 static_cast<StellarEvolution::QuantityID>(quantityID)
219 static_cast<StellarEvolution::QuantityID>(quantityID)
227 static_cast<StellarEvolution::QuantityID>(quantityID)
235 static_cast<StellarEvolution::QuantityID>(quantityID)
double metallicity_from_feh(double feh)
Alias for StellarEvolution::metallicity_from_feh()
void destroy_interpolator(MESAInterpolator *interpolator)
Destroy a previously created interpolator.
const int RADIUS
Identifier for the stellar radius as an interpolation quantity.
struct LIB_PUBLIC EvolvingStellarQuantity
Opaque struct to cast to/from StellarEvolution::EvolvingStellarQuantity pointers. ...
static const std::vector< bool > & default_vs_log_age()
Return the default vs_log_age argument to pass to constructor.
MESAInterpolator * load_interpolator(const char *filename)
Load a previously saved interpolator state (faster than creating it).
const int ICONV
Identifier for the convective zone moment of inertia as an interpolation quantity.
bool default_vs_log_age(int quantityID)
Return whether by default the given quantity is interpolated vs. log(age).
const double Zprotosun
The metal fraction with which the Sun formed.
double quantity_max_age(const EvolvingStellarQuantity *quantity)
Return the maximum age for which the quantity is defined.
const int LUM
Identifier for the stellar luminosity as an interpolation quantity.
static const std::vector< bool > & default_log_quantity()
Return the default log_quantity argument to pass to constructor.
static const std::vector< double > & default_smoothing()
Return the default smoothing argument to pass to constructor.
struct LIB_PUBLIC MESAInterpolator
Opaque struct to cast to/from StellarEvolution::Interpolator pointers.
Declare C-style functions for accessing the functionality of the StellarEvolution library...
A class for stellar properties that depend on age.
virtual double order(unsigned deriv_order=1) const =0
Derivative of the given order of the function with respect to its argument.
double evaluate_quantity(const EvolvingStellarQuantity *quantity, double age)
Evaluate a stellar quantity at a given age.
void differentiate_quantity(const EvolvingStellarQuantity *quantity, double age, double *result)
Calculate the zeroth, first and second derivatives of a quantity.
const EvolvingStellarQuantity * create_quantity(const MESAInterpolator *interpolator, int quantityID, double mass, double feh)
Create a single quantity interpolation for a given star.
A stellar evolution interpolator based on the MESA tracks.
double default_smoothing(int quantityID)
Return the default smoothing argument used for the given quantity.
void differentiate_quantity_array(const EvolvingStellarQuantity *quantity, double *age, unsigned nvalues, double *result)
Calculate the derivatives of a quantity at an array of ages.
void quantity_continuous_range(const EvolvingStellarQuantity *quantity, double age, double *range_min, double *range_max)
Return the range of ages surrounding a given age over which a quantity is guaranteed continuous...
A class representing arbitrary order derivatives of a function.
double feh_from_metallicity(double metallicity)
Alias for StellarEvolution::feh_from_metallicity()
const int IRAD
Identifier for the radiative zone moment of inertia as an interpolation quantity. ...
static const std::vector< int > & default_nodes()
Return the default nodes argument to pass to constructor.
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.
const int NUM_QUANTITIES
The number of interpolation quantities currentyl supported.
int default_nodes(int quantityID)
Return the default number of interpolation nodes used for the given quantity.
void evaluate_quantity_array(const EvolvingStellarQuantity *quantity, double *age, unsigned nvalues, double *result)
Evaluate a stellar quantity at an array of ages.
virtual void load_state(const std::string &filename="../interp_state_data")
Loads data from serialization.
bool default_log_quantity(int quantityID)
Return whether by default the log(given quantity) is interpolated vs. the quantity itself...
QuantityID
Defines the quantities tracked by stellar evolution and their order.
double feh_from_z(double z)
Calculate [Fe/H] given Z (metal mass fraction) for a star.
void save_interpolator(MESAInterpolator *interpolator, const char *filename)
Save the state of an interpolator for faster creation.
const int MRAD
Identifier for the radiative zone mass of inertia as an interpolation quantity.
double quantity_min_age(const EvolvingStellarQuantity *quantity)
Return the minimum age for which the quantity is defined.
MESAInterpolator * create_interpolator(const char *mesa_dir, double *smoothing, int *nodes, bool *vs_log_age, bool *log_quantity, unsigned num_threads)
Create an interpolator from a directory containing MESA tracks.
const int RRAD
Identifier for the convective-radiative boundary as an interpolation quantity.
double z_from_feh(double feh)
Calculate Z (metal mass fraction) given [Fe/H] for a star.
void destroy_quantity(EvolvingStellarQuantity *quantity)
Destroy a previously created evolving stellar quantity.