Anda di halaman 1dari 35

program he_sim7

*
* Program to generate a SimIon 7 geometry file for a HEEPS-E detector from
* geometry parameters. Author Kevin G. Rhoads, started July 2005.
*
* SAVE SOURCE FILE WITHOUT TAB CONVERSION
*
*---------------------------------------------------------------------* Version 1.123 Thursday July 12, 2007 - further refine BEEPS model
* Version 1.121 Tuesday May 8, 2007 - refine BEEPS model
* Version 1.113 Monday April 30, 2007 - First ions through a BEEPS model
* Version 1.099 Tuesday April 24, 2007 - clean-up, get magnetic stuff started
* Version 1.092 Monday April 23, 2007 - HT/HM/BT screens & screen locations
* Version 1.083 Wednesday April 4, 2007 - First BT screen
* Version 1.081 Monday April 2, 2007 - More BT stuff, more ION stuff
* Version 1.068 Thusday March 29, 2007 - HE/HT/HM/HH*/BT* defaults setups added (* placeholders)
* Version 1.067 Wednesday March 28, 2007 - Grounded Screen, Magnet Electrodes & Magnetic Fields
* Version 1.062 Wednesday March 21, 2007 - Filenames, defaults for differin detectors
* Version 1.057 Tuesday March 13, 2007 - Use of .GEM file
* Version 1.055 Tuesday March 13, 2007 - scaling related issues & Upper & Lower gammas
*------------------------ 2006 -> 2007
* Version 1.053 Sunday July 23, 2006 - fixing some consistency checks, preparing for non-integer output
*------------------------ 2005 -> 2006
* Version 1.051 Wednesday July 27, 2005
* Version 1.048 Tuesday July 26, 2005 - removing unused (formerly used) variables
* Version 1.044 Tuesday July 26, 2005 - fixed problem of change to theta, gamma not showing in thetaRad, gammaRad
* Version 1.043 Tuesday July 26, 2005 - removed small geometry glitch just above lower TopHat near entry to analyzer
* Version 1.042 Tuesday July 26, 2005 - user input to override parameters
* Version 1.037 Monday July 25, 2005 - First version to (apparently) get it all right
* Version 0.030 Monday July 25, 2005 - first to get Top Hat reasonably correct
* Version 0.020 Friday July 22, 2005 - first to generate three electrodes, nearly correct, HE_BIG2.FOR
* Version 0.011 Thursday July 21, 2005 - first to generate inner hemisphere electrode from default values, HE_BIG1.FOR
*---------------------------------------------------------------------* To Do (no particular order)
* (.F67, partial) Change output filename at run time
* read parameter file, generate .GEM
* (.F50, done) make TopHat top electrode to inner hemisphere spacing a variable, not fixed to two delta
* (.F67, done) add electrode under hemisphere for ION Heepses
* add lower cutoff angle for non-stretched TopHat
* add more comments
* (.F48, done) remove unused variables and old code
*
*---------------------------------------------------------------------* Declarations
*----*
*; Rs - Radius of "stretch" cylinder, nominal 67, range 0->
*; Ri - a.k.a., R1; inner radius of analyzer, nominal 604, range 0->

*; Ro - a.k.a., R2; outer radius of analyzer, nominal 659, range Ri->


*; theta - angle up from exit plane to analyser entrance, nominal 74 degrees,
*; gamma - (sometimes alpha) angle of entrance electrodes from parallel, nominal 6 degrees
*; offset - distance from exit plane to bottom of simulation region, nominal 400
*; HatRad - radius of "Top Hat", nominal Ro+1*delta (i.e., Ro1d)
*; NumPnts - Number of array points per axis, nominal 1001
*
*; hold default values for associated variables
$include:'def.inc'
*;------------ derived parameters
$include:'wrk.inc'
*--$include:'iw.inc'
integer itemp
*--*--*; delta = (Ro - Ri)
*; h = Ri*sin(theta)
*; hplus = 2*delta + Ri*sin(theta)
*; Wi = Ri*cos(theta)
*; Hi = Ri*sin(theta) [alias for h]
*; Wo = Ro*cos(theta)
*; Ho = Ro*sin(theta)
*; WSi = Rs + Ri*cos(theta)
*; WSo = Rs + Ro*cos(theta)
*; RoPlus = Ro + 2*delta
*; RiRs = Ri + Rs
*; RoRs = Ro + Rs
*; RoPlRs = RoPlus + Rs
*; hBlend = (Hi + Ho)/2.0
*; wBlend = (Wi + Wo)/2.0
*; Ho1d = Ho + 1.0*delta
*; Hotan = Ho - tan(gamma)*(HatRad-Wo)
*; Hotand = Ho - tan(gamma)*(HatRad-Wo) - delta
**; Ho2d = Ho - 2.0*delta
**; Ho3d = Ho - 3.0*delta
**; Ho4d = Ho - 4.0*delta
*; outer IS HatRad
*; Hi1d = Hi + 1.0*delta
*; HidSep = Hi + Separation - delta
*; Hi2d = Hi + 2.0*delta
*; HiSep = Hi + Separation
*; u = tan(gamma) * (HatRad - WSo)
*; Hi2du = Hi + 2.0*delta + u
*; HiSepu = Hi + Separation + u
*; Hi3d = Hi + 3.0*delta
*; HiSepd = Hi + Separation + delta
*; Hi3du = Hi + 3.0*delta + u

*; HiSepdu = Hi + Separation + ddelta + u


**; Hi4d = Hi + 4.0*delta
*; Hi5d = Hi + 5.0*delta
**; Hi6d = Hi + 6.0*delta
*; hBlend1d = hBlend + 1.0*delta
*; WSoblend = (WSo + Rs) /2.0
character*66 banner(5)
character*20 atemp,char1*1
character*127 fname,fname2
character drive*1,path*64,file*8,ext*3
real temp,zi,zo,degrees
integer i,iatemp,izi,izo,idegrees
logical electrons,usem,useh,useb,uset,bigger,oldbig,magscr2
character*8 bumpfilename
external bumpfilename,fnsep,fnjoin,dwrking,iwrking,cwrking
external ht_defaults,hm_defaults,he_defaults,HowTo
external bt_defaults,hh_defaults,heb_defaults,hr_defaults
external old_heb_defaults,old_hr_defaults
*----*---------------------------------------------------------------------* Initialization, Banner & Copyright
*----*
9001 continue
Banner(1) = ' Heeps-X (non-defl) .GEM (SimIon geometry file) '//
& 'generator'
Banner(2) = ' Version 1.123 Thursday July 12, 2007 Lynch Rocket '
& //'Lab'
Banner(3) = ' author: Kevin G. Rhoads; Language: F77'
Banner(4) = ' Copyright 2007 Dartmouth College - Lynch Rocket Lab'
Banner(5) = ' Permission is granted for copying for academic use'
write (*,7002) (banner(i),i=1,5)
Pi = 3.1415926535897932384626d0
scale = 0.0254d0
electrons = .true.
bigger = .false.
oldbig = .false.
uset = .false.
usem = .false.
useh = .false.
useb = .false.
magscr2 = .true.
*
*---- initialize default Heeps-E analyser geometry parameters - mils & degrees
* d<name> variable holds default value for <name> variable
9002 continue
call he_defaults()

*
*----- copy default values into working variables
call dwrking()
*---------------------------------------------------------------------* get parameters -- from file or interactively
*----* from file - Presently UNimplemented
print *,' '
*---9113 continue
print *,' Please choose ION or ELECTRON and default detector ',
& 'style.'
print *,' Electron detector forms are HE(e) and HEBIGGER(r,g)'
print *,' and the incorrect "old" HEBIG(o)'
print *,' Ion detector forms are HT, HM, (HH) and BT'
print *,' Thermal ions, plain: HT(t,i), mass-resolved: BT(b)'
print *,' Medium energy ions: HM(m), (High energy: HH(h))'
print *,' y to keep current values '
print *,' '
if (electrons) then
print *, 'ELECTRONS or Ions? (E/g/i/t/m/h/b): b for Beeps,'
print *,' g for HEBIGGER, r for HEBIGGER, o for Old HEBIG, '
print *,' i for Heeps thermal Ion, m for HM medium energy,'
print *,' t for Heeps Thermal ion, h for HH high energy'
else
print *, 'Electrons or IONS? (e/g/I/t/m/h/b): b for Beeps'
print *,' i for Heeps thermal Ion, m for HM medium energy,'
print *,' t for Heeps Thermal ion, h for HH high energy,'
print *,' g for HEBIGGER, r for HEBIGGER, o for Old HEBIG '
endif
print *,' '
read (*,7001) char1
if (char1.eq.'e'.or.char1.eq.'E') then
print *,' HE - HEEPS Electron detector'
electrons = .true.
bigger = .false.
oldbig = .false.
Voltage = 1000.0
uset = .false.
usem = .false.
useh = .false.
useb = .false.
call he_defaults()
call dwrking()
Banner(1) = ' Heeps-E (non-defl) .GEM (SimIon geometry '//
&
'file) generator'
elseif (char1.eq.'r'.or.char1.eq.'R'.or.
&
char1.eq.'g'.or.char1.eq.'G') then

