source: PSPA/parmelaPSPA/tags/v0.1/sbload.f @ 101

Last change on this file since 101 was 101, checked in by garnier, 12 years ago

premier tag

File size: 3.2 KB
Line 
1      subroutine sbload(ne)
2c---calculate effects of single-bunch beam loading
3c---sbload paramaters are l,aperature,iout,zlen,number of cells,
4c--- a1,a2,a3,a4,a5,ta1,ta2,ta3,ta4,ta5
5c--- The coefficents for the transvers wake are ta1 to ta5. the transvers
6c--- wake is applied if the parameter ncells is negative.
7c--- the longitudnal wake is applied in either case.
8c---------------------------------------------------------------------------
9c
10      include 'param_sz.h'
11      include 'constcom.h'
12      include 'coordcom.h'
13      include 'ncordscom.h'
14      include 'pcordcom.h'
15      include 'syscom.h'
16      include 'ucom.h'
17c
18      common/pnum/ipnum(imaa)
19      common/sbload1/tsbparm(5,50)
20c--------------------------------------------------------------------------
21c*
22      write(nnout,*) ' subroutine sbload : dbgxy was not defined ! '
23      dbgxy=0.01
24      zlen=el(4,ne)
25      cells=el(5,ne)
26      a1=el(6,ne)
27      a2=el(7,ne)
28      a3=el(8,ne)
29      a4=el(9,ne)
30      a5=el(10,ne)
31      if(cells.lt.0)then
32      nc=el(11,ne)
33      ta1=tsbparm(1,nc)
34      ta2=tsbparm(2,nc)
35      ta3=tsbparm(3,nc)
36      ta4=tsbparm(4,nc)
37      ta5=tsbparm(5,nc)
38      endif
39c--if a1 to a5 are zero assume 1.3ghz fel cavity and scale for freq.
40c--to be compatiable with previous versions of sbload.
41      if(a1.eq.0)then
42      scale=freq/1300
43      a1=1.5316e13*scale
44      a2=1.40056*scale
45      a3=-5.024e14*scale*scale
46      a4=5.41*sqrt(scale)
47      a5=0.
48      ta1=ta1*scale*scale
49      ta2=ta2*scale
50      ta3=ta3*scale*scale*scale
51      ta4=ta4*sqrt(scale)
52      ta5=0.0
53      endif
54      zr=cord(5,1)
55      zmax=zr+.5*zlen
56      zmin=zmax-zlen
57      if(cells.gt.0.0) then
58      do 20 n=2,ngood
59       c4=cells*weight(n)*1.e-6/erest
60      zq=cord(5,n)
61      if ((zq-zmin)*(zq-zmax).gt.0.) go to 20
62      if(a5.ne.0.)then
63      do 10 m=1,ngood
64      z=cord(5,m)
65      dz=zq-z
66   10 continue
67       else
68      do 15 m=1,ngood
69      z=cord(5,m)
70      dz=zq-z
71   15 continue
72       endif
73   20 continue
74      else
75      cells=-cells
76      do 21 n=2,ngood
77       c4=cells*weight(n)*1.e-6/erest
78      zq=cord(5,n)
79      if ((zq-zmin)*(zq-zmax).gt.0.) go to 21
80      if(a5.ne.0..and.ta5.ne.0.)then
81      do 11 m=1,ngood
82      z=cord(5,m)
83      dz=zq-z
84      cord(2,m)=cord(2,m)+dbgxy*cord(1,n)
85      cord(4,m)=cord(4,m)+dbgxy*cord(3,n)
86   11 continue
87       elseif(a5.eq.0.and.ta5.eq.0.)then
88      do 12 m=1,ngood
89      z=cord(5,m)
90      dz=zq-z
91      cord(2,m)=cord(2,m)+dbgxy*cord(1,n)
92      cord(4,m)=cord(4,m)+dbgxy*cord(3,n)
93   12 continue
94      elseif(a5.ne.0..and.ta5.eq.0.)then
95      do 13 m=1,ngood
96      z=cord(5,m)
97      dz=zq-z
98      cord(2,m)=cord(2,m)+dbgxy*cord(1,n)
99      cord(4,m)=cord(4,m)+dbgxy*cord(3,n)
100   13 continue
101       elseif(a5.eq.0..and.ta5.ne.0.)then
102      do 14 m=1,ngood
103      z=cord(5,m)
104      dz=zq-z
105      cord(2,m)=cord(2,m)+dbgxy*cord(1,n)
106      cord(4,m)=cord(4,m)+dbgxy*cord(3,n)
107   14 continue
108       endif
109   21 continue
110      endif
111      n=1
11230    continue
113      bgzsq=gam(n)**2-(1.+cord(2,n)**2+cord(4,n)**2)
114      if (bgzsq.gt.0.) go to 50
115      cord(6,n)=-sqrt(-bgzsq)
116      go to 60
117   50 cord(6,n)=sqrt(bgzsq)
118   60 n=n+1
119      if (n.le.ngood) go to 30
120      return
121      end
122c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.