Screamer Project  V3.3.1
Screamer Structure
 All Files Functions Variables
getvar.f
Go to the documentation of this file.
1  subroutine get_variable (vtype, branch, node, lastnode, blktype,
2  & dt, rdt, time, savev, savev2, value,
3  & time_flag, block, ipinblk)
4 c
5 c Input variables
6 c
7  integer vtype, branch, node, lastnode, blktype
8  real dt, rdt, time, savev, savev2, value
9  integer block, ipinblk
10 c
11 c Note:time_flag defined as integer in zdemparam
12 c
13 c ---------------------------------------------------------------------
14 c Modifications:
15 c KWS, 03/07/94, Fixed outputs for MFI and SW models to
16 c allow multiple calls to those routines.
17 c Earlier fixes involved adding callouts for
18 c radiation yields in the cylindrical foil model.
19 c MLK, 03/07/95, Change include filenames to be 8 characters or less
20 c KWS, 05/30/95, Added output parameters due to addition of Zflow
21 c plasma loss model
22 c MLK, 01/15/96, Added additional argument, ipinblk, the block
23 c number to be used to ref the "pin" array when it is
24 c used to store calculations this routine needs
25 c MLK, 02/14/97, Changed `type` variable to `vtype` so as not to
26 c conflict with Fortran 90 TYPE statement
27 c KWS, 08/12/97, Added Zflow and Cathode Current diagnostics
28 c 2014-02-06 RBS: Changed real*4 to real
29 c 2014-05-02 RBS: Changed integer*4 to integer
30 c 2014-05-02 RBS: Split the real and integer declarations to reflect
31 c called and local variables.
32 c ---------------------------------------------------------------------
33 c
34 c value is the returned value of the requested variable.
35 c type is variable requested.
36 c branch, block and node specify its location in the circuit.
37 c node is the first block node, lastnode is the lastblock node.
38 c blktype is type of circuit block it is for.
39 c ipinblk is the block number to used to reference the "pin" array
40 c (2nd index in that array)
41 c dt is the timestep.
42 c rdt is 1/dt.
43 c time is the problem time (only needed for some t=0 calculations).
44 c savev is some saved value from the last time step
45 c for energy calculations (all energy requests) or for
46 c power calculations (capacitors and inductors if variable).
47 c This is updated and returned if necessary.
48 c
49  include 'zdemmax.h'
50  include 'zdemcomm.h'
51  include 'zdemwork.h'
52  include 'zdemout.h'
53  include 'zdempprm.h'
54  include 'zdemparm.h'
55 c
56 c local variables
57 c
58  real cvalue, ivalue
59 
60 c
61 c Resistor circuit element (series R2, shunt R1 and R3)
62 c
63  if ((vtype .eq. ip_vr1) .or. (vtype .eq. ip_vr3)) then
64  value = fvblk(node, branch, time_flag)
65  else if (vtype .eq. ip_vr2) then
66  value = fvr2(node, branch, time_flag)
67  else if ((vtype .eq. ip_ir1) .or. (vtype .eq. ip_ir3)) then
68  value = fir1(node, branch, time_flag)
69  else if (vtype .eq. ip_ir2) then
70  value = fiout(node, branch, time_flag)
71  else if ((vtype .eq. ip_pr1) .or. (vtype .eq. ip_pr3)) then
72  value = fpr1(node, branch, time_flag)
73  else if (vtype .eq. ip_pr2) then
74  value = fpr2(node, branch, time_flag)
75  else if ((vtype .eq. ip_er1) .or. (vtype .eq. ip_er3)) then
76  value = savev + fpr1(node, branch, time_flag) * dt
77  savev = value
78  else if (vtype .eq. ip_er2) then
79  value = savev + fpr2(node, branch, time_flag) * dt
80  savev = value
81  else if ((vtype .eq. ip_r1) .or. (vtype .eq. ip_r3)) then
82  value = 1.0 / (g(node,branch) + 1.0e-20)
83  else if (vtype .eq. ip_r2) then
84  value = rr(node,branch)
85  else if ((vtype .eq. ip_qr1) .or. (vtype .eq. ip_qr3)) then
86  value = savev + fir1(node, branch, time_flag) * dt
87  savev = value
88  else if (vtype .eq. ip_qr2) then
89  value = savev + fiout(node, branch, time_flag) * dt
90  savev = value
91 c
92 c Capacitor circuit element (shunt).
93 c Watch for initial state for current or power.
94 c
95  else if ((vtype .eq. ip_vc1) .or. (vtype .eq. ip_vc3)) then
96  value = fvblk(node, branch, time_flag)
97  else if ((vtype .eq. ip_ic1) .or. (vtype .eq. ip_ic3)) then
98  if (time .gt. 0.0) then
99  charg = fqc1(node, branch, time_flag)
100  value = (charg - savev) * rdt
101  savev = charg
102  else
103  savev = fqc1(node, branch, time_flag)
104  value = 0.0
105  end if
106  else if ((vtype .eq. ip_pc1) .or. (vtype .eq. ip_pc3)) then
107  if (time .gt. 0.0) then
108  epowr = fec1(node, branch, time_flag)
109  value = fpc1(node, branch, time_flag) +
110  & (epowr - savev) * rdt
111  savev = epowr
112  else
113  savev = fec1(node, branch, time_flag)
114  value = 0.0
115  end if
116  else if ((vtype .eq. ip_ec1) .or. (vtype .eq. ip_ec3)) then
117  savev = savev + fpc1(node, branch, time_flag) * dt
118  value = fec1(node, branch, time_flag) + savev
119  else if ((vtype .eq. ip_c1) .or. (vtype .eq. ip_c3)) then
120  value = cechk(node,branch)
121  else if ((vtype .eq. ip_qc1) .or. (vtype .eq. ip_qc3)) then
122  value = fqc1(node, branch, time_flag)
123  else if ((vtype .eq. ip_c1e) .or. (vtype .eq. ip_c3e)) then
124  value = c(node,branch)
125 c
126 c Inductor circuit element (series).
127 c Watch for initial voltage and power.
128 c
129  else if (vtype .eq. ip_vl2) then !V=d(flux)/dt
130  if (time .gt. 0.0) then
131  fluxl = ffl2(node, branch, time_flag)
132  value = (fluxl - savev) * rdt
133  savev = fluxl
134  else
135  savev = ffl2(node, branch, time_flag)
136  value = 0.0
137  end if
138  else if (vtype .eq. ip_il2) then
139  value = fiout(node, branch, time_flag)
140  else if (vtype .eq. ip_pl2) then !P=0.5*(d(L*I*I)/dt + I*I*dL/dt))
141  if (time .gt. 0.0) then
142  epowr = fel2(node, branch, time_flag)
143  value = fpl2(node, branch, time_flag) +
144  & (epowr - savev) * rdt
145  savev = epowr
146  else
147  savev = fel2(node, branch, time_flag)
148  value = 0.0
149  end if
150  else if (vtype .eq. ip_el2) then !E=0.5*(L*I*I + sum(I*I*dL/dt))
151  savev = savev + fpl2(node, branch, time_flag) * dt
152  value = fel2(node, branch, time_flag) + savev
153  else if (vtype .eq. ip_l2) then
154  value = zlrechk(node, branch)
155  else if (vtype .eq. ip_fl2) then
156  value = ffl2(node, branch, time_flag)
157  else if (vtype .eq. ip_ql2) then
158  value = savev + fiout(node, branch, time_flag) * dt
159  savev = value
160  else if (vtype .eq. ip_l2e) then
161  value = zlr(node, branch)
162 c
163 c Source block.
164 c
165  else if (vtype .eq. ip_vsrc) then
166  if ((blktype .eq. voltsource) .or.
167  & (blktype .eq. cendsource) .or.
168  & (blktype .eq. csclsource)) then
169  value = fvblk(node, branch, time_flag)
170 c write(9,*) 'time = ',time,
171 c & ' node = ',node,' branch = ',branch,
172 c & ' time_flag = ', time_flag,
173 c & ' v(node,branch) = ',v(node,branch),
174 c & ' vn(node,branch) = ',vn(node,branch)
175  else if ((blktype .eq. currsource) .or.
176  & (blktype .eq. vendsource)) then
177  value = fvblk(node+1, branch, time_flag)
178  end if
179  else if (vtype .eq. ip_isrc) then
180  value = fiout(node, branch, time_flag)
181  else if (vtype .eq. ip_psrc) then
182  if (blktype .eq. voltsource) then
183  value = fiout(node,branch, time_flag) *
184  & fvblk(node, branch, time_flag)
185  else if ((blktype .eq. cendsource) .or.
186  & (blktype .eq. csclsource)) then
187  value = -1.0 * fiout(node,branch, time_flag) *
188  & fvblk(node, branch, time_flag)
189  else if (blktype .eq. currsource) then
190  value = fiout(node,branch, time_flag) *
191  & fvblk(node+1, branch, time_flag)
192  else if (blktype .eq. vendsource) then
193  value = -1.0 * fiout(node,branch, time_flag) *
194  & fvblk(node+1, branch, time_flag)
195  end if
196  else if (vtype .eq. ip_esrc) then
197  if (blktype .eq. voltsource) then
198  value = savev +
199  & fiout(node,branch, time_flag) *
200  & fvblk(node, branch, time_flag) * dt
201  savev = value
202  else if ((blktype .eq. cendsource) .or.
203  & (blktype .eq. csclsource)) then
204  value = savev -
205  & fiout(node,branch, time_flag) *
206  & fvblk(node, branch, time_flag) * dt
207  savev = value
208  else if (blktype .eq. currsource) then
209  value = savev +
210  & fiout(node,branch, time_flag) *
211  & fvblk(node+1, branch, time_flag) * dt
212  savev = value
213  else if (blktype .eq. vendsource) then
214  value = savev -
215  & fiout(node,branch, time_flag) *
216  & fvblk(node+1, branch, time_flag) * dt
217  savev = value
218  end if
219  else if (vtype .eq. ip_qsrc) then
220  value = savev + fiout(node, branch, time_flag) * dt
221  savev = value
222 c
223 c Generic input to blocks.
224 c
225  else if (vtype .eq. ip_vin) then
226  value = fvblk(node, branch, time_flag)
227  else if (vtype .eq. ip_iin) then
228  value = fiin(node, branch, time_flag)
229  else if (vtype .eq. ip_pin) then
230  value = fvblk(node, branch, time_flag) *
231  & fiin(node, branch, time_flag)
232  else if (vtype .eq. ip_ein) then
233  value = savev +
234  & fvblk(node, branch, time_flag) *
235  & fiin(node, branch, time_flag) * dt
236  savev = value
237  else if (vtype .eq. ip_qin) then
238  value = savev + fiin(node, branch, time_flag) * dt
239  savev = value
240 c
241 c Generic output from blocks.
242 c
243  else if (vtype .eq. ip_vout) then
244  value = fvblk(node, branch, time_flag)
245  else if (vtype .eq. ip_iout) then
246  value = fiout(node, branch, time_flag)
247  else if (vtype .eq. ip_pout) then
248  value = fvblk(node, branch, time_flag) *
249  & fiout(node, branch, time_flag)
250  else if (vtype .eq. ip_eout) then
251  value = savev +
252  & fvblk(node, branch, time_flag) *
253  & fiout(node, branch, time_flag) * dt
254  savev = value
255  else if (vtype .eq. ip_qout) then
256  value = savev + fiout(node, branch, time_flag) * dt
257  savev = value
258 c
259 c Foil implosion parameters not available above.
260 c Values passed through common block FOILPARM.
261 c
262  else if (vtype .eq. ip_frad) then
263  value = foilrad
264  else if (vtype .eq. ip_fvel) then
265  value = foilvel
266  else if (vtype .eq. ip_facc) then
267  value = foilacc
268  else if (vtype .eq. ip_fke) then
269  value = foilke
270  else if (vtype .eq. ip_yw_al) then
271  value = yw_al
272  else if (vtype .eq. ip_ym_al) then
273  value = ym_al
274  else if (vtype .eq. ip_yw_ar) then
275  value = yw_ar
276  else if (vtype .eq. ip_ym_ar) then
277  value = ym_ar
278  else if (vtype .eq. ip_yw_cu) then
279  value = yw_cu
280  else if (vtype .eq. ip_ym_cu) then
281  value = ym_cu
282  else if (vtype .eq. ip_yw_kr) then
283  value = yw_kr
284  else if (vtype .eq. ip_ym_kr) then
285  value = ym_kr
286  else if (vtype .eq. ip_yw_xe) then
287  value = yw_xe
288  else if (vtype .eq. ip_ym_xe) then
289  value = ym_xe
290 c
291  else if (vtype .eq. ip_srad) then
292  value = shellrad
293  else if (vtype .eq. ip_svel) then
294  value = shellvel
295  else if (vtype .eq. ip_sacc) then
296  value = shellacc
297  else if (vtype .eq. ip_ske) then
298  value = shellke
299  else if (vtype .eq. ip_smass) then
300  value = shellm
301  else if (vtype .eq. ip_srad1) then
302  value = shellradius(1)
303  else if (vtype .eq. ip_srad2) then
304  value = shellradius(2)
305  else if (vtype .eq. ip_srad3) then
306  value = shellradius(3)
307  else if (vtype .eq. ip_srad4) then
308  value = shellradius(4)
309  else if (vtype .eq. ip_srad5) then
310  value = shellradius(5)
311  else if (vtype .eq. ip_scur1) then
312  value = shellcurr(1)
313  else if (vtype .eq. ip_scur2) then
314  value = shellcurr(2)
315  else if (vtype .eq. ip_scur3) then
316  value = shellcurr(3)
317  else if (vtype .eq. ip_scur4) then
318  value = shellcurr(4)
319  else if (vtype .eq. ip_scur5) then
320  value = shellcurr(5)
321 c
322 c
323 c MFI CB parameters not available above.
324 c
325  else if (vtype .eq. ip_efld) then
326  value = var_model(9,invarl(inumout))
327  else if (vtype .eq. ip_bfld) then
328  value = var_model(10,invarl(inumout))
329  else if (vtype .eq. ip_xmfi) then
330  value = var_model(11,invarl(inumout))
331 c
332 c Toms sw parameters not available above.
333 c
334  else if (vtype .eq. ip_fc) then
335  value = var_model(8,invarl(inumout))
336 c
337 c Gas puff implosion parameters not available above.
338 c Values passed through common block FIPARM.
339 c
340  else if (vtype .eq. ip_grad) then
341  value = gasrad
342  else if (vtype .eq. ip_gvel) then
343  value = gasvel
344  else if (vtype .eq. ip_gacc) then
345  value = gasacc
346  else if (vtype .eq. ip_gke) then
347  value = gaske
348 c
349 c Zflow model parameters available for plotting
350 c
351  else if (vtype .eq. ip_zflow) then
352  value = var_model(12,invarl(inumout))
353  else if (vtype .eq. ip_gzflow) then
354  value = var_model(13,invarl(inumout))
355 c
356 c ---------------------------------------------------------------------
357 c KWS - new parameters for Zflow Plasma Loss Current Model
358 c ---------
359 c
360 c
361 c Zflow Plasma Loss Current Model parameters available for plotting
362 c
363  else if (vtype .eq. ip_zloss) then
364  value = var_model(6,invarl(inumout))
365  else if (vtype .eq. ip_gloss) then
366  value = var_model(7,invarl(inumout))
367 c
368 c
369 c MITL Model parameters available for plotting
370 c
371  else if (vtype .eq. ip_aloss) then
372  value = pin(10,ipinblk,branch)
373 c
374 c ---------------------------------------------------------------------
375 c
376 c Outputs for the Measure Zflow and Cathode Current Block
377 c
378 c ---------------------------------------------------------------------
379 c
380 c Measure Zflow and Cathode Current block.
381 c
382  else if (vtype .eq. ip_icathode) then
383  value = ccathode(mzflowblock)
384  else if (vtype .eq. ip_iplasma) then
385  value = cplasma(mzflowblock)
386  else if (vtype .eq. ip_zot) then
387  value = measdzflow(mzflowblock)
388 c
389 c ---------------------------------------------------------------------
390 c
391 c User variables. The values are stored in the uservars array based
392 c on block and branch, rather than node and branch as in the other
393 c variable arrays.
394 c
395  else if (vtype .eq. ip_u1) then
396  value = uservars(block,branch,1)
397  else if (vtype .eq. ip_u2) then
398  value = uservars(block,branch,2)
399  else if (vtype .eq. ip_u3) then
400  value = uservars(block,branch,3)
401  else if (vtype .eq. ip_u4) then
402  value = uservars(block,branch,4)
403  else if (vtype .eq. ip_u5) then
404  value = uservars(block,branch,5)
405  else if (vtype .eq. ip_u6) then
406  value = uservars(block,branch,6)
407  else if (vtype .eq. ip_u7) then
408  value = uservars(block,branch,7)
409  else if (vtype .eq. ip_u8) then
410  value = uservars(block,branch,8)
411  else if (vtype .eq. ip_u9) then
412  value = uservars(block,branch,9)
413  else if (vtype .eq. ip_u10) then
414  value = uservars(block,branch,10)
415 c
416  else if (vtype .eq. ip_pdline) then
417  psum = 0.0
418 c *Sum the power dissipated on each resistor in the line
419  do i = node, lastnode
420  psum = fpr1(i, branch, time_flag) + psum
421  enddo
422  value = psum
423 c
424  elseif (vtype .eq. ip_edline) then
425  esum = 0.0
426 c *Sum the energy dissipated on each resistor in the line
427  do i = node, lastnode
428  esum = fpr1(i,branch,time_flag)*dt + esum
429  enddo
430  value = savev + esum
431  savev = value
432 c
433  else if (vtype .eq. ip_eline) then
434 c
435 c First get the energy stored in all of the capacitors in the line
436 c
437  psum = 0.0
438  do i = node, lastnode
439  psum = fpc1(i, branch, time_flag)*dt + psum
440  enddo
441  savev = savev + psum
442  esum = 0.0
443  do i = node, lastnode
444  esum = fec1(i, branch, time_flag) + esum
445  enddo
446  cvalue = esum + savev
447 c
448 c Then get the energy stored in all of the the inductors in the line
449 c
450  psum = 0.0
451  do i = node, lastnode
452  psum = fpl2(i, branch, time_flag)*dt + psum
453  enddo
454  savev2 = savev2 + psum
455  esum = 0.0
456  do i = node, lastnode
457  esum = fel2(i, branch, time_flag) + esum
458  enddo
459  ivalue = esum + savev2
460 c
461 c Add the energy stored in the capacitors to the energy stored in the
462 c inductors to get the total energy stored in the line
463 c
464  value = cvalue + ivalue
465 c
466  else if (vtype .eq. ip_pline) then
467 c
468 c First get the power stored in all of the capacitors in the line
469 c
470  esum = 0.0
471  do i = node, lastnode
472  esum = fec1(i, branch, time_flag) + esum
473  enddo
474 
475  if (time .gt. 0.0) then
476  psum = 0.0
477  do i = node, lastnode
478  psum = fpc1(i, branch, time_flag) + psum
479  enddo
480  cvalue = psum + (esum - savev) * rdt
481  else
482  cvalue = 0.0
483  endif
484  savev = esum
485 c
486 c Then get the power stored in all the inductors in the line
487 c
488  esum = 0.0
489  do i = node, lastnode
490  esum = fel2(i, branch, time_flag) + esum
491  enddo
492 
493  if (time .gt. 0.0) then
494  psum = 0.0
495  do i = node, lastnode
496  psum = fpl2(i, branch, time_flag) + psum
497  enddo
498  ivalue = psum + (esum - savev2) * rdt
499  else
500  ivalue = 0.0
501  endif
502  savev2 = esum
503 c
504 c Add the power stored in the capacitors to the power stored in the
505 c inductors to get the total power stored in the line
506 c
507  value = cvalue + ivalue
508 c
509  end if
510 c
511  return
512  end
function fec1(inod, ibrn, time_flag)
Definition: enrgyc1.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 branch
Definition: zdemfmt.h:36
function fvr2(inod, ibrn, time_flag)
Definition: voltgr2.f:1
function fiin(inod, ibrn, time_flag)
Definition: crrntin.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
function fir1(inod, ibrn, time_flag)
Definition: crrntr1.f:1
function ffl2(inod, ibrn, time_flag)
Definition: fluxl2.f:1
function fpr1(inod, ibrn, time_flag)
Definition: powerr1.f:1
function fel2(inod, ibrn, time_flag)
Definition: enrgyl2.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 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 c c c158 MFI Insulator CB c c c c161 Z FLOW Plasma Loss Current c c c Applied B Diode c &Ion Ion c c c c Initial c PRINT Output Request for block
Definition: zdemfmt.h:192
function fqc1(inod, ibrn, time_flag)
Definition: chargc1.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 c
Definition: zdemfmt.h:7
function fiout(inod, ibrn, time_flag)
Definition: crrntout.f:1
function fpr2(inod, ibrn, time_flag)
Definition: powerr2.f:1
function fpl2(inod, ibrn, time_flag)
Definition: powerl2.f:1
function fvblk(inod, ibrn, time_flag)
Definition: voltgblk.f:1
subroutine get_variable(vtype, branch, node, lastnode, blktype, dt, rdt, time, savev, savev2, value, time_flag, block, ipinblk)
Definition: getvar.f:1
function fpc1(inod, ibrn, time_flag)
Definition: powerc1.f:1