-
Notifications
You must be signed in to change notification settings - Fork 4
/
pbalance.f
100 lines (73 loc) · 2.66 KB
/
pbalance.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
subroutine pbalance
c/ This subroutine performs a global particle balance, as
c/ an additional test of the correctness of the solution.
c/ John Mandrekas, June 2003
implicit none
include 'neutGlob.inc'
c/ Local variables:
integer i, i_true, j, jj, kk, kpl, kw, kw_true, ll
real sum_gext, sum_gion, sum_ion, sum_vol, sum_core, sum_wall
c/ First, calculate the gains:
c/ ---------------------------
c/ Ion and neutral fluxes from wall segments:
sum_gext = 0.0
sum_gion = 0.0
do kw = 1, nWallSegm
sum_gext = sum_gext + g_ex(kw)
sum_gion = sum_gion + g_ion(kw)
enddo
c/ Volumetric source contributions, if any:
sum_vol = 0.0
do i = 1, nCells
sum_vol = sum_vol + S_ext(i)
enddo
c/ Now, calculate the losses:
c/ --------------------------
c/ Ionization loss first:
sum_ion = 0.0
do i = 1, nCells
sum_ion = sum_ion + inzRate(i)
enddo
c/ Losses through the core plasma-interface:
sum_core = 0.0
if (nPlasmReg.GT.0) then
do kpl = 1, nPlasmReg
i_true = nCells + kpl
do jj = 1, nSides(i_true)
j = adjCell(jj,i_true)
do kk = 1, nSides(j)
if (adjCell(kk,j).EQ.i_true) then
sum_core = sum_core +gflux(j,kk,1) *
. (1.0 - albedo(kpl))
endif
enddo
enddo
enddo
endif
c/ Wall losses due to wall absorption or pumping:
sum_wall = 0.0
do kw = 1, nWallSegm
kw_true = nCells + nPlasmReg + kw
j = adjCell(1,kw_true)
do ll = 1, nSides(j)
if (adjCell(ll,j).EQ.kw_true) then
sum_wall = sum_wall + fwabsorb(kw) * (1.0 - refln(kw)) *
. (gflux(j,ll,1) + g_ion(kw))
endif
enddo
enddo
c/ Calculate global particle balance parameters:
fluxn_tot = srcNormFact *sum_gext ! external surface fluxes (gas puffing)
fluxi_tot = srcNormFact *sum_gion ! ion fluxes (recycling)
volsrc_tot = srcNormFact *sum_vol ! volumetric sources
coreloss_tot = srcNormFact *sum_core ! lost to the core plasma region
wloss_tot = srcNormFact *sum_wall ! lost by wall absorption or pumping
ionloss_tot = srcNormFact *sum_ion ! lost by ionization
c/ Total particles entering volume:
tot_part_in = (fluxn_tot + fluxi_tot + volsrc_tot)
c/ Total particles lost in volume:
tot_part_out = (coreloss_tot + wloss_tot + ionloss_tot)
c/ Relative percentage error:
partbalnerr = 100.0 * (tot_part_in - tot_part_out) / tot_part_in
return
end