9 #ifndef __EVOLVING_STELLAR_QUANTITY_H 10 #define __EVOLVING_STELLAR_QUANTITY_H 12 #include "../Core/SharedLibraryExportMacros.h" 16 #include "InterpolatedDerivatives.h" 18 #include "../Core/Functions.h" 19 #include "../Core/InterpSolutionIterator.h" 20 #include "../Core/InterpolatingFunctionALGLIB.h" 21 #include "../Core/Error.h" 110 mutable alglib::real_1d_array
125 __max_interp_mass_index,
129 __min_interp_feh_index,
133 __max_interp_feh_index;
144 {
return feh_index * __track_masses.size() + mass_index;}
155 assert(track_i < __min_interp_ages.size());
156 assert(track_i < __max_interp_ages.size());
157 return (__min_interp_ages[track_i] <= age
159 __max_interp_ages[track_i] >= age);
175 {
return track_in_range(track_index(mass_i, feh_i), age);}
179 void check_grid_range()
const;
189 const std::valarray<double> &boundaries,
202 void set_interp_age_ranges();
209 double evaluate_track(
229 void check_grid_expansion_directions(
250 void update_interpolation_grid()
const;
264 {
return age_to_interp_param(age, __mass, __feh);}
269 {
return interp_param_to_age(interp_param, __mass, __feh);}
276 virtual double age_to_interp_param(
294 virtual double interp_param_to_age(
322 const std::valarray<double> &track_masses,
326 const std::valarray<double> &track_feh,
331 const std::vector<const OneArgumentDiffFunction *>
340 bool log_quantity=
true,
344 bool starts_zero=
false 357 {
return interpolate(age);}
368 {
return (__initially_zero ? -Core::Inf : __min_age);}
371 virtual const std::vector<double> &discontinuities()
const 372 {
return __interp_grid_change_ages;}
380 virtual double next_discontinuity()
const 381 {
return *__next_grid_change_age;}
385 virtual double previous_discontinuity()
const;
389 virtual void enable_next_interpolation_region()
const;
396 "Called EvolvingStellarQuantity::crossings, which are ill" bool __initially_zero
Should the quantity be assumed zero below the minimum track age.
double __min_age
The minimum age for which this quantity is defined in Gyr.
struct LIB_PUBLIC EvolvingStellarQuantity
Opaque struct to cast to/from StellarEvolution::EvolvingStellarQuantity pointers. ...
std::vector< const OneArgumentDiffFunction * > __evolution_tracks
The model tracks for the evolution of the quantity on the grid defined by ::__track_masses and ::__tr...
size_t __mass_index_below
The index of the largest track mass not exceeding ::__mass.
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.
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.
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.
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.
A class representing a once differentiable function of a single argument.
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.
Define a single function performing mass-[Fe/H] interpolations.
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...
Declares & defines a class describing how the mass-[Fe/H] interpolation grid is allowed to grow...
A class for stellar properties that depend on age.
An iterator over a set of solutions to an interpolating function.
Declares & defines a class for the derivative of a quantity which is the sum of two other quantities...
size_t __min_interp_mass_index
The index within ::__track_masses of the lowest mass currently participating in the interpolation...
std::valarray< double > __track_masses
The masses of the evolution tracks.
void select_interpolation_region(const EvolvingStar *star, double age)
Prepare the zone quantities for interpolation around the given age.
double interp_param_to_age(double interp_param) const
Return the age for the given interpoltaion parameter for the current star.
A class representing arbitrary order derivatives of a function.
double __mass
The mass to which to interpolate in .
Declares a class to switch from logarithmic to linear derivative.
bool __log_age
Whether the tracks have log(age) instead of age as their argument.
double age_to_interp_param(double age) const
Return the interpoltaion parameter for the given age for the current star.
bool __log_quantity
Whether the tracks are of log(quantity) instead of the quantity.
EvolvingStellarQuantity()
Default constructor (only useful for derived classes which do not use the interpolation).
std::valarray< double > __min_interp_ages
The minimum interpolation age for the current star to which each track can contribute.
bool track_in_range(size_t track_i, double age) const
Answer if a given track can participate in interpolating to the given age.
std::vector< double > __interp_grid_change_ages
The ages at which the interpolation grid needs to be re-determined.
alglib::real_1d_array __interp_masses
The current track masses participating in the interpolation.