print *,' HEBIGGER - BIG HEEPS Electron detector'


electrons = .true.
bigger = .true.
oldbig = .false.
Voltage = 1000.0
uset = .false.
usem = .false.
useh = .false.
useb = .false.
call heb_defaults()
call dwrking()
Banner(1) = ' HE Bigger .GEM (SimIon geometry file) '//
&
'generator'
elseif (char1.eq.'o'.or.char1.eq.'O') then
print *,' OHEBIG - OLD HEBIG HEEPS Electron detector'
electrons = .true.
bigger = .true.
oldbig = .true.
Voltage = 1000.0
uset = .false.
usem = .false.
useh = .false.
useb = .false.
call old_heb_defaults()
call dwrking()
Banner(1) = ' Old HE Bigger .GEM (SimIon geometry file) '//
&
'generator'
elseif (char1.eq.'i'.or.char1.eq.'I') then
print *,' HT - HEEPS Thermal Ion detector'
electrons = .false.
bigger = .false.
oldbig = .false.
uset = .true.
usem = .false.
useh = .false.
useb = .false.
call ht_defaults()
call dwrking()
Banner(1) = ' Heeps-T .GEM (SimIon geometry file) generator'
elseif (char1.eq.'j'.or.char1.eq.'J') then
print *,' Old HT - HEEPS Thermal Ion detector'
electrons = .false.
bigger = .false.
oldbig = .false.
uset = .false.
usem = .false.
useh = .false.
useb = .false.

call old_ht_defaults()
call dwrking()
Banner(1) = ' Old Heeps-I .GEM (SimIon geometry file) '//
&
'generator'
elseif (char1.eq.'m'.or.char1.eq.'M') then
print *,' HM - HEEPS Medium energy Ion detector'
electrons = .false.
bigger = .false.
oldbig = .false.
uset = .false.
usem = .true.
useh = .false.
useb = .false.
call hm_defaults()
call dwrking()
Banner(1) = ' Heeps-M .GEM (SimIon geometry file) generator'
elseif (char1.eq.'h'.or.char1.eq.'H') then
print *,' HH - HEEPS High energy Ion detector'
print *,' HH is presently not implemented, using HM defaults'
electrons = .false.
bigger = .false.
oldbig = .false.
uset = .false.
usem = .false.
useh = .true.
useb = .false.
call hh_defaults()
call dwrking()
Banner(1) = ' Heeps-H .GEM (SimIon geometry file) generator'
elseif (char1.eq.'t'.or.char1.eq.'T') then
print *,' HT - HEEPS Thermal Ion detector'
electrons = .false.
bigger = .false.
oldbig = .false.
uset = .true.
usem = .false.
useh = .false.
useb = .false.
call ht_defaults()
call dwrking()
Banner(1) = ' Heeps-T .GEM (SimIon geometry file) generator'
elseif (char1.eq.'b'.or.char1.eq.'B') then
print *,' BT - Mass resolved HEEPS Thermal Ion detector'
print *,' a.k.a., BEEPS-T; this is HT with added magnetics'
print *,' BT definitions are not finished, work in progress'
electrons = .false.
bigger = .false.
oldbig = .false.

uset = .false.
usem = .false.
useb = .true.
useh = .false.
call bt_defaults()
call dwrking()
Banner(1) = ' Beeps-T .GEM (SimIon geometry file) generator'
elseif (char1.eq.'y'.or.char1.eq.'Y') then
* Do nothing, keep prior value
elseif (char1.eq.'n'.or.char1.eq.'N') then
* Reverse prior value
electrons = .not. electrons
bigger = .false.
oldbig = .false.
if (electrons) then
uset = .false.
usem = .false.
useh = .false.
useb = .false.
call he_defaults()
call dwrking()
else
uset = .true.
usem = .false.
useh = .false.
useb = .false.
call ht_defaults()
call dwrking()
endif
else
* Do nothing, keep prior value
endif
**---if (usem) then
magscr2 = .false.
elseif (useh) then
magscr2 = .false.
elseif (useb) then
magscr2 = .true.
elseif (uset) then
magscr2 = .false.
elseif (electrons) then
magscr2 = .false.
endif
*---9101 continue
print *,' Rs (stretch cyl. radius [mil]) = ',Rs
read (*,7001) atemp

iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9101) temp
if (temp.ge.0.0) Rs = temp
endif
*---9102 continue
print *,' Ri (inner R for analyzer [mil]) = ',Ri
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9102) temp
if (temp.ge.0.0) then
Ri = temp
delta = Ro-Ri
separation = 2.0*delta
endif
endif
*---9103 continue
print *,' Ro (outer R for analyzer [mil]) = ',Ro
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9103) temp
if (temp.ge.0.0) then
Ro = temp
delta = Ro-Ri
separation = 2.0*delta
endif
endif
*---9104 continue
print *,' theta (analyzer angular extent [degrees] {inner} )= ',
&
theta
read (*,7001) atemp

iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9104) temp
if (temp.ge.0.0) theta = temp
endif
thetai = theta
thetao = theta
*---9112 continue
print *,' theta {outer} angle [degrees])= ',thetao
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9112) temp
if (temp.ge.0.0) thetao = temp
endif
*---9105 continue
print *,' gamma (entrance expansion angle [degrees] {lower}) = ',
&
gamma
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9105) temp
if (temp.ge.0.0) gamma = temp
endif
gammau = gamma
gammal = gamma
*---9111 continue
print *,' gammau upper angle [degrees] = ',gammau
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then

read (atemp,7010,err=9111) temp


if (temp.ge.0.0) gammau = temp
endif
*---if (.not.electrons) then
continue
print *,'spacing to screen [mil]) = ',screen
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9118) temp
if (temp.ge.0.0) screen = temp
endif
9106
continue
print *,' extra width for screen aperature [mil]) = ',extra
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9106) temp
extra = temp
endif
endif
9107 continue
print *,' NumPnts (Number of Points [unitless]) = ',NumPnts
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9107) temp
if (temp.ge.0.0) NumPnts = temp
endif
*---HatRad = max(HatRad,Ro + 1.0*(Ro-Ri))
9109 continue
print *,' HatRad (Radius of Top Hat [mil]) = ',HatRad
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
9118

elseif (atemp.ne.' ') then


read (atemp,7010,err=9109) temp
if (temp.ge.0.0) HatRad = temp
endif
*---9114 continue
print *,' offset (shift up from zero plane [mil]) = ',offset
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9114) temp
if (temp.ge.0.0) offset = temp
endif
*---9110 continue
print *,' Separation (TopHat vs. inner [mil]) = ',Separation
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9110) temp
if (temp.ge.0.0) Separation = temp
endif
*---9108 continue
print *,' Scaling (Geom scaling factor [unitless]) = ',Scaling
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9108) temp
if (temp.ge.0.0) Scaling = temp
endif
*------------------9332 continue
if (useb) then
*---9115
continue
print *,' Space to top of magnets [mil] = ',bscreenspace
read (*,7001) atemp

iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9115) temp
if (temp.gt.0.0) bscreenspace = temp
endif
*---9116

continue
print *,' bextra [mil] = ',bextra
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9116) temp
if (temp.gt.0.0) bextra = temp
endif

*---9117

*---9120

continue
print *,' Magnet thickness [mil] = ',bthickness
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9117) temp
if (temp.gt.0.0) bthickness = temp
endif
continue
print *,' Magnet ring outer radius [mil] = ',MagRo
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9120) temp
if (temp.gt.0.0) MagRo = temp

endif
*---9119

continue
print *,' Magnet ring inner radius [mil] = ',MagRi
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
read (atemp,7010,err=9119) temp
if (temp.gt.0.0) MagRi = temp
endif

*---9121

