void PIC::Boris_uxy(Grid2D& Bx, Grid2D& By, double dt) { long j; double tx, ty, tabs2, Bxj, Byj, Babs, u2, gamma, ux0, uy0, uz0; for(j=0; j<part.size(); j++) { Bxj=Bx.Grid2PIC(part[j].x,part[j].y); Byj=By.Grid2PIC(part[j].x,part[j].y); Babs=sqrt(pow(Bxj,2)+pow(Byj,2)); u2=pow(part[j].uy,2)+pow(part[j].ux,2)+pow(part[j].uz,2); gamma=sqrt(1.0+u2/pow(clight,2)); ux0=part[j].ux;uy0=part[j].uy;uz0=part[j].uz; if (Babs > 0.0) { tx=Bxj/Babs*tan(charge_p*dt*Babs/(2.0*gamma*mass_p)); ty=Byj/Babs*tan(charge_p*dt*Babs/(2.0*gamma*mass_p)); } else {tx=0.0; ty=0.0;} tabs2=pow(tx,2)+pow(ty,2); part[j].ux+=-part[j].uz*ty; part[j].uy+=part[j].uz*tx; part[j].uz+=part[j].ux*ty-part[j].uy*tx; part[j].ux=ux0-part[j].uz*ty*2.0/(1.0+tabs2); part[j].uy=uy0+part[j].uz*tx*2.0/(1.0+tabs2); part[j].uz=uz0+part[j].ux*ty*2.0/(1.0+tabs2)-part[j].uy*tx*2.0/(1.0+tabs2); } }
void Pic::kick(Grid2D& Ex, Grid2D& Ey, double ds){ double beta0 = SP->beta0, gamma0 = SP->gamma0, A = SP->A, Z = SP->Z; double temp = qe*Z/(mp*A*pow(gamma0, 3)*pow(beta0*clight, 2))*ds; double ex, ey; for(long j=0; j < pics.size(); ++j){ ex = temp*Ex.Grid2PIC(pics[j].x, pics[j].y); ey = temp*Ey.Grid2PIC(pics[j].x, pics[j].y); //momenta: pics[j].xs += ex; pics[j].ys += ey; } }
double PIC::total_energy(Grid2D& pot) { long j, n=part.size(); double ekin=total_kinetic_energy(); double epot=0.0; for(j=0; j<n; j++) epot+=macroN*pot.Grid2PIC(part[j].x,part[j].y); return ekin+epot; }