Program for deducing potentials and fields at a flat mesh of parallel flat strips (test2d18.dat).

 

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

 

 

Program used to deduce vm, vc and ec from the results in the output data

file (tmp18a.dat):

C Program for finding average potentials in region of a mesh

C Used in conjunction with test2d18.dat

DIMENSION a(201)

CHARACTER dummy*6

n = 100

w = 0.05

C =half-width of a strip

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

C =trajectory output file

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

C =results file

C Read unwanted lines:

100 READ (1,'(A6)') dummy

IF (dummy.NE.' x') GOTO 100

C The results give the potential along x for constant y

C Integrate over x, 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

DO iz = 1 , 1

C -corresponds to z=0

C Integrate over x:

DO i = 1 , n

READ (1,*) dummy1 , dummy2 , a(i)

ENDDO

avx = a(n)

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

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

avx = avx + 4.*a(i)

C =odd points

ENDDO

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

avx = avx + 2.*a(i)

C =even points

ENDDO

avx = avx/3.

C =Simpson integration, for unit spacing

avx = avx/real(n)

C =average for this row

C =average from x=0 to x=0.5-w

avx = avx*(1.-2.*w)

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

DO i = 1 , 5

READ (1,'(A1)') dummy

ENDDO

ENDDO

C Finally, read pot and field at centre:

READ (1,'(A1)') dummy

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

pot = a(3)

field = a(5)

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

STOP

END