Program for for finding average potentials in region of a mesh, flat strips, used in conjunction with xmpl3d29.dat

 

This can be copied from the end of file xmpl3d29.dat, which is supplied with the CPO3D package.

 

 

Program used to extract vm, vc and ec from the output data file

(in Fortran):

C Program for finding average potentials in region of a mesh, flat strips

C Used in conjunction with xmpl3d29.dat

DIMENSION a(201) , avx(201)

CHARACTER phrase1*1 , phrase3*3

n = 20

C -must be even

OPEN (UNIT=1,FILE='temp29a.dat',STATUS='OLD')

C =trajectory output file

OPEN (UNIT=2,FILE='tempres.dat',STATUS='UNKNOWN')

C =results file

100 READ (1,'(A3)') phrase3

IF (phrase3.NE.'Tot') GOTO 100

READ (1,'(A1)') phrase1

C The results give the potential along rows of x, for successive y, for z=0

C Integrate over each row, using Simpsons rule, then add results of the

C y values, again using Simpsons rule

C The first point in each row is not given in the output file. It is 0,

C the potential at the wire

total = 0.

DO iy = 1 , n

C Integrate over the row of x values, at constant y:

DO i = 1 , n

READ (1,*) a(i)

ENDDO

avx(iy) = a(n)

C =end points (remembering that the first end point is 0)

DO i = 1 , (n-1) , 2

avx(iy) = avx(iy) + 4.*a(i)

C =odd points

ENDDO

DO i = 2 , (n-2) , 2

avx(iy) = avx(iy) + 2.*a(i)

C =even points

ENDDO

avx(iy) = avx(iy)/3.

C =Simpson integration, for unit spacing

avx(iy) = avx(iy)/real(n)

C =average for this row

ENDDO

C Integrate over the y values:

av = avx(n)

C =end points (remembering that the first end point is 0)

DO i = 1 , (n-1) , 2

av = av + 4.*avx(i)

C =odd points

ENDDO

DO i = 2 , (n-2) , 2

av = av + 2.*avx(i)

C =even points

ENDDO

av = av/(3.*real(n))

C =average for the area (0.5)**2

WRITE (2,'(F10.6)') av

C Finally, read pot and field at centre:

DO i = 1 , 6

READ (1,'(A1)') phrase1

ENDDO

READ (1,*) (a(i), i = 1 , 4)

pot = a(4)

DO i = 1 , 6

READ (1,'(A1)') phrase1

ENDDO

READ (1,*) (a(i), i = 1 , 6)

field = a(6)

WRITE (2,'(2F10.6)') pot , field

STOP

END