/* Get parameters according to the canonical two-disk model of those two guys who made a two-disk model...shit, what are their names? Regardless, can check Mao et al., 2015, for the functional form that is used throughout this project. */ void get_params( PARAMS *p, unsigned long int N ){ /* Integral of thick and thin density functions */ double z_thin_integral; double r_thin_integral; double z_thick_integral; double r_thick_integral; /* combined integral terms */ double thin_term; double thick_term; /* normalization of density */ double density_const; /* Disk params */ p->z0_thin = 0.233; p->r0_thin = 2.34; p->z0_thick = 0.674; p->r0_thick = 2.51; p->ratio = 0.1; /* Generous sized geometric sample limits */ /* Use to make stars only roughly in solar neighbordhood */ p->r_min = 4.5; p->r_max = 11.5; p->z_min = 0.0; p->z_max = 3.1; p->phi_max = atan(0.5); p->phi_min = -p->phi_max; p->phi_min += M_PI; p->phi_max += M_PI; p->phi_range = p->phi_max - p->phi_min; /* Partial integrals */ z_thin_integral = integrate_Z(p->z0_thin, p->z_min, p->z_max); r_thin_integral = integrate_R(p->r0_thin, p->r_min, p->r_max); z_thick_integral = integrate_Z(p->z0_thick, p->z_min, p->z_max); r_thick_integral = integrate_R(p->r0_thick, p->r_min, p->r_max); /* PDF normalizations */ p->z0_pdf_norm_thin = 1.0 / z_thin_integral; p->r0_pdf_norm_thin = 1.0 / r_thin_integral; p->z0_pdf_norm_thick = 1.0 / z_thick_integral; p->r0_pdf_norm_thick = 1.0 / r_thick_integral; /* Get number of stars in each disk */ /* extra factor of 2 accounts for symmetry about MW plane */ /* thin and thick integrals */ thin_term = 2.0 * z_thin_integral * r_thin_integral * p->phi_range; thick_term = 2.0 * p->ratio * z_thick_integral * r_thick_integral * p->phi_range; /* normalize to get density constant */ density_const = (double)N / (thin_term + thick_term); /* get stars in thin disk */ long double temp = density_const * thin_term; p->N_thin = (unsigned long int)temp; /* get stars in thick disk */ /* add 1 to account for int roundoff */ temp = density_const * thick_term; p->N_thick = (unsigned long int)temp + 1; fprintf(stderr, "%lu stars in the thin disk. \n", p->N_thin); fprintf(stderr, "%lu stars in the thick disk. \n", p->N_thick); fprintf(stderr, "%lu total stars. \n", p->N_thin + p->N_thick); }
int main() { std_setup(); int n=6; double a=1.0; transform_args args( a,n,0 ); { double xi_f = 10.0; int N = 500; double h = xi_f/N; double *rp = ml_alloc<double> (2*N+1); double *ip = ml_alloc<double> (2*N+1); double *xi = ml_alloc<double> (2*N+1); for ( int j=-N; j<=N; j++ ) { args.xi = h*j; xi[j+N] = args.xi; rp[j+N] = integrate_R ( real_part, (void *)(&args) ); ip[j+N] = integrate_R ( imag_part, (void *)(&args) ); } output( xi, rp, ip, 2*N+1, "/workspace/output/temp/FTF" ); } //--------------------- { double xf = 10.0; int N = 500; double h = xf/N; double *F = ml_alloc<double> (2*N+1); double *X = ml_alloc<double> (2*N+1); for ( int j=-N; j<=N; j++ ) { double x = h*j; X[j+N] = x; F[j+N] = exp(-a*x*x)*pow(x,n); } output( X, F, 2*N+1, "/workspace/output/temp/F" ); } //----------------------- { double xi_f = 10.0; int N = 500; double h = xi_f/N; double *FTR = ml_alloc<double> (2*N+1); double *FTI = ml_alloc<double> (2*N+1); double *Xi = ml_alloc<double> (2*N+1); ml_poly<double > P0(n); P0 = 0.0; ml_poly<double > P1(n); P1 = 0.0; ml_poly<double > P2(n); P2 = 0.0; ml_poly<double > P3(n); P3 = 0.0; for ( int k=0; k<=n; k++ ) { if (k%4 == 0) P0[k] = binom(n,k)*dfact2n_n[n-k]*sqrtpi*pow(a,-n)*pow(2.0,k-2*n); if (k%4 == 1) P1[k] = binom(n,k)*dfact2n_n[n-k]*sqrtpi*pow(a,-n)*pow(2.0,k-2*n); if (k%4 == 2) P2[k] = binom(n,k)*dfact2n_n[n-k]*sqrtpi*pow(a,-n)*pow(2.0,k-2*n); if (k%4 == 3) P3[k] = binom(n,k)*dfact2n_n[n-k]*sqrtpi*pow(a,-n)*pow(2.0,k-2*n); } ml_poly<double > PR(n); P0 = 0.0; ml_poly<double > PI(n); P1 = 0.0; PR = P0; PR -= P2; PI = P1; PI-= P3; for ( int j=-N; j<=N; j++ ) { double xi = h*j; Xi[j+N] = xi; FTR[j+N] = exp(-xi*xi/(a*4))*PR(xi); FTI[j+N] = exp(-xi*xi/(a*4))*PI(xi); } output( Xi, FTR, FTI, 2*N+1, "/workspace/output/temp/test" ); } std_exit(); }