A class for stellar properties that depend on age. More...
#include <EvolvingStellarQuantity.h>
Public Member Functions | |
EvolvingStellarQuantity () | |
Default constructor (only useful for derived classes which do not use the interpolation). More... | |
EvolvingStellarQuantity (double mass, const std::valarray< double > &track_masses, The(\f$[Fe/H]\f$) for which evolution tracks are given. const std::valarray< double > &track_feh, The evolution tracks of the relevant quantity on the grid defined by \p track_masses and \p track_feh. The const std::vector< const OneArgumentDiffFunction *> &evolution_tracks, Whether the track uses log(age) as the independent argument instead of age. bool log_age=true, Whether the track is uses log(quantity) as the dependent argument instead of quantity. bool log_quantity=true, Whether this is a quantity that is identically zero below some age and turns on afterwards bool starts_zero=false) | |
Create an evolving quantity that interpolates to the given mass. More... | |
brief Prepare the quantity for interpolation around the given age After calling this requesting values or derivatives outside the range of the continuous region containing this | age (see ::discontinuities) fails an assert. virtual void select_interpolation_region(double age) const |
Return the value the quantity takes at the given age in virtual Gyr double | operator() (double age) const |
The value of the function at the given abscissa. More... | |
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. More... | |
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. More... | |
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. More... | |
The ages at which the quantity may be virtual discontinuous const std::vector< double > & | discontinuities () const |
An iterator over the | ages (in Gyr) where the quantity takes the given y value. InterpSolutionIterator crossings(double=0) const |
Public Member Functions inherited from Core::OneArgumentFunction< double, double > | |
virtual InterpSolutionIterator | crossings (double y=0) const=0 |
An iterator over the abscissas where the function takes the given y value. More... | |
virtual | ~OneArgumentFunction () |
Provide a virtual destructor for a virtual class. More... | |
Public Attributes | |
brief Prepare the quantity for interpolation around the given age After calling this | method |
Protected Member Functions | |
virtual double | age_to_interp_param (double age, double mass, double feh) const |
Return the interpoltaion parameter given age, mass and [Fe/H]. More... | |
virtual double | interp_param_to_age (double interp_param, double mass, double feh) const |
Return the age in Gyrs given an interpolation parameter, mass, and [Fe/H]. More... | |
Private Member Functions | |
size_t | track_index (size_t mass_index, size_t feh_index) const |
Return the index within ::__evolution_tracks for the given mass and [Fe/H] indices. More... | |
bool | track_in_range (size_t track_i, double age) const |
Answer if a given track can participate in interpolating to the given age. More... | |
bool | track_in_range (size_t mass_i, size_t feh_i, double age) const |
Answer if a given track can participate in interpolating to the given age. More... | |
void | check_grid_range () const |
Verify that the stellar mass and [Fe/H] are within range of the evolution tracks. More... | |
void | find_cell (const std::valarray< double > &boundaries, double value, size_t &below_index, size_t &above_index) const |
The two indices within the given sorted array defining the closed internal containing value. More... | |
void | set_interp_age_ranges () |
Fill the ::__min_interp_ages and ::__max_interp_ages members. More... | |
double | evaluate_track (double age, const OneArgumentDiffFunction &track, const FunctionDerivatives **derivatives) const |
Interpolate the quantity for the given track to the given age, returning NaN if out of age range. More... | |
void | check_grid_expansion_directions (AllowedGridGrowth &grow, double age) const |
Figure out in which directions we can expand a mass-[Fe/H] interpolation grid, assuming a single direction expansion. More... | |
bool | expand_grid (const AllowedGridGrowth &grow, double age) const |
Attempt to expand the current interpolation grid returning true on success. More... | |
void | update_interpolation_grid () const |
Find the best sub-grid of tracks to interpolate on. More... | |
double | interpolate (double age, const FunctionDerivatives **derivatives=NULL) const |
Interpolate the quantity to the desired age. More... | |
double | age_to_interp_param (double age) const |
Return the interpoltaion parameter for the given age for the current star. More... | |
double | interp_param_to_age (double interp_param) const |
Return the age for the given interpoltaion parameter for the current star. More... | |
Private Attributes | |
double | __mass |
The mass to which to interpolate in \(M_\odot\). More... | |
double | __feh |
The [Fe/H] to which to interpolate. More... | |
double | __min_age |
The minimum age for which this quantity is defined in Gyr. More... | |
double | __max_age |
The maximum age for which this quantity is defined in Gyr. More... | |
bool | __log_age |
Whether the tracks have log(age) instead of age as their argument. More... | |
bool | __log_quantity |
Whether the tracks are of log(quantity) instead of the quantity. More... | |
bool | __initially_zero |
Should the quantity be assumed zero below the minimum track age. More... | |
std::valarray< double > | __track_masses |
The masses of the evolution tracks. More... | |
std::valarray< double > | __track_feh |
The [Fe/H] of the evolution tracks. More... | |
std::valarray< double > | __min_interp_ages |
The minimum interpolation age for the current star to which each track can contribute. More... | |
std::valarray< double > | __max_interp_ages |
The maximum interpolation age for the current star to which each track can contribute. More... | |
std::vector< double > | __interp_grid_change_ages |
The ages at which the interpolation grid needs to be re-determined. More... | |
std::vector< double >::const_iterator | __next_grid_change_age |
The entry in ::__interp_grid_change_ages up to which the current interpolation grid is valid. More... | |
size_t | __mass_index_above |
The index of the smallest track mass not smaller than ::__mass. More... | |
size_t | __mass_index_below |
The index of the largest track mass not exceeding ::__mass. More... | |
size_t | __feh_index_above |
The index of the smallest track [Fe/H] not smaller than ::__feh. More... | |
size_t | __feh_index_below |
The index of the largest track [Fe/H] not exceeding ::__feh. More... | |
std::vector< const OneArgumentDiffFunction * > | __evolution_tracks |
The model tracks for the evolution of the quantity on the grid defined by ::__track_masses and ::__track_feh. More... | |
alglib::real_1d_array | __interp_masses |
The current track masses participating in the interpolation. More... | |
alglib::real_1d_array | __interp_feh |
The current track [Fe/H] values participating in the interpolation. More... | |
size_t | __min_interp_mass_index |
The index within ::__track_masses of the lowest mass currently participating in the interpolation. More... | |
size_t | __max_interp_mass_index |
The index within ::__track_masses of the highest mass currently participating in the interpolation. More... | |
size_t | __min_interp_feh_index |
The index within ::__track_feh of the lowest [Fe/H] currently participating in the interpolation. More... | |
size_t | __max_interp_feh_index |
The index within ::__track_feh of the highest [Fe/H] currently participating in the interpolation. More... | |
A class for stellar properties that depend on age.
Definition at line 38 of file EvolvingStellarQuantity.h.
|
inline |
Default constructor (only useful for derived classes which do not use the interpolation).
Definition at line 310 of file EvolvingStellarQuantity.h.
StellarEvolution::EvolvingStellarQuantity::EvolvingStellarQuantity | ( | double | mass, |
const std::valarray< double > & | track_masses, | ||
The(\f$[Fe/H]\f$) for which evolution tracks are given. const std::valarray< double > & | track_feh, | ||
The evolution tracks of the relevant quantity on the grid defined by \p track_masses and \p track_feh. The const std::vector< const OneArgumentDiffFunction *> & | evolution_tracks, | ||
Whether the track uses log(age) as the independent argument instead of age. bool | log_age = true , |
||
Whether the track is uses log(quantity) as the dependent argument instead of quantity. bool | log_quantity = true , |
||
Whether this is a quantity that is identically zero below some age and turns on afterwards bool | starts_zero = false |
||
) |
Create an evolving quantity that interpolates to the given mass.
mass | The stellar mass to interpolate to in \(M_\odot\) |
feh | The stellar ( |
|
inlineprivate |
Return the interpoltaion parameter for the given age for the current star.
Definition at line 263 of file EvolvingStellarQuantity.h.
|
protectedvirtual |
Return the interpoltaion parameter given age, mass and [Fe/H].
Must be an increasing monotonic function
age | The age for which the interpolation parameter is needed in Gyrs. |
mass | The stellar mass for which the interpolation parameter is needed in \(M_\odot\). |
feh | The stellar [Fe/H] for which the interpolation parameter is needed in \([Fe/H]\). |
Definition at line 475 of file EvolvingStellarQuantity.cpp.
|
private |
Figure out in which directions we can expand a mass-[Fe/H] interpolation grid, assuming a single direction expansion.
grow | The current state of the grid expansion possibilities. On output, directions in which growth is no longer allowed are disabled. |
age | The age for which we will interpolate. |
Definition at line 168 of file EvolvingStellarQuantity.cpp.
|
private |
Verify that the stellar mass and [Fe/H] are within range of the evolution tracks.
Definition at line 15 of file EvolvingStellarQuantity.cpp.
|
virtual |
Returns a pointer to the derivative of the function.
The use of a pointer allows avoiding potentially expensive copy opertaions.
Implements Core::OneArgumentDiffFunction.
Reimplemented in StellarEvolution::PolynomialEvolutionQuantity, StellarEvolution::SumQuantity, and StellarEvolution::ZeroQuantity.
Definition at line 656 of file EvolvingStellarQuantity.cpp.
|
private |
Interpolate the quantity for the given track to the given age, returning NaN if out of age range.
If derivatives is not NULL initializes that to a pointer to a derivatives at the current age structure.
age | The age at which to evaluate the track. If ::__log_age is true, the track is evaluated at log(track_age ), otherwise it is directly passed to the track. In particular, the caller should have already transformed this argument to the correct interpolation parameter. |
track | The track to evaluate. Should be an entry from ::__evolution_tracks. |
derivatives | If not NULL, *derivatives is set to a newly allocated derivative instance of one of the children FunctionDerivatives classes. |
Definition at line 143 of file EvolvingStellarQuantity.cpp.
|
private |
Attempt to expand the current interpolation grid returning true on success.
grow | The current state of the grid expansion possibilities. |
age | The age to which we will interpolate. |
Definition at line 238 of file EvolvingStellarQuantity.cpp.
|
private |
The two indices within the given sorted array defining the closed internal containing value.
If value is not exactly equal to an array entry, the two indices are consecutive, if the value is exactly equal to an entry, the two indices are the same.
boundaries | The boundaries of the grid cells in a single dimension. |
value | The value whose cell we are looking for. |
below_index | The index of the largest boundary <= value . |
above_index | The index of the smallest boundary >= value . |
Definition at line 51 of file EvolvingStellarQuantity.cpp.
|
inlineprivate |
Return the age for the given interpoltaion parameter for the current star.
Definition at line 268 of file EvolvingStellarQuantity.h.
|
protectedvirtual |
Return the age in Gyrs given an interpolation parameter, mass, and [Fe/H].
Must be an increasing monotonic function
interp_param | The interpolation parameter for which the age is needed. |
mass | The stellar mass for which the interpolation parameter is needed in \(M_\odot\). |
feh | The stellar [Fe/H] for which the interpolation parameter is needed in \([Fe/H]\). |
Definition at line 494 of file EvolvingStellarQuantity.cpp.
|
private |
Interpolate the quantity to the desired age.
If derivatives is not NULL initializes that to a pointer to a derivatives at the current age structure.
Definition at line 388 of file EvolvingStellarQuantity.cpp.
|
inlinevirtual |
The value of the function at the given abscissa.
Implements Core::OneArgumentFunction< double, double >.
Reimplemented in StellarEvolution::PolynomialEvolutionQuantity, StellarEvolution::SumQuantity, and StellarEvolution::ZeroQuantity.
Definition at line 356 of file EvolvingStellarQuantity.h.
|
inlinevirtual |
The lower end of the range over which the function is defined.
Implements Core::OneArgumentFunction< double, double >.
Reimplemented in StellarEvolution::PolynomialEvolutionQuantity, StellarEvolution::SumQuantity, and StellarEvolution::ZeroQuantity.
Definition at line 363 of file EvolvingStellarQuantity.h.
|
inlinevirtual |
The upper end of the range over which the function is defined.
Implements Core::OneArgumentFunction< double, double >.
Reimplemented in StellarEvolution::PolynomialEvolutionQuantity, StellarEvolution::SumQuantity, and StellarEvolution::ZeroQuantity.
Definition at line 367 of file EvolvingStellarQuantity.h.
|
private |
Fill the ::__min_interp_ages and ::__max_interp_ages members.
Definition at line 95 of file EvolvingStellarQuantity.cpp.
|
inlineprivate |
Answer if a given track can participate in interpolating to the given age.
track_i | The index of the track to check within ::__evolution_tracks. |
age | The age to which interpolation is desired. |
Definition at line 148 of file EvolvingStellarQuantity.h.
|
inlineprivate |
Answer if a given track can participate in interpolating to the given age.
mass_i | The index of the mass of the track to check within ::__track_masses. |
feh_i | The index of the [Fe/H] of the track to check within ::__track_feh. |
age | The age to which interpolation is desired. |
Definition at line 164 of file EvolvingStellarQuantity.h.
|
inlineprivate |
Return the index within ::__evolution_tracks for the given mass and [Fe/H] indices.
mass_index | The index within ::__track_masses of the desired mass. |
feh_index | The index within ::__track_feh of the desired [Fe/H]. |
Definition at line 137 of file EvolvingStellarQuantity.h.
|
private |
Find the best sub-grid of tracks to interpolate on.
Definition at line 337 of file EvolvingStellarQuantity.cpp.
|
private |
The model tracks for the evolution of the quantity on the grid defined by ::__track_masses and ::__track_feh.
The mass index varies faster.
Definition at line 108 of file EvolvingStellarQuantity.h.
|
private |
The [Fe/H] to which to interpolate.
Definition at line 42 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index of the smallest track [Fe/H] not smaller than ::__feh.
Definition at line 91 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index of the largest track [Fe/H] not exceeding ::__feh.
Definition at line 91 of file EvolvingStellarQuantity.h.
|
private |
Should the quantity be assumed zero below the minimum track age.
Definition at line 62 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The current track [Fe/H] values participating in the interpolation.
Definition at line 112 of file EvolvingStellarQuantity.h.
|
private |
The ages at which the interpolation grid needs to be re-determined.
Definition at line 82 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The current track masses participating in the interpolation.
Definition at line 112 of file EvolvingStellarQuantity.h.
|
private |
Whether the tracks have log(age) instead of age as their argument.
Definition at line 56 of file EvolvingStellarQuantity.h.
|
private |
Whether the tracks are of log(quantity) instead of the quantity.
Definition at line 59 of file EvolvingStellarQuantity.h.
|
private |
The mass to which to interpolate in \(M_\odot\).
Definition at line 42 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index of the smallest track mass not smaller than ::__mass.
Definition at line 91 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index of the largest track mass not exceeding ::__mass.
Definition at line 91 of file EvolvingStellarQuantity.h.
|
private |
The maximum age for which this quantity is defined in Gyr.
Definition at line 50 of file EvolvingStellarQuantity.h.
|
private |
The maximum interpolation age for the current star to which each track can contribute.
Definition at line 74 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index within ::__track_feh of the highest [Fe/H] currently participating in the interpolation.
Definition at line 121 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index within ::__track_masses of the highest mass currently participating in the interpolation.
Definition at line 121 of file EvolvingStellarQuantity.h.
|
private |
The minimum age for which this quantity is defined in Gyr.
Definition at line 50 of file EvolvingStellarQuantity.h.
|
private |
The minimum interpolation age for the current star to which each track can contribute.
Definition at line 74 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index within ::__track_feh of the lowest [Fe/H] currently participating in the interpolation.
Definition at line 121 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The index within ::__track_masses of the lowest mass currently participating in the interpolation.
Definition at line 121 of file EvolvingStellarQuantity.h.
|
mutableprivate |
The entry in ::__interp_grid_change_ages up to which the current interpolation grid is valid.
Definition at line 86 of file EvolvingStellarQuantity.h.
|
private |
The [Fe/H] of the evolution tracks.
Definition at line 66 of file EvolvingStellarQuantity.h.
|
private |
The masses of the evolution tracks.
Definition at line 66 of file EvolvingStellarQuantity.h.