Screamer Project  V3.3.1
Screamer Structure
 All Files Functions Variables
energy_checks.f
Go to the documentation of this file.
1  subroutine energy_checks
2 c
3 c-----description-------------------------------------------------------
4 c
5 c author/date: mathias bavay 11/04
6 c modifications:
7 c
8 c ----------------------------------------------------------------------
9 c
10 c purpose: this subroutines does an energy check at the half time step.
11 c
12 c called by: Program zdem
13 c
14 c
15 
16 c include the files with the various keywords and integer flags.
17 c
18  include 'zdemparm.h'
19  include 'zdempprm.h'
20 c
21 c include the files specifying the array dimensions and the common blocks.
22 c
23  include 'zdemmax.h'
24  include 'zdemcomm.h'
25  include 'zdemwork.h'
26  include 'zdemout.h'
27  include 'zdemenv.h'
28  include 'zdemvars.h'
29 c
30 c include file with version string
31 c
32  include 'version.h'
33 
34 c -----------------------------------------------------------------------------
35 
36 c
37 c -----------------------------------------------------------------------------
38 c
39 c energy check at the half time step.
40 c calculate:
41 c
42 c the energy currently stored in the capacitors(ecap),
43 c the energy currently stored in the inductors(eind),
44 c the energy dissipated in the shunt conductances this step(decon),
45 c the energy dissipated in the series resistors this step(deres),
46 c the total energy dissipated in the shunt conductances(econ),
47 c the total energy dissipated in the series resistors(eres),
48 c the energy dissipated by a variable inductor in this step(dlossind),
49 c the energy dissipated by a variable capacitor in this step(dlosscap),
50 c the total energy dissipated by variable inductors(elossind),
51 c the total energy dissipated by variable capacitors(elosscap).
52 c
53  ecap = 0.0
54  eind = 0.0
55  decon = 0.0
56  deres = 0.0
57  dlossind = 0.0
58  dlosscap = 0.0
59 c
60 c calculate the energy associated with each circuit g, c, l, r.
61 c
62  do ib = 1, nb
63  nrx = nr(ib)
64  do i = 1, nrx
65  halfi = 0.5 * (zirn(i,ib) + zir(i,ib))
66  halfi2 = halfi * halfi
67  halfv = 0.5 * (vn(i,ib) + v(i,ib))
68  halfv2 = halfv * halfv
69  eind = 0.5 * zlrechk(i,ib) * halfi2 + eind
70  ecap = 0.5 * cechk(i,ib) * halfv2 + ecap
71  decon = ht * g(i,ib) * halfv2 + decon
72  deres = ht * rr(i,ib) * halfi2 + deres
73  dlossind = htd2 * zlrdot(i,ib) * halfi2 + dlossind
74  dlosscap = htd2 * cdot(i,ib) * halfv2 + dlosscap
75  end do
76  end do
77 c
78 c find the energy added by sources in the last time step.
79 c
80  psource = 0.0
81  do i = 1, nvoltsource
82  node = indexvs(1,i)
83  ibranch = indexvs(2,i)
84  halfv = 0.5 * (v(node,ibranch) + vn(node,ibranch))
85 c
86 c for a voltsource block.
87 c
88  if (node .eq. 1) then
89  halfi = 0.5 * (zir(node,ibranch) + zirn(node,ibranch))
90  psource = psource + (halfv * halfi)
91 c
92 c for a vendsource block.
93 c
94  else
95  node1 = node - 1
96  halfi = 0.5 * (zir(node1,ibranch)+zirn(node1,ibranch))
97  psource = psource - (halfv * halfi)
98  end if
99  end do
100 c
101  do i = 1, ncurrsource
102  node = indexcs(1,i)
103  ibranch = indexcs(2,i)
104  halfi = 0.5 * (zir(node,ibranch) + zirn(node,ibranch))
105 c
106 c for a currsource block.
107 c
108  if (node .eq. 1) then
109  node2 = node + 1
110  halfv = 0.5 * (v(node2,ibranch) + vn(node2,ibranch))
111  psource = psource + (halfv * halfi)
112 c
113 c for a cendsource block.
114 c
115  else
116  halfv = 0.5 * (v(node,ibranch) + vn(node,ibranch))
117  psource = psource - (halfv * halfi)
118  end if
119  end do
120 c
121  esource = psource * ht
122 c
123 c check total energy from all components against the total
124 c from all sources.
125 c
126  econ = econ + decon
127  eres = eres + deres
128  elossind = elossind + dlossind
129  elosscap = elosscap + dlosscap
130  esour = esour + esource
131  esum = -esour + eind + ecap + eres + econ
132  & + elossind + elosscap
133  error = esum / (esour+1.0e-4)
134 c
135 
136  return
137  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 time
Definition: zdemfmt.h:85
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
subroutine zdem(ifile, clen)
Definition: zdem.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
subroutine energy_checks
Definition: energy_checks.f:1
c This is a Fortran header file
Definition: sfc.h:3