Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_SetGasVars.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 ! ******************************************************************************
24 !
25 ! Purpose: Set gas variables.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to region
31 ! icgBeg Beginning cell index
32 ! icgEnd Ending cell index
33 !
34 ! Output: None.
35 !
36 ! Notes: None.
37 !
38 ! ******************************************************************************
39 !
40 ! $Id: RFLU_SetGasVars.F90,v 1.10 2008/12/06 08:44:13 mtcampbe Exp $
41 !
42 ! Copyright: (c) 2004-2006 by the University of Illinois
43 !
44 ! ******************************************************************************
45 
46 SUBROUTINE rflu_setgasvars(pRegion,icgBeg,icgEnd)
47 
48  USE moddatatypes
49  USE modparameters
50  USE moderror
51  USE modglobal, ONLY: t_global
52  USE moddatastruct, ONLY: t_region
53  USE modgrid, ONLY: t_grid
54 
55 #ifdef SPEC
56  USE modspecies, ONLY: t_spec_type
57 #endif
58 
59  USE modinterfaces, ONLY: mixtperf_m_r, &
62 
63  IMPLICIT NONE
64 
65 ! ******************************************************************************
66 ! Definitions and declarations
67 ! ******************************************************************************
68 
69 ! ==============================================================================
70 ! Arguments
71 ! ==============================================================================
72 
73  INTEGER, INTENT(IN) :: icgbeg,icgend
74  TYPE(t_region), POINTER :: pregion
75 
76 ! ==============================================================================
77 ! Locals
78 ! ==============================================================================
79 
80  CHARACTER(CHRLEN) :: rcsidentstring
81  INTEGER :: icg,indcp,indmol
82  REAL(RFREAL) :: cpgasref,gc,ggas,ggasref
83  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pgv
84  TYPE(t_global), POINTER :: global
85 
86 #ifdef SPEC
87  INTEGER :: ispec
88  REAL(RFREAL) :: cp,gcg,gcm,imm,immg,mmg,phip,r,yg,yi
89  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcvspec
90  TYPE(t_spec_type), POINTER :: pspectype
91 #endif
92 
93 ! ******************************************************************************
94 ! Start
95 ! ******************************************************************************
96 
97  rcsidentstring = '$RCSfile: RFLU_SetGasVars.F90,v $ $Revision: 1.10 $'
98 
99  global => pregion%global
100 
101  CALL registerfunction(global,'RFLU_SetGasVars',&
102  'RFLU_SetGasVars.F90')
103 
104 ! ******************************************************************************
105 ! Set variables and pointers
106 ! ******************************************************************************
107 
108  pcv => pregion%mixt%cv
109  pgv => pregion%mixt%gv
110 
111 #ifdef SPEC
112  pcvspec => pregion%spec%cv
113 #endif
114 
115  indcp = pregion%mixtInput%indCp
116  indmol = pregion%mixtInput%indMol
117 
118  cpgasref = global%refCp
119  ggasref = global%refGamma
120 
121 ! ******************************************************************************
122 ! Compute dependent variables
123 ! ******************************************************************************
124 
125  SELECT CASE ( pregion%mixtInput%fluidModel )
126 
127 ! ==============================================================================
128 ! Incompressible fluid model
129 ! ==============================================================================
130 
131  CASE ( fluid_model_incomp )
132 
133 ! ==============================================================================
134 ! Compressible fluid model
135 ! ==============================================================================
136 
137  CASE ( fluid_model_comp )
138  SELECT CASE ( pregion%mixtInput%gasModel )
139 
140 ! ------------------------------------------------------------------------------
141 ! Thermally and calorically perfect gas
142 ! ------------------------------------------------------------------------------
143 
144  CASE ( gas_model_tcperf )
145  gc = mixtperf_r_cpg(cpgasref,ggasref)
146 
147  DO icg = icgbeg,icgend
148  pgv(gv_mixt_mol,icg*indmol) = mixtperf_m_r(gc)
149  pgv(gv_mixt_cp ,icg*indcp ) = cpgasref
150  END DO ! icg
151 
152 ! ------------------------------------------------------------------------------
153 ! Mixture of thermally and calorically perfect gases
154 ! ------------------------------------------------------------------------------
155 
156  CASE ( gas_model_mixt_tcperf )
157 #ifdef SPEC
158  IF ( pregion%spec%cvState /= cv_mixt_state_prim ) THEN
159  CALL errorstop(global,err_cv_state_invalid,__line__)
160  END IF ! pRegion%spec%cvState
161 
162  DO icg = icgbeg,icgend
163  imm = 0.0_rfreal
164  cp = 0.0_rfreal
165 
166  DO ispec = 1,pregion%specInput%nSpecies
167  pspectype => pregion%specInput%specType(ispec)
168 
169  imm = imm + pcvspec(ispec,icg)/pspectype%pMaterial%molw
170  cp = cp + pcvspec(ispec,icg)*pspectype%pMaterial%spht
171  END DO ! iSpec
172 
173  pgv(gv_mixt_mol,icg) = 1.0_rfreal/imm
174  pgv(gv_mixt_cp ,icg) = cp
175  END DO ! icg
176 #else
177  CALL errorstop(global,err_reached_default,__line__) ! Defensive coding
178 #endif
179 
180 ! ------------------------------------------------------------------------------
181 ! Mixture of thermally and calorically perfect gaseous species and
182 ! particulate species, treated as pseudo-gas
183 ! ------------------------------------------------------------------------------
184 
185  CASE ( gas_model_mixt_pseudo )
186 #ifdef SPEC
187  IF ( pregion%spec%cvState /= cv_mixt_state_prim ) THEN
188  CALL errorstop(global,err_cv_state_invalid,__line__)
189  END IF ! pRegion%spec%cvState
190 
191  DO icg = icgbeg,icgend
192  r = pcv(cv_mixt_dens,icg)
193 
194  immg = 0.0_rfreal
195  cp = 0.0_rfreal
196  yg = 0.0_rfreal
197  phip = 0.0_rfreal
198 
199  DO ispec = 1,pregion%specInput%nSpecies
200  pspectype => pregion%specInput%specType(ispec)
201 
202  yi = pcvspec(ispec,icg)
203 
204  cp = cp + yi*pspectype%pMaterial%spht
205 
206  IF ( pspectype%discreteFlag .EQV. .true. ) THEN
207  phip = phip + r*yi/pspectype%pMaterial%dens
208  ELSE
209  immg = immg + yi/pspectype%pMaterial%molw
210  yg = yg + yi
211  END IF ! pSpecType%discreteFlag
212  END DO ! iSpec
213 
214  mmg = yg/immg
215  gcg = mixtperf_r_m(mmg)
216  gcm = yg*gcg
217 
218  pgv(gv_mixt_mol,icg) = mixtperf_m_r(gcm)
219  pgv(gv_mixt_cp ,icg) = cp
220  END DO ! icg
221 #else
222  CALL errorstop(global,err_reached_default,__line__) ! Defensive coding
223 #endif
224 
225 ! ------------------------------------------------------------------------------
226 ! Gas-liquid mixture fluid model
227 ! ------------------------------------------------------------------------------
228 
229  CASE ( gas_model_mixt_gasliq )
230 #ifdef SPEC
231  IF ( pregion%spec%cvState /= cv_mixt_state_prim ) THEN
232  CALL errorstop(global,err_cv_state_invalid,__line__)
233  END IF ! pRegion%spec%cvState
234 
235  DO icg = icgbeg,icgend
236  pgv(gv_mixt_mol,icg*indmol) = &
237  pregion%specInput%specType(1)%pMaterial%molw
238  pgv(gv_mixt_cp ,icg*indcp ) = &
239  pregion%specInput%specType(1)%pMaterial%spht
240  END DO ! icg
241 
242 #else
243  CALL errorstop(global,err_reached_default,__line__) ! Defensive coding
244 #endif
245 
246 ! ------------------------------------------------------------------------------
247 ! Default
248 ! ------------------------------------------------------------------------------
249 
250  CASE default
251  CALL errorstop(global,err_reached_default,__line__)
252  END SELECT ! pRegion%mixtInput%gasModel
253 
254 ! ==============================================================================
255 ! Default
256 ! ==============================================================================
257 
258  CASE default
259  CALL errorstop(global,err_reached_default,__line__)
260  END SELECT ! pRegion%mixtInput%fluidModel
261 
262 
263 ! ******************************************************************************
264 ! End
265 ! ******************************************************************************
266 
267  CALL deregisterfunction(global)
268 
269 END SUBROUTINE rflu_setgasvars
270 
271 ! ******************************************************************************
272 !
273 ! RCS Revision history:
274 !
275 ! $Log: RFLU_SetGasVars.F90,v $
276 ! Revision 1.10 2008/12/06 08:44:13 mtcampbe
277 ! Updated license.
278 !
279 ! Revision 1.9 2008/11/19 22:17:26 mtcampbe
280 ! Added Illinois Open Source License/Copyright
281 !
282 ! Revision 1.8 2006/08/15 15:23:54 haselbac
283 ! Cosmetic changes only
284 !
285 ! Revision 1.7 2006/04/07 15:19:16 haselbac
286 ! Removed tabs
287 !
288 ! Revision 1.6 2006/03/26 20:21:44 haselbac
289 ! Added support for GL model
290 !
291 ! Revision 1.5 2005/11/14 16:55:17 haselbac
292 ! Added support for pseudo-gas model
293 !
294 ! Revision 1.4 2005/11/10 02:15:33 haselbac
295 ! Added support for different gas models
296 !
297 ! Revision 1.3 2005/04/15 15:06:21 haselbac
298 ! Added range arguments, removed pGrid declaration
299 !
300 ! Revision 1.2 2004/11/14 19:43:09 haselbac
301 ! Added setting of gv for incompressible fluid model
302 !
303 ! Revision 1.1 2004/10/19 19:23:55 haselbac
304 ! Initial revision
305 !
306 ! ******************************************************************************
307 
308 
309 
310 
311 
312 
313 
unsigned char r() const
Definition: Color.h:68
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
real(rfreal) function mixtperf_r_cpg(Cp, G)
Definition: MixtPerf_R.F90:39
real(rfreal) function mixtperf_m_r(R)
Definition: MixtPerf_M.F90:39
subroutine rflu_setgasvars(pRegion, icgBeg, icgEnd)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469