MFIX  2016-1
set_ic_dem.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! SUBROUTINE Name: DES_SET_IC !
4 ! !
5 ! Purpose: Assign initial conditions to particles basded upon thier !
6 ! location within the domain. !
7 ! !
8 ! Author: J.Musser Date: 15-Feb-11 !
9 ! !
10 ! Comments: !
11 ! !
12 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
13  SUBROUTINE set_ic_dem
14 
15  use run, only: energy_eq, species_eq
16 
17  use ic
18 
19  use des_thermo, only: des_t_s
20 
21  use derived_types, only: pic
22  use discretelement, only: max_pip
23  use discretelement, only: pinc
24  use discretelement, only: pijk
25 
26  USE des_rxns, only: des_x_s
27 
28  use param1, only: undefined, zero
29 
30  use physprop, only: c_ps0
31  use physprop, only: nmax
32 
33  USE compar
34  use indices
35  use geometry
36 
37  use error_manager
38  use functions
39  use toleranc
40 
41  IMPLICIT NONE
42 
43 ! Dummy indices
44  INTEGER :: ICV
45  INTEGER :: I, J, K, IJK
46  INTEGER :: M, NN
47  INTEGER :: NP
48  INTEGER :: NINDX
49 
50  CALL init_err_msg("SET_IC_DEM")
51 
52  DO icv = 1, dimension_ic
53  IF(.NOT.ic_defined(icv)) cycle
54 
55  DO k = ic_k_b(icv), ic_k_t(icv)
56  DO j = ic_j_s(icv), ic_j_n(icv)
57  DO i = ic_i_w(icv), ic_i_e(icv)
58 
59 ! Set the initial conditions for particles in cells that are
60 ! not dead and that this rank owns.
61  IF (.NOT.is_on_mype_plus2layers(i,j,k)) cycle
62  IF (dead_cell_at(i,j,k)) cycle
63 
64  ijk = funijk(i,j,k)
65 
66 ! Loop through particles in cell IJK.
67  DO nindx = 1,pinc(ijk)
68  np = pic(ijk)%P(nindx)
69 
70 ! Shift the phase index to the absolute phase index.
71  m = pijk(np,5)
72 
73 ! Set the initial particle temperature.
74  IF(energy_eq) THEN
75  des_t_s(np) = ic_t_s(icv,m)
76  ENDIF
77 
78 ! Set the initial species composition.
79  IF((energy_eq .AND. c_ps0(m) == undefined) .OR. &
80  species_eq(m)) THEN
81  des_x_s(np,:) = zero
82  DO nn = 1, nmax(m)
83  des_x_s(np,nn) = ic_x_s(icv,m,nn)
84  ENDDO
85  ENDIF
86  ENDDO
87  ENDDO
88  ENDDO
89  ENDDO
90  ENDDO
91 
92 
93 ! Verify that all particles have a specified temperature and species
94 ! mass fractions that sum to one. These checks are needed as the
95 ! basic checks for IC_T_s and IC_X_s can be skipped if the IC region
96 ! is specified with EPg = 1.
97  DO np = 1, max_pip
98 ! skipping non-existent particles
99  IF(is_nonexistent(np)) cycle
100 ! skipping ghost particles
101  IF(is_ghost(np) .OR. is_entering_ghost(np) .OR. is_exiting_ghost(np)) cycle
102  IF(is_ghost(np)) cycle
103 
104  m = pijk(np,5)
105 
106 ! Check that the temperature is specified.
107  IF(energy_eq) THEN
108  IF(des_t_s(np) == zero) THEN
109  WRITE(err_msg, 2000) trim(ival(np)), trim(ival(m))
110  CALL flush_err_msg(abort=.true.)
111  ENDIF
112  ENDIF
113 
114  2000 FORMAT('Error 2000: Particle ',a,' does not have a specified ', &
115  'initial',/'temperature. Verify that the IC region ', &
116  'containing this particle',/'has a solids temperature ', &
117  'defined: IC_T_s(ICV,',a,').')
118 
119 ! Check that the species mass fractions are specified.
120  IF((energy_eq .AND. c_ps0(m) == undefined) .OR. &
121  species_eq(m)) THEN
122  IF(.NOT.compare(sum(des_x_s(np,1:nmax(m))),one)) THEN
123  WRITE(err_msg, 2001) trim(ival(np)), trim(ival(m))
124  CALL flush_err_msg(abort=.true.)
125  ENDIF
126  ENDIF
127 
128  2001 FORMAT('Error 2001: The initial species mass fraction for ', &
129  'particle ',a,/'does not sum to one. Verify that the IC ', &
130  'region containing this particle',/'has the solids species ', &
131  'mass fractions defined: IC_X_s(ICV,',a,',:).')
132 
133  ENDDO
134 
135  CALL finl_err_msg
136 
137  RETURN
138  END SUBROUTINE set_ic_dem
double precision, dimension(dim_m) c_ps0
Definition: physprop_mod.f:83
subroutine finl_err_msg
logical function compare(V1, V2)
Definition: toleranc_mod.f:94
integer, dimension(dimension_ic) ic_j_s
Definition: ic_mod.f:47
double precision, dimension(:), allocatable des_t_s
logical, dimension(0:dim_m) species_eq
Definition: run_mod.f:115
integer, dimension(dimension_ic) ic_j_n
Definition: ic_mod.f:50
logical, dimension(dimension_ic) ic_defined
Definition: ic_mod.f:107
double precision, parameter undefined
Definition: param1_mod.f:18
subroutine init_err_msg(CALLER)
Definition: ic_mod.f:9
integer, dimension(dimension_ic) ic_i_w
Definition: ic_mod.f:41
logical, dimension(:,:,:), allocatable dead_cell_at
Definition: compar_mod.f:127
integer, dimension(dimension_ic) ic_i_e
Definition: ic_mod.f:44
integer, dimension(dimension_ic) ic_k_b
Definition: ic_mod.f:53
subroutine set_ic_dem
Definition: set_ic_dem.f:14
double precision, dimension(:,:), allocatable des_x_s
Definition: des_rxns_mod.f:21
double precision, dimension(dimension_ic, dim_m, dim_n_s) ic_x_s
Definition: ic_mod.f:113
Definition: run_mod.f:13
integer, dimension(dimension_ic) ic_k_t
Definition: ic_mod.f:56
integer, dimension(0:dim_m) nmax
Definition: physprop_mod.f:119
logical energy_eq
Definition: run_mod.f:100
character(len=line_length), dimension(line_count) err_msg
type(iap1), dimension(:), allocatable pic
double precision, dimension(dimension_ic, dim_m) ic_t_s
Definition: ic_mod.f:83
double precision, parameter zero
Definition: param1_mod.f:27
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)