![]() |
SEVN
|
#include <lambda_klencki21.h>
Public Member Functions | |
| Lambda_Klencki (const Star *s) | |
| Lambda_Klencki (const IO *io) | |
| virtual | ~Lambda_Klencki ()=default |
| std::vector< double > | find_row (double Mzams, double Z) |
| double | operator() (const Star *s) override |
| virtual double | operator() (double Mzams, double Z, double R) |
Static Protected Member Functions | |
| static double | estimate_lambda (double R, const std::vector< double > &coefficients) |
Protected Attributes | |
| sevnstd::SevnLogging | svlog |
| double | Mzams_cache {0} |
| double | Z_cache {0} |
| std::vector< double > | vector_cache |
| const double | Zsun =0.017 |
Static Protected Attributes | |
| static thread_local std::vector< std::vector< double > > | table |
| static thread_local bool | already_loaded =false |
Basic Lambda_Klencki class. The Lambda fit comes from Appendix A in Klencki+21 (https://ui.adsabs.harvard.edu/abs/2021A%26A...645A..54K/abstract). Lambda is thus estimates as: log10(lambda) = a*x^3 + b*x^2 + c*x + d where x=log10(R) The value of a,b,c,d depends on the Mass (Mzams), Z (metallicity) and Radius. All these values are tabulated for a set of given tracks, the table is in auxiliary_data/lambda_fit_Klencki21.dat (original link https: //ftp.science.ru.nl/astro/jklencki/).
During the first class initialisation in each thread, the table is loaded as a static 2D vector The following class initialisations will just use the already loaded table.
The lambda can be retrieved using the overload operator (Star *s) or (double Mzams, double Z, double R).
Notice: the lambda is estimated by Klenci+21 using MESA tracks between 10 and 80 Msun and Z/Zsun 0.01 - 0.1, where Zsun=0.017 (not all the tracks contains all the ranges in Z). Using this class the lambda is estimated in a quantised way, i.e. for a Mzams and a Z not present in the table, the closed track with Mtrack>Mzams and Ztrack>Z. If Mzams<10, Mtracks=10 is used, for Z/Zsun<0.01, Z/Zsun=0.01 is used.
| Lambda_Klencki::Lambda_Klencki | ( | const Star * | s | ) |
| Lambda_Klencki::Lambda_Klencki | ( | const IO * | io | ) |
|
virtualdefault |
|
staticprotected |
Estimate lambda from Klencki+21 using Eq. A.1
| R | radius in Rsun |
| coefficients | coefficients of the Eq. A.1 in Klencki + R12,R23 and Rmax, it has to be a vector with dimension 17 with the following columns:
|
| std::vector< double > Lambda_Klencki::find_row | ( | double | Mzams, |
| double | Z | ||
| ) |
Find the row of the Klencki table that best match Mzams and Z in input. The best match is the one for which Mtrack>Mzams and Ztrack>Z. If Mzams<10, Mtracks=10 is used, for Z/Zsun<0.01, Z/Zsun=0.01 is used.
| Mzams | zams mass (Msun) of the star for which we want to find the the related track in the Klencki table |
| Z | Z of the star for which we want to find the the related track in the Klencki table |
|
overridevirtual |
Estimate lambda for a given star. Internally it calles the operator(double Mzams, double Z, double R).
| s | Star for which we want to estimate lambda |
Implements Lambda_Base.
|
virtual |
Estimate the value of lambda as function of Mzams, Z and R. Some part of the lambda estimate are cached. In particular the coefficient from Klencki+21 depends on the Mzams and Z, therefore these two values are cached and the coefficients (see find_row) are loaded only if Mzams or Z are different with respect to the last call.
| Mzams | Zams mass in Msun |
| Z | metallicity |
| R | radius in Rsun |
Reimplemented in Lambda_Klencki_interpolator.
|
staticprotected |
flag to check if it is needed to load table
|
protected |
|
protected |
|
staticprotected |
Here now we define two quantities that are used to load the external table only once per class per thread. In this way we can save memory not loading one table for each Lambda instance, this is possibile using static variables. At the same time using thread_local we force to have one separate definition for these variable for each thread avoiding data racing. In this case it is equivalent to defining the variable as threadprivate (see https://stackoverflow.com/questions/60932116/does-thread-local-work-for-openmp-threads), Variables that appear in threadprivate directives or variables with the _Thread_local (in C) or thread_local (in C++) storage-class specifier are threadprivate
In the class constructors the table is loaded only if the variable already_loaded is set to false, after the table loading alread_loaded is set to false. 2D table 170 rows, 17 columns
|
protected |
Last coefficient used to estimate lambda
|
protected |
Last Mzams and Z used to estimate lambda
|
protected |
Value of Z for the sun as assumed in Klencki+21