MFIX  2016-1
calc_rrates_des.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Module name: CALC_RRATES_DES !
4 ! Author: J. Musser Date: 10-Oct-12 !
5 ! !
6 ! Purpose: Calculate reaction rates for various reactions for DES. !
7 ! !
8 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
9  SUBROUTINE calc_rrates_des(NP, pRgp, pRgc, pRPhase, pHoRg, pSUMRg)
10 
11  USE compar
12  USE constant
13  USE des_rxns
14  USE des_thermo
15  USE discretelement
16  USE energy
17  USE fldvar
18  USE funits
19  USE geometry
20  USE indices
21  USE parallel
22  USE param
23  USE param1
24  USE physprop
25  USE run
26  USE rxns
27  USE sendrecv
28  USE usr
29  Use parse
30  use functions
31  use toleranc, only: zero_x_gs, compare
32  use physprop, only: nmax
33  use param1, only: dimension_lm
34  use param, only: dimension_m
35 
36  IMPLICIT NONE
37 
38 ! Passed variables
39 !---------------------------------------------------------------------//
40  INTEGER, INTENT(IN) :: NP ! particle index
41 
42 ! Local gas phase values.
43  DOUBLE PRECISION, INTENT(OUT) :: pRgp(nmax(0)) ! Rate of production
44  DOUBLE PRECISION, INTENT(OUT) :: pRgc(nmax(0)) ! Rate of consumption
45  DOUBLE PRECISION, INTENT(OUT) :: pHoRg ! Heat of reaction
46  DOUBLE PRECISION, INTENT(OUT) :: pSUMRg
47  DOUBLE PRECISION, INTENT(OUT) :: pRPhase(dimension_lm+dimension_m-1)
48 
49 ! Local variables
50 !---------------------------------------------------------------------//
51  INTEGER :: pM ! Global Solids Phase index
52  INTEGER :: IJK ! fluid cell index
53 
54  INTEGER :: H ! Reaction loop counter
55  INTEGER :: M ! Global Phase index loop counter
56  INTEGER :: NN ! Global species index
57  INTEGER :: lN ! Local reaction speices index/loop counter
58  INTEGER :: LM !
59 
60  INTEGER :: mXfr ! Global phase index for mass transfer
61 
62 ! User-defined reaction rates returned from USR_RATES
63  DOUBLE PRECISION :: DES_RATES(no_of_des_rxns)
64 
65  DOUBLE PRECISION :: lRate
66  DOUBLE PRECISION :: lTp
67  DOUBLE PRECISION :: lHoRs, llHoRg
68 
69  DOUBLE PRECISION :: RxH
70 
71 ! Reaction limiters. If a species mass fraction is less than this
72 ! value, then the reaction is suppressed.
73  DOUBLE PRECISION :: speciesLimiter
74 
75 ! External functions
76 !---------------------------------------------------------------------//
77 ! Enthalpy calculations (cal/gram)
78  DOUBLE PRECISION, EXTERNAL :: CALC_H
79 
80 ! Alias particle temperature.
81  ltp = des_t_s(np)
82  ijk = pijk(np,4)
83  pm = pijk(np,5)
84 
85 ! Initialize storage arrays
86  prgp(:) = zero
87  prgc(:) = zero
88  phorg = zero
89 
90  prphase = zero
91  psumrg = zero
92 
93 ! Set the species limiter:
94  specieslimiter = zero_x_gs
95 
96 ! Calculate user defined reaction rates.
97  des_rates(:) = zero
98  CALL usr_rates_des(np, pm, ijk, des_rates)
99 
100 ! Loop over reactions.
101  rxn_lp: DO h = 1, no_of_des_rxns
102 
103 ! Skip empty reactions
104  IF(des_reaction(h)%nSpecies == 0) cycle rxn_lp
105  IF(compare(des_rates(h),zero)) cycle rxn_lp
106 
107 ! Initialize local loop arrays
108  llhorg = zero
109  lhors = zero
110  rxh = zero
111 
112 ! Calculate the rate of formation/consumption for each species.
113 !---------------------------------------------------------------------//
114  DO ln = 1, des_reaction(h)%nSpecies
115 ! Global phase index.
116  m = des_reaction(h)%Species(ln)%pMap
117 ! Global species index.
118  nn = des_reaction(h)%Species(ln)%sMap
119 ! Index for interphase mass transfer. For a gas/solid reaction, the
120 ! index is stored with the gas phase.
121  mxfr = des_reaction(h)%Species(ln)%mXfr
122  lrate = des_rates(h) * des_reaction(h)%Species(ln)%MWxStoich
123 ! Gas Phase:
124  IF(m == 0) THEN
125 ! Consumption of gas phase species.
126  IF(lrate < zero) THEN
127  IF(x_g(ijk,nn) > specieslimiter) THEN
128  prgc(nn) = prgc(nn) - lrate
129 ! Enthalpy transfer associated with mass transfer. (gas/solid)
130  IF(m /= mxfr) rxh = rxh + &
131  lrate*calc_h(t_g(ijk),0,nn)
132  ELSE
133 ! There is an insignificant amount of reactant. Skip this reaction.
134  des_rates(h) = zero
135  cycle rxn_lp
136  ENDIF
137  ELSE
138 ! Formation of gas phase species.
139  prgp(nn) = prgp(nn) + lrate
140 ! Enthalpy transfer associated with mass transfer. (gas/solid)
141  IF(m /= mxfr) rxh = rxh + lrate*calc_h(ltp,0,nn)
142  ENDIF
143 ! Discrete Solids Phase:
144  ELSE
145 ! Formation/consumption of solids phase species.
146  des_r_s(np,nn) = des_r_s(np,nn) + lrate
147  ENDIF
148  ENDDO ! Loop of species
149 
150 
151 ! Calculate and store the heat of reaction.
152 !---------------------------------------------------------------------//
153  IF(energy_eq) THEN
154 ! Automated heat of reaction calculations
155  IF(des_reaction(h)%Calc_DH) THEN
156 ! Loop over reaction species.
157  DO ln = 1, des_reaction(h)%nSpecies
158 ! Global phase index.
159  m = des_reaction(h)%Species(ln)%pMap
160 ! Global species index.
161  nn = des_reaction(h)%Species(ln)%sMap
162 ! Rate of formation/consumption for speices N
163  lrate = des_rates(h) * &
164  des_reaction(h)%Species(ln)%MWxStoich
165 ! Gas phase enthalpy chnage from energy equation derivation.
166  IF(m == 0) THEN
167  llhorg = llhorg + calc_h(t_g(ijk),0,nn) * lrate
168 ! Solid phase enthalpy change from energy equation derivation.
169  ELSE
170  lhors = lhors + calc_h(ltp,m,nn) * lrate
171  ENDIF
172  ENDDO
173 
174 ! Apply enthalpy transfer associated with mass transfer to get the
175 ! complete heat of reaction for Reaction H.
176  llhorg = llhorg - rxh
177  lhors = lhors + rxh
178 
179 ! Convert the heat of reaction to the appropriate units (if SI), and
180 ! store in the global array.
181  IF(units == 'SI') THEN
182  phorg = phorg + 4.183925d3*llhorg
183  q_source(np) = q_source(np) - 4.183925d3*lhors
184  ELSE
185  phorg = phorg + llhorg
186  q_source(np) = q_source(np) - lhors
187  ENDIF
188  ELSE
189 ! User-defined heat of reaction.
190  hor_g(ijk) = hor_g(ijk) + &
191  des_reaction(h)%HoR(0) * des_rates(h)
192  q_source(np) = q_source(np) - &
193  des_reaction(h)%HoR(pm) * des_rates(h)
194  ENDIF
195  ENDIF
196 
197 ! Update rate of interphase mass transfer.
198 !---------------------------------------------------------------------//
199  lm = 1 + (pm - 1)*pm/2
200  prphase(lm) = prphase(lm) + &
201  des_rates(h) * des_reaction(h)%rPHASE(lm)
202 
203  ENDDO rxn_lp ! Loop over reactions.
204 
205 ! Calculate the toal rate of formation and consumption for each species.
206 !---------------------------------------------------------------------//
207  IF(species_eq(0)) THEN
208  psumrg = sum(prgp(:nmax(0)) - prgc(:nmax(0)))
209  ELSE
210  DO h=1, no_of_des_rxns
211  IF(des_reaction(h)%nPhases <= 0) cycle
212  lm = 1 + ((pm-1)*pm)/2
213  psumrg = psumrg + &
214  des_rates(h) * des_reaction(h)%rPHASE(lm)
215  ENDDO
216  ENDIF
217 
218  RETURN
219  END SUBROUTINE calc_rrates_des
220 
221 
222 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
223 ! Subroutine name: CALC_RRATE_DES !
224 ! !
225 ! Purpose: This routine manages gas-solid reactions for the continuum !
226 ! phase. !
227 ! !
228 ! Author: J.Musser Date: 16-May-11 !
229 ! !
230 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
231  SUBROUTINE zero_rrate_des
233  USE des_rxns
234  USE param1, only: zero
235 
236  IMPLICIT NONE
237 
238  des_r_gp(:,:) = zero
239  des_r_gc(:,:) = zero
240  des_r_phase(:,:) = zero
241  des_hor_g(:) = zero
242  des_sum_r_g(:) = zero
243 
244  RETURN
245  END SUBROUTINE zero_rrate_des
double precision, dimension(:,:), allocatable des_r_s
Definition: des_rxns_mod.f:24
logical function compare(V1, V2)
Definition: toleranc_mod.f:94
integer dimension_lm
Definition: param1_mod.f:13
double precision, dimension(:), allocatable des_t_s
double precision, dimension(:), allocatable des_hor_g
Definition: des_rxns_mod.f:46
Definition: rxns_mod.f:1
logical, dimension(0:dim_m) species_eq
Definition: run_mod.f:115
double precision, dimension(:), allocatable t_g
Definition: fldvar_mod.f:63
double precision, dimension(:), allocatable des_sum_r_g
Definition: des_rxns_mod.f:42
subroutine calc_rrates_des(NP, pRgp, pRgc, pRPhase, pHoRg, pSUMRg)
double precision, dimension(:,:), allocatable x_g
Definition: fldvar_mod.f:75
double precision, dimension(:,:), allocatable des_r_gc
Definition: des_rxns_mod.f:40
integer no_of_des_rxns
Definition: des_rxns_mod.f:51
Definition: run_mod.f:13
subroutine zero_rrate_des
Definition: param_mod.f:2
Definition: usr_mod.f:1
double precision, dimension(:,:), allocatable des_r_phase
Definition: des_rxns_mod.f:44
Definition: parse_mod.f:1
character(len=16) units
Definition: run_mod.f:30
integer, dimension(0:dim_m) nmax
Definition: physprop_mod.f:119
logical energy_eq
Definition: run_mod.f:100
double precision, parameter zero_x_gs
Definition: toleranc_mod.f:19
double precision, dimension(:), allocatable q_source
double precision, dimension(:,:), allocatable des_r_gp
Definition: des_rxns_mod.f:38
subroutine usr_rates_des(NP, pM, IJK, DES_RATES)
Definition: usr_rates_des.f:45
integer dimension_m
Definition: param_mod.f:18
double precision, parameter zero
Definition: param1_mod.f:27
double precision, dimension(:), allocatable hor_g
Definition: energy_mod.f:6