source: PSPA/parmelaPSPA/trunk/cathod.f @ 447

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

parmela pspa initial

File size: 1.5 KB
Line 
1      real function cathod(rsq)
2c        calculate the cathode shape z(rsq,ajones) according to Jones
3c        IEEE NS-32, 1794 (1985)
4c----------------------------------------------------------------------
5c
6      include 'param_sz.h'
7c
8      common/jones/ajones,zjones,zcath(imaa)
9      real ajones,zjones,zcath
10c----------------------------------------------------------------------
11c        use units such that z = 1 at the zero-field point
12      rrsq = rsq/zjones**2
13      p3 = -ajones
14      p = 3.*p3
15      q = -3. + 6.*ajones - 1.5*rrsq
16      r = 1.5*ajones*rrsq
17      a = (3.*q - p**2)/3.
18      b = (2.*p*p**2 - 9.*p*q + 27.*r)/27.
19      const = a*a**2/27.
20      surd = 0.25*b**2 + const
21      cathod = 0.
22      if (surd.ge.0.) then
23        root = sqrt(surd)
24        aa = -0.5*b + root
25        sign = 1.
26        if (aa.lt.0) then
27          sign = -1.
28          aa = -aa
29        endif
30        aa = sign*aa**.333333
31        bb = -0.5*b - root
32       sign = 1.
33       if (bb.lt.0) then
34          sign = -1.
35          bb = -bb
36        endif
37        bb = sign*bb**.333333
38        cathod = aa + bb - p3
39      else
40        phi = acos(-0.5*b/sqrt(-const))/3.
41        fact = 2.*sqrt(-a/3.)
42c        c1 = fact*cos(phi) - p3
43c        c2 = fact*cos(phi + 2.094395) - p3
44c          it appears that the 3rd root is the desired one
45        cathod = fact*cos(phi + 4.188790) - p3
46      endif
47      cathod = cathod*zjones
48      return
49      end
50c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
Note: See TracBrowser for help on using the repository browser.