void IS_Taylor(double ****OLP, double ****IOLP, int rlmax_IS) { static int ct_AN,Taylor_switch; static int wan,tno1,i,ig,ino1,k,p,q; static double dum1,dum2,dum; Taylor_switch = rlmax_IS; Taylor(Taylor_switch,OLP,IOLP); /**************************************************** Averaging of IOLP ****************************************************/ for (ct_AN=1; ct_AN<=atomnum; ct_AN++){ wan = WhatSpecies[ct_AN]; tno1 = Spe_Total_NO[wan] - 1; for (i=1; i<=(FNAN[ct_AN]+SNAN[ct_AN]); i++){ ig = natn[ct_AN][i]; ino1 = Spe_Total_NO[WhatSpecies[ig]] - 1; k = RMI2[ct_AN][i][0]; for (p=0; p<=tno1; p++){ for (q=0; q<=ino1; q++){ dum1 = IOLP[ct_AN][i][p][q]; dum2 = IOLP[ig][k][q][p]; dum = 0.50*(dum1 + dum2); IOLP[ct_AN][i][p][q] = dum; IOLP[ig][k][q][p] = dum; } } } } }
HDINLINE picongpu::float_32 operator()(const vector_64& n, const Particle & particle) const { // 1/gamma^2: const picongpu::float_64 gamma_inv_square(particle.get_gamma_inv_square<When::now > ()); //picongpu::float_64 value; // storage for 1-\beta \times \vec n // if energy is high enough to cause numerical errors ( equals if 1/gamma^2 is close enough to zero) // chose a Taylor approximation to to better calculate 1-\beta \times \vec n (which is close to 1-1) // is energy is low, then the approximation will cause a larger error, therefor calculate // 1-\beta \times \vec n directly // with 0.18 the relative error will be below 0.001% for a Taylor series of 1-sqrt(1-x) of 5th order if (gamma_inv_square < picongpu::GAMMA_INV_SQUARE_RAD_THRESH) { const picongpu::float_64 cos_theta(particle.get_cos_theta<When::now > (n)); // cosine between looking vector and momentum of particle const picongpu::float_64 taylor_approx(cos_theta * Taylor()(gamma_inv_square) + (1.0 - cos_theta)); return (taylor_approx); } else { const vector_64 beta(particle.get_beta<When::now > ()); // calculate v/c=beta return (1.0 - beta * n); } }
void plot(int num){ double i; gfx_color(255,0,255); for(i = -10; i<= 10; i+=.005){ gfx_point((i*25)+250,(Taylor(i,num)*-25)+250); } }
HDINLINE numtype1 operator()(const vec2& n, const Particle & particle) const { // 1/gamma^2: const numtype2 gamma_inv_square(particle.get_gamma_inv_square<When::now > ()); //numtype2 value; // storage for 1-\beta \times \vec n // if energy is high enough to cause numerical errors ( equals if 1/gamma^2 is closs enought to zero) // chose a Taylor approximation to to better calculate 1-\beta \times \vec n (which is close to 1-1) // is energy is low, then the Appriximation will acuse a larger error, therfor calculate // 1-\beta \times \vec n directly if (gamma_inv_square < 0.18) // with 0.18 the relativ error will be below 0.001% for Taylor series of order 5 { const numtype2 cos_theta(particle.get_cos_theta<When::now > (n)); // cosinus between looking vector and momentum of particle const numtype2 taylor_approx(cos_theta * Taylor()(gamma_inv_square) + (1.0 - cos_theta)); return (taylor_approx); } else { const vec2 beta(particle.get_beta<When::now > ()); // calc v/c=beta return (1.0 - beta * n); } }
int main (void) { puts ("\tTaylor\n"); printf("%wywolanie funkcji %0.1f\n", Taylor(1)); return 0; }