continue
print *,' Electrode screen ABOVE magnets? ',magscr2
read (*,7001) atemp
iatemp = ichar(atemp(1:1))
if (useb.and.iatemp.eq.2) then
goto 9332
elseif (iatemp.eq.4) then
goto 9333
elseif (atemp.ne.' ') then
i = 0
9122
continue
i = i + 1
char1 = atemp(i:i)
if (char1.eq.' '.and.i.lt.20) goto 9122
magscr2 = char1.eq.'T' .or. char1.eq.'t'
magscr2 = char1.eq.'Y' .or. char1.eq.'y' .or. magscr2
endif
endif
*------------------9333 continue
*---------------------------------------------------------------------* check for consistency, over/under-constrained, use defaults as needed, report parameters
*----* Presently Mostly UNimplemented
if (theta.lt.0.0.or.theta.gt.90.0) then
print *,' theta out of range, reverting to default '
theta = dtheta
endif
if (thetai.lt.0.0.or.thetai.gt.90.0) then
print *,' thetai out of range, reverting to default '
thetai = dthetai
endif

if (thetao.lt.0.0.or.thetao.gt.90.0) then
print *,' thetao out of range, reverting to default '
thetao = dthetao
endif
if (gamma.lt.0.0.or.gamma.gt.90.0) then
print *,' gamma out of range, reverting to default '
gamma = dgamma
endif
if (gammau.lt.0.0.or.gammau.gt.90.0) then
print *,' gammau out of range, reverting to default '
gammau = dgammau
endif
if (gammal.lt.0.0.or.gammal.gt.90.0) then
print *,' gammal out of range, reverting to default '
gammal = dgammal
endif
if (Ri.gt.Ro) then
print *,' Ri > Ro, swapping '
temp = Ri
Ri = Ro
Ro = temp
endif
*
if (scaling.ne.1.0.and.scaling.gt.0.0) then
Print *,' Rescaling geometry by ',scaling
Rs = Rs*scaling
Ri = Ri*scaling
Ro = Ro*scaling
offset = offset*scaling
NumPnts = NumPnts*scaling
HatRad = HatRad*scaling
NumPnts = max(HatRad+Rs,NumPnts)
separation = separation*scaling
endif
if (electrons) then
Voltage = 1000.0
iVoltage = 1000
else
Voltage = -1000.0
iVoltage = -1000
endif
*
*;------------ compute derived parameters from working variables
itemp = 0
9003 continue
itemp = itemp + 1
call cwrking(useb)
if ( (.not.useb.and.iNumPntsX.gt.iNumPnts)

&
&

.or.(iNumPntsY.gt.iNumPnts)
.or.(iNumPntsX.gt.(iNumPnts*3/2+1)) ) then
NumPnts = max(NumPnts,NumPntsX,NumPntsY)
print *,' '
print *,' Expanding PA size to ',NumPnts
* NO MORE than one interation of this
if (itemp.lt.2) goto 9003
endif
*
*---- round to nearest integer for both basic and derived parameters
call iwrking()
*
*---------------------------------------------------------------------* determine output filename -- ask if interactive, derive from input filename else
* or use default (HE_nnnnn)
*
* Presently partially implemented, basename based on detector defaults
* bump numbers used for uniqueness
*
*----* Open
if (electrons) then
fname = 'HE000000.GEM'
if (bigger) then
fname = 'HEBIG000.GEM'
if (oldbig) then
fname = 'OHEBIG00.GEM'
endif
endif
elseif (uset) then
fname = 'HT000000.GEM'
elseif (usem) then
fname = 'HM000000.GEM'
elseif (useh) then
fname = 'HH000000.GEM'
elseif (useb) then
fname = 'BT000000.GEM'
else
fname = 'HI000000.GEM'
endif
9004 continue
open (unit=10,file=fname,status='new',iostat=i)
if (i.ne.0) then
call fnsep(fname,drive,path,file,ext)
file = bumpfilename(file)
call fnjoin(fname,drive,path,file,ext)
goto 9004
endif

