Research Article

Development of the Object-Oriented Dynamic Simulation Models Using Visual C++ Freeware

Algorithm 2

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