cir.v



[CIRbessdata] [CIRfield] [CIRflags] [CIRgeneral] [CIRhist] [CIRmatch] [CIRsetacc] [CIRsubs] [CIRtmp] [CIRvars] [CIRvartmp] [CIRversion]

cir
#@(#) File CIR.V, version $Revision: 3.10 $, $Date: 2003/10/23 23:30:56 $
# Copyright (c) 1999, The Regents of the University of California.
# All rights reserved.  See LEGAL.LLNL for full text and disclaimer.
# This is the parameter and variable database for CIRCE.
# Dave Grote,    LLNL, (510) 423-7194  dave@hif.llnl.gov 
# Bill Sharp,    LLNL 
{
}


[cirinit] [cirvers]
Module CIRversion:
# Version control for cir package
verscir  character*19 /"$Revision: 3.10 $"/  # Current code version, set by CVS


[circesetlatt] [cirexe] [cirgen] [cirx] [initbeam]
Module CIRvars dump:
# Variables needed by the package CIR
dscir real /0.0/  [m]    # Step size in envelope calculation
zlcir real /0.0/  [m]    # Starting z for CIRCE calc
zucir real /0.0/  [m]    # Maximum  z for CIRCE calc
nscir integer /0/        # Total number of time steps
nit       integer [1]    # Number of point along beam
acir(nit)   dynamic real [m]    # Width in x (1)[0]
apcir(nit)  dynamic real [1]    # Slope in x (2)[1]
bcir(nit)   dynamic real [m]    # Width in y (3)[2]
bpcir(nit)  dynamic real [1]    # Slope in y (4)[3]
xcir(nit)   dynamic real [m]    # Centroid in x (5)[4]
xpcir(nit)  dynamic real [m]    # Centroid slope in x (6)[5]
ycir(nit)   dynamic real [m]    # Centroid in y (7)[6]
ypcir(nit)  dynamic real [m]    # Centroid slope in y (8)[7]
tcir(nit)   dynamic real [s]    # Time (9)[8]
vzcir(nit)  dynamic real [1]    # Axial velocity over clight (10)[9]
enxcir(nit) dynamic real [pi-m-rad] # Normalized X emittance (11)[10]
enycir(nit) dynamic real [pi-m-rad] # Normalized Y emittance (12)[11]
cur(nit)    dynamic real [Amps] # Current (13)[12]
dq(nit)     dynamic real [?]    # Charge per slice (14)[13]
den(nit)    dynamic real        # Line-charge density times clight (15)[14]
var(16,nit) dynamic real        # Copy of envelope data, all in one place.


[cirexe] [cirx] [initbeam]
Module CIRgeneral dump:
lcirout    logical  /.true./ # Print diagnostic output
cirtime    real              # Total runtime
footrise    real
tfoot    real
curfoot    real
tiltmid    real /0.5/
tiltlen    real /10.0/


[circesetlatt] [cirexe] [cirgen] [cirx] [initbeam]
Module CIRflags dump:
ltdependent logical /.false./ # When true, CIRCE uses follows a beam
                              # using time as the independent variable
                              # instead of position
icharge    integer /1/ # The space-charge model...
                       # 1: uses simple g-factor space-charge model
                       # 2: includes envelope variation in space-charge model
                       # 3: includes end effects in space-charge model
                       # 4: uses a more accurate model of end effects
                       # 5: uses a Bessel-series model of end effects
lezbeam    logical /.true./ # Turns on use of axial self-field
lperveance logical /.true./ # Turns on use of perveance (transverse self-field)
lemittance logical /.true./ # Turns on use of emittance
lallez     logical /.true./ # Turns on use of all axial fields
llinear    logical /.true./ # Only includes linear turns in bends
limage     logical /.true./ # Turns on use of image fields
lendzero   logical /.true./ # If true, a zero radius at the first and last
                            # slice is kept zero
lsavehist  logical /.true./ # Turns on saving of history of envelope
icurload   integer /0/ # current-load flag
                       # 0 sets up line-charge profile as function of time
                       # 1 sets up line-charge profile as function of s
iprofile   integer /0/ # line-charge profile flag
                       # 0 uses hyperbolic-tangent profile
                       # 1 uses flat-top profile with linear fall-off
                       # 2 uses flat-top profile with quadratic fall-off
                       # 3 uses flat-top profile with cubic fall-off
                       # 4 uses flat-top profile with Gaussian fall-off
                       # 5 uses flat-top profile with Fermi-function fall-off
ivelload   integer /0/ # velocity-tilt flag
                       # 0 sets up an initial tilt in beam velocity vs time
                       # 1 sets up an initial tilt in beam velocity vs position
igrid      integer /0/ # controls initial spacing of arrival-time values
                       # 0 uniform layout
                       # 1 cell size decreasing near ends
iemload    integer /0/ # emittance-load flag
                       # 0 gives uniform emittance
                       # 1 gives uniform transverse temperature
                       # 2 gives uniform charge density
                       # 3 gives uniform beam radius
lfixed     logical /.false./ # if true, the correct expression for d(lambda)/dz is used


[circegetimage] [cirgen] [cirrun] [derivs] [extebcir] [initbeam] [setears]
Module CIRfield:
# Applid fields at the current location
nitfield    integer # Size of arrays
ex(nitfield)     dynamic real # From dipole
ey(nitfield)     dynamic real # From dipole
ez(nitfield)     dynamic real # From accelation gap
ears(nitfield)   dynamic real # From axially confining ear field
bx(nitfield)     dynamic real # From dipole
by(nitfield)     dynamic real # From dipole
bz(nitfield)     dynamic real # (Unused)
dedx(nitfield)   dynamic real # From quadrupole
dbdx(nitfield)   dynamic real # From quadrupole
fx(nitfield)     dynamic real # From image
fy(nitfield)     dynamic real # From image
gxx(nitfield)    dynamic real # From image
gxy(nitfield)    dynamic real # From image
gyx(nitfield)    dynamic real # From image
gyy(nitfield)    dynamic real # From image
ezbeam(nitfield) dynamic real [V/m] # Self axial electric field
yflderr      real
bendcurv     real /0.0/
ipipetype    integer /0/
rpipe        real
xpipeerr     real /0.0/
ypipeerr     real /0.0/
sinrot       real /0.0/
cosrot       real /1.0/


[cirrun] [cirx] [gettemp] [initbeam]
Module CIRvartmp:
# These are used as temporary space in the integration of the envelope
# equations.
nitvartmp         integer
yt(16,nitvartmp)  dynamic real
dy1(16,nitvartmp) dynamic real
dy2(16,nitvartmp) dynamic real
dy3(16,nitvartmp) dynamic real


[cirgen] [derivs] [getezbeam] [initbeam] [setears]
Module CIRtmp:
nittmp           integer
gtemp(nittmp)    dynamic real # Temp space for getezbeam, G-factor
curmid(nittmp)   dynamic real # Temp space for getezbeam
denmid(nittmp)   dynamic real # Temp space for getezbeam
dden(nittmp)     dynamic real # Temp space for getezbeam
denv(nittmp)     dynamic real # Temp space for getezbeam
rad(nittmp)      dynamic real # Temp space for getezbeam
zeta(nittmp)     dynamic real # Temp space for getezbeam
sum0(nittmp)     dynamic real # Temp space for getezbeam
sum1(nittmp)     dynamic real # Temp space for getezbeam
dlna(nittmp)     dynamic real # Temp space for getezbeam
dlnb(nittmp)     dynamic real # Temp space for getezbeam
etemp(nittmp)    dynamic real # Temp space for getezbeam
ftemp(nittmp)    dynamic real # Temp space for getezbeam
ezval(nittmp)    dynamic real # Temp space for setears
dummy(nittmp)    dynamic real # Temp space for setears


Module CIRmatch:
varfract            real /0.05/
varstepmin          real /1.0e-08/
nitmatch            integer
varold(8,nitmatch) dynamic real
varnew(8,nitmatch) dynamic real
del(8)              real
der(8,8,nitmatch)  dynamic real
delvar(8,nitmatch) dynamic real
ratio(nitmatch)    dynamic real


[getezbeam]
Module CIRbessdata dump:
nmax integer /150/
#besszero real /2.408255577/
besszeros(10) real /2.4048255577, 5.5201, 8.6537, 11.7915, 14.9309, 18.0711, 21.2116, 24.3525, 27.4935, 30.6346/
bessdenom(10) real /1.5587, 3.5280, 5.5182, 7.5134, 9.5106, 11.5088, 13.5075, 15.5065, 17.5058, 19.5052/


[cirexe] [cirgen] [cirrun] [initbeam] [savehistcir] [savehistcir1]
Module CIRhist dump:
lhcir integer
nhcir integer
nithist  integer # Number of slices whose history is saved
jhcir integer /-1/
hscir(0:lhcir)        dynamic real [m]   limited(0:jhcir)     # Beam location
hacir(nithist,0:lhcir)   dynamic real [m]   limited(nithist,0:jhcir)
hapcir(nithist,0:lhcir)  dynamic real [m]   limited(nithist,0:jhcir)
hbcir(nithist,0:lhcir)   dynamic real [m]   limited(nithist,0:jhcir)
hbpcir(nithist,0:lhcir)  dynamic real [m]   limited(nithist,0:jhcir)
hxcir(nithist,0:lhcir)   dynamic real [m]   limited(nithist,0:jhcir) # X centroid in x
hxpcir(nithist,0:lhcir)  dynamic real [m]   limited(nithist,0:jhcir) # X centroid slope
hycir(nithist,0:lhcir)   dynamic real [m]   limited(nithist,0:jhcir) # Y centroid in y
hypcir(nithist,0:lhcir)  dynamic real [m]   limited(nithist,0:jhcir) # Y centroid slope
htcir(nithist,0:lhcir)   dynamic real [s]   limited(nithist,0:jhcir) # Time
hvzcir(nithist,0:lhcir)  dynamic real [m/s] limited(nithist,0:jhcir) # Axial velocity
henxcir(nithist,0:lhcir) dynamic real []    limited(nithist,0:jhcir) #
henycir(nithist,0:lhcir) dynamic real []    limited(nithist,0:jhcir) #
hcur(nithist,0:lhcir)    dynamic real []    limited(nithist,0:jhcir) #
hdq(nithist,0:lhcir)     dynamic real []    limited(nithist,0:jhcir) #
hden(nithist,0:lhcir)    dynamic real []    limited(nithist,0:jhcir) #


[setacc]
Module CIRsetacc:
# Temporary arrays for setacc
nitacc integer
ct0(nitacc)      dynamic real
ctold(nitacc)    dynamic real
ctnext(nitacc)   dynamic real
betinit(nitacc)  dynamic real
betaold(nitacc)  dynamic real
betanext(nitacc) dynamic real
curinit(nitacc)  dynamic real
sumslice(nitacc) dynamic real
tout(nitacc)     dynamic real
accout(nitacc)   dynamic real
earout(nitacc)   dynamic real
betamid_set       real
deltbeam_set      real
iaccl             integer


Module CIRsubs:
#  Callable subroutines in the CIR package
cirinit()  subroutine
cirgen()   subroutine
cirexe()   subroutine
cirx ()    subroutine #  Python-level interface to CIRCE
initbeam() subroutine # Calls setbeam using WARP database
cirrun(nit:integer,y:real,zlcir:real,zucir:real,dscir:real,nscir:integer,
       aion:real,zion:real,
       icharge:integer,lezbeam:logical,lperveance:logical,lemittance:logical,
       lallez:logical,llinear:logical,limage:logical,lendzero:logical,
       lsavehist:logical,lfixed:logical) subroutine
  # Runs CIRCE kernel
setstep(s:real,ds:real,zlcir:real,zucir:real,dscir:real) subroutine
  # Sets step size, looking for beginning of the next element
extebcir(z:real,dz:real,y:real,nit:integer) subroutine
  # Gather applied fields
derivs(s:real,ds:real,dsfrac:real,y:real,dy:real,nit:integer,
       aion:real,zion:real,
       icharge:integer,lezbeam,lperveance,lemittance,lallez,llinear,
       limage:logical,lendzero:logical,lfixed:logical) subroutine
  # Calculates new envelope quantities based using applied and self fields
integrt(y:real,yt:real,dy1:real,dy2:real,dy3:real,nit:integer,s:real,ds:real,
        aion:real,zion:real,
        icharge:integer,lezbeam,lperveance,lemittance,lallez,llinear,
        limage:logical,lendzero:logical,lfixed:logical) subroutine
  # Complete Runga-Kutta integration step
circegetimage(y:real,nit:integer,llinear,limage:logical,lendzero:logical) subroutine
  # Calculate images fields from surrounding pipe
getezbeam(nit:integer,y:real,eval:real,rpipe:real,icharge:integer,
          lezbeam:logical,lendzero:logical,lfixed:logical,lfailed:logical) subroutine
  # Calculates self axial field
savehistcir(s:real,y:real,nit:integer,nscir:integer,lsavehist:logical)
    subroutine
  # Checks if history needs to be save and saves it
savehistcir1(s:real,y:real,nit:integer) subroutine
  # Copies data into history arrays (experts only)
setcur(nit:integer,y:real,
       curmax:real,currise:real,curfall:real,deltbeam:real,footrise:real,
       tfoot:real,curfoot:real,
       icurload:integer,iprofile:integer,
       beta0:real,tilt:real,tiltmid:real,tiltlen:real,
       ivelload:integer) subroutine
  # Loads a current (and velocity) based on the given profile and tilts.
  # Calls setbeta to load the velocity
setbeta(beta0:real,y:real,nit:integer,
        tilt:real,tiltmid:real,tiltlen:real,
        ivelload:integer) subroutine
  # Loads a velocity based on the given tilt
settval(nit:integer,y:real,deltbeam:real,time0:real,igrid:integer) subroutine
  # Loads the initial time values

getphase(sig0:real,sig1:real,hlp:real,betaval:real,curval:real,tval:real,
         sval:real,emitx:real,emity:real,aion:real,zion:real,
         lperveance:logical) subroutine
  # Calculates sig0 and sig at one slice
getphaset(nit:integer,sig0:real,sig1:real,hlp:real,sval:real,y:real,
          aion:real,zion:real,lperveance:logical) subroutine
  # Calculates sig0 and sig at each slice
setears(nit:integer,y:real,ntval:integer,earval:real,tval:real,z:real,
        iearset:integer,iearform:integer,icharge:integer,ieargap:integer,
        lendzero:logical,lfailed:logical) subroutine
  # Calculates the ear field
setemit(nit:integer,y:real,iemload:integer,lperveance:logical) subroutine
  # Sets emittance
getlen(nit:integer,y:real,beamlen:real) subroutine
  # Get beam length
gettemp(nit:integer,y:real,s:real,beamtemp:real,delv:real,aion:real,zion:real,
        icharge:integer,lezbeam:logical,lperveance:logical,lemittance:logical,
        lallez:logical,llinear:logical,limage:logical,lendzero:logical,lfixed:logical)
        subroutine
  # Get beam temperature
resetbeta(nit:integer,y:real,inout:string) subroutine
  # Adjust axial velocity in entrance and exit of a dipole
setbeam(nit:integer,y:real,a0:real,b0:real,ap0:real,bp0:real,
        x0:real,y0:real,xp0:real,yp0:real,
        ibeam:real,currise:real,curfall:real,deltbeam:real,
        footrise:real,tfoot:real,curfoot:real,
        beta:real,gammabar:real,tilt:real,tiltmid:real,tiltlen:real,
        emitx:real,emity:real,time:real,zbeam:real,aion:real,zion:real,
        icurload:integer,iprofile:integer,ivelload:integer,igrid:integer,
        iemload:integer,lperveance:logical,lendzero:logical) subroutine
  # Loads all of the data needed for a beam.
setacc(schedule:string,nit:integer,y:real,ekinstart:real,ekinend:real,
       zlcir:real,zucir:real,deltbeam:real,curmax:real,currise:real,
       curfall:real,footrise:real,tfoot:real,curfoot:real,icurload:integer,
       iprofile:integer,beta0:real,tilt:real,tiltmid:real,tiltlen:real,
       ivelload:integer,lperveance:logical,aion:real,zion:real) subroutine
  # Sets accelerating schedules for the gaps