File: N:\mfix\model\set_ro_s.f

1     !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2     !                                                                      !
3     !  Subroutine: SET_RO_s                                                !
4     !                                                                      !
5     !  Author: J.Musser                                   Date: 09-Oct-13  !
6     !  Reviewer:                                                           !
7     !                                                                      !
8     !  Purpose: Initialize solids densities.                               !
9     !                                                                      !
10     !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
11           SUBROUTINE SET_RO_S
12     
13     ! Global Variables:
14     !---------------------------------------------------------------------/
15     ! Number of solids phases.
16           use physprop, only: MMAX
17     ! Solids density field variable.
18           use fldvar, only: RO_s, ROP_s
19     ! Solid phase species mass fractions.
20           use fldvar, only: X_s
21     ! Initial mass fraction of inert species
22           use physprop, only: X_S0
23     ! Index of inert solids phase species.
24           use physprop, only: INERT_SPECIES
25     ! Inert solids phase species mass fraction in dilute region.
26           use physprop, only: DIL_INERT_X_VSD
27     ! Factor to define dilute region where DIL_INERT_X_VSD is used
28           use physprop, only: DIL_FACTOR_VSD
29     ! Run-time flag for variable soilds density
30           use run, only: SOLVE_ROs
31     ! Constant solids density.
32           use physprop, only: RO_s0
33     ! Minimum solids volume fraction
34           use toleranc, only: DIL_EP_s
35     
36     ! Function for evaluating solids density.
37           use eos, only: EOSS
38     
39     ! Modules needed to support function.inc
40           use compar
41           use geometry
42           use indices
43           use functions
44     
45           implicit none
46     
47     ! Local Variables:
48     !---------------------------------------------------------------------/
49     ! Solids phase index
50           INTEGER :: M
51     ! Fluid cell index
52           INTEGER :: IJK
53     ! Index of the inert solids species.
54           INTEGER :: IIS
55     ! Flag for debugging.
56           LOGICAL, parameter :: dbgMode = .FALSE.
57     
58           DOUBLE PRECISION :: minROPs
59     
60     ! Loop over all solids
61           DO M=1,MMAX
62     
63     ! Variable solids density.
64              IF (SOLVE_ROs(M)) THEN
65     ! Set the index of the intert phase.
66                 IIS = INERT_SPECIES(M)
67     ! Calculate the minimum solids denisty.
68     !            minROPs = RO_s0(M)*DIL_EP_s
69                 minROPs = RO_s0(M)*(DIL_FACTOR_VSD*DIL_EP_s)
70     ! Debug/Development option.
71                 IF(dbgMode) CALL CHECK_SET_ROs()
72     
73     ! Calculate Ro_s in all fluid and flow boundary cells.
74                 DO IJK = ijkStart3, ijkEnd3
75                    IF(WALL_AT(IJK)) CYCLE
76                    IF(ROP_s(IJK,M) > minROPs) THEN
77                       RO_S(IJK,M) = EOSS(RO_s0(M), X_s0(M,IIS),         &
78                          X_s(IJK,M,IIS))
79                    ELSE
80     !                  RO_s(IJK,M) = RO_s0(M)
81                       RO_S(IJK,M) = EOSS(RO_s0(M), X_s0(M,IIS),            &
82                          DIL_INERT_X_VSD(M))
83                    ENDIF
84                 ENDDO
85              ELSE
86     ! Constant solids density.
87                 DO IJK = ijkstart3, ijkend3
88                    IF (WALL_AT(IJK)) CYCLE
89                    RO_S(IJK,M) = RO_S0(M)
90                 ENDDO
91              ENDIF
92           ENDDO
93     
94           RETURN
95     
96           CONTAINS
97     
98     !``````````````````````````````````````````````````````````````````````!
99     !  Subroutine: CHECK_SET_ROs                                           !
100     !  Author: J.Musser                                   Date: 21-JAN-92  !
101     !                                                                      !
102     !  Purpose: Verify that all the variable solids density information is !
103     !           present for solids phase M.                                !
104     !                                                                      !
105     !           Note: The check_data routines should have caught any       !
106     !           problematic IC/BC specifications. This is included mainly  !
107     !           for development efforts.                                   !
108     !``````````````````````````````````````````````````````````````````````!
109           SUBROUTINE CHECK_SET_ROs()
110     
111           use exit, only: mfix_exit
112     ! Flag for who writes
113           use funits, only: DMP_LOG
114     ! Solids species mass fractions.
115           use fldvar, only: X_s
116     
117           use param1, only: zero
118     ! Number of phase species.
119           use physprop, only: NMAX
120     ! Index of inert species.
121           use physprop, only: INERT_SPECIES
122     
123           use toleranc
124     
125           implicit none
126     
127     ! Sum of solids phase mass fractions.
128           DOUBLE PRECISION :: SUM_Xs
129     ! Index of inert solids phase species.
130           INTEGER :: INERT
131     ! Integer Error Flag.
132           INTEGER :: IER(2)
133     
134     ! Error file log.
135           INTEGER, parameter :: lUnit = 8454
136           LOGICAL :: lExists
137           CHARACTER(LEN=64) :: lFName
138     
139     ! Initialize error flags.
140           IER = 0
141     
142     ! Set the inert species index.
143           INERT = INERT_SPECIES(M)
144     
145     ! Check all computational cells.
146           DO IJK = ijkStart3, ijkEnd3
147     ! Skip walls.
148              IF (WALL_AT(IJK)) CYCLE
149     ! Calculate the solids species mass fraction sum.
150              SUM_Xs = sum(X_s(IJK,M,:NMAX(M)))
151     ! Verify that the species mass fractions are specified and valid.
152              IF(.NOT.compare(ONE,SUM_Xs)) IER(1) = IER(1)+1
153     ! Verify that the inert species mass fraction is greater than zero.
154              IF(X_s(IJK,M,INERT) <= ZERO) IER(2) = IER(2)+1
155     
156           ENDDO
157     
158     ! An error was detected. Open a log file.
159           IF(sum(IER) /= 0) THEN
160              lFName=''
161              IF(numPEs == 1) THEN
162                 WRITE(lFName,"('setROs.log')")
163              ELSE
164                 WRITE(lFName,"('setROs_',I6.6,'.log')") myPE
165              ENDIF
166              inquire(file=trim(lFName),exist=lExists)
167              IF(lExists) THEN
168                 OPEN(CONVERT='BIG_ENDIAN',unit=lUnit,file=trim(lFName),status='replace')
169              ELSE
170                 OPEN(CONVERT='BIG_ENDIAN',unit=lUnit,file=trim(lFName),status='new')
171              ENDIF
172           ENDIF
173     
174     
175     ! An error was detected in species mass fraction sum.
176           IF(IER(1) /= 0)THEN
177              WRITE(lUnit,1100) myPE
178     ! Skip walls.
179              DO IJK = ijkStart3, ijkEnd3
180                 IF (WALL_AT(IJK)) CYCLE
181     ! Calculate the solids species mass fraction sum.
182                 SUM_Xs = sum(X_s(IJK,M,:NMAX(M)))
183     ! Verify that the species mass fractions are specified and valid.
184                 IF(.NOT.compare(ONE,SUM_Xs)) WRITE(lUnit,1101) IJK, SUM_Xs
185              ENDDO
186              WRITE(lUnit,9999)
187           ENDIF
188     
189     ! An error was detected in inert species mass fraction.
190           IF(IER(2) /= 0)THEN
191              WRITE(lUnit,1200) myPE
192              WRITE(lUnit,1201) M
193              WRITE(lUnit,1202) INERT
194     ! Skip walls.
195              DO IJK = ijkStart3, ijkEnd3
196                 IF (WALL_AT(IJK)) CYCLE
197     ! Calculate the solids species mass fraction sum.
198     ! Verify that the species mass fractions are specified and valid.
199                 IF(X_s(IJK,M,INERT) <= ZERO) WRITE(lUnit,1203)             &
200                    IJK, X_s(IJK,M,INERT)
201              ENDDO
202              WRITE(lUnit,9999)
203           ENDIF
204     
205     ! Close the file, cleanup, and exit.
206           IF(sum(IER) /= 0) THEN
207              CLOSE(lUnit)
208              IF(DMP_LOG) THEN
209              ENDIF
210              CALL MFIX_EXIT(myPE)
211           ENDIF
212     
213     
214           RETURN
215     
216      1100 FORMAT(//1X,70('*')/' From: CHECK_SET_ROs',/,' Error 1100:',     &
217              ' One or more fluid cells contain invalid species mass',/     &
218              ' fractions which do NOT sum to one.'/,'   > myPE = ',I6)
219     
220      1101 FORMAT('   > sum(X_s(',I6,')) = ',g12.5)
221     
222      1200 FORMAT(//1X,70('*')/' From: CHECK_SET_ROs',/,' Error 1200:',     &
223              ' One or more fluid cells contain an invalid species mass',/  &
224              ' fraction for the inert material.'/,'   > myPE = ',I6)
225     
226      1201 FORMAT('   > Solid Phase: ',I2)
227     
228      1202 FORMAT('   > Inert species index: ',I4)
229     
230      1203 FORMAT('   > X_s(',I6,',INERT) = ',g12.5)
231     
232      9999 FORMAT(1x,70('*')/)
233     
234           END SUBROUTINE CHECK_SET_ROs
235     
236           END SUBROUTINE SET_RO_S
237