first commit
This commit is contained in:
commit
aaf40315c8
15 changed files with 17524 additions and 0 deletions
76
cmd.c
Normal file
76
cmd.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
int cmd(int kstar, double rstar, double lstar, double Rgal, double *abvmag, double *vmag, double *BV, double *Teff, double *dvmag, double *dBV)
|
||||
{
|
||||
|
||||
double lTeff, BC, kb;
|
||||
double bvc[8], bcc[8];
|
||||
double dbmag;
|
||||
double BCsun, abvmagsun;
|
||||
double rand1, rand2, prand;
|
||||
|
||||
kb = 5.6704E-08*0.5*1.3914E9*0.5*1.3914E9/3.846E26; //Stefan-Boltzmann constant in Lsun Rsun^-2 K^-4
|
||||
|
||||
bvc[0] = -654597.405559323;
|
||||
bvc[1] = 1099118.61158915;
|
||||
bvc[2] = -789665.995692672;
|
||||
bvc[3] = 314714.220932623;
|
||||
bvc[4] = -75148.4728506455;
|
||||
bvc[5] = 10751.803394526;
|
||||
bvc[6] = -853.487897283685;
|
||||
bvc[7] = 28.9988730655392;
|
||||
|
||||
bcc[0] = -4222907.80590972;
|
||||
bcc[1] = 7209333.13326442;
|
||||
bcc[2] = -5267167.04593882;
|
||||
bcc[3] = 2134724.55938336;
|
||||
bcc[4] = -518317.954642773;
|
||||
bcc[5] = 75392.2372207101;
|
||||
bcc[6] = -6082.7301194776;
|
||||
bcc[7] = 209.990478646363;
|
||||
|
||||
BCsun = 0.11; //sun's bolometric correction
|
||||
abvmagsun = 4.83; //sun's absolute V magnitude
|
||||
|
||||
if( rstar && (kstar<14) )
|
||||
{
|
||||
*Teff = pow(lstar/(4.0*Pi*rstar*rstar*kb),0.25);
|
||||
|
||||
if( (*Teff>3000.0) && (*Teff<55000.0) )
|
||||
{
|
||||
lTeff = log10(*Teff);
|
||||
*BV = bvc[0] + bvc[1]*lTeff + bvc[2]*pow(lTeff,2) + bvc[3]*pow(lTeff,3) + bvc[4]*pow(lTeff,4) + bvc[5]*pow(lTeff,5) + bvc[6]*pow(lTeff,6) + bvc[7]*pow(lTeff,7);
|
||||
BC = bcc[0] + bcc[1]*lTeff + bcc[2]*pow(lTeff,2) + bcc[3]*pow(lTeff,3) + bcc[4]*pow(lTeff,4) + bcc[5]*pow(lTeff,5) + bcc[6]*pow(lTeff,6) + bcc[7]*pow(lTeff,7);
|
||||
if(lstar) *abvmag = -2.5*log10(lstar)-BC+BCsun+abvmagsun;
|
||||
*vmag = *abvmag + 5.0*log10(Rgal) - 5.0;
|
||||
|
||||
do{
|
||||
rand1 = 2.0*drand48()-1.0;
|
||||
rand2 = 2.0*drand48()-1.0;
|
||||
} while (rand1*rand1+rand2*rand2 > 1.0);
|
||||
|
||||
prand = sqrt(-2.0*log(rand1*rand1+rand2*rand2)/(rand1*rand1+rand2*rand2));
|
||||
*dvmag = rand1*prand*sqrt(pow(0.02,2) + pow(0.07*pow(10.0, 0.4*(*vmag-25.0)),2));
|
||||
dbmag = rand2*prand*sqrt(pow(0.02,2) + pow(0.07*pow(10.0, 0.4*(*vmag-25.0)),2));
|
||||
*dBV = *dvmag + dbmag;
|
||||
}
|
||||
else
|
||||
{
|
||||
*vmag = 9999.9;
|
||||
*abvmag = 9999.9;
|
||||
*BV = 9999.9;
|
||||
*dvmag = 0.0;
|
||||
*dBV = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*Teff = 0.0;
|
||||
*vmag = 9999.9;
|
||||
*abvmag = 9999.9;
|
||||
*BV = 9999.9;
|
||||
*dvmag = 0.0;
|
||||
*dBV = 0.0;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue