MFIX  2016-1
check_data_30.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! Module name: CHECK_DATA_30 !
3 ! Author: M. Syamlal Date: 27-OCT-92 !
4 ! !
5 ! Purpose: Check whether the sum of reaction rates is zero and the !
6 ! sum of mass fractions is 1.0 and EP_g >= EP_Star. !
7 ! and EP_g >= EP_star. Set miscellaneous constants !
8 ! !
9 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
10  SUBROUTINE check_data_30
11 
12 ! Global variables: (common to sub-functions)
13 !---------------------------------------------------------------------//
14  use run, only: energy_eq, species_eq
15  use compar, only: istart2, iend2
16  use compar, only: jstart2, jend2
17  use compar, only: kstart2, kend2
18  use physprop, only: smax, nmax
19  use param1, only: zero, one
20  use rxns, only: use_rrates
21  use mms, only: use_mms
22  use param, only: dimension_m
23 
24  use error_manager
25 
26  IMPLICIT NONE
27 
28 ! Local variables:
29 !---------------------------------------------------------------------//
30 ! Flag for error message headers.
31  INTEGER :: ERR_TAG
32 ! Flags to report stats on species equations.
33  LOGICAL :: REPORT_SPECIES(0:dimension_m)
34 !......................................................................!
35 
36 
37 ! Check physical properties in inflow/outflow cells.
38  IF(.NOT.use_mms) CALL check_flow_cell_props
39 ! Verify physical values for field variables.
41 ! Generate species report if needed.
42  IF(any(report_species)) CALL report_species_stats
43 ! Check interphase mass transfer.
45 
46  RETURN
47 
48  CONTAINS
49 
50 !----------------------------------------------------------------------!
51 ! Module name: CHECK_FLOW_PROPS !
52 ! Author: M. Syamlal Date: 27-OCT-92 !
53 ! !
54 ! Purpose: Verify that inflow/outflow cells do not contain physical !
55 ! properties for specified variables. !
56 ! !
57 !----------------------------------------------------------------------!
58  SUBROUTINE check_flow_cell_props
59 
60 ! Global variables:
61 !---------------------------------------------------------------------//
62  use visc_s, only: mu_s, lambda_s
63  use visc_g, only: mu_gt, lambda_gt
64  use physprop, only: k_g, k_s
65  use physprop, only: dif_s, dif_g
66 
67  use functions, only: funijk
68  use functions, only: flow_at
69  use compar, only: dead_cell_at
70 
71  IMPLICIT NONE
72 
73 ! Local variables:
74 !---------------------------------------------------------------------//
75 ! Loop counters
76  INTEGER :: I, J, K, IJK
77  INTEGER :: M, N
78 ! Integer error flag.
79  INTEGER :: IER
80 !......................................................................!
81 
82  CALL init_err_msg("CHECK_FLOW_CELL_PROPS")
83 
84  ier = 0
85  err_tag=2000
86 
87  DO k = kstart2, kend2
88  DO j = jstart2, jend2
89  DO i = istart2, iend2
90 
91  IF (dead_cell_at(i,j,k)) cycle ! skip dead cells
92 
93  ijk = funijk(i,j,k)
94 
95  IF(flow_at(ijk)) THEN
96 
97 ! Turbulent viscosity of fluid phase.
98  IF(mu_gt(ijk) /= zero) CALL report_error &
99  (ier, i, j, k, mu_gt(ijk), '/=', zero, 'MU_GT')
100 
101 ! Granular second coefficient of viscosity.
102  IF(lambda_gt(ijk) /= zero) CALL report_error &
103  (ier, i, j, k, lambda_gt(ijk), '/=', zero, 'LAMBDA_GT')
104 ! Gas conductivity.
105  IF(k_g(ijk) /= zero) CALL report_error &
106  (ier, i, j, k, k_g(ijk),'/=',zero,'K_G')
107 ! Diffusivity of gas species N.
108  DO n = 1, nmax(0)
109  IF(dif_g(ijk, n) /= zero) CALL report_error &
110  (ier, i, j, k, dif_g(ijk,n),'/=',zero,'DIF_G',n)
111  ENDDO
112 
113  DO m = 1, smax
114 ! Granular first coefficient of (shear) viscosity.
115  IF(mu_s(ijk, m) /= zero) CALL report_error &
116  (ier, i, j, k, mu_s(ijk,m),'/=',zero,'MU_S',m)
117 ! Granular second coefficient of viscosity.
118  IF(lambda_s(ijk, m) /= zero) CALL report_error &
119  (ier, i, j, k, lambda_s(ijk,m),'/=',zero,'LAMBDA_S',m)
120 ! Solids thermal conductivity.
121  IF(k_s(ijk, m) /= zero) CALL report_error &
122  (ier, i, j, k, k_s(ijk,m),'/=',zero,'K_S', m)
123 ! Diffusivity of solids phase M, species N.
124  DO n = 1, nmax(m)
125  IF(dif_s(ijk,m,n) /= zero) CALL report_error &
126  (ier, i,j,k, dif_s(ijk,m,n),'/=',zero,'DIF_S',m,n)
127  ENDDO
128  ENDDO
129  ENDIF
130 
131  ENDDO
132  ENDDO
133  ENDDO
134 
135  IF(ier /= 0) THEN
136  WRITE(err_msg,"('End of Report.')")
137  CALL flush_err_msg(header=.false., abort=.true.)
138 ! Close DMP logs when running in interactive mode.
139  CALL close_pe_log
140  ENDIF
141 
142  CALL finl_err_msg
143 
144  RETURN
145  END SUBROUTINE check_flow_cell_props
146 
147 
148 
149 !----------------------------------------------------------------------!
150 ! !
151 ! Module name: CHECK_PHYSICAL_BOUNDS !
152 ! Author: M. Syamlal Date: 27-OCT-92 !
153 ! !
154 ! Purpose: Verify that fluid cells have physical values for the !
155 ! specified variables. !
156 ! !
157 !----------------------------------------------------------------------!
158  SUBROUTINE check_physical_bounds
160 ! Global variables:
161 !---------------------------------------------------------------------//
162  use toleranc, only: tmin, tmax, tol_com
163  use fldvar, only: x_g, x_s
164  use fldvar, only: t_g, t_s
165  use fldvar, only: rop_s
166  use rxns, only: rox_gc, rox_sc
167  use rxns, only: r_gp, r_sp
168  use visc_s, only: mu_s
169  use physprop, only: k_g, k_s
170  use physprop, only: c_pg, c_ps
171  use physprop, only: dif_s, dif_g
172  use physprop, only: mu_g
173  use physprop, only: mw_mix_g
174 
175  use mpi_utility, only: global_all_sum
176  use mpi_utility, only: global_all_or
177 
178  use functions, only: funijk
179  use functions, only: wall_at
180  use compar, only: dead_cell_at
181 
182  IMPLICIT NONE
183 
184 ! Local variables:
185 !---------------------------------------------------------------------//
186  INTEGER :: I, J, K, IJK
187  INTEGER :: M, N
188 ! Integer error flag.
189  INTEGER :: IER
190 
191  CALL init_err_msg("CHECK_PHYSICAL_BOUNDS")
192 
193  ier = 0
194  err_tag = 3000
195  report_species = .false.
196 
197  DO k = kstart2, kend2
198  DO j = jstart2, jend2
199  DO i = istart2, iend2
200  IF (dead_cell_at(i,j,k)) cycle ! skip dead cells
201  ijk = funijk(i,j,k)
202  IF (.NOT.wall_at(ijk)) THEN
203 
204 ! Gas viscosity must be non-negative.
205  IF(mu_g(ijk) < zero) CALL report_error &
206  (ier, i, j, k, mu_g(ijk), '<', zero, 'MU_G')
207 
208 ! Mixture molecular weight must be positive.
209  IF(mw_mix_g(ijk) <= zero) CALL report_error &
210  (ier, i, j, k,mw_mix_g(ijk), '<=', zero, 'MW_MIX_G')
211 
212 ! Verify thermodynamic properties when solving energy equations:
213  IF(energy_eq) THEN
214 ! Gas conductivity must be non-negative.
215  IF(k_g(ijk) < zero) CALL report_error &
216  (ier, i, j, k, k_g(ijk), '<', zero, 'K_G')
217 ! Gas phase specific heat must be positive.
218  IF(c_pg(ijk) <= zero) CALL report_error &
219  (ier, i, j, k, c_pg(ijk), '<=', zero, 'C_PG')
220 ! Verify that the gas phase temperature is within the bounds.
221  IF(t_g(ijk) <= tmin) CALL report_error &
222  (ier, i, j, k, t_g(ijk), '<=', tmin, 'T_G')
223  IF(t_g(ijk) >= tmax) CALL report_error &
224  (ier, i, j, k, t_g(ijk), '>=', tmax, 'T_G')
225 
226 ! Diffusivity of gas species N must be non-negative.
227  DO n = 1, nmax(0)
228  IF(dif_g(ijk, n) < zero) CALL report_error &
229  (ier, i,j,k, dif_g(ijk,n),'<',zero, 'DIF_G',n)
230  IF(x_g(ijk,n) < zero) CALL report_error &
231  (ier, i, j, k, x_g(ijk,n), '<', zero, 'X_G',n)
232  IF(x_g(ijk,n) > one) CALL report_error &
233  (ier, i, j, k, x_g(ijk,n), '>', one, 'X_G',n)
234  ENDDO
235  ENDIF
236 
237 ! Verify that the gas phase mass fractons sum to one.
238  IF(species_eq(0)) THEN
239  IF(abs(one - sum(x_g(ijk,1:nmax(0)))) > tol_com) &
240  report_species(0) = .true.
241 
242 ! Verify that the rates of formation and consumption adhear to the
243 ! expected coding restraints. (non-negative)
244  IF(use_rrates) THEN
245  DO n = 1, nmax(0)
246  IF(r_gp(ijk,n) < zero) CALL report_error &
247  (ier,i,j,k, r_gp(ijk,n),'<',zero,'R_GP',n)
248  IF(rox_gc(ijk,n) < zero) CALL report_error &
249  (ier,i,j,k,rox_gc(ijk,n),'<',zero,'RoX_GC',n)
250  ENDDO
251  ENDIF
252 
253  ENDIF
254 
255  DO m = 1, smax
256 
257 ! Solids viscosity should be non-negativel.
258  IF(mu_s(ijk,m) < zero) CALL report_error &
259  (ier, i, j, k, mu_s(ijk,m), '<', zero, 'MU_S',m)
260 
261  IF(energy_eq) THEN
262 
263 ! Thermal conductivity must be non-negative.
264  IF(k_s(ijk,m) < zero) CALL report_error &
265  (ier, i, j, k, k_s(ijk,m), '<', zero, 'K_S',m)
266 
267 ! Solids specific heat must be positive.
268  IF(c_ps(ijk,m) <= zero) CALL report_error &
269  (ier, i, j, k, c_ps(ijk,m), '<=', zero, 'C_PS',m)
270 
271 ! Verify that the solids temperature is within the required bounds.
272  IF(t_s(ijk,m) <= tmin) CALL report_error &
273  (ier, i, j, k, t_s(ijk,m), '<=', tmin, 'T_S',m)
274  IF(t_s(ijk,m) >= tmax) CALL report_error &
275  (ier, i, j, k, t_s(ijk,m), '>=', tmax, 'T_S',m)
276 
277  ENDIF
278 
279  DO n = 1, nmax(m)
280  IF(dif_s(ijk, m, n) < zero) CALL report_error &
281  (ier, i, j, k, dif_s(ijk,m,n),'<',zero,'DIF_S',m,n)
282  ENDDO
283 
284 ! Sum of solids mass fractions should be one
285  IF(species_eq(m)) THEN
286  IF(rop_s(ijk,m) /= zero) THEN
287  IF(abs(one-sum(x_s(ijk,m,1:nmax(m)))) > tol_com) &
288  report_species(m) = .true.
289  ENDIF
290 
291  DO n = 1, nmax(m)
292  IF(x_s(ijk, m, n) < zero) CALL report_error &
293  (ier, i,j,k, x_s(ijk,m,n),'<',zero, 'X_S',m,n)
294  IF(x_s(ijk, m, n) > one) CALL report_error &
295  (ier, i,j,k, x_s(ijk,m,n),'>',one, 'X_S',m,n)
296  ENDDO
297  ENDIF
298 
299 ! Verify that the rates of formation and consumption adhear to the
300 ! expected coding restraints. (non-negative)
301  IF(species_eq(m) .AND. use_rrates) THEN
302  DO n = 1, nmax(0)
303  IF(r_sp(ijk,m,n) < zero) CALL report_error &
304  (ier,i,j,k,r_sp(ijk,m,n),'<',zero,'R_SP',m,n)
305  IF(rox_gc(ijk,n) < zero) CALL report_error &
306  (ier,i,j,k,rox_sc(ijk,m,n),'<',zero,'RoX_SC',m,n)
307  ENDDO
308  ENDIF
309  ENDDO
310 
311  ENDIF ! IF(.NOT.WALL_AT(IJK))
312  ENDDO ! DO I = ISTART2, IEND2
313  ENDDO ! DO J = JSTART2, JEND2
314  ENDDO ! DO K = KSTART2, KEND2
315 
316  CALL global_all_sum(ier)
317 
318  IF(ier /= 0) THEN
319  WRITE(err_msg,"('End of Report.')")
320  CALL flush_err_msg(header=.false., abort=.true.)
321  CALL close_pe_log
322  ENDIF
323 
324  CALL global_all_or(report_species)
325 
326  CALL finl_err_msg
327 
328  RETURN
329  END SUBROUTINE check_physical_bounds
330 
331 
332 
333 !----------------------------------------------------------------------!
334 ! !
335 ! Module name: REPORT_SPECIES_STATS !
336 ! Author: M. Syamlal Date: 27-OCT-92 !
337 ! !
338 ! Purpose: Collect information on the sums of species mass fractions. !
339 ! This routine is call as-needed. !
340 ! !
341 !----------------------------------------------------------------------!
342  SUBROUTINE report_species_stats
344 ! Global variables:
345 !---------------------------------------------------------------------//
346  use fldvar, only: x_g, x_s
347  use fldvar, only: rop_s
348  use run, only: time
349  use mpi_utility, only: global_all_sum
350  use mpi_utility, only: global_all_max
351  use mpi_utility, only: global_all_min
352 
353  use functions, only: funijk
354  use functions, only: wall_at
355 
356  use param1, only: undefined
357  use compar, only: dead_cell_at
358 
359  IMPLICIT NONE
360 
361 ! Local variables:
362 !---------------------------------------------------------------------//
363  INTEGER :: I, J, K, IJK, L
364  INTEGER :: M
365 
366  INTEGER :: COUNT(0:dimension_m, 9)
367  INTEGER :: MIN_LOC(0:dimension_m)
368  INTEGER :: MAX_LOC(0:dimension_m)
369 
370  DOUBLE PRECISION :: MIN_VAL(0:dimension_m)
371  DOUBLE PRECISION :: MAX_VAL(0:dimension_m)
372 
373  DOUBLE PRECISION :: lSUM
374 !......................................................................!
375 
376  CALL init_err_msg('REPORT_SPECIES_STATS')
377 
378  WRITE(err_msg, 4000) time
379  CALL flush_err_msg(footer=.false.)
380 
381  4000 FORMAT('Time = ',g12.5,/'Warning: The sum of mass fractions ', &
382  'is not equal to one.')
383 
384 ! Initialize the counters
385  count = 0
386  max_val = -undefined
387  min_val = undefined
388 
389 ! Collect stats on species across the domain.
390  DO k = kstart2, kend2
391  DO j = jstart2, jend2
392  DO i = istart2, iend2
393  IF (dead_cell_at(i,j,k)) cycle ! skip dead cells
394  ijk = funijk(i,j,k)
395  IF (.NOT.wall_at(ijk)) THEN
396 
397  IF(species_eq(0)) THEN
398  lsum = sum(x_g(ijk,1:nmax(0)))
399  IF (lsum < min_val(0)) THEN
400  min_val(0) = lsum
401  min_loc(0) = ijk
402  ENDIF
403  IF (lsum > max_val(0)) THEN
404  max_val(0) = lsum
405  max_loc(0) = ijk
406  ENDIF
407  IF (lsum < 0.9) THEN
408  count(0,1) = count(0,1) + 1 ! < 0.9pP
409  ELSE IF (lsum < 0.99) THEN
410  count(0,2) = count(0,2) + 1 ! 0.9 - 0.99
411  ELSE IF (lsum < 0.999) THEN
412  count(0,3) = count(0,3) + 1 ! 0.99 - 0.999
413  ELSE IF (lsum < 0.9999) THEN
414  count(0,4) = count(0,4) + 1 ! 0.999 - 0.9999
415  ELSE IF (lsum < 1.0001) THEN
416  count(0,5) = count(0,5) + 1 ! 0.9999 - 1.0001
417  ELSE IF (lsum < 1.001) THEN
418  count(0,6) = count(0,6) + 1 ! 1.0001 - 1.001
419  ELSE IF (lsum < 1.01) THEN
420  count(0,7) = count(0,7) + 1 ! 1.001 - 1.01
421  ELSE IF (lsum < 1.1) THEN
422  count(0,8) = count(0,8) + 1 ! 1.01 - 1.1
423  ELSE
424  count(0,9) = count(0,9) + 1 ! > 1.1
425  ENDIF
426  ENDIF
427 
428 
429  DO m = 1, smax
430 ! Sum of solids mass fractions should be one
431  IF(species_eq(m)) THEN
432  lsum = sum(x_s(ijk,m,1:nmax(m)) )
433  IF(rop_s(ijk,m) /= zero) THEN
434  IF(lsum < min_val(m)) THEN
435  min_val(m) = lsum
436  min_loc(m) = ijk
437  ENDIF
438  IF (lsum > max_val(m)) THEN
439  max_val(m) = lsum
440  max_loc(m) = ijk
441  ENDIF
442  IF (lsum < 0.9) THEN
443  count(m,1) = count(m,1) + 1 ! < 0.9
444  ELSE IF (lsum < 0.99) THEN
445  count(m,2) = count(m,2) + 1 ! 0.9 - 0.99
446  ELSE IF (lsum < 0.999) THEN
447  count(m,3) = count(m,3) + 1 ! 0.99 - 0.999
448  ELSE IF (lsum < 0.9999) THEN
449  count(m,4) = count(m,4) + 1 ! 0.999 - 0.9999
450  ELSE IF (lsum < 1.0001) THEN
451  count(m,5) = count(m,5) + 1 ! 0.9999 - 1.0001
452  ELSE IF (lsum < 1.001) THEN
453  count(m,6) = count(m,6) + 1 ! 1.0001 - 1.001
454  ELSE IF (lsum < 1.01) THEN
455  count(m,7) = count(m,7) + 1 ! 1.001 - 1.01
456  ELSE IF (lsum < 1.1) THEN
457  count(m,8) = count(m,8) + 1 ! 1.01 - 1.1
458  ELSE
459  count(m,9) = count(m,9) + 1 ! > 1.1
460  ENDIF
461  ENDIF
462  ENDIF
463  ENDDO
464 
465 
466  ENDIF ! IF(.NOT.WALL_AT(IJK))
467  ENDDO ! DO I = ISTART2, IEND2
468  ENDDO ! DO J = JSTART2, JEND2
469  ENDDO ! DO K = KSTART2, KEND2
470 
471 
472  CALL global_all_sum(count)
473  CALL global_all_max(max_val)
474  CALL global_all_min(min_val)
475 
476 
477  4100 FORMAT(//'Statistics of sum of gas species mass fraction',/ &
478  1x,'Minimum sum of X_g=',g12.5,/1x,'Maximum sum of X_g=', &
479  g12.5,2/,3x,'Sum of X_g',t20,'No of Cells Distribution')
480 
481  IF(report_species(0)) THEN
482  lsum = sum(count(0,:))
483  WRITE(err_msg,4100) min_val(0), max_val(0)
484  CALL flush_err_msg(header=.false., footer=.false.)
485  WRITE(err_msg,4999) (count(0,l),dble(count(0,l))/lsum,l=1,9)
486  CALL flush_err_msg(header=.false., footer=.false.)
487  ENDIF
488 
489 
490  4200 FORMAT(//'Statistics of sum of solids phase ',i2,' species ', &
491  'mass fractions',/1x,'Minimum sum of X_s=',g12.5,/1x, &
492  'Maximum sum of X_s=',g12.5,2/,3x,'Sum of ',a,t20,'No of ', &
493  'Cells',2x,'Distribution')
494 
495  DO m=1,smax
496  IF(report_species(m)) THEN
497  lsum = sum(count(m,:))
498  WRITE(err_msg,4200) m, min_val(m), max_val(m), &
499  trim(ivar('X_s',m))
500  CALL flush_err_msg(header=.false., footer=.false.)
501  WRITE(err_msg,4999) (count(m,l),dble(count(m,l))/lsum,l=1,9)
502  CALL flush_err_msg(header=.false., footer=.false.)
503  ENDIF
504  ENDDO
505 
506  WRITE(err_msg,"(/'End of report.')")
507  CALL flush_err_msg(header=.false.)
508 
509  4999 FORMAT( &
510  1x,'<0.9 ',t20,i9,t33,g12.5,/&
511  1x,' 0.9 - 0.99 ',t20,i9,t33,g12.5,/&
512  1x,' 0.99 - 0.999 ',t20,i9,t33,g12.5,/&
513  1x,' 0.999 - 0.9999',t20,i9,t33,g12.5,/&
514  1x,' 0.9999 - 1.0001',t20,i9,t33,g12.5,/&
515  1x,' 1.0001 - 1.001 ',t20,i9,t33,g12.5,/&
516  1x,' 1.001 - 1.01 ',t20,i9,t33,g12.5,/&
517  1x,' 1.01 - 1.1 ',t20,i9,t33,g12.5,/&
518  1x,'>1.1 ',t20,i9,t33,g12.5)
519 
520  CALL finl_err_msg
521 
522  RETURN
523  END SUBROUTINE report_species_stats
524 
525 
526 
527 !----------------------------------------------------------------------!
528 ! !
529 ! Module name: CHECK_RXN_MASS_BALANCE !
530 ! Author: M. Syamlal Date: 27-OCT-92 !
531 ! !
532 ! Purpose: Verify that the net interphase mass transfer rates sum to !
533 ! zero. This check is not needed with updated rates implementation. !
534 ! !
535 !----------------------------------------------------------------------!
536  SUBROUTINE check_rxn_mass_balance
537 !
538 !-----------------------------------------------
539 ! M o d u l e s
540 !-----------------------------------------------
541  USE param
542  USE param1
543  USE toleranc
544  USE fldvar
545  USE rxns
546  USE visc_s
547  USE visc_g
548  USE geometry
549  USE run
550  USE constant
551  USE physprop
552  USE indices
553  USE funits
554  USE mpi_utility
555  USE discretelement
556  USE mms
557  USE functions
558  use compar, only: dead_cell_at
559 
560  IMPLICIT NONE
561 !-----------------------------------------------
562 ! G l o b a l P a r a m e t e r s
563 !-----------------------------------------------
564 !-----------------------------------------------
565 ! L o c a l P a r a m e t e r s
566 !-----------------------------------------------
567 !-----------------------------------------------
568 ! L o c a l V a r i a b l e s
569 !-----------------------------------------------
570 !
571 ! Loop counters:
572  INTEGER :: I, J, K, IJK
573  INTEGER :: M, L, LM
574 ! Temp variable for summations.
575  DOUBLE PRECISION :: lSUM
576 
577  INTEGER :: COUNT(dimension_m+2, 2)
578  INTEGER :: MAX_LOC(dimension_m+2)
579  DOUBLE PRECISION :: MAX_VAL(dimension_m+2)
580 !......................................................................!
581 
582  CALL init_err_msg('CHECK_RXN_MASS_BALANCE')
583 
584 
585  count = 0
586  max_loc = 0
587  max_val = zero
588 
589 
590  DO k = kstart2, kend2
591  DO j = jstart2, jend2
592  DO i = istart2, iend2
593  IF (dead_cell_at(i,j,k)) cycle ! skip dead cells
594  ijk = funijk(i,j,k)
595  IF (.NOT.wall_at(ijk)) THEN
596 
597 !---------------------------------------------------------------------//
598 
599 ! The rate of interphase mass transfer must sum to zero over all phases.
600  lsum = sum_r_g(ijk)
601  IF(smax > 0) lsum = lsum + sum(sum_r_s(ijk,1:smax))
602 
603  IF (abs(lsum) > small_number) THEN
604  IF(abs(lsum) > abs(max_val(1))) THEN
605  max_val(1) = lsum
606  max_loc(1) = ijk
607  ENDIF
608 ! Bin the fluid cells: Good/Bad
609  IF (abs(lsum) > tol_com) THEN
610  count(1,2) = count(1,2) + 1
611  ELSE
612  count(1,1) = count(1,1) + 1
613  ENDIF
614  ENDIF
615 
616 ! Verify that the net rate of production (SUM_R_x) matches the the total
617 ! amount of mass transferred from other phases.
618  DO l = 0, smax
619  IF (l == 0) THEN
620  lsum = sum_r_g(ijk)
621  ELSE
622  lsum = sum_r_s(ijk,l)
623  ENDIF
624  DO m = 0, smax
625  IF (m > l) THEN
626  lm = l + 1 + (m - 1)*m/2
627  lsum = lsum - r_phase(ijk,lm)
628  ELSE IF (l > m) THEN
629  lm = m + 1 + (l - 1)*l/2
630  lsum = lsum + r_phase(ijk,lm)
631  ENDIF
632  ENDDO
633 
634  IF(abs(lsum) > small_number) THEN
635  IF(abs(lsum) > abs(max_val(l+2))) THEN
636  max_val(l+2) = lsum
637  max_loc(l+2) = ijk
638  ENDIF
639 
640 ! Force an exit if an imbalance exceeds the tollerance.
641  IF(abs(lsum) > tol_com) then
642  count(l+2,2) = count(l+2,2) + 1
643  ELSE
644 ! Count the number of cells that do not sum to one, but are below the
645 ! tollerance for force and exit.
646  count(l+2,1) = count(l+2,1) + 1
647  ENDIF
648  ENDIF
649  END DO
650 
651  ENDIF ! IF(.NOT.WALL_AT(IJK))
652  ENDDO ! DO I = ISTART2, IEND2
653  ENDDO ! DO J = JSTART2, JEND2
654  ENDDO ! DO K = KSTART2, KEND2
655 
656  CALL global_all_sum(count)
657 
658  IF(sum(count(:,2)) > 0) THEN
659 
660  CALL global_all_max(max_val)
661 
662  WRITE(err_msg,5000)
663  CALL flush_err_msg(footer=.false.)
664 
665  IF(count(1,2) > 0) THEN
666  WRITE(err_msg, 5100) count(1,1), count(1,2), max_val(1)
667  CALL flush_err_msg(header=.false., footer=.false.)
668  ENDIF
669 
670  DO l=0,smax
671  IF(count(l+2,2) > 0) THEN
672  WRITE(err_msg, 5200) l, count(l+2,1), count(l+2,2),&
673  max_val(l+2)
674  CALL flush_err_msg(header=.false., footer=.false.)
675  ENDIF
676  ENDDO
677 
678  WRITE(err_msg,"(/'End of report.')")
679  CALL flush_err_msg(header=.false., abort=.true.)
680  ENDIF
681 
682  CALL finl_err_msg
683 
684  RETURN
685  5000 FORMAT(5x,'Time = ',g12.5,/&
686  'Message: One or more of the following errors detected:',/ &
687  ' 1. Discrepancies in the reaction rates.',/ &
688  ' 2. The rate of production of phases (SUM_R_g or SUM_R_s)',/&
689  ' and the interphase mass transfer rates (R_Phase) are',/ &
690  ' inconsistent (in subroutine RRATES).',/4x,'I',t14,'J', &
691  t24,'K',t34,'M',t45,'Value')
692 
693  5100 FORMAT(//'Sum of all the reaction rates is not zero!',/, &
694  'Number of cells with discrepancy < error tolerance = ',i5,/, &
695  'Number of cells with discrepancy > error tolerance = ',i5,/, &
696  'Maximum discrepancy = ',g12.5)
697 
698  5200 FORMAT(//'Mesage: Production of phase ',i2,' not equal to ', &
699  'total mass transfer',/'from other phases!',/ &
700  'Number of cells with discrepancy < error tolerance = ',i9,/ &
701  'Number of cells with discrepancy > error tolerance = ',i9,/ &
702  'Maximum discrepancy = ',g12.4)
703 
704 
705  END SUBROUTINE check_rxn_mass_balance
706 
707 
708 
709 !----------------------------------------------------------------------!
710 ! Subroutine: REPORT_ERROR !
711 ! !
712 ! Purpose: Manage error messages for CHECK_DATA_30. !
713 !----------------------------------------------------------------------!
714  SUBROUTINE report_error(pIER, pI, pJ, pK, VAL, RELATION, BND, &
715  var, lc1, lc2)
717  INTEGER, INTENT(INOUT) :: pIER
718  INTEGER, INTENT(IN) :: pI, pJ, pK
719  DOUBLE PRECISION, INTENT(IN) :: BND, VAL
720  CHARACTER(LEN=*), INTENT(IN) :: RELATION
721  CHARACTER(LEN=*), INTENT(IN) :: VAR
722  INTEGER, INTENT(IN), OPTIONAL :: LC1, LC2
723  CHARACTER(LEN=32) :: VAR_FULL
724 
725  INTEGER :: lIER
726 
727  var_full=''
728  IF(PRESENT(lc2)) THEN
729  var_full = ivar(var,lc1,lc2)
730  ELSEIF(PRESENT(lc1)) THEN
731  var_full = ivar(var,lc1)
732  ELSE
733  var_full = var
734  ENDIF
735 
736  IF(pier == 0) THEN
737  CALL open_pe_log(lier)
738  SELECT CASE(err_tag)
739  CASE(2000); WRITE(err_msg,2000)
740  CASE(3000); WRITE(err_msg,3000)
741  END SELECT
742  CALL flush_err_msg(footer=.false.)
743  pier = 1
744  ENDIF
745 
746  2000 FORMAT('Error 2000: Physical properties detected in flow cells.',&
747  2/3x,'I',6x,'J',6x,'K',5x,'Value',8x,a,2x,'Bound',5x,'Variable')
748 
749  3000 FORMAT('Error 3000: Unphysical field variables detected.',&
750  2/3x,'I',6x,'J',6x,'K',5x,'Value',8x,a,2x,'Bound',5x,'Variable')
751 
752  WRITE(err_msg,9000) pi, pj, pk, val, relation, bnd, trim(var_full)
753  CALL flush_err_msg(header=.false., footer=.false.)
754 
755  9000 FORMAT(3(i6,1x),g12.4,1x,a,g12.4,1x,a)
756 
757  RETURN
758  END SUBROUTINE report_error
759  END SUBROUTINE check_data_30
integer jend2
Definition: compar_mod.f:80
double precision, dimension(:,:), allocatable c_ps
Definition: physprop_mod.f:86
double precision, dimension(:,:), allocatable mu_s
Definition: visc_s_mod.f:5
double precision, parameter tmax
Definition: toleranc_mod.f:31
character(len=32) function ivar(VAR, i1, i2, i3)
subroutine finl_err_msg
double precision, dimension(:,:), allocatable dif_g
Definition: physprop_mod.f:110
double precision, parameter one
Definition: param1_mod.f:29
double precision, dimension(:), allocatable mu_gt
Definition: visc_g_mod.f:8
subroutine check_rxn_mass_balance
integer istart2
Definition: compar_mod.f:80
Definition: rxns_mod.f:1
logical, dimension(0:dim_m) species_eq
Definition: run_mod.f:115
integer iend2
Definition: compar_mod.f:80
double precision, dimension(:), allocatable t_g
Definition: fldvar_mod.f:63
double precision, dimension(:), allocatable sum_r_g
Definition: rxns_mod.f:28
double precision, dimension(:,:), allocatable sum_r_s
Definition: rxns_mod.f:35
double precision, dimension(:,:,:), allocatable rox_sc
Definition: rxns_mod.f:33
double precision, parameter undefined
Definition: param1_mod.f:18
integer kend2
Definition: compar_mod.f:80
integer kstart2
Definition: compar_mod.f:80
double precision, parameter tmin
Definition: toleranc_mod.f:34
double precision, parameter tol_com
Definition: toleranc_mod.f:28
subroutine init_err_msg(CALLER)
logical use_rrates
Definition: rxns_mod.f:21
logical, dimension(:,:,:), allocatable dead_cell_at
Definition: compar_mod.f:127
double precision, dimension(:,:,:), allocatable x_s
Definition: fldvar_mod.f:78
subroutine check_flow_cell_props
Definition: check_data_30.f:59
double precision, parameter small_number
Definition: param1_mod.f:24
double precision, dimension(:,:), allocatable t_s
Definition: fldvar_mod.f:66
double precision, dimension(:,:), allocatable x_g
Definition: fldvar_mod.f:75
integer jstart2
Definition: compar_mod.f:80
Definition: mms_mod.f:12
double precision, dimension(:,:,:), allocatable r_sp
Definition: rxns_mod.f:31
double precision, dimension(:,:,:), allocatable dif_s
Definition: physprop_mod.f:116
subroutine report_species_stats
Definition: run_mod.f:13
subroutine check_data_30
Definition: check_data_30.f:11
double precision, dimension(:,:), allocatable lambda_s
Definition: visc_s_mod.f:31
double precision, dimension(:,:), allocatable r_phase
Definition: rxns_mod.f:38
Definition: param_mod.f:2
double precision, dimension(:,:), allocatable rox_gc
Definition: rxns_mod.f:26
subroutine check_physical_bounds
double precision, dimension(:), allocatable mw_mix_g
Definition: physprop_mod.f:130
integer, dimension(0:dim_m) nmax
Definition: physprop_mod.f:119
double precision, dimension(:), allocatable mu_g
Definition: physprop_mod.f:68
double precision, dimension(:), allocatable lambda_gt
Definition: visc_g_mod.f:17
logical energy_eq
Definition: run_mod.f:100
logical use_mms
Definition: mms_mod.f:15
subroutine close_pe_log
Definition: open_files.f:359
character(len=line_length), dimension(line_count) err_msg
double precision, dimension(:), allocatable k_g
Definition: physprop_mod.f:92
double precision, dimension(:,:), allocatable rop_s
Definition: fldvar_mod.f:51
integer smax
Definition: physprop_mod.f:22
subroutine report_error(ABORT, pI, pJ, pK, VAR, LC1, LC2)
double precision time
Definition: run_mod.f:45
integer dimension_m
Definition: param_mod.f:18
subroutine open_pe_log(IER)
Definition: open_files.f:270
double precision, dimension(:,:), allocatable k_s
Definition: physprop_mod.f:98
double precision, dimension(:), allocatable x
Definition: geometry_mod.f:129
double precision, parameter zero
Definition: param1_mod.f:27
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)
double precision, dimension(:,:), allocatable r_gp
Definition: rxns_mod.f:24
double precision, dimension(:), allocatable c_pg
Definition: physprop_mod.f:80