source: PSPA/parmelaPSPA/trunk/scheff3.f @ 404

Last change on this file since 404 was 12, checked in by lemeur, 12 years ago

parmela pspa initial

File size: 3.4 KB
Line 
1      subroutine scheff3(dist,mt,wtsauv)
2c
3c     point to point space charge calculations by Bourat
4c     ref : thesis Bourat 1988 - orsay
5c
6c----
7c         dist = distance travelled by light since last call to scheff
8c         sce(1)=beam current in amperes.
9c         sce(2)=3 program number
10c         sce(3)=opt particle size factor
11c         sce(4)=no. of adjacent bunches
12c         sce(5)=distance between bunches.
13c
14c-------------------------------------------------------------------------
15      save
16c
17      include 'param_sz.h'
18      include 'constcom.h'
19      include 'coordcom.h'
20      include 'fldcom.h'
21      include 'misccom.h'
22      include 'ncordscom.h'
23      include 'pipecom.h'
24      include 'psizescom.h'
25      include 'sccom.h'
26      include 'ucom.h'
27c
28      common/intype/intype
29c----
30      data cte/1.758804786/     ! e/m0 in cgs units
31c
32      if (dist) 20,10,20
33c      intialization
34  10   continue
35       beami=sce(1)
36       opt=abs(sce(3))
37       if (opt.le.0.)opt=1.
38       nip=sce(4)
39       pl=sce(5)
40       if(pl.le.0)pl=wavel
41       xnp=float(npoints-1)
42       qmacro=beami/(freq*xnp)
43       rmacro=opt*(qmacro**.33333333333)*1.e-8
44       facq=qmacro*cte
45c
46       write(nnout,*) ' Space charge subroutine number ',iprog
47       if (ip.eq.1 .or. ip.eq.2 .or. ip.eq.4) then
48          qmacroprint=qmacro*1.e+03
49          write (nnout,410) qmacroprint
50  410     format (' point to point space charge calculation'/
51     .    '  qmacro = ',1pg11.3,' nC per superparticle')
52          abeami = abs(beami)
53          if (beami.gt.0.) write (nnout,420) abeami
54  420     format (' beam current = ',1pg12.3,' amps')
55          write (nnout,450) opt
56  450     format (' particle size factor =',t40,1pg12.3)
57       endif
58c
59       return
60c
61c      space charge calculation
62c
63  20   continue
64       do 30 j=2,ngood
65c        calcul of impuls of j
66       xj=cord(1,j)
67       gbxj=cord(2,j)
68       yj=cord(3,j)
69       gbyj=cord(4,j)
70       zj=cord(5,j)
71       if(zj.le.0)goto 30   ! jg (zj.le.z0)
72       gbzj=cord(6,j)
73       gamj=gam(j)
74       bxj=gbxj/gamj
75       byj=gbyj/gamj
76       bzj=gbzj/gamj
77c
78       do 40 i=2,ngood
79c       field create by i
80       if(i.eq.j)goto 40
81       xi=cord(1,i)
82       gbxi=cord(2,i)
83       yi=cord(3,i)
84       gbyi=cord(4,i)
85       gbzi=cord(6,i)
86       gami=gam(i)
87       bxi=gbxi/gami
88       byi=gbyi/gami
89       bzi=gbzi/gami
90c
91       do 50 ni=-nip,nip
92c        adjacent bunches
93       zi=cord(5,i)+ni*pl
94c
95       xij=xj-xi
96       yij=yj-yi
97       zij=zj-zi
98       rijbi=xij*bxi+yij*byi+zij*bzi
99       gi2=gami*gami/(gami+1.)
100       grb=gi2*rijbi
101c
102       xpij=xij+bxi*grb
103       ypij=yij+byi*grb
104       zpij=zij+bzi*grb
105       rpij=sqrt(xpij*xpij+ypij*ypij+zpij*zpij)
106       if(rpij.le.rmacro)rpij=rmacro
107       rp3=rpij**3
108c
109       epxin=xpij/rp3
110       epyin=ypij/rp3
111       epzin=zpij/rp3
112c
113       biep=bxi*epxin+byi*epyin+bzi*epzin
114       bjep=bxj*epxin+byj*epyin+bzj*epzin
115       bjbi=bxj*bxi+byj*byi+bzj*bzi
116       bjbi1=1.-bjbi
117       ggi=gami/(gami+1.)
118       facbi=bjep-ggi*biep
119c
120       fdp=facq*dist
121c
122       dgbxj=fdp*gami*(epxin*bjbi1+bxi*facbi)
123       dgbyj=fdp*gami*(epyin*bjbi1+byi*facbi)
124       dgbzj=fdp*gami*(epzin*bjbi1+bzi*facbi)
125c
126       cord(2,j)=cord(2,j)+dgbxj
127       cord(4,j)=cord(4,j)+dgbyj
128       cord(6,j)=cord(6,j)+dgbzj
129       gam(j)=sqrt(1.+cord(2,j)**2+cord(4,j)**2+cord(6,j)**2)
130c
131  50   continue
132  40   continue
133  30   continue
134c
135       return
136       end
137c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.