Screamer Project  V3.3.1
Screamer Structure
 All Files Functions Variables
findzflo.f
Go to the documentation of this file.
1  Subroutine findzflow (time, ianode, V, Z,icathode,iplasma,zflow)
2 c
3 c KWS 10/31/95. Calculates the cathode current and zflow using the
4 c Cliff Mendel pressure balance equation
5 c
6  include 'zdemmax.h'
7  include 'zdemout.h'
8 c
9 c Define passed variables
10 c
11  real time, ianode, v, z, icathode, iplasma, zflow
12 c
13 c Define internal variables
14 c
15  complex root1, root2, root3
16  double precision a, a1, a2, a3, d
17  real r(3), root, cur2diff, z2, ve, ve2, zflowlim
18 c
19 c
20 c
21  parameter(ve=2.5549953e5)
22 c Ve = mc^2/2e
23  parameter(ve2=6.5280010e10)
24  parameter(zflowlim=1.0e3)
25 
26 c
27 c Set up coefficients
28 c
29  a = ianode * ianode
30  z2 = z*z
31  a1 = (v*v - 2.0*v*ve + ve2 - a*z2)/z2
32  a2 = 2.0*ve*a*(v - ve)/z2
33  a3 = (ve2*a*a)/z2
34 c
35 c
36  if((a .gt. 1.) .and. (v .gt. 1.)) then
37  call cubicroots(a1,a2,a3,d,root1,root2,root3)
38 c
39 c
40 c Find the right root. Note that the first root is
41 c the real root for d>0 and d=0
42 c
43  r(1) = real(root1)
44  r(2) = real(root2)
45  r(3) = real(root3)
46  root = 0.0
47  if (d .ge. 0.0) then
48  if (r(1) .ge. 0.0) then
49  root = r(1)
50  else
51  root = a
52  endif
53  else
54  do i=1,3
55  if (r(i) .ge. 0.0) then
56  if((r(i) .le. a) .and. (r(i) .gt. root)) root = r(i)
57  endif
58  end do
59  if (root .eq. 0.0) root = a
60  endif
61 c
62 c Find the plasma current and zflow
63 c
64  icathode = sqrt(root)
65  iplasma = abs(ianode) - icathode
66  cur2diff = a - icathode*icathode
67  if (cur2diff.gt.1.0) then
68  zflow = v / sqrt(cur2diff)
69  else
70  zflow = zflowlim
71  endif
72  else
73  icathode=ianode
74  iplasma=0.0
75  zflow=zflowlim
76  a1=0.
77  a2=0.
78  a3=0.
79  d=0.
80  root1=0.
81  root2=0.
82  root3=0.
83  endif
84 c
85 c
86 c write(9,600) time,ianode,icathode,iplasma,zflow,v,z,a1,a2,a3,d,
87 c & root1,root2,root3
88  600 format(6x,'t',11x,'Ia',10x,'Ic',10x,'Ip',10x,'zf',10x,'V'/
89  & 6e12.4/
90  & 18x,'Z',11x,'a1',10x,'a2',10x,'a3',10x,'d'/
91  & 12x,5e12.4/
92  & 16x,'root1',19x,'root2',19x,'root3'/
93  & 12x,6e12.4//)
94  return
95  end
96 c
97 c
98 c
99 c
100 c
101 c **************************************************
102  Subroutine cubicroots (da1,da2,da3,d,z1,z2,z3)
103 c **************************************************
104 c
105 c Ken Struve
106 c Nov. 8, 1995
107 c
108 c
109 c This routine calculates the roots of the cubic equation
110 c
111 c x**3 + a1*x**2 + a2*x + a3 = 0.0
112 c
113 c where a1, a2, and a3 are real.
114 c As a check, the roots should obey the following:
115 c
116 c z1 + z2 + z3 = -a1
117 c
118 c z1*z2 + z2*z3 + z3*z1 = a2
119 c
120 c z1 * z2 * z3 = -a3
121 c
122 c where z1, z2, and z3 are the three roots.
123 c
124 c
125 c Define passed variables
126 c
127  double precision da1, da2, da3, d
128  complex z1,z2,z3
129 c
130 c Difine internal variables
131 c
132  double precision q, r, s, t, s3, t3
133  double precision da13,z,theta
134  double precision check1, check2, check3
135  parameter(pi=3.1415926535)
136 c
137 c Calculate the intermediate values
138 c
139  q = (3.0*da2 - da1*da1)/9.0
140  r = (9.0*da1*da2 - 27.0*da3 -2.0*da1*da1*da1)/54.0
141  d = q*q*q + r*r
142  da13=da1/3.0
143 c
144 c Find the roots for the three cases
145 c
146 c *******************************************
147 c Case 1 and Case 2: d greater or equal to 0
148 c *******************************************
149 c
150  if (d .ge. 0.0) then
151  s3 = r + dsqrt(d)
152  if (s3 .ge. 0.0) then
153  s = s3**(1.0/3.0)
154  else
155  s = -1.0*(-1.0*s3)**(1.0/3.0)
156  endif
157  t3 = r - dsqrt(d)
158  if (t3 .ge. 0.0) then
159  t = t3**(1.0/3.0)
160  else
161  t = -1.0*(-1.0*t3)**(1.0/3.0)
162  endif
163  z1 = s + t - da13
164  z2 = -0.5*(s+t) - da13 + 0.5*(0.0,1.0)*sqrt(3.0)*(s-t)
165  z3 = conjg(z2)
166 c
167 c *******************************************
168 c Case 3: d less than 0
169 c *******************************************
170 c
171  else
172  theta = acos(r/sqrt(-1.0*q*q*q))
173  z = 2.0*sqrt(-q)
174  z1 = z * cos(theta/3.0) - da13
175  z2 = z * cos((theta + 2.0*pi)/3.0) - da13
176  z3 = z * cos((theta - 2.0*pi)/3.0) - da13
177  endif
178 c
179 c *******************************************
180 c Error Check
181 c *******************************************
182 c
183 c check1 = -1.0 * (z1 + z2 +z3)
184 c check2 = z1*z2 + z2*z3 + z3*z1
185 c check3 = -1.0 * z1 * z2 * z3
186 c write(9,*)
187 c write(9,*) 'Check1 = ',check1,' It should be ', da1
188 c write(9,*) 'Check2 = ',check2,' It should be ', da2
189 c write(9,*) 'Check3 = ',check3,' It should be ', da3
190 c
191  return
192  end
c *****************************************************************************c Various format statements for read_screamer_data output c To get these into made format to be characters c for each line corrected spelling errors in format added statement for Zflow Plasma Loss Model added format for CSV output type fixed more lines longer than characters added format for Measure Zflow Block and forward c reverse current directions in Zflow plasma loss c and Zflow POS models added format for SFC output type c removed from all code calls c c c c c a80 c i10 c No grids on plots c Do not write files containing the plotted points c Execute only one cycle c Do not echo the setup parameters and indicies c c &exitting c a13 c c c c c c c c102 c &described as a function of time c c c &described as a function of time c c c &function of time c c shell c &min A K c &trapped field c153 c c c Sin c c c remaining calls in rdscrelem c Tabular a10 Cond c c c &used with this model c Exponential model of a resistive c c c Rise model of a resistive c c Z FLOW POS c c c c SW1 a3
Definition: zdemfmt.h:140
subroutine findzflow(time, ianode, V, Z, icathode, iplasma, zflow)
Definition: findzflo.f:1
c *****************************************************************************c Various format statements for read_screamer_data output c To get these into made format to be characters c for each line corrected spelling errors in format added statement for Zflow Plasma Loss Model added format for CSV output type fixed more lines longer than characters added format for Measure Zflow Block and forward c reverse current directions in Zflow plasma loss c and Zflow POS models added format for SFC output type c removed from all code calls c c c c c a80 c i10 c No grids on plots c Do not write files containing the plotted points c Execute only one cycle c Do not echo the setup parameters and indicies c c &exitting c a13 c c c c c c c c102 c &described as a function of time c c c &described as a function of time c c c &function of time c c shell c &min A K c &trapped field time
Definition: zdemfmt.h:85
subroutine cubicroots(da1, da2, da3, d, z1, z2, z3)
Definition: findzflo.f:102
c *****************************************************************************c Various format statements for read_screamer_data output c To get these into made format to be characters c for each line corrected spelling errors in format added statement for Zflow Plasma Loss Model added format for CSV output type fixed more lines longer than characters added format for Measure Zflow Block and forward c reverse current directions in Zflow plasma loss c and Zflow POS models added format for SFC output type c removed from all code calls c c c c c a80 c i10 c No grids on plots c Do not write files containing the plotted points c Execute only one cycle c Do not echo the setup parameters and indicies c c &exitting c a13 c c c c c c c c102 c &described as a function of time c c c &described as a function of time c c c &function of time c c shell c &min A K c &trapped field c153 c c c Sin c c c remaining calls in rdscrelem c Tabular a10 Cond c c c &used with this model c Exponential model of a resistive c c c Rise model of a resistive c c Z FLOW POS c & zflow
Definition: zdemfmt.h:133