inquire (unit=10,name=fname2,iostat=i)
if (i.ne.0) then
fname2 = fname
endif
if (useb) then
call fnsep(fname,drive,path,file,ext)
file(1:1) = 'M'
call fnjoin(fname,drive,path,file,ext)
open (unit=11,file=fname,status='unknown',iostat=i)
endif
print *,' '
print *,' Output to ',fname2(1:len_trim(fname2))
*---------------------------------------------------------------------* write out output .GEM file
*----* write out .GEM file comments; these include all the comments in the manually
* generated precursor file and additional auto-generated comments from this
* program, including an echo of the parameters
*
*======================================================================
*
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
if (electrons) then
write (10,7001) ';BEGIN autogenerated Top Hat Heeps-E GEM file'
elseif (uset) then
write (10,7001) ';BEGIN autogenerated Top Hat Heeps-T GEM file'
elseif (usem) then
write (10,7001) ';BEGIN autogenerated Top Hat Heeps-M GEM file'
elseif (useh) then
write (10,7001) ';BEGIN autogenerated Top Hat Heeps-H GEM file'
elseif (useb) then
write (10,7001) ';BEGIN autogenerated Top Hat Beeps-T GEM file'
else
write (10,7001) ';BEGIN autogenerated Top Hat Heeps-X GEM file'
endif
write (10,7001) (';'//banner(i),i=1,5)
write (10,7001) ';_______________________________________________'
& // '______________________________'
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
if (useb) then
write (11,7001) ';BEGIN autogenerated Top Hat Beeps-T GEM file2'
write (11,7001) (';'//banner(i),i=1,5)
write (11,7001) ';_______________________________________________'
& // '______________________________'
write (11,7001) ';This is the MAGNETIC PA GEM file that goes with'
write (11,7001) '; '//fname2(1:len_trim(fname2))
write (11,7001) ';_______________________________________________'
& // '______________________________'

endif
*----call HowTo()
*----* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
write (10,7001) ';_______________________________________________'
& // '______________________________'
if (electrons) then
write (10,7001) ';Generated Heeps-E SimIon7 Geometry file (.GEM)'
elseif (uset) then
write (10,7001) ';Generated Heeps-T SimIon7 Geometry file (.GEM)'
elseif (usem) then
write (10,7001) ';Generated Heeps-M SimIon7 Geometry file (.GEM)'
elseif (useh) then
write (10,7001) ';Generated Heeps-H SimIon7 Geometry file (.GEM)'
elseif (useb) then
write (10,7001) ';Generated Beeps-T SimIon7 Geometry file (.GEM)'
else
write (10,7001) ';Generated Heeps-X SimIon7 Geometry file (.GEM)'
endif
write (10,7001) '; based on manually generated file HEBIG.GEM'
write (10,7001) '; and previously developed HT, HM, HH, BT, HE'
write (10,7001) '; designs developed at UNH '
write (10,7001) '; '
write (10,7001) '; Original author Kevin G. Rhoads
July 2005'
write (10,7001) '; '
write (10,7001) '; We are designing Top Hat detector/analyser in'
& //' mils, with nominally 1001'
write (10,7001)'; sized arrays where sizes are nominally in mils.'
& //' Geometries can be rescaled'
write (10,7001) '; in SimIon afterwards if needed. Dimensions '
& //'are rounded to nearest mil.'
write (10,7001) '; Nominal High Voltage, HV, is 1000V. This is '
& //'easy to rescale in SimIon,'
write (10,7001) '; but is also a specifiable parameter. Angles '
& //'are in degrees.'
write (10,7001) '; '
*
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* write out .GEM file parameters, with present values
write (10,7001) '; Design parameters: (rounded to integer)'
write (10,7003) '; Rs - Radius of "stretch" cylinder, nominal 67,'
& //' actual ',iRs
write (10,7003) '; Ri - a.k.a., R1; inner radius of analyzer, '
& //'nominal 604, actual ',iRi
write (10,7003) '; Ro - a.k.a., R2; outer radius of analyzer, '
& //'nominal 659, actual ',iRo

write (10,7003) '; theta - angle up from exit plane to analyser '
& //'entrance, nominal 74 degrees, actual ',itheta
write (10,7003) '; gamma - (sometimes alpha) angle of entrance '
& //'electrodes from parallel, nominal 6 degrees, actual ',igamma
write (10,7003) '; gammau- (sometimes alpha) angle of entrance '
& //'electrodes from parallel, nominal 6 degrees, actual ',igammau
write (10,7003) '; gammal- (sometimes alpha) angle of entrance '
& //'electrodes from parallel, nominal 6 degrees, actual ',igammal
write (10,7023) '; offset - distance from exit plane to bottom of'
& //' simulation region, nominal 6.35, actual ',offset
write (10,7003) '; HatRad - radius of "Top Hat", nom. Ro+2*delta '
& //'(i.e., RoPlus), value ',iRoPlus
write (10,7003) '; NumPnts - Number of array points per axis, '
& //'nominal 1001, actual ',iNumPnts
*----* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
if (electrons) then
write (10,7003) '; Voltage - HV electrode voltage, nominal '
&
//' 1000, actual ',iVoltage
write (10,7001) '; ELECTRON detector specifics'
else
write (10,7003) '; Voltage - HV electrode voltage, nominal'
&
//' -1000, actual ',iVoltage
write (10,7001) '; '
write (10,7001) '; ION detector specifics'
if (usem) then
write (10,7003) '; Spacing down to screen electrode [mil]'
&
//', nominal -70, actual ',iscreen
else
write (10,7003) '; Spacing down to screen electrode [mil]'
&
//', nominal -63, actual ',iscreen
endif
write (10,7003) '; Aperture width extra space, '
&
//'nominal 0, actual ',iextra
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
if (useb) then
write (10,7001) '; '
write (10,7001) '; BEEPS (ion mass analyser) specifics:'
write (10,7003) '; Space to top of magnets [mil] = ',
&
ibscreenspace
write (10,7003) '; bextra [mil] = ',ibextra
write (10,7003) '; Magnet thickness [mil] = ',
&
ibthickness
&

write (10,7003) '; Space from bottom of magnets to screen'


//' [mil] = ',ibspace
write (10,7003) '; bVoltage - magnet section voltage, '

&

//'nominal -1000, actual ',ibVoltage


write (10,7003) '; MagRi [mil] = ',iMagRi
write (10,7003) '; MagRo [mil] = ',iMagRo

*
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
* write BEEPS parameters out as comments in second PA .GEM file also
write (11,7003) '; Space to top of magnets [mil] = ',
&
ibscreenspace
write (11,7003) '; bextra [mil] = ',ibextra
write (11,7003) '; Magnet thickness [mil] = ',
&
ibthickness
write (11,7003) '; Space from bottom of magnets to screen'
&
//' [mil] = ',ibspace
write (11,7003) '; bVoltage - magnet section voltage, '
&
//'nominal -1000, actual ',ibVoltage
write (11,7003) '; MagRi [mil] = ',iMagRi
write (11,7003) '; MagRo [mil] = ',iMagRo
write (11,7001) '; '
write (11,7001) ';------------ derived parameters'
endif
endif
*
*======================================================================
*
* write out .GEM file derived parameters, with present values
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
write (10,7001) '; '
write (10,7001) ';------------ derived parameters'
write (10,7003) '; delta = (Ro - Ri); value ',idelta
write (10,7003) '; h = Ri*sin(theta); value ',ih
write (10,7001) '; Hi2d is the same as hplus'
write (10,7003) '; hplus = 2*delta+Ri*sin(theta); value ',ihplus
write (10,7003) '; Wi = Ri*cos(theta); value ',iWi
write (10,7001) '; Hi is the same as h'
write (10,7003) '; Hi = Ri*sin(theta) [alias for h]; value ',iHi
write (10,7003) '; Wo = Ro*cos(theta); value ',iWo
write (10,7003) '; Ho = Ro*sin(theta); value ',iHo
write (10,7003) '; WSi = Rs + Ri*cos(theta); value ',iWSi
write (10,7003) '; WSo = Rs + Ro*cos(theta); value ',iWSo
write (10,7003) '; RoPlus = Ro + 2*delta; value ',iRoPlus
write (10,7003) '; hBlend = (Hi + Ho)/2.0; value ',ihBlend
write (10,7003) '; wBlend = (Wi + Wo)/2.0; value ',iwBlend
write (10,7003) '; RiPlus = Ri + 2*delta; value ',iRiPlus
write (10,7003) '; RoPlus = Ro + 2*delta; value ',iRoPlus
write (10,7003) '; hBlend = (Hi + Ho)/2.0; value ',ihBlend
write (10,7003) '; wBlend = (Wi + Wo)/2.0; value ',iwBlend
write (10,7003) '; Ho1d = Ho + 1.0*delta; value ',iHo1d

write (10,7003) '; Hotan = Ho - tan(gamma)*HatRad; value ',iHotan


write (10,7003) '; Hotand = Hotan -delta; value ',iHotand
*
write (10,7003) '; Ho2d = Ho - 2.0*delta; value ',iHo2d
*
write (10,7003) '; Ho3d = Ho - 3.0*delta; value ',iHo3d
*
write (10,7003) '; Ho4d = Ho - 4.0*delta; value ',iHo4d
write (10,7003) '; outer = HatRad; value ',iouter
write (10,7003) '; Hi1d = Hi + 1.0*delta; value ',iHi1d
write (10,7003) '; HidSep = Hi+Separation-delta; value ',iHidSep
write (10,7001) '; ----- Hi2d is the same as hplus '
write (10,7003) '; Hi2d = Hi + 2.0*delta; value ',iHi2d
write (10,7003) '; HiSep = Hi + Separation; value ',iHiSep
write (10,7003) '; Hi2du = Hi + 2.0*delta + u; value ',iHi2du
write (10,7003) '; HiSepu = Hi+Separation+u; value ',iHiSepu
write (10,7003) '; Hi3d = Hi + 3.0*delta; value ',iHi3d
write (10,7003) '; HiSepd = Hi+Separation+delta; value ',iHiSepd
write (10,7003) '; Hi3du = Hi + 3.0*delta + u; value ',iHi3du
write (10,7003) '; HiSepdu = Hi + Separation + delta + u; value ',
&
iHiSepdu
*
write (10,7003) '; Hi4d = Hi + 4.0*delta; value ',iHi4d
write (10,7003) '; Hi5d = Hi + 5.0*delta; value ',iHi5d
*
write (10,7003) '; Hi6d = Hi + 6.0*delta; value ',iHi6d
write (10,7003) '; hBlend1d = hBlend + 1.0*delta; value ',
&
ihBlend1d
write (10,7003) '; Wo2dcot = Wo + 2.0*delta*cot(gamma); value ',
&
iWo2dcot
write (10,7003) '; Wo2dcotclip = min(Wo2dcot,HatRad,NumPnts-Rs);'
& // ' value ',iWo2dcotclip
write (10,7003) '; NumPntsX = max(NumPnts,Hi5d,Ho1d), value ',
& iNumPntsX
write (10,7003) '; NumPntsY = max(NumPnts,Wo2dcotclip,WSo,RoPlus)'
& // ', value ',iNumPntsY
*----* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
if (useb) then
write (10,7003) '; Analyser exit plane to top of magnets '
&
//'[mil] = ',imagstart
write (10,7003) '; Analyser exit plane to bottom of magnets '
&
//'[mil] = ',imagstop
write (10,7003) '; Analyser exit plane to magnet screen '
&
//' [mil] = ',ibscreen
write (11,7003) '; Analyser exit plane to top of magnets '
&
//'[mil] = ',imagstart
write (11,7003) '; Analyser exit plane to bottom of magnets '
&
//'[mil] = ',imagstop
write (11,7003) '; Analyser exit plane to magnet screen '
&
//' [mil] = ',ibscreen
endif
*

*=======================================================================
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
* write out .GEM file parameters, with present values
write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '; Design parameters: '
write (10,7023) '; Rs - Radius of "stretch" cylinder, nominal 67,'
& //' actual ',Rs
write (10,7023) '; Ri - a.k.a., R1; inner radius of analyzer, '
& //'nominal 604, actual ',Ri
write (10,7023) '; Ro - a.k.a., R2; outer radius of analyzer, '
& //'nominal 659, actual ',Ro
write (10,7023) '; theta - angle up from exit plane to analyser '
& //'entrance, nominal 74 degrees, actual ',theta
write (10,7023) '; gamma - (sometimes alpha) angle of entrance '
& //'electrodes from parallel, nominal 6 degrees, actual ',gamma
write (10,7023) '; gammau- (sometimes alpha) angle of entrance '
& //'electrodes from parallel, nominal 6 degrees, actual ',gammau
write (10,7023) '; gammal- (sometimes alpha) angle of entrance '
& //'electrodes from parallel, nominal 6 degrees, actual ',gammal
if (useb) then
write (10,7023) '; offset - distance from exit plane to bot'
&
//'tom of simulation region, nominal 18.05, actual ',offset
else
write (10,7023) '; offset - distance from exit plane to bot'
&
//'tom of simulation region, nominal 6.35, actual ',offset
endif
write (10,7023) '; HatRad - radius of "Top Hat", nom. Ro+2*delta '
& //'(i.e., RoPlus), value ',RoPlus
write (10,7023) '; NumPnts - Number of array points per axis, '
& //'nominal 1001, actual ',NumPnts
write (10,7023) '; Voltage - HV electrode voltage, nominal '
& //' 1000, actual ',Voltage
*
*======================================================================
*
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
* write out .GEM file derived parameters, with present values
write (10,7001) ';------------ derived parameters'
write (10,7023) '; delta = (Ro - Ri); value ',delta
write (10,7023) '; h = Ri*sin(theta); value ',h
write (10,7001) '; Hi2d is the same as hplus'
write (10,7023) '; hplus = 2*delta+Ri*sin(theta); value ',hplus
write (10,7023) '; Wi = Ri*cos(theta); value ',Wi
write (10,7001) '; Hi is the same as h'

*
*
*

*
*

write (10,7023) '; Hi = Ri*sin(theta) [alias for h]; value ',Hi


write (10,7023) '; Wo = Ro*cos(theta); value ',Wo
write (10,7023) '; Ho = Ro*sin(theta); value ',Ho
write (10,7023) '; WSi = Rs + Ri*cos(theta); value ',WSi
write (10,7023) '; WSo = Rs + Ro*cos(theta); value ',WSo
write (10,7023) '; RoPlus = Ro + 2*delta; value ',RoPlus
write (10,7023) '; hBlend = (Hi + Ho)/2.0; value ',hBlend
write (10,7023) '; wBlend = (Wi + Wo)/2.0; value ',wBlend
write (10,7023) '; RiPlus = Ri + 2*delta; value ',RiPlus
write (10,7023) '; RoPlus = Ro + 2*delta; value ',RoPlus
write (10,7023) '; hBlend = (Hi + Ho)/2.0; value ',hBlend
write (10,7023) '; wBlend = (Wi + Wo)/2.0; value ',wBlend
write (10,7023) '; Ho1d = Ho + 1.0*delta; value ',Ho1d
write (10,7023) '; Hotan = Ho - tan(gamma)*HatRad; value ',Hotan
write (10,7023) '; Hotand = Hotan -delta; value ',Hotand
write (10,7023) '; Ho2d = Ho - 2.0*delta; value ',Ho2d
write (10,7023) '; Ho3d = Ho - 3.0*delta; value ',Ho3d
write (10,7023) '; Ho4d = Ho - 4.0*delta; value ',Ho4d
write (10,7023) '; outer = HatRad; value ',outer
write (10,7023) '; Hi1d = Hi + 1.0*delta; value ',Hi1d
write (10,7023) '; HidSep = Hi+Separation-delta; value ',HidSep
write (10,7001) '; ----- Hi2d is the same as hplus '
write (10,7023) '; Hi2d = Hi + 2.0*delta; value ',Hi2d
write (10,7023) '; HiSep = Hi + Separation; value ',HiSep
write (10,7023) '; Hi2du = Hi + 2.0*delta + u; value ',Hi2du
write (10,7023) '; HiSepu = Hi+Separation+u; value ',HiSepu
write (10,7023) '; Hi3d = Hi + 3.0*delta; value ',Hi3d
write (10,7023) '; HiSepd = Hi+Separation+delta; value ',HiSepd
write (10,7023) '; Hi3du = Hi + 3.0*delta + u; value ',Hi3du
write (10,7023) '; HiSepdu = Hi + Separation + delta + u; value ',
&
HiSepdu
write (10,7023) '; Hi4d = Hi + 4.0*delta; value ',Hi4d
write (10,7023) '; Hi5d = Hi + 5.0*delta; value ',Hi5d
write (10,7023) '; Hi6d = Hi + 6.0*delta; value ',Hi6d
write (10,7023) '; hBlend1d = hBlend + 1.0*delta; value ',
&
hBlend1d
write (10,7023) '; Wo2dcot = Wo + 2.0*delta*cot(gamma); value ',
&
Wo2dcot
write (10,7023) '; Wo2dcotclip = min(Wo2dcot,HatRad,NumPnts-Rs);'
& // ' value ',Wo2dcotclip
write (10,7023) '; NumPntsX = max(NumPnts,Hi5d,Ho1d), value ',
& NumPntsX
write (10,7023) '; NumPntsY = max(NumPnts,Wo2dcotclip,WSo,RoPlus)'
& // ', value ',NumPntsY
write (10,7003) '; iNumPntsX = ',iNumPntsX
write (10,7003) '; iNumPntsY = ',iNumPntsY
if (useb) then
write (10,*) '; magstart [mil] = ',magstart

write (10,*) '; magstop [mil] = ',magstop


write (10,*) '; imagstart [mil] = ',imagstart
write (10,*) '; imagstop [mil] = ',imagstop
endif
*
*
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* write out .GEM file version history
write (10,7001) ' '
write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '; VERSION HISTORY of manually generated versions'
write (10,7001) '; Fifth version Tuesday March 12, 2007 -- kgr '
& // '-- finishing comments, starting on Fortran to autogenerate '
& // 'TopHat .GEMs'
write (10,7001) '; Fourth version Tuesday July 19, 2005 -- kgr --'
& // ' starting on Top Hat grounded electrode'
write (10,7001) '; Third version Tuesday July 19, 2005 -- kgr -- '
& // 'starting on grounded electrodes, outer hemisphere first'
write (10,7001) '; Second version Monday July 18, 2005 -- kgr -- '
& // 'start defining electrodes, got inner HV electrode done'
write (10,7001) '; First version Monday July 18, 2005 -- kgr -- '
& // 'just get most basic stuff'
write (10,7001) ' '
write (10,7001) ';_______________________________________________'
& // '______________________________'
*
*======================================================================
*
* write out .GEM file Potential Array definition
if (.not.useb) then
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
write (10,7004) 'PA_Define (',iNumPntsX,',',iNumPntsY,
&
',1,Cylindrical,Y,Electrostatic) ;define a 2D poten'
&
// 'tial array with cylindrical symmetry, Y mirrored'
else
write (10,7004) 'PA_Define (',iNumPntsX,',',iNumPntsY,
&
',1,Cylindrical,Y,Electrostatic) ;define a 2D poten'
&
// 'tial array with cylindrical symmetry, Y mirrored'
* Unit 11 writes to MTnnnnnn.GEM for second magnetic PA for BEEPS
write (11,7014) 'PA_Define (',iNumPntsX,',',iNumPntsY,
&
',',iNumPntsY,',Planar,None,Magnetostatic) ;define '
&
// 'a 3D potential array No mirroring'
*
write (10,7004) 'PA_Define (',iNumPntsX*3/2,',',iNumPntsY,
*
&
',1,Cylindrical,Y,Electrostatic) ;define a 2D poten'
*
&
// 'tial array with cylindrical symmetry, Y mirrored'
endif
write (10,7001) ' '

*
* write out locate command to shift origin and comment for same
write (10,7024) 'Locate (',offset,',0,0,',scale,
& ',0,0,0) { ; (1) shift'
& //' origin up the X axis to leave space for outgoing electrons '
& // 'from analyzer toward MCP'
write (10,7001) ';Locate (offset,0,0,.0254,0,0,0) { ; (1) shift'
& // ' origin to (0,0)'' (Point B)'
write (10,7001) ' '
if (useb) then
write (11,7024) 'Locate (',offset,',0,0,',scale,
& ',0,0,0) { ; (1) shift'
& //' origin up the X axis to leave space for outgoing electrons '
& // 'from analyzer toward MCP'
write (11,7001) ';Locate (offset,0,0,.0254,0,0,0) { ; (1) shift'
& // ' origin to (0,0)'' (Point B)'
write (11,7001) ' '
endif
*
*======================================================================
*
* Unit 10 writes to XXnnnnnn.GEM where XX=HE, HT, HM, HH or BT
* write out commands to create inner hemisphere electrode
write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '
;define inner "hemisphere" electrode, '
& // 'which is the electrode driven at High Voltage'
write (10,7005) '
electrode(',iVoltage,') {
;HV elec'
& // 'trode (inner) nominal 1000V
electrode(HV)'
write (10,7005) '
rotate_fill(',360,') { ;Cylindrical'
& // ' symmetry, so rotate 360 degrees about X-axis'
write (10,7001) '
;2D geometry is '
& // 'defined in X-Y plane, and Z does not exist in definitions'
write (10,7001) '
;3D cylindrical '
& // 'form is generated by mirroring Y to -Y and rotating Y into '
& // 'Z about X'
write (10,7001) '
;(Why did they '
& // 'not make Z the axis for the cylinder?)'
write (10,7005) '
Locate (0,',iRs,',0,1,0,0,0) { '
& // '; (2.5) shift origin out Y-axis to edge of cylinder'
write (10,7001) '
;Locate (0,Rs,0,1,0,0,0) (2.'
& // '5) move origin to (0,0)'''' (Point C) '
write (10,7001) '
; (3) include in HV 1/4 circ'
& // 'ular arc at Ri [3]'
write (10,7009) '
within{ Circle(',0,0,iRi,iRi,
&
') } ; within{ Circle(0,0,Ri,Ri) }'
*
* Get a "hole" in inner electrode with either of the following exclusions ?!?

* ? WHY ?
*
write (10,7009) '
notin{ Box2D(',0,-iRi,iRi,
*
&
0,') }
; exclude left side
notin{ Box2D(0,0,Ri,0) } '
**
write (10,7009) '
notin{ Box2D(',-iRi,-iRi,iRi,
**
&
0,') }
; exclude left side
notin{ Box2D(-Ri,-Ri,Ri,0) } '
write (10,7009) '
notin{ Box2D(',-iRi,-iRi,0,
&
iRi,') } ; exclude bottom region notin{ Box2D(-Ri,-Ri,0,Ri) }'
write (10,7009) '
notin{ Box2D(',ih,-iRi,
& ihPlus,iRi,') }; exclude top region
notin{ Box2D(h,-Ri,'
& // 'h+2*delta,Ri) } '
write (10,7001) '
'
& // '
;(5) exclude 2* delta high rectangular region [2]'
write (10,7001) '
} ;END locate(0,Rs,0,1,0,0,0) '
write (10,7009) '
within{ Box2D(',0,0,ih,iRs,
&
') }
;within { Box2D(0,0,h,Rs) } '
write (10,7001) '
; (2) include in HV cylinder [1]'
& // ' that makes this a "stretched" TopHat'
write (10,7001) '
; Box2D(0,0,h,Rs) when rotated '
& // 'is cylinder, h high, Rs radius'
write (10,7009) '
within{ Box2D(',0,0,ih,iwsoblend,
&
') }
;within { Box2D(0,0,h,(Rs+WSo)/2) } '
write (10,7001) '
; force overlap '
write (10,7001) '
} ;END rotate_fill(360)'
write (10,7001) ' '
write (10,7001) '
} ;END electrode(HV)'
write (10,7001) ' '
*
*======================================================================
*
* write out commands to create outer hemisphere electrode
write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '
;define outer "hemisphere" electrode, '
& // 'which is grounded and includes lower Top Hat'
write (10,7005) '
electrode(',0,') {
;grounded '
& // 'electrode (outer) nominal 0V '
write (10,7005) '
rotate_fill(',360,') { ;Cylindrical'
& // ' symmetry, so rotate 360 degrees about X-axis'
write (10,7001) '
;2D geometry is '
& // 'defined in X-Y plane, and Z does not exist in definitions'
write (10,7001) '
;3D cylindrical '
& // 'form is generated by mirroring Y to -Y and rotating Y into '
& // 'Z about X'
write (10,7001) '
;(Why did they '
& // 'not make Z the axis for the cylinder?)'
write (10,7005) '
Locate (0,',iRs,',0,1,0,0,0) { '
& // '; (2.5) shift origin out Y-axis to edge of cylinder'
write (10,7001) '
;Locate (0,Rs,0,1,0,0,0) (2.'

&

// '5) move origin to (0,0)'''' (Point C) '


write (10,7009) '
within{ Circle(',0,0,iRo1d,
&
iRo1d,') }
; within{ Circle(0,0,Ro1d,Ro1d) }'
write (10,7009) '
notin{ Circle(',0,0,iRo,iRo,
&
') }
; notin{ Circle(0,0,Ro,Ro) } ; (4) exclude gap betw'
& // 'een Ri and Ro (delta width) [4] '
write (10,7009) '
notin{ Box2D(',-iRoPlus,
&
-iRoPlus,0,iRoPlus,') } ; exclude left and bottom regions '
& // 'notin{ Box2D(-RoPlus,-RoPlus,0,RoPlus) }'
write (10,7009) '
notin{ Box2D(',iHi1d,
&
-iRoPlus,iRoPlus,iRo,') }; exclude top region
notin{ '
& // 'Box2D(h+delta,-RoPlus,RoPlus,Ro) } '
write (10,7001) '
'
& //
'
; (5) exclude 2* delta'
& // ' high rectangular region [2] '
write (10,7001) '
;force exclusion of crud '
& // 'along upper surface of lower Top Hat electrode'
*
* make sure top surface of lower Top Hat is well defined with no encroachment
* from outer cylinder (exclusion next is copy of later exclusion)
write (10,7007) '
notin{ PolyLine ( ',iHo,iWo,
&
'
; Ho, Wo, Point "E" '
write (10,7007) '
',iHo,
&
iHatRad,'
; Ho, HatRad, '
*
write (10,7007) '
',iHotan,
*
&
iHatRad,'
; Hotan, HatRad,'
*
* These two points MUST match the first two points in the WITHIN (next)
write (10,7007) '
',iHotan,
&
iHatRad,'
; Hotan, HatRad,'
write (10,7008) '
',iHo,iWo,
&
') }
; Ho, Wo) } Point "E" '
write (10,7001) '
'
*
* lower portion of "Top Hat"
& // ';lower portion of "Top Hat" next '
write (10,7007) '
within{ PolyLine ( ',iHo,iWo,
&
'
; Ho, Wo, Point "E" '
write (10,7007) '
',iHotan,
&
iHatRad,'
; Hotan, HatRad,'
write (10,7007) '
',iHotand,
&
iHatRad,'
; Hotan-delta, HatRad, '
write (10,7008) '
',iHo,iWo,
&
') }
; Ho, Wo) } Point "E" '
write (10,7007) '
'
; Ho, Wo, Point "E" '

&

notin{ PolyLine ( ',iHo,iWo,

write (10,7007) '


iWo,'
; Ho+delta, Wo, '
write (10,7007) '
&
iHatRad,'
; Ho+delta, HatRad, '

',iHo1d,

&

*
* These two
write
&
write
&

',iHo1d,

points MUST match the first two points in the WITHIN (prior)
(10,7007) '
',iHotan,
iHatRad,'
; Hotan, HatRad, '
(10,7008) '
',iHo,iWo,
') }
; Ho, Wo) } Point "E" '

write (10,7001) '


'
// '
;remove any glitches in cross-over space '
write (10,7007) '
notin{ PolyLine ( ',ihBlend,
&
iwBlend,'
; hBlend, wBlend, '
write (10,7007) '
',
&
ihBlend1d,iwBlend,'
; hBlend+delta, wBlend, '
write (10,7007) '
',
&
ihBlend1d,0,'
; hBlend+delta, 0, '
write (10,7007) '
',
&
ihBlend,0,'
; hBlend, 0, '
write (10,7008) '
',ihBlend,
&
iwBlend,') }
; hBlend, wBlend) } '
write (10,7001) '
'
& // '
;more glitch removal in cross-over space '
write (10,7007) '
notin{ PolyLine ( ',iHo,
&
0,'
; Ho, 0, '
write (10,7007) '
',
&
iHo,iWo,'
; Ho, Wo, '
write (10,7007) '
',
&
iHo1d,iWo,'
; Ho1d, Wo, '
write (10,7007) '
',iHo1d,
&
0,'
; Ho1d, 0,
'
write (10,7008) '
',iHo,
&
0,') }
; Ho, 0) } '
&

*
* close definition of electrode
write (10,7001) '
} ;END locate(0,Rs...'
write (10,7001) '
} ;END rotate_fill(360)'
write (10,7001) '
} ;END electrode(0) outer, lower TopHat'
write (10,7001) ' '
*
*======================================================================
*
* write out commands to create upper TopHat electrode
write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '
;define upper "Top Hat" electrode, which'

&

// ' is grounded'
write (10,7005) '
electrode(',0,') {
;grounded elect'
& // 'rode (Top Hat) nominal 0V'
write (10,7005) '
rotate_fill(',360,') { ;Cylindrical'
& // ' symmetry, so rotate 360 degrees about X-axis'
write (10,7001) '
;2D geometry is '
& // 'defined in X-Y plane, and Z does not exist in definitions'
write (10,7001) '
;3D cylindrical '
& // 'form is generated by mirroring Y to -Y and rotating Y into '
& // 'Z about X'
write (10,7001) '
;(Why did they '
& // 'not make Z the axis for the cylinder?)'
write (10,7007) '
'
; Hi+separation, 0,'

within{ PolyLine ( ',iHiSep,0,

&

*
* next two points must be same as fourth and fifth points in NOTIN below
* (opposite order)
write (10,7007) '
',iHiSep,iWSo,
& '
; Hi+Separation, Wo+Rs, Point "F"'
write (10,7007) '
',iHiSepu,
& iHatRadS,'
; Hi+Separation+u, HatRad '
write (10,7007) '
',iHiSepdu,
& iHatRadS,'
; Hi+Separation+delta+u, HatRad '
write (10,7007) '
',iHiSepd,
& iWSo,'
; Hi+Separation+delta, Wo+Rs, Point "F" +delta'
write (10,7007) '
',iHiSepd,0,
& '
; Hi+Separation+delta, 0,'
write (10,7008) '
',iHiSep,0,
& ') }
; Hi+Separation, 0) }'
write (10,7007) '
notin{ PolyLine ( ',iHidSep,0,
'
; h+Separation, 0,'
write (10,7007) '
',iHidSep,
& iWSo,'
; h+Separation, Wo+Rs, '
write (10,7007) '
',iHidSep,
&
iHatRadS,'
; Hi+Separation, HatRad '
&

*
* next two points must be same as second and third points in WITHIN above
* (opposite order)
write (10,7007) '
',iHiSepu,
&
iHatRadS,'
; Hi+Separation+u, HatRad '
write (10,7007) '
',iHiSep,
& iWSo,'
; Hi+Separation, Wo+Rs,
Point "F" '
write (10,7007) '
',iHiSep,0,
& '
; Hi+Separation, 0, '
write (10,7008) '
',iHidSep,0,
& ') }
; Hi+Separation-delta, 0) } '

write (10,7001) '


write (10,7001) '

} ;END rotate_fill(360)'
;END electrode(0) upper TopHat'

*
*======================================================================
*
* write out commands to create screen electrode IF doing IONS
if (.not.electrons) then
write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '
;define ground screen electrode, which'
& // ' is (Duh!) grounded'
write (10,7005) '
electrode(',0,') {
;grounded elect'
& // 'rode - ground screen '
write (10,7005) '
rotate_fill(',360,') { ;Cylindrical'
& // ' symmetry, so rotate 360 degrees about X-axis'
write (10,7001) '
;2D geometry is '
& // 'defined in X-Y plane, and Z does not exist in definitions'
write (10,7001) '
;3D cylindrical '
& // 'form is generated by mirroring Y to -Y and rotating Y into '
& // 'Z about X'
write (10,7001) '
;(Why did they '
& // 'not make Z the axis for the cylinder?)'
**
**
**
**
**
*
*
*
*
*

**
**
**

within{ PolyLine ( -00003, 00000,


; iscreen, 0,
-00003, 00671,
; iscreen, Ri+Rs,
-00005, 00671,
; iscreen-2, Ri+Rs,
-00005, 00000,
; iscreen-2, 0,
-00003, 00000) }
; iscreen, 0) }
within{ PolyLine ( -00063, 00000,
; iscreen, 0,
-00063, 00724,
; iscreen, Ri+Rs-extra
-00065, 00724,
; iscreen-2, Ri+Rs-extra
-00065, 00000,
; iscreen-2, 0
-00063, 00000) }
; iscreen, 0) }
write (10,7007) '
within{ PolyLine ( ',iscreen,0,
& '
; iscreen, 0,'
write (10,7007) '
',iscreen,
& iRiRs,'
; iscreen, Ri+Rs-extra '
write (10,7007) '
',iscreen-2,
& iRiRs,'
; iscreen-2, Ri+Rs-extra '
write (10,7007) '
',iscreen-2,
& 0,'
; iscreen-2, 0'
write (10,7008) '
',iscreen,0,
& ') }
; iscreen, 0) }'
within{ PolyLine ( -00003, 00726,
-00003, 00836,
-00005, 00836,

; iscreen, Ro+Rs,
; iscreen, RoPlus+Rs,
; iscreen-2, RoPlus+Rs,

**
**
*
*
*
*
*

-00005, 00726,
; iscreen-2, Ro+Rs,
-00003, 00726) }
; iscreen, Ro+Rs) }
within{ PolyLine ( -00063, 00774,
; iscreen, Ro+Rs+extra,
-00063, 00874,
; iscreen, RoPlus+Rs,
-00065, 00874,
; iscreen-2, RoPlus+Rs,
-00065, 00774,
; iscreen-2, Ro+Rs+extra,
-00063, 00774) }
; iscreen, Ro+Rs+extra) }
write (10,7007) '
within{ PolyLine ( ',iscreen,
& iRoRs,'
; iscreen, Ro+Rs+extra,'
write (10,7007) '
',iscreen,
& iRoPlRs,'
; iscreen, RoPlus+Rs,'
write (10,7007) '
',iscreen-2,
& iRoPlRs,'
; iscreen-2, RoPlus+Rs, '
write (10,7007) '
',iscreen-2,
& iRoRs,'
; iscreen-2, Ro+Rs+extra,'
write (10,7008) '
',iscreen,
& iRoRs,') }
; iscreen, Ro+Rs+extra) }'

write (10,7001) '


} ;END rotate_fill(360)'
write (10,7001) '
} ;END electrode(0) grounded screen'
endif
*======================================================================
*
* write out commands to create Magnet area - BEEPS
if (useb) then
write (11,7001) ';_______________________________________________'
& // '______________________________'
write (11,7001) '
;define magnet area'
write (11,7005) '
electrode(',iMags,
&
') {
;magnet faces '
write (11,7001) '
fill { '
*
yi = MagRi
zi = 0.0
*
iyi = iMagRi
izi = nint(zi)
*
yo = MagRo
zo = 2.0
*
iyo = iMagRo
izo = nint(zo)
do 6001 i = 0,14
degrees = 9.1 + i * 24.0
idegrees = nint(degrees)
write (11,7025) '
locate(0,0,0,.0254,0,0,',
&
degrees,') { '
write (11,7017) '
within{ Box3D ( ',-imagstop,
&
iMagRi,izi
write (11,7018) '
',-imagstart,
&
iMagRo,izo,' ) } '

write (11,7001) '


} ; locate '
6001 continue
write (11,7001) '
} ; fill'
write (11,7001) '
} ;END Magnet faces '
*----write (11,7005) '
electrode(',0,
&
') {
;magnet faces 2'
write (11,7001) '
fill { '
do 6002 i = 0,14
degrees = 0.0 + i * 24.0
idegrees = nint(degrees)
write (11,7025) '
locate(0,0,0,.0254,0,0,',
&
degrees,') { '
write (11,7017) '
within{ Box3D ( ',-imagstop,
&
iMagRi,izi
write (11,7018) '
',-imagstart,
&
iMagRo,izo,' ) } '
write (11,7001) '
} ; locate '
6002 continue
write (11,7001) '
} ; fill'
write (11,7001) '
} ;END Magnet faces 2'
endif
*
if (useb) then
*======================================================================
*
* write out commands to create SECOND screen electrode IF doing BEEPS
* and possibly a THIRD screen (second and third are at same potential)
*
if (useb) then
if (magscr2) then
*----write (10,7001) ';_______________________________________________'
& // '______________________________'
write (10,7001) '
;define extra magnet screen electrode, '
& // 'which is NOT grounded'
write (10,7005) '
electrode(',ibVoltage,
&
') {
;extra magnet screen electrode '
write (10,7005) '
rotate_fill(',360,') { ;Cylindrical'
& // ' symmetry, so rotate 360 degrees about X-axis'
write (10,7001) '
;2D geometry is '
& // 'defined in X-Y plane, and Z does not exist in definitions'
write (10,7001) '
;3D cylindrical '
& // 'form is generated by mirroring Y to -Y and rotating Y into '
& // 'Z about X'
write (10,7001) '
;(Why did they '
& // 'not make Z the axis for the cylinder?)'
**

within{ PolyLine ( -00003, 00000,

; -iscreen2, 0,

**
**
**
**
*
*
*
*
*

-00003, 00671,
; -iscreen2, Ri+Rs,
-00005, 00671,
; -iscreen2-2, Ri+Rs,
-00005, 00000,
; -iscreen2-2, 0,
-00003, 00000) }
; -iscreen2, 0) }
within{ PolyLine ( -00580, 00000,
; -iscreen2, 0,
-00580, 00724,
; -iscreen2, Ri+Rs,
-00582, 00724,
; -iscreen2-2, Ri+Rs,
-00582, 00000,
; -iscreen2-2, 0
-00580, 00000) }
; -iscreen2, 0) }
write (10,7007) '
within{ PolyLine ( ',-iscreen2,0,
& '
; -iscreen2, 0,'
write (10,7007) '
',-iscreen2,
& ibRiRs,'
; -iscreen2, bRi+Rs '
write (10,7007) '
',-iscreen2-2,
& ibRiRs,'
; -iscreen2-2, bRi+Rs '
write (10,7007) '
',-iscreen2-2,
& 0,'
; -iscreen2-2, 0'
write (10,7008) '
',-iscreen2,0,
& ') }
; -iscreen2, 0) }'

**
**
**
**
**
*
*
*
*
*

within{ PolyLine ( -00003, 00726,


; -iscreen2, Ro+Rs,
-00003, 00836,
; -iscreen2, RoPlus+Rs,
-00005, 00836,
; -iscreen2-2, RoPlus+Rs,
-00005, 00726,
; -iscreen2-2, Ro+Rs,
-00003, 00726) }
; -iscreen2, Ro+Rs) }
within{ PolyLine ( -00580, 00774,
; -iscreen2, Ro+Rs,
-00580, 00874,
; -iscreen2, RoPlus+Rs,
-00582, 00874,
; -iscreen2-2, RoPlus+Rs,
-00582, 00774,
; -iscreen2-2, Ro+Rs,
-00580, 00774) }
; -iscreen2, Ro+Rs) }
write (10,7007) '
within{ PolyLine ( ',-iscreen2,
& ibRoRs,'
; -iscreen2, bRo+Rs,'
write (10,7007) '
',-iscreen2,
& ibRoPlRs,'
; -iscreen2, bRoPlus+Rs, '
write (10,7007) '
',-iscreen2-2,
& ibRoPlRs,'
; -iscreen2-2, bRoPlus+Rs, '
write (10,7007) '
',-iscreen2-2,
& ibRoRs,'
; -iscreen2-2, bRo+Rs,'
write (10,7008) '
',-iscreen2,
& ibRoRs,') }
; -iscreen2, bRo+Rs) }'
write (10,7001) '
write (10,7001) '

} ;END rotate_fill(360)'
;define extra magnet screen electrode'

*----endif
*
*-----

if (magscr2) then

write (10,7001) ';_______________________________________________'

&

// '______________________________'
write (10,7001) '
;define magnet screen electrode, which'
& // ' is NOT grounded'
write (10,7005) '
electrode(',ibVoltage,
&
') {
;magnet screen electrode '
write (10,7005) '
rotate_fill(',360,') { ;Cylindrical'
& // ' symmetry, so rotate 360 degrees about X-axis'
write (10,7001) '
;2D geometry is '
& // 'defined in X-Y plane, and Z does not exist in definitions'
write (10,7001) '
;3D cylindrical '
& // 'form is generated by mirroring Y to -Y and rotating Y into '
& // 'Z about X'
write (10,7001) '
;(Why did they '
& // 'not make Z the axis for the cylinder?)'
**
**
**
**
**
*
*
*
*
*

within{ PolyLine ( -00003, 00000,


; -ibscreen, 0,
-00003, 00671,
; -ibscreen, Ri+Rs,
-00005, 00671,
; -ibscreen-2, Ri+Rs,
-00005, 00000,
; -ibscreen-2, 0,
-00003, 00000) }
; -ibscreen, 0) }
within{ PolyLine ( -00580, 00000,
; -ibscreen, 0,
-00580, 00724,
; -ibscreen, Ri+Rs,
-00582, 00724,
; -ibscreen-2, Ri+Rs,
-00582, 00000,
; -ibscreen-2, 0
-00580, 00000) }
; -ibscreen, 0) }
write (10,7007) '
within{ PolyLine ( ',-ibscreen,0,
& '
; -ibscreen, 0,'
write (10,7007) '
',-ibscreen,
& imRiRs,'
; -ibscreen, mRi+Rs '
write (10,7007) '
',-ibscreen-2,
& imRiRs,'
; -ibscreen-2, mRi+Rs '
write (10,7007) '
',-ibscreen-2,
& 0,'
; -ibscreen-2, 0'
write (10,7008) '
',-ibscreen,0,
& ') }
; -ibscreen, 0) }'

**
**
**
**
**
*
*
*
*
*

within{ PolyLine ( -00003, 00726,


; -ibscreen, Ro+Rs,
-00003, 00836,
; -ibscreen, RoPlus+Rs,
-00005, 00836,
; -ibscreen-2, RoPlus+Rs,
-00005, 00726,
; -ibscreen-2, Ro+Rs,
-00003, 00726) }
; -ibscreen, Ro+Rs) }
within{ PolyLine ( -00580, 00774,
; -ibscreen, Ro+Rs,
-00580, 00874,
; -ibscreen, RoPlus+Rs,
-00582, 00874,
; -ibscreen-2, RoPlus+Rs,
-00582, 00774,
; -ibscreen-2, Ro+Rs,
-00580, 00774) }
; -ibscreen, Ro+Rs) }
write (10,7007) '
within{ PolyLine ( ',-ibscreen,
& imRoRs,'
; -ibscreen, mRo+Rs,'

write (10,7007) '


imRoPlRs,'
; -ibscreen, mRoPlus+Rs, '
write (10,7007) '
& imRoPlRs,'
; -ibscreen-2, mRoPlus+Rs, '
write (10,7007) '
& imRoRs,'
; -ibscreen-2, mRo+Rs,'
write (10,7008) '
& imRoRs,') }
; -ibscreen, mRo+Rs) }'

',-ibscreen,

&

write (10,7001) '


write (10,7001) '

',-ibscreen-2,
',-ibscreen-2,
',-ibscreen,

} ;END rotate_fill(360)'
;define magnet screen electrode'

*----endif
*
if (useb) then
*======================================================================
*
*---------------------------------------------------------------------write (10,7001) '} ;END Locate (offset,0,0,.0254,0,0,0) { ; (1)'
& // ' shift orig'
write (10,7001) ';END of autogenerated Top Hat Heeps-X GEM file'
write (10,7001) ';_______________________________________________'
& // '______________________________'
if (useb) then
write (11,7001) '} ;END Locate (offset,0,0,.0254,0,0,0) { ; (1)'
& // ' shift orig'
write (11,7001) ';END of autogenerated Top Hat Heeps-X GEM file'
write (11,7001) ';_______________________________________________'
& // '______________________________'
endif
*
*======================================================================
*
*---------------------------------------------------------------------* ?Do another?, ask if interactive else check for more filenames on command line
* repeat or exit
*----* Presently UNimplemented -- just close test file and stop
close (unit=10,status='keep',err=9901)
9901 continue
if (useb) then
close (unit=11,status='keep',err=9902)
9902
continue
endif
print *,' '
print *,' Output is complete, program terminating.'
print *,' '
stop ' Live long and prosper'
*----------------------------------------------------------------------

* error handlers
*----*---------------------------------------------------------------------* Formats
*----7001 format (a)
7002 format (a66)
7003 format (a,i6.5)
7004 format (a,i6.5,a,i6.5,a)
7005 format (a,i6.5,a)
7006 format (a,i6.5,a,g16.6,a)
* 7006 format (a,i6.5,',',i6.5,',',i6.5,',',i6.5,',',a)
7007 format (a,i6.5,',',i6.5,',',a)
7008 format (a,i6.5,',',i6.5,a)
7009 format (a,i6.5,',',i6.5,',',i6.5,',',i6.5,a)
7010 format (e13.0)
7014 format (a,i6.5,a,i6.5,a,i6.5,a)
7017 format (a,i6.5,',',i6.5,',',i6.5)
7018 format (a,i6.5,',',i6.5,',',i6.5,a)
7023 format (a,g13.4)
7024 format (a,g13.4,a,g13.4,a)
7025 format (a,g13.4,a)
7027 format (a,g13.4,',',g13.4,',',a)
7028 format (a,g13.4,',',g13.4,a)
7029 format (a,g13.4,',',g13.4,',',g13.4,',',g13.4,a)
end

Anda mungkin juga menyukai