removed many ifdefs blocks and associated included c files

This commit is contained in:
Yohai Meiron 2020-03-05 17:00:13 -05:00
parent e9455c0a0e
commit dd77ecde75
6 changed files with 5 additions and 2895 deletions

76
cmd.c
View file

@ -1,76 +0,0 @@
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);
}

View file

@ -1,38 +0,0 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
void DEF_DEN(double x_gas[][3], double m_gas[], double h_gas[], int sosed_gas[][NB], double DEN_gas[])
{
double Xij, Yij, Zij, Rij, tmp;
/* SPH style */
for(i=0;i<N_GAS;i++)
{
tmp = 0.0;
for(k=0;k<NB;k++)
{
j = sosed_gas[i][k];
Xij = x_gas[i][0]-x_gas[j][0];
Yij = x_gas[i][1]-x_gas[j][1];
Zij = x_gas[i][2]-x_gas[j][2];
Rij = sqrt( Xij*Xij + Yij*Yij + Zij*Zij );
tmp = tmp + 0.5 * m_gas[j] * ( W(Rij,h_gas[i]) + W(Rij,h_gas[j]) );
} /* j */
DEN_gas[i] = tmp;
} /* i */
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/

View file

@ -1,74 +0,0 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
void DEF_DEN_STAR(double x_star, double y_star, double z_star, double x_gas[][3], double m_gas[], double h_gas[], double *DEN_star)
{
//int NB_STAR=0;
//int sosed_tmp[N_GAS_MAX];
double Xij, Yij, Zij, Rij, tmp=0.0, tmp2;
/* DEF DEN dlja odnoj STAR chastici */
//NB_STAR = 0;
tmp = 0.0;
tmp2 = 0.0;
for(j=0;j<N_GAS;j++) // GAS
{
tmp2 = SQR(x_star) + SQR(y_star);
if( (ABS(z_star) < 1e-2) && (tmp2 < 0.2) ) // zamenity na h & (2*R0)^2 = 0.1936
{
Xij = x_star - x_gas[j][0];
Yij = y_star - x_gas[j][1];
Zij = z_star - x_gas[j][2];
Rij = sqrt(Xij*Xij + Yij*Yij + Zij*Zij);
if( Rij < (2.0*h_gas[j]) )
{
// sosed_tmp[NB_STAR] = j;
// NB_STAR++;
tmp = tmp + m_gas[j] * W(Rij,h_gas[j]);
}
}
// sosed_tmp[j] = j;
} /* j */
//printf("%06d \t %.8E \n",NB_STAR, tmp);
// my_sort(0, N-1, d, sosed_tmp);
// tmp = my_select(0, N_GAS-1, NB-1, d, sosed_tmp); d[NB-1] = tmp;
/* SPH style */
/*
tmp = 0.0;
for(k=0;k<NB_STAR;k++)
{
j = sosed_tmp[k];
Rij = sqrt(d[k]);
tmp = tmp + m[j] * W(Rij,h_gas[j]);
}
*/
*DEN_star = tmp;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/

85
def_H.c
View file

@ -1,85 +0,0 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
double W(double Rij, double h)
{
double v, v2, v3, tmp=0.0;
v = Rij/h; v2 = v*v; v3 = v*v*v;
if( (v >= 0.0) && (v <= 1.0) )
{
tmp = 1.0 - 1.5*v2 + 0.75*v3;
}
else
{
if( (v > 1.0) && (v < 2.0) )
{
tmp = 0.25*(2.0-v)*(2.0-v)*(2.0-v);
}
else
{
tmp = 0.0; /* if ( v >= 2.0 ) */
}
}
tmp = 1.0/(Pi*h*h*h)*tmp;
return(tmp);
}
/*************************************************************************/
void DEF_H(double x_gas[][3], double h_gas[], int sosed_gas[][NB])
{
int sosed_tmp[N_GAS_MAX];
double Xij, Yij, Zij;
for(i=0;i<N_GAS;i++)
{
for(j=0;j<N_GAS;j++)
{
Xij = x_gas[i][0]-x_gas[j][0];
Yij = x_gas[i][1]-x_gas[j][1];
Zij = x_gas[i][2]-x_gas[j][2];
d[j] = Xij*Xij + Yij*Yij + Zij*Zij;
sosed_tmp[j] = ind_gas[j];
} /* j */
my_sort(0, N_GAS-1, d, sosed_tmp);
// tmp = my_select(0, N_GAS-1, NB-1, d, sosed_tmp); d[NB-1] = tmp;
h_gas[i] = sqrt( d[NB-1] )*0.5;
for(k=0;k<NB;k++) sosed_gas[i][k] = sosed_tmp[k];
/*
h_gas[i] = MAX(h_gas[i], h_min);
h_gas[i] = MIN(h_gas[i], h_max);
*/
/*
tmp_l = ldiv(i, N/64);
if(tmp_l.rem == 0)
{
printf(".");
fflush(stdout);
}
*/
} /* i */
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/

View file

@ -1,185 +0,0 @@
/*****************************************************************************
File Name : "Drag Force.c"
Contents : Drag force calculus.
: Converted & optimized from Chingis Omarov Fortran code.
Coded by : Taras Panamarev,
: Denis Yurin, Maxim Makukov & Peter Berczik :-)
Last redaction : 2012-11-15 15:33
*****************************************************************************/
// main parameters
const double Md = 0.01;
const double s=4, beta_s=0.7, alpha=0.75, h=0.001;
const double r_lim2=(0.5*0.5), h_lim2=(5e-3*5e-3);
const double gradP_rho = 0.90; // account for -grad(P)/rho in gas disk...
const double Qtot = 0.01; // 16e3
/*
const double Qtot = 0.00547000; // 8e3
const double Qtot = 0.00296975; // 16e3
const double Qtot = 0.00193372; // 32e3
const double Qtot = 0.00054215; // 128KB
*/
int K;
double RDISC, //projection of radius vector to the disc plane
h_z, // disc profile
RDISC2, Z2, RDISC_3over2, R, RR0, RR02, RR0_s, RDISC_5over2, R_zeta, R0_zeta, RRcrit, RRcrit_zeta,Rcrit_zeta, R_zetaR,
inner_hole, temp, sqrt_m_bh, pot_drag,
sigma0, R02, hR02, Rcrit, R0, zeta,
R_DOT, //the first derivative of absolute value of projection
COEFDENS,
RHO, RHODOT, //disc density and it's firs derivative with respect to time
VXDISC, VYDISC,//disc particle velocity components
VXRE, VYRE, VZRE, VRE,//the absolute value of relative (star-disc) velocity and it's components
coef,
FDRAGX, FDRAGY, FDRAGZ,//drag force components
DVXRE, DVYRE, DVZRE, DVRE,//first derivative of relative velocity and it's absolute value
KFDOT;
void init_drag_force()
{
R0 = R_0;
Rcrit = R_CRIT;
sigma0 = (2-alpha)*Md/(TWOPi*sqrt_TWOPi*h*R0);
R02 = SQR(R0);
hR02 = SQR(h*R0);
}
void calc_drag_force()
{
if (min_t < t_diss_on) return;
// if (min_t == t_diss_on) init_drag_force();
init_drag_force();
for (i=0; i<n_act; i++)
{
K = ind_act[i];
RDISC2 = SQR(x_act_new[i][0]) + SQR(x_act_new[i][1]);
Z2 = SQR(x_act_new[i][2]);
if( (RDISC2 < r_lim2) && (Z2 < h_lim2) )
{
RDISC2 = SQR(x_act_new[i][0]) + SQR(x_act_new[i][1]);
R = sqrt(RDISC2 + SQR(x_act_new[i][2]));
RDISC = sqrt(RDISC2);
R_DOT = ( x_act_new[i][0]*v_act_new[i][0] + x_act_new[i][1]*v_act_new[i][1] )/RDISC;
RR0 = RDISC/R0;
RR02 = SQR(RR0);
// RR0_s = pow(RR0, s);
RR0_s = SQR(RR02);
RRcrit = RDISC/Rcrit;
/*
if (RDISC < Rcrit) zeta = 1; else zeta = 0;
RRcrit_zeta = pow(RRcrit, zeta);
R_zeta = pow(RDISC, -2*zeta);
R0_zeta = pow(R0, -2*zeta);
Rcrit_zeta = pow(Rcrit, -2*zeta);
*/
if (RDISC < Rcrit)
{
zeta = 1;
RRcrit_zeta = RRcrit;
R_zeta = 1.0/RDISC2;
R0_zeta = 1.0/R02;
Rcrit_zeta = 1.0/SQR(Rcrit);
}
else
{
zeta = 0;
RRcrit_zeta = 1.0;
R_zeta = 1.0;
R0_zeta = 1.0;
Rcrit_zeta = 1.0;
}
R_zetaR = R_zeta/R;
COEFDENS = pow(RR0, -alpha) * exp(-beta_s*RR0_s)/RRcrit_zeta;
RHO = sigma0*COEFDENS*exp(-Z2/(2.0*hR02*SQR(RRcrit_zeta)));
RHODOT = - R_DOT*(zeta+alpha+beta_s*s*RR0_s )/RDISC
- (v_act_new[i][2]*x_act_new[i][2]*R_zeta-zeta*R_zetaR*Z2*R_DOT)/(hR02*Rcrit_zeta);
RDISC_3over2 = sqrt(RDISC2*RDISC);
RDISC_5over2 = RDISC_3over2*RDISC;
sqrt_m_bh = sqrt(m_bh);
sqrt_m_bh *= gradP_rho; // account for -grad(P)/rho in gas disk...
VXDISC = -sqrt_m_bh * x_act_new[i][1]/RDISC_3over2;
VYDISC = +sqrt_m_bh * x_act_new[i][0]/RDISC_3over2;
VXRE = VXDISC - v_act_new[i][0];
VYRE = VYDISC - v_act_new[i][1];
VZRE = - v_act_new[i][2];
VRE = sqrt( SQR(VXRE) + SQR(VYRE) + SQR(VZRE) );
coef = Qtot*RHO*VRE;
FDRAGX = coef*VXRE;
FDRAGY = coef*VYRE;
FDRAGZ = coef*VZRE;
DVXRE = -sqrt_m_bh * v_act_new[i][1]/RDISC_3over2
+sqrt_m_bh * 1.5*x_act_new[i][1]*R_DOT/RDISC_5over2
-a_act_new[i][0];
DVYRE = +sqrt_m_bh * v_act_new[i][0]/RDISC_3over2
-sqrt_m_bh * 1.5*x_act_new[i][0]*R_DOT/RDISC_5over2
-a_act_new[i][1];
DVZRE = -a_act_new[i][2];
DVRE = (VXRE*DVXRE + VYRE*DVYRE + VZRE*DVZRE)/VRE;
KFDOT = Qtot*RHO;
adot_drag[K][0] = KFDOT*(RHODOT*VXRE*VRE + DVRE*VXRE + DVXRE*VRE);
adot_drag[K][1] = KFDOT*(RHODOT*VYRE*VRE + DVRE*VYRE + DVYRE*VRE);
adot_drag[K][2] = KFDOT*(RHODOT*VZRE*VRE + DVRE*VZRE + DVZRE*VRE);
pot_drag = -0.5*( (a_drag[K][0]+FDRAGX)*(x_act_new[i][0]-x_act[i][0]) +
(a_drag[K][1]+FDRAGY)*(x_act_new[i][1]-x_act[i][1]) +
(a_drag[K][2]+FDRAGZ)*(x_act_new[i][2]-x_act[i][2]) );
E_sd += m[K]*pot_drag;
a_drag[K][0] = FDRAGX;
a_drag[K][1] = FDRAGY;
a_drag[K][2] = FDRAGZ;
}
else
{
adot_drag[K][0] = 0.0;
adot_drag[K][1] = 0.0;
adot_drag[K][2] = 0.0;
a_drag[K][0] = 0.0;
a_drag[K][1] = 0.0;
a_drag[K][2] = 0.0;
} /* if( (RDISC2 < r_lim2) && (Z2 < h_lim2) ) */
} /* i */
}
/***************************************************************/
/***************************************************************/
/***************************************************************/

File diff suppressed because it is too large Load diff