source: PSPA/parmelaPSPA/trunk/alpham.f @ 315

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

parmela pspa initial

File size: 4.0 KB
Line 
1      subroutine alpham(dwtp,iend,np)   
2c--------------------------------------------------------------------------
3      save
4c
5      include 'param_sz.h'
6      include 'constcom.h'
7      include 'pcordcom.h'
8      include 'syscom.h'
9      include 'ucom.h'
10c
11      common/aswap/acor(7,imaa) 
12      data itest/0/             
13c--------------------------------------------------------------------------
14cbm !!! warning is for theta = 40.71 degres
15cbm      data thetar,sr,cr,tr/.71052354,.65223071,.75802051,0.8604394/!LIU
16c--------------------------------------------------------------------------
17c*
18c       el(1,ne)=l distance travelled by the r.p. for a complete cycle
19c       el(2,ne)=aper (vmax) for dropping
20c       el(3,ne)=iout
21c       el(4,ne)=wr energy of r.p.
22c       el(5,ne)=thetd incident and exiting angles in degrees
23c       el(6,ne)=wmax
24c       el(7,ne)=deltab
25c       el(8,ne)=l1
26c       el(9,ne)=l2
27c       el(10,ne)=xles
28c       el(11,ne)=xhes
29c
30c       -------------------------------
31      ne=rne
32        if(itest.eq.0) then
33                gr=el(4,ne)/erest
34                bg=sqrt(gr*(2.+gr))
35                rhour=brhof*bg/el(7,ne)
36        endif           
37        thetar=el(5,ne)*radian
38        sr=sin(thetar)
39        cr=cos(thetar)
40        tr=tan(thetar)
41C       ---------------------------
42        if(gamma.le.1.5) go to 100      !added oct 20 89
43c       ---------------------------
44        dphi=dcon*dwtp
45        xp=bgx/bgz
46        yp=bgy/bgz
47        if(acor(7,np).eq.1.) go to 70  !particle  in
48        bz=bgz/gamma
49        dz=bz*dphi
50        x=x+xp*dz
51        y=y+yp*dz
52        z=z+dz
53        if(acor(7,np).eq.-1.) then
54                zaway=zloc(ne)-z        !particle out
55                zn=el(9,ne)-zaway
56                u=-zn*cr-x*sr
57                v=zn*sr-x*cr
58                if(zaway.le.0.) then
59                        iend=1
60                        acor(7,np)=0.0
61                endif
62                return
63        else
64                zaway=zloc(ne-1)+el(8,ne)+x*tr-z
65                zn=-zaway
66                u=zn*cr-x*sr
67                v=zn*sr+x*cr
68        endif
69        if(u.lt.0.) go to 65
70        bx=bgx/gamma
71        by=bgy/gamma
72        acor(1,np)=u
73        acor(2,np)=v
74        acor(3,np)=y
75        acor(4,np)=bz*cr-bx*sr
76        acor(5,np)=bz*sr+bx*cr
77        acor(6,np)=by
78        acor(7,np)=1.
7965      continue
80        return
8170      continue
82c       -----------------------
83        u=acor(1,np)
84        v=acor(2,np)
85        w=acor(3,np)
86        bu=acor(4,np)
87        bv=acor(5,np)
88        bw=acor(6,np)
89c       ------------------------------
90        if(abs(u).lt.0.1.and.(abs(v).ge.el(2,ne).or.abs(w).ge.el(6,ne)))
91     .   go to 100
92c       ------------------------------
93        theta1=atan(xp)
94c       theta1=atan2(bx,bz)
95        con=1.+xp**2+yp**2
96c       thetai=thetar+theta1    !injection angle for an electron
97c       -------------------------
98c       buvsq=bu**2+bv**2
99c       buv=sqrt(buvsq)
100c       rhou=bgd*buv    !for an electron
101c
102c       ac=deltab/(gamma*brhof)
103        acd=dphi*el(7,ne)/(gamma*brhof)
104c       phi0=0.5*(0.5*pi-thetai)
105c       umax=2.*cos(phi0)*sqrt(buv/ac)
106c       ------------------------------------
107c       h1=v*cr
108c       hf=-h1-1.28*umax*theta1
109c       hf=-h1-1.28*umax*xp
110c       
111        dbu=acd*u*bv
112        dbv=acd*(w*bw-u*bu)
113        dbw=-acd*w*bv
114c
115        bu=bu+dbu
116        bv=bv+dbv
117        bw=bw+dbw
118        buvsq=bu**2+bv**2
119        buv=sqrt(buvsq)
120c
121        du=bu*dphi
122        dv=bv*dphi
123        dw=bw*dphi
124        u=u+du
125        v=v+dv
126        w=w+dw
127c       print 110,x,z,u,v,bv
128c110    format(1x,5(e12.5,1x))
129c       1.3=.85(r of d.t)/sr   !!!!!!!!
130        if(u.lt.1.3) go to 72
131        vsign=v/acor(2,np)
132        if(vsign.lt.0.0.and.(u.le.el(10,ne) .or. u.ge.el(11,ne))) 
133     .    go to 100
134  72    continue
135        rccc=(bu*dbv-bv*dbu)/dphi
136        rhoa=abs(buvsq*buv/rccc)
137        thetaa=atan2(bv,bu)
138c       --------------------------
139        ur=u+x*sin(thetaa-theta1)  !u of c.r.
140c       if(ur.le.0.0) goto 66
141        rhor=rhour/ur
142        rh=rhor+x
143        ds=sqrt(du**2+dv**2)
144        be=ds*cos(theta1)
145c       be=ds  !modified for test
146        ang=be/rh
147        dz=rhor*ang
148c
149        ant=ang+theta1
150        sant=sin(ant)
151        cant=cos(ant)
152c       ct1=cos(theta1)
153        arg=sant-(rh/rhoa)*sin(ang)
154        if(abs(arg).ge.1.) go to 100
155        theta2=asin(arg)
156        ct2=cos(theta2)
157        h2=-rhor+rh*cos(ang)+rhoa*(ct2-cant)
158c       ---------
159        zn=z+dz
160        z = zn
161        x=h2
162c       y=y+yp*rhoa*(ant-theta2)*ct1
163c       yp=yp*ct1/ct2
164        y=w
165        by=bw
166        yp=by/(buv*ct2)
167        xp=tan(theta2)
168        bgz=bgz*sqrt(con/(1.+xp**2+yp**2))
169        bgx=xp*bgz
170        bgy=yp*bgz
171        gamma=sqrt(1.+bgx**2+bgy**2+bgz**2)
172c
173        if(u.gt.0.) go to 90
174        acor(7,np)=-1.
175        return
176  90    continue
177        acor(1,np)=u
178        acor(2,np)=v
179        acor(3,np)=w
180        acor(4,np)=bu
181        acor(5,np)=bv
182        acor(6,np)=bw
183        return
184 100    continue
185c       WRITE(NDIAG,101) IEND,(ACOR(KK,NP),KK=1,7)
186c       write(ndiag,101) np,u,v,w,bu,bv,bw,acor(7,np)
187c       write(ndiag,101) ne,x,y,z,bx,by,bz,gamma
188c101    format(1x,i5,7(e9.2,1x))
189        x=2.*el(2,ne)
190        return
191        end
192c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.