| 1.2 #pragma once |
| 2.2 #include"field.h" |
| 3.2 #include"rk4_4eq.h" |
| 4.2 #include<vector> |
| 5.2 |
| 6.2 class Particle |
| 7.2 public: |
| 8.2 static const double m, q; //mass and charge of a particle |
| 9.2 double W0, W, v; |
| 10.2 double t, z, y, vz, vy; |
| 11.2 struct Data |
| 12.2 double t, z, y, vz, vy, v, W; |
| 13.2 currentData; |
| 14.2 double fz, fy; //components of an electric force |
| 15.2 double dz, dy; //spacing of the field grid along z and y axes |
| 16.2 static Field* pF; |
| 17.2 double uLeft, uRight, uTop, uBottom; |
| 18.2 double yCellTop, yCellBottom, zCellLeft, zCellRight; |
| 19.2 int iTopLeft, jTopLeft; |
| 20.2 vector<Data> history; |
| 21.2 double kVy; |
| 22.2 bool stop; |
| 23.2 Particle(double W0 = 25., double kVy = 0.): W0(W0), W(W0), |
| 24.2 t(0.), z(0.), y(0.), kVy(kVy), fz(0.), fy(0.), |
| 25.2 v(sqrt(2./m*W0*1.6022e-19)), |
| 26.2 vz(v/sqrt(1.+kVy*kVy)), vy(kVy*vz), stop(false) |
| 27.2 dy = dz = pF->h; |
| 28.2 zCellLeft = zCellRight = 0.; |
| 29.2 if(y == 0) |
| 30.2 yCellTop = yCellBottom = 0.; |
| 31.2 |
| 32.2 void FzFy(); //computing the force components fy and fz |
| 33.2 double DzDt() return vz; |
| 34.2 double DyDt() return vy; |
| 35.2 double DvzDt() return 1./m*fz; |
| 36.2 double DvyDt() return 1./m*fy; |
| 37.2 ; |
| 38.2 const double Particle::m = 1.6726e-27; //kg |
| 39.2 const double Particle::q = 1.6022e-19; //C (Coulomb) |
| 40.2 Field* Particle::pF = NULL; |