real function cathod(rsq) c calculate the cathode shape z(rsq,ajones) according to Jones c IEEE NS-32, 1794 (1985) c---------------------------------------------------------------------- c include 'param_sz.h' c common/jones/ajones,zjones,zcath(imaa) real ajones,zjones,zcath c---------------------------------------------------------------------- c use units such that z = 1 at the zero-field point rrsq = rsq/zjones**2 p3 = -ajones p = 3.*p3 q = -3. + 6.*ajones - 1.5*rrsq r = 1.5*ajones*rrsq a = (3.*q - p**2)/3. b = (2.*p*p**2 - 9.*p*q + 27.*r)/27. const = a*a**2/27. surd = 0.25*b**2 + const cathod = 0. if (surd.ge.0.) then root = sqrt(surd) aa = -0.5*b + root sign = 1. if (aa.lt.0) then sign = -1. aa = -aa endif aa = sign*aa**.333333 bb = -0.5*b - root sign = 1. if (bb.lt.0) then sign = -1. bb = -bb endif bb = sign*bb**.333333 cathod = aa + bb - p3 else phi = acos(-0.5*b/sqrt(-const))/3. fact = 2.*sqrt(-a/3.) c c1 = fact*cos(phi) - p3 c c2 = fact*cos(phi + 2.094395) - p3 c it appears that the 3rd root is the desired one cathod = fact*cos(phi + 4.188790) - p3 endif cathod = cathod*zjones return end c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*