Screamer Project  V3.3.1
Screamer Structure
 All Files Functions Variables
start_run.f
Go to the documentation of this file.
1  subroutine init_problem(status)
2 c
3 c Define passed variables
4 c
5  integer status
6 c 7jul2008 dlr added logic and calls for time w/ gfortran
7 c
8 c-----Description-------------------------------------------------------
9 c
10 c Author/Date: Mathias Bavay 11/04
11 c Modifications:
12 c 2008-09-10 RBS Redefine buffer to 80
13 c
14 c ----------------------------------------------------------------------
15 c
16 c Purpose: This subroutines initialize variables for a run.
17 c Its does it by reading the input deck
18 c
19 c Called by: Program ZDEM
20 c
21 c Calls: Subroutines setup_trline,setup_rcground,setup_rlseries,
22 c setup_pisection,setup_rlseries,setup_rlseries,setup_rlseries,
23 c setup_voltsource,setup_vendsource,setup_currsource,
24 c setup_cendsource,setup_cendsource,setup_trline,setup_trline,
25 c setup_adder,setup_mzflow,echo_indicies,banner,cycle_print,
26 c open_outfile,get_variable
27 c
28 
29 c Include the files with the various keywords and integer flags.
30 c
31  include 'zdemparm.h'
32  include 'zdempprm.h'
33 c
34 c Include the files specifying the array dimensions and the common blocks.
35 c
36  include 'zdemmax.h'
37  include 'zdemcomm.h'
38  include 'zdemwork.h'
39  include 'zdemout.h'
40  include 'zdemvars.h'
41  include 'zdemloop.h'
42 
43 c if everything is fine, we will return 0 in status
44  character initln*80
45 
46 c----Variable definition for C++ stdout-----------------------------
47  character(len=80)::buffer
48 c-------------------------------------------------------------------
49 
50  initln = 'Initial SCREAMER Circuit Status'
51  cyclln = 'SCREAMER Circuit Status for t > 0'
52  status=0
53 
54 c -------------------------------------------------------------------
55 c set-up information
56 c nb = number of branches
57 c ib = branch number
58 c nr = counts up the total # of nodes as branches are added
59 c nbk(ib) = number of blocks in branch ib
60 c ibk = block number
61 c ibt = block type
62 c 0 = transmission line - tau, zin, zout, 0, 0, 0
63 c 1 = plotting request - no nodes or elements (quasi-block)
64 c 2 = resistor and capacitor to ground - r1, c1, 0, 0, 0, 0
65 c 3 = pi section - r1, c1, r2, l2, r3, c3
66 c 5 = voltage source - r, l, 0, 0, 0, 0
67 c 6 = MITL line - circumf, gap, tau, zin, zout
68 c 7 = adder block - 0, 0, 0, 0, 0, 0
69 c 8 = end-of-branch voltage source - r, l, 0, 0, 0, 0
70 c 9 = PMITL line - perveance, tau, zline, 0, 0, 0
71 c 10 = RL series - r, l, 0, 0, 0, 0
72 c 11 = Current source - r, c, 0, 0, 0, 0
73 c 12 = end-of-branch current source - r, c, 0, 0, 0, 0
74 c 13 = end-of-branch SCL current source - r, c, 0, 0, 0, 0
75 c 31 = cylfoil implosion model - r, l, 0, 0, 0, 0
76 c 32 = gas puff implosion model - r, l, 0, 0, 0, 0
77 c 33 = sphfoil implosion model - r, l, 0, 0, 0, 0
78 c 34 = measure zflow block
79 c 35 = nshell implosion block
80 c
81 c
82 c ivn = element number for variable element
83 c 0=none,1=r1,2=c1,3=r2,4=c2,5=r3,6=c3
84 c ibr = branch type from block
85 c 0=no branch,1=top branch,2=end branch
86 c
87 c the blocks will be converted into the following general circuit
88 c
89 c ^ | ^ |
90 c | | | |
91 c zib(i)| zib(i+1)|
92 c | zir(i) -> |
93 c | v,vn(i) | v,vn(i+1)
94 c -------------o---------- rr(i) ----- zlr(i) ----------o------------
95 c | | | |
96 c | | | |
97 c g(i) c(i) g(i+1) c(i+1)
98 c | | | |
99 c | | | |
100 c --------------------------------------------------------------------
101 c node:i node:i+1
102 c
103 c
104 c ----------------------------------------------------------------------
105 c
106 c
107  data icycle, esour / 0, 0.0 /
108  data ecap, eind, econ, eres / 0.0, 0.0, 0.0, 0.0 /
109  data elossind, elosscap / 0.0, 0.0 /
110  ecapsource = 0.0
111  eindsource = 0.0
112 c
113 c
114 c
115 c------------------------------------------------------------------------
116 c
117 c ----- problem set-up ----------------------------------------------------
118 c
119 c Set the number of steps according to iset.
120 c
121  nbm = nb - 1
122  if (iset .eq. one_cycle) then
123  tmax = ht
124  nsteps = 1
125  else
126  nsteps = tmax / ht
127  end if
128 c
129 c Set the inverse of the time step, half a time step, and the number of cycles
130 c between printouts.
131 c
132  rht = 1.0 / ht
133  htd2 = ht / 2.0
134  ncycle = nsteps / nprint
135 c
136 c
137 c Determine the size of the screamer temporary file and ask the user
138 c if he wants to continue
139 c
140 c
141  itfilesz = 12 + 10 * numout + 8 * (1 + numout) * nsteps
142  xtfilesz = float(itfilesz) / 1.0e6
143 c
144 c Write message to log file that SCREAMER is now running
145 c
146 c write (buffer,947)
147 c call writebuffer(buffer)
148 c 947 format (' SCREAMER is now running'/)
149 c
150 c
151 c Set-up from block elements
152 c
153 c Set some counters to zero: Variable element counter, secondary branch
154 c counter, lossless trans. line counter, MITL counter,
155 c voltage source counter, current source counter,
156 c initial condition (V or I) counter,
157 c output request counter.
158 c
159  icv = 0
160  icb = 0
161  itrl_counter = 0
162  imitl_counter = 0
163  ivs_counter = 0
164  ics_counter = 0
165  ic_counter = 0
166  itab_counter = 0
167  icout = 0
168 c
169 c Loop over the branches and set the number of blocks in that branch.
170 c
171  do 200 ib = 1, nb
172  nbkx = nbk(ib)
173 c
174 c Specify first block for ib > 1 to be a short (zero series resistance
175 c and inductance). This connects the new branch to the main via this
176 c short (as all blocks are connected). This adds one node (nr=1) to this
177 c branch. Else set the node counter to zero for the first branch.
178 c
179  if (ib .gt. 1) then
180  nr(ib) = 1
181  g(1,ib) = 0.0
182  rr(1,ib) = 0.0
183  zlr(1,ib) = 0.0
184  c(1,ib) = 0.0
185  cechk(1,ib) = 0.0
186  zlrechk(1,ib) = 0.0
187  else
188  nr(ib) = 0
189  end if
190 c
191 c Set an index which only counts the circuit blocks and not the output requests
192 c
193  ncirblk = 0
194 c
195 c Loop over the blocks. (Each output request is considered as a block)
196 c
197  do 201 ibk = 1,nbkx
198 c
199 c Set a flag for output to id each node.
200 c ibt is the block type, ivn is the variable element number, ibr is the branch
201 c exit type, iinit is the initial condition type, ibk is the block number,
202 c ioutreq is the type of output request.
203 c
204  ibt = iin(1,ibk,ib)
205  if (ibt .ne. outputreq) then
206  ncirblk = ncirblk + 1
207  end if
208  ivn = iin(2,ibk,ib)
209  ibr = iin(3,ibk,ib)
210  iinit = iin(4,ibk,ib)
211  ioutreq = iin(5,ibk,ib)
212  iflgs = 10000000*ib + ncirblk*100000 + 1000*ibt
213  & + 100*iinit + 10*ivn + ibr
214 c
215 c Reset the counter if we have an initial voltage or current in this block.
216 c
217  if (iinit .gt. 0) then
218  ic_counter = ic_counter + 1
219  end if
220 c
221 c------------------------------------------------------------------------
222 c Now sort out the block types.
223 c
224  if (ibt .eq. transline) then
225  itrl_counter = itrl_counter + 1
226  call setup_trline(ib, ibk, itrl_counter, na, iflgs,
227  & transline, iinit, ic_counter)
228 c
229 c If an output request, set the node index.
230 c
231  else if (ibt .eq. outputreq) then
232  icout = icout + 1
233  ixnodout(icout) = ifnodreq(itypout(icout), nr(ib), na)
234  ixlstnodout(icout) = nr(ib)
235 c
236  else if (ibt .eq. rcground) then
237  call setup_rcground(ib,ibk,na,iflgs,iinit,ic_counter)
238 c
239  else if (ibt .eq. rlseries) then
240  call setup_rlseries(ib,ibk,na,iflgs,iinit,ic_counter)
241 c
242  else if (ibt .eq. pisection) then
243  call setup_pisection(ib,ibk,na,iflgs,iinit,ic_counter)
244 c
245  else if (ibt .eq. cylfoilblock) then
246  call setup_rlseries(ib,ibk,na,iflgs,iinit,ic_counter)
247 c
248  else if (ibt .eq. sphfoilblock) then
249  call setup_rlseries(ib,ibk,na,iflgs,iinit,ic_counter)
250 c
251  else if (ibt .eq. gaspuffblock) then
252  call setup_rlseries(ib,ibk,na,iflgs,iinit,ic_counter)
253 c
254  else if (ibt .eq. voltsource) then
255  ivs_counter = ivs_counter + 1
256  call setup_voltsource(ib, ibk, ivs_counter, na, iflgs,
257  & iinit, ic_counter)
258 c
259  else if (ibt .eq. vendsource) then
260  ivs_counter = ivs_counter + 1
261  call setup_vendsource(ib, ibk, ivs_counter, na, iflgs,
262  & iinit, ic_counter)
263 c
264  else if (ibt .eq. currsource) then
265  ics_counter = ics_counter + 1
266  call setup_currsource(ib, ibk, ics_counter, na, iflgs,
267  & iinit, ic_counter)
268 c
269  else if (ibt .eq. cendsource) then
270  ics_counter = ics_counter + 1
271  itypcs = itypcend(ics_counter)
272  call setup_cendsource(ib, ibk, ics_counter, na, iflgs,
273  & iinit, ic_counter, itypcs)
274 c
275  else if (ibt .eq. csclsource) then
276  ics_counter = ics_counter + 1
277  itypcs = itypcend(ics_counter)
278  call setup_cendsource(ib, ibk, ics_counter, na, iflgs,
279  & iinit, ic_counter, itypcs)
280 c
281  else if (ibt .eq. mitline) then
282  imitl_counter = imitl_counter + 1
283  call setup_trline(ib, ibk, imitl_counter, na, iflgs,
284  & mitline, iinit, ic_counter)
285 c
286  else if (ibt .eq. pmitline) then
287  imitl_counter = imitl_counter + 1
288  call setup_trline(ib, ibk, imitl_counter, na, iflgs,
289  & pmitline, iinit, ic_counter)
290 c
291  else if (ibt .eq. adder) then
292  call setup_adder(ib, ibk, na, iflgs)
293 c
294  else if (ibt .eq. measurezflow) then
295  call setup_mzflow(ib, ibk, na, iflgs)
296 c
297  end if
298 c
299 c------------------------------------------------------------------------
300 c Set the node for a variable element and the current number of nodes in
301 c this branch.
302 c
303  if (ibt .ne. outputreq) then
304  nvar_node = nr(ib) + 1
305  nrx = nr(ib) + na
306  nr(ib) = nrx
307  end if
308 c
309 c If we have a branch exitting this block, increment the exit
310 c branch counter, then set the circuit element index and the branch
311 c exit type for this exit branch.
312 c
313  if (ibr .gt. 0) then
314  icb = icb + 1
315  indexb(1,icb) = nrx
316  indexb(2,icb) = ibr
317  end if
318 c
319 c If we have a variable element in this block, increment the variable
320 c element counter, then set the circuit element index, the number of
321 c the variable element in this block, and the branch index for this
322 c variable element.
323 c
324  if (ivn .gt. 0) then
325  icv = icv + 1
326  indexv(1,icv) = nvar_node
327  indexv(2,icv) = ivn
328  indexv(3,icv) = ib
329  end if
330  201 continue
331  200 continue
332 c
333 c Check number of nodes to see if limit exceeded
334 c
335  do 202 ib=1,nb
336  if (nr(ib) .gt. max_nodes) then
337  write(buffer,203) ib, nr(ib), max_nodes
338  call writebuffer(buffer)
339  write(9,203) ib, nr(ib), max_nodes
340  status=1
341  goto 802
342  endif
343  202 continue
344  203 format(' Maximum number of nodes exceeded. Reset',
345  &' resolution time.'/' Or, recompile with larger',
346  &' MAX_NODES parameter in the file zdemmax.h.'/
347  &' Branch = ',i3,5x,'Number of nodes = ',i4,5x,
348  $'Maximum is ',i4/
349  &' Run stopped.')
350 c
351 c
352 c
353 c List the various indicies we have just set.
354 c
355  if (echoset .eq. yes_echo) then
356  call echo_indicies
357  end if
358 c
359 c -----------------------------------------------------------------------------
360 c
361 c Set the initial energy in the circuit and
362 c print out the initial status of the circuit.
363 c
364  esour = ecapsource + eindsource
365  i2 = 0
366  tim = 0.0
367  error = 0.0
368  call banner(initln)
369  call cycle_print(i2, tim, esour, eindsource, ecapsource, econ,
370  & eres, elossind, elosscap, error)
371 c
372 c Initialize everything needed for plots, print, files, tables, ufo, idr.
373 c Determine the first points.
374 c Set t=0 points if requested.
375 c
376  fflag = newfile
377  iunit = outunit
378  call open_outfile(iunit, fflag, ierr)
379 c
380 c outunit is set in zdemout.h
381 c
382  write(outunit) numout
383  write(outunit) (tagout(jj),jj=1,numout)
384 c
385 c Variables needed to calculate block number used in "pin" array
386 c to pass to get_variable:
387 c ibrnsav is the number of the branch associated with the last output request
388 c iblksav is the number of the block associated with the last output request
389 c ipinsav is the number of output requests in this branch
390 c ipin is the block number used in "pin"
391 c
392  ibrnsav = 0
393  iblksav = 0
394  ipin = 0
395  ipinsav = 0
396  do i = 1, numout
397  tstart = tbegout(i)
398  tstop = tendout(i)
399  node = ixnodout(i)
400  lnode = ixlstnodout(i)
401  ibrn = ixbrnout(i)
402  iblk = ixblkout(i)
403  ivartyp = itypout(i)
404  iblktyp = iblkout(i)
405  valsave = 0.0
406  valsave2 = 0.0
407  time_flag = half_step
408  if (ibrnsav .ne. ibrn) then
409  ibrnsav = ibrn
410  iblksav = 0
411  ipin = 0
412  ipinsav = 0
413  end if
414  if (iblksav .ne. iblk) then
415  iblksav = iblk
416  ipin = ipinsav + iblk
417  end if
418  ipinsav = ipinsav + 1
419  call get_variable(ivartyp, ibrn, node, lnode, iblktyp, ht,
420  & rht, 0.0, valsave, valsave2, value1,
421  & time_flag, iblk, ipin)
422  val1(i) = value1
423  saveout1(i) = valsave
424  saveout2(i) = valsave2
425  time_flag = whole_step
426  valsave = 0.0
427  valsave2 = 0.0
428  call get_variable(ivartyp, ibrn, node, lnode, iblktyp, ht,
429  & rht, 0.0, valsave, valsave2, value2,
430  & time_flag, iblk, ipin)
431  val2(i) = value2
432  saveout3(i) = valsave
433  saveout4(i) = valsave2
434 c
435  end do
436 c
437  write(outunit) 0.0,0.0,(val1(jj),val2(jj),jj=1,numout)
438 c
439 c Set some invariant counters:
440 c ntot is the total number of nodes, nbv(i) is the total number of nodes in all
441 c previous branches and the current one, nbe is the total number of nodes times
442 c 2 in all the previous branches, nadd_array is the total number of nodes in
443 c all the previous branches.
444 c
445  k = 2
446  nxx = 0
447  ntot = nr(1)
448  nbv(1) = ntot
449  nbe(1) = 0
450  nadd_array(1) = 0
451  do i = 2, nb
452  ntot = ntot + nr(i)
453  nbv(i) = ntot
454  nxx = nxx + nbv(i-1)
455  nbe(i) = nxx * k
456  nadd_array(i) = nadd_array(i-1) + nr(i-1)
457  end do
458 
459  802 return
460  end
subroutine init_problem(status)
Definition: start_run.f:1
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character tendout
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c & numout
Definition: zdemout.h:47
subroutine setup_rlseries(ib, ibk, na, iflgs, ic_type, ic_counter)
Definition: setrlser.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 i3
Definition: zdemfmt.h:36
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & saveout3
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character val2
Definition: zdemout.h:59
subroutine open_outfile(iunit, status, ierr)
Definition: opnoutfl.f:1
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & tagout
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & ixlstnodout
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character saveout2
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & ixblkout
Definition: zdemout.h:59
integer function ifnodreq(otype, lastnode, numnodes)
Definition: findnode.f:1
subroutine setup_pisection(ib, ibk, na, iflgs, ic_type, ic_counter)
Definition: setpisec.f:1
subroutine setup_rcground(ib, ibk, na, iflgs, ic_type, ic_counter)
Definition: setrcgnd.f:1
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & val1
Definition: zdemout.h:59
subroutine setup_adder(ib, ibk, na, iflgs)
Definition: setadder.f:1
subroutine setup_mzflow(ib, ibk, na, iflgs)
Definition: setmzflo.f:1
subroutine echo_indicies
Definition: echoindx.f:1
subroutine cycle_print(icycle, time, esour, eind, ecap, econ, eres, elossind, elosscap, error)
Definition: cyclprnt.f:1
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & tbegout
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character ixnodout
Definition: zdemout.h:59
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character saveout4
Definition: zdemout.h:59
subroutine banner(line)
Definition: prtbannr.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
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character itypout
Definition: zdemout.h:59
subroutine setup_trline(ib, ibk, icounter, na, iflgs, switch, ic_type, ic_counter)
Definition: settrlin.f:1
subroutine setup_vendsource(ib, ibk, ivs_counter, na, iflgs, ic_type, ic_counter)
Definition: setvends.f:1
subroutine setup_cendsource(ib, ibk, ics_counter, na, iflgs, ic_type, ic_counter, itypcs)
Definition: setcends.f:1
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character ixbrnout
Definition: zdemout.h:59
subroutine setup_currsource(ib, ibk, ics_counter, na, iflgs, ic_type, ic_counter)
Definition: setcurrs.f:1
c *****************************************************************************c Common blocks for SCREAMER output and tabling c numsfc character & iblkout
Definition: zdemout.h:59
subroutine setup_voltsource(ib, ibk, ivs_counter, na, iflgs, ic_type, ic_counter)
Definition: setvolts.f:1
subroutine get_variable(vtype, branch, node, lastnode, blktype, dt, rdt, time, savev, savev2, value, time_flag, block, ipinblk)
Definition: getvar.f:1