SEVN
Loading...
Searching...
No Matches
Lambda_Klencki Class Reference

#include <lambda_klencki21.h>

Inheritance diagram for Lambda_Klencki:
Lambda_Base Lambda_Klencki_interpolator

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Lambda_Klencki() [1/2]

Lambda_Klencki::Lambda_Klencki ( const Star s)

◆ Lambda_Klencki() [2/2]

Lambda_Klencki::Lambda_Klencki ( const IO io)

◆ ~Lambda_Klencki()

virtual Lambda_Klencki::~Lambda_Klencki ( )
virtualdefault

Member Function Documentation

◆ estimate_lambda()

double Lambda_Klencki::estimate_lambda ( double  R,
const std::vector< double > &  coefficients 
)
staticprotected

Estimate lambda from Klencki+21 using Eq. A.1

Parameters
Rradius in Rsun
coefficientscoefficients of the Eq. A.1 in Klencki + R12,R23 and Rmax, it has to be a vector with dimension 17 with the following columns:
  • 0: Mzams
  • 1: Z
  • 2: R12
  • 3: R23
  • 4: Rmax
  • 5-8: a1,b1,c1,d1
  • 9-12: a2,b2,c2,d2
  • 13-16: a3,b3,c3,d3
Returns
value of lambda

◆ find_row()

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.

Parameters
Mzamszams mass (Msun) of the star for which we want to find the the related track in the Klencki table
ZZ of the star for which we want to find the the related track in the Klencki table
Returns
return the quantities of the matched table row as a vector with dimension 17

◆ operator()() [1/2]

double Lambda_Klencki::operator() ( const Star s)
overridevirtual

Estimate lambda for a given star. Internally it calles the operator(double Mzams, double Z, double R).

Parameters
sStar for which we want to estimate lambda
Returns
value of lambda. 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). The lambda is estimated in a quantised way, i.e. for a Mzams and a Z not present in the table, the closest 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.

Implements Lambda_Base.

◆ operator()() [2/2]

double Lambda_Klencki::operator() ( double  Mzams,
double  Z,
double  R 
)
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.

Parameters
MzamsZams mass in Msun
Zmetallicity
Rradius in Rsun
Returns
value of lambda. 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). 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.

Reimplemented in Lambda_Klencki_interpolator.

Member Data Documentation

◆ already_loaded

thread_local bool Lambda_Klencki::already_loaded =false
staticprotected

flag to check if it is needed to load table

◆ Mzams_cache

double Lambda_Klencki::Mzams_cache {0}
protected

◆ svlog

sevnstd::SevnLogging Lambda_Klencki::svlog
protected

◆ table

thread_local std::vector< std::vector< double > > Lambda_Klencki::table
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

◆ vector_cache

std::vector<double> Lambda_Klencki::vector_cache
protected

Last coefficient used to estimate lambda

◆ Z_cache

double Lambda_Klencki::Z_cache {0}
protected

Last Mzams and Z used to estimate lambda

◆ Zsun

const double Lambda_Klencki::Zsun =0.017
protected

Value of Z for the sun as assumed in Klencki+21


The documentation for this class was generated from the following files: