subroutine cathode(dwtp,iend,ibeg) c---------------------------------------------------------------------- c include 'param_sz.h' include 'bfieldcom.h' include 'constcom.h' include 'pcordcom.h' include 'syscom.h' include 'ucom.h' c common/cathcur/rcur c-------------------------------------------------------------------------- c* ne=rne bz=bgz/gamma dz=bz*dcon*dwtp c----particle will be moved into next element during this step. c----the next element should be a cell of length greater then c----the distance this element moves the particles. c----the next element in particular must not have zero length! c----the location of this element should be at z=0. a zero length c----drift could preceed this element. if(dz.ge.0.)iend=1 c-----allow particle to go backwards if(ne.ge.1.and.dz.lt.0.and.z+dz.le.zloc(ne-1))then c----particle will cross into previous element during this step ibeg=1 endif r=sqrt(x*x+y*y) if(iend.eq.1.and.rcur.gt.r)then theata=asin(r/rcur) dz=rcur*(1.-cos(theata)) z=z+dz bgz=bgz*cos(theata) bgr=-bgz*sin(theata) if(r.ne.0.)then bgx=x/r*bgr bgy=y/r*bgr endif endif if(ibeg.eq.1)z=zloc(ne-1) dwtp=0. return end c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*