• No results found

Particle Pushing Subroutine

This is the subroutine that calculates the new position and velocities of the particles and then uses these to calculate the new density and current density moments on the grid.

The first step of this subroutine sets all the moment arrays to zero. To solve for the new particle positions and velocities the electric and magnetic fields must be known at the particle positions. To simplify this calculation all the field components are interpolated to the full integer grid points. As an example of this consider the following example lines from the code which says

do iz=1,nz do ix=2,nx

exh(ix,iz)=0.5*(ex(ix,iz)+ex(ix-1,iz)) enddo

enddo

Thex component of the electric field is defined on the grid at half integer grid points in x and full integer grid points inzdirections. The lines of code above show that this component of the electric field is interpolated so it is known at the full integer grid point for bothxandz where exh is the interpolated value of the x component of the electric field. The same procedure is followed for the other electric and magnetic field components. An illustration of this process for thexcomponent of the electric field is shown in Figure4.3.

Figure 4.3: An illustration to show how the field components on half integer grid points are inter- polated to the full integer grid points for the particle move subroutine. Thisxcomponent of the electric field is used as an example which is located on half integer grid points in thexdirection.

The next step is to get the fields at the particle locations. For each individual particle its position is found. To calculate the interpolation factors the next lowest index of the nearest grid point is calculated and hence the distance in thexandzdirections between the particle and the position of the four nearest grid points. These lengths are used to calculate the area weightings which are used to interpolate the fields on the grid points to the particle position. Figure4.4 shows graphically how this is done and which interpolation factor multiplies which grid point’s field value. The black

circle represents the particle. It can be seen clearly that it is the opposite area to the grid point which multiplies the field value at that grid point. This is emphasised where the coloured areas correspond to the colours of the grid points for which that area weighting is used. Once the fields

Figure 4.4: An illustration to show the interpolation of the fields to the particle positions for the particle move subroutine.

have been interpolated to the particle positions then the velocities are advanced by integrating the equation of motion, dv dt = qs ms (E+v×B). (4.27)

The difference equation that must be solved is

vt+∆t−vt

∆t = qs ms

(E+vt+∆2t ×B), (4.28)

which can be written in the form,

vt+∆t=vt+β

α(E+ (αv

t+∆t+ (1α)vt)×B), (4.29)

whereαis an implicit factor andvt+∆2t has been rewritten as

vt+∆2t =αvt+∆t+ (1−α)vt, (4.30) where β α = qs ms ∆t. (4.31)

This can then be rewritten as

vt+∆t−βvt+∆t×B=vt+β

α(E+ (1−α)v

t×B) =T, (4.32)

which can be rearranged to give

vt+∆t×B= 1

β(v

t+∆tT). (4.33)

Taking the cross product of this equation withBthis becomes

vt+∆t×B+βvt+∆tB2 =T×B. (4.34)

This in turn implies that

vt+∆t+β2vt+∆tB2=βT×B+T. (4.35)

Splitting upvt+∆tinto parallel and perpendicular components this can be written as

vtk+∆t+vt+∆t(1 +β2B2) =βT×B+T. (4.36) Now taking the cross product of this again withBthis equation becomes

vt+∆t×B= 1

(1 +β2B2)(β(T×B)×B+T×B). (4.37) Finally, substituting into Eq. (4.33) and expanding the triple vector product the expression for

vt+∆tis

vt+∆t=T+ β

(1 +β2B2)(−β(TB

2B(T·B)) +T×B). (4.38) The new velocities are used to advance the particle positions. The difference equations for this step are given by

xt+∆t = xt+vxt+∆t∆t (4.39)

zt+∆t = zt+vzt+∆t∆t. (4.40)

The only thing left to do is to make sure the boundary conditions are satisfied. In the examples considered in the next chapter two different sets of boundary conditions are used. In the Harris sheet cases the boundary conditions in the x direction are periodic and in the z direction the particles are specularly reflected at the boundaries. Illustrations of these two boundary conditions are shown in Figure4.5. In examples using periodic equilibria as initial conditions the boundary conditions are doubly periodic so that thezboundary is periodic as well.

Figure 4.5: An illustration to show the boundary conditions for the particle positions

The second part of the particle move subroutine is to use the new positions and velocities of the particles to calculate the 1st and 2nd order moments for each particle species at the grid points. This is done in a similar way to the particle move calulation except that now the new particle positions and velocities are used to calculate and interpolate the new number densities and average drift velocities to the grid points. The weightings for each grid point are exactly the same as shown in Figure4.4. The actual quantities calculated by the code are essentially the following first and second order moments for each species.

ns = Z ∞ −∞ fsd3v, (4.41) nshvis = Z ∞ −∞ vfsd3v. (4.42)

To calculate the new densities and average drift velocities on the grid points you sum over each particle species finding the position and velocity of each particle and then using the area weight- ings shown in Figure4.4to allocate the number density and average drift velocity contribution at each grid point.

In all cases the boundary conditions in thexdirection are periodic. It is important to note though that the way the densities are gathered on the grid the outer cells only receive half the total density. So assuming symmetry the amount the outer cells receive is just doubled. The boundary conditions on thezboundary for the Harris sheet cases is that the densities atiz=2 andiz=nz are set to the densities atiz=3 andiz=nz-1 . On the zboundary the velocities are set to zero. In the case of a periodic initial condition the boundary conditions on thezboundary are periodic.

Related documents