MFIX  2016-1
toleranc_mod.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Module name: tolerance C
4 ! Purpose: Specify all tolerance parameters C
5 ! C
6 ! Author: M. Syamlal Date: 24-JUL-92 C
7 ! C
8 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
9 
10  MODULE toleranc
11 
12  use param1, only: one
13 
14 ! Minimum value of solids volume fraction tracked
15  DOUBLE PRECISION, PARAMETER :: zero_ep_s = 1.0d-8
16 
17 ! Small value for species mass fraction for disregarding residual
18 ! calculation
19  DOUBLE PRECISION, PARAMETER :: zero_x_gs = 1.0d-7
20 
21 ! Dilute flow threshold. When the volume fraction of a certain phase
22 ! in a cell is smaller than this value the momentum equation for that
23 ! phase is not solved in the cell.
24  DOUBLE PRECISION, PARAMETER :: dil_ep_s = 1.0d-4
25 
26 ! Tolerance used for comparing two numbers for equality in function
27 ! compare(a, b)
28  DOUBLE PRECISION, PARAMETER :: tol_com = 1.0d-4
29 
30 ! Upper bound for temperatures
31  DOUBLE PRECISION, PARAMETER :: tmax = 4000.d0
32 
33 ! Lower bound for temperatures
34  DOUBLE PRECISION, PARAMETER :: tmin = 250.d0
35 
36 ! Reciprocal of a maximum molecular weight
37  DOUBLE PRECISION, PARAMETER :: omw_max = (one/500.d0)
38 
39 ! Maximum value of velocities set to avoid divergence problems.
40  DOUBLE PRECISION :: max_inlet_vel
41 
42 ! User definable factor used to scale MAX_INLET_VEL. Default value is 1.
43  DOUBLE PRECISION :: max_inlet_vel_fac
44 
45 ! Maximum allowed velocity of gas or solids in case no inlet velocities
46 ! (or zero velocities) are defined at inlet (see function
47 ! check_vel_bound)
48  DOUBLE PRECISION, PARAMETER :: max_allowed_vel = 500.0d+2
49 
50 ! The following quantities can be specified through the input data
51 ! file, with namelist inputs of the same name.
52 ! ------------------------------------------------------------------->>
53 ! Tolerance in residuals allowed for convergence
54  DOUBLE PRECISION :: tol_resid
55 
56 ! Tolerance in energy eq residuals allowed for convergence
57  DOUBLE PRECISION :: tol_resid_t
58 
59 ! Tolerance in species eq residuals allowed for convergence
60  DOUBLE PRECISION :: tol_resid_x
61 
62 ! Tolerance in scalr eq residuals allowed for convergence
63  DOUBLE PRECISION :: tol_resid_scalar
64 
65 ! Tolerance in K & Epsilon eq residuals allowed for convergence
66  DOUBLE PRECISION :: tol_resid_k_epsilon
67 
68 ! Tolerance in Granular Temperature eq residuals allowed for convergence
69  DOUBLE PRECISION :: tol_resid_th
70 
71 ! Minimum residual for declaring divergence
72  DOUBLE PRECISION :: tol_diverge
73 
74 ! Factor for normalizing the residual of gas cont. eq.
75  DOUBLE PRECISION :: norm_g
76 
77 ! Factor for normalizing the residual of solids cont. eq.
78  DOUBLE PRECISION :: norm_s
79 ! -------------------------------------------------------------------<<
80 
81 ! Detect negative Rho_g in physical_prop to reduce DT in iterate
82  LOGICAL :: neg_rho_g = .false.
83 
84  CONTAINS
85 
86 
87 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
88 ! !
89 ! Purpose: Test if two small values are nearly equal !
90 ! !
91 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
92 
93  LOGICAL FUNCTION compare (V1, V2)
94 
95  use param1, only: small_number, one
96  IMPLICIT NONE
97 
98 ! Dummy arguments
99 ! -------------------------------------------------------------------//
100 ! Values to be compared
101  DOUBLE PRECISION, INTENT(IN) :: V1, V2
102 
103  IF (abs(v1) <= small_number) THEN
104  IF (abs(v2) <= small_number) THEN
105  compare = .true.
106  ELSE
107  compare = .false.
108  ENDIF
109  ELSE
110  IF (abs(v2/v1 - one) <= tol_com) THEN
111  compare = .true.
112  ELSE
113  compare = .false.
114  ENDIF
115  ENDIF
116  RETURN
117  END FUNCTION compare
118 
119 
120 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
121 ! !
122 ! Purpose: Test if given variable is smaller than specified tolerance !
123 ! !
124 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
125 
126  LOGICAL FUNCTION is_small (V, TOL)
128  use compar, only: ijkstart3, ijkend3
129  use functions, only: fluid_at
130  use param, only: dimension_3
131  IMPLICIT NONE
132 
133 ! Dummy arguments
134 !--------------------------------------------------------------------//
135 ! Tolerance value for small
136  DOUBLE PRECISION, INTENT(IN) :: TOL
137 ! Field variable array
138  DOUBLE PRECISION, INTENT(IN), DIMENSION(DIMENSION_3) :: V
139 
140 ! Local variables
141 !--------------------------------------------------------------------//
142  INTEGER :: IJK
143 
144  is_small = .false.
145  DO ijk = ijkstart3, ijkend3
146  IF (fluid_at(ijk)) THEN
147  IF (abs(v(ijk)) > tol) RETURN
148  ENDIF
149  END DO
150  is_small = .true.
151 
152  RETURN
153  END FUNCTION is_small
154 
155  END MODULE toleranc
double precision norm_s
Definition: toleranc_mod.f:78
logical function is_small(V, TOL)
Definition: toleranc_mod.f:127
double precision, parameter tmax
Definition: toleranc_mod.f:31
integer ijkend3
Definition: compar_mod.f:80
logical function compare(V1, V2)
Definition: toleranc_mod.f:94
double precision, parameter one
Definition: param1_mod.f:29
integer dimension_3
Definition: param_mod.f:11
double precision, parameter omw_max
Definition: toleranc_mod.f:37
double precision tol_resid_t
Definition: toleranc_mod.f:57
double precision tol_resid_scalar
Definition: toleranc_mod.f:63
double precision max_inlet_vel
Definition: toleranc_mod.f:40
double precision, parameter max_allowed_vel
Definition: toleranc_mod.f:48
double precision tol_resid_k_epsilon
Definition: toleranc_mod.f:66
logical neg_rho_g
Definition: toleranc_mod.f:82
double precision, parameter tmin
Definition: toleranc_mod.f:34
double precision, parameter tol_com
Definition: toleranc_mod.f:28
double precision, parameter small_number
Definition: param1_mod.f:24
double precision tol_resid_th
Definition: toleranc_mod.f:69
double precision, parameter zero_ep_s
Definition: toleranc_mod.f:15
double precision tol_diverge
Definition: toleranc_mod.f:72
Definition: param_mod.f:2
double precision, parameter dil_ep_s
Definition: toleranc_mod.f:24
double precision tol_resid
Definition: toleranc_mod.f:54
integer ijkstart3
Definition: compar_mod.f:80
double precision tol_resid_x
Definition: toleranc_mod.f:60
double precision, parameter zero_x_gs
Definition: toleranc_mod.f:19
double precision max_inlet_vel_fac
Definition: toleranc_mod.f:43
double precision norm_g
Definition: toleranc_mod.f:75