Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_SetDependentVars.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 dependent 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:
37 ! 1. Restricted to perfect gas.
38 !
39 ! ******************************************************************************
40 !
41 ! $Id: RFLU_SetDependentVars.F90,v 1.11 2008/12/06 08:44:13 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2004-2006 by the University of Illinois
44 !
45 ! ******************************************************************************
46 
47 SUBROUTINE rflu_setdependentvars(pRegion,icgBeg,icgEnd)
48 
49  USE moddatatypes
50  USE modparameters
51  USE moderror
52  USE modglobal, ONLY: t_global
53  USE moddatastruct, ONLY: t_region
54  USE modgrid, ONLY: t_grid
55 
56 #ifdef SPEC
57  USE modspecies, ONLY: t_spec_type
58 #endif
59 
60  USE modinterfaces, ONLY: mixtgasliq_c, &
61  mixtgasliq_p, &
62  mixtliq_c2_bp, &
66  mixtperf_cv_cpr, &
68  mixtperf_g_cpr, &
70  mixtperf_r_m, &
73 
74  IMPLICIT NONE
75 
76 ! ******************************************************************************
77 ! Definitions and declarations
78 ! ******************************************************************************
79 
80 ! ==============================================================================
81 ! Arguments
82 ! ==============================================================================
83 
84  INTEGER, INTENT(IN) :: icgbeg,icgend
85  TYPE(t_region), POINTER :: pregion
86 
87 ! ==============================================================================
88 ! Locals
89 ! ==============================================================================
90 
91  CHARACTER(CHRLEN) :: rcsidentstring
92  INTEGER :: icg,indcp,indmol
93  REAL(RFREAL) :: eo,g,gc,ir,r,rg,term,vm2
94  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv,pgv
95  TYPE(t_global), POINTER :: global
96 
97 #ifdef SPEC
98  INTEGER :: ispec
99  REAL(RFREAL) :: bg2,bl2,bp,bt,bv2,cg2,cl2,cpg,cpm,cv2,cvg,cvl,cvm,cvv, &
100  gcg,gcm,gcv,gm,immg,mmg,mmm,phip,po,rl,ro,rv,ryg,ryi,ryl, &
101  ryv,to,vfg,vfl,vfv,yg
102  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcvspec
103  TYPE(t_spec_type), POINTER :: pspectype
104 #endif
105 
106 ! ******************************************************************************
107 ! Start
108 ! ******************************************************************************
109 
110  rcsidentstring = '$RCSfile: RFLU_SetDependentVars.F90,v $ $Revision: 1.11 $'
111 
112  global => pregion%global
113 
114  CALL registerfunction(global,'RFLU_SetDependentVars',&
115  'RFLU_SetDependentVars.F90')
116 
117 ! ******************************************************************************
118 ! Set variables and pointers
119 ! ******************************************************************************
120 
121  pcv => pregion%mixt%cv
122  pdv => pregion%mixt%dv
123  pgv => pregion%mixt%gv
124 
125 #ifdef SPEC
126  pcvspec => pregion%spec%cv
127 #endif
128 
129  indcp = pregion%mixtInput%indCp
130  indmol = pregion%mixtInput%indMol
131 
132 ! ******************************************************************************
133 ! Compute dependent variables
134 ! ******************************************************************************
135 
136  SELECT CASE ( pregion%mixtInput%fluidModel )
137 
138 ! ==============================================================================
139 ! Incompressible fluid model
140 ! ==============================================================================
141 
142  CASE ( fluid_model_incomp )
143 
144 ! ==============================================================================
145 ! Compressible fluid model. NOTE check state of solution vector.
146 ! ==============================================================================
147 
148  CASE ( fluid_model_comp )
149  SELECT CASE ( pregion%mixtInput%gasModel )
150 
151 ! ------------------------------------------------------------------------------
152 ! Thermally and calorically perfect gas (single species)
153 ! ------------------------------------------------------------------------------
154 
155  CASE ( gas_model_tcperf )
156  IF ( pregion%mixt%cvState /= cv_mixt_state_cons ) THEN
157  CALL errorstop(global,err_cv_state_invalid,__line__)
158  END IF ! pRegion%mixt%cvState
159 
160  DO icg = icgbeg,icgend
161  gc = mixtperf_r_m(pgv(gv_mixt_mol,icg*indmol))
162  g = mixtperf_g_cpr(pgv(gv_mixt_cp,icg*indcp),gc)
163 
164  r = pcv(cv_mixt_dens,icg)
165  ir = 1.0_rfreal/r
166  eo = ir*pcv(cv_mixt_ener,icg)
167 
168  vm2 = ir*ir*(pcv(cv_mixt_xmom,icg)*pcv(cv_mixt_xmom,icg) + &
169  pcv(cv_mixt_ymom,icg)*pcv(cv_mixt_ymom,icg) + &
170  pcv(cv_mixt_zmom,icg)*pcv(cv_mixt_zmom,icg))
171 
172  pdv(dv_mixt_pres,icg) = mixtperf_p_deogvm2(r,eo,g,vm2)
173  pdv(dv_mixt_temp,icg) = mixtperf_t_dpr(r,pdv(dv_mixt_pres,icg),gc)
174  pdv(dv_mixt_soun,icg) = mixtperf_c_grt(g,gc, &
175  pdv(dv_mixt_temp,icg))
176  END DO ! icg
177 
178 ! ------------------------------------------------------------------------------
179 ! Mixture of thermally and calorically perfect gases
180 ! ------------------------------------------------------------------------------
181 
182  CASE ( gas_model_mixt_tcperf )
183  IF ( pregion%mixt%cvState /= cv_mixt_state_cons ) THEN
184  CALL errorstop(global,err_cv_state_invalid,__line__)
185  END IF ! pRegion%mixt%cvState
186 
187  DO icg = icgbeg,icgend
188  gc = mixtperf_r_m(pgv(gv_mixt_mol,icg))
189  g = mixtperf_g_cpr(pgv(gv_mixt_cp,icg),gc)
190 
191  r = pcv(cv_mixt_dens,icg)
192  ir = 1.0_rfreal/r
193  eo = ir*pcv(cv_mixt_ener,icg)
194 
195  vm2 = ir*ir*(pcv(cv_mixt_xmom,icg)*pcv(cv_mixt_xmom,icg) + &
196  pcv(cv_mixt_ymom,icg)*pcv(cv_mixt_ymom,icg) + &
197  pcv(cv_mixt_zmom,icg)*pcv(cv_mixt_zmom,icg))
198 
199  pdv(dv_mixt_pres,icg) = mixtperf_p_deogvm2(r,eo,g,vm2)
200  pdv(dv_mixt_temp,icg) = mixtperf_t_dpr(r,pdv(dv_mixt_pres,icg),gc)
201  pdv(dv_mixt_soun,icg) = mixtperf_c_grt(g,gc, &
202  pdv(dv_mixt_temp,icg))
203  END DO ! icg
204 
205 ! ------------------------------------------------------------------------------
206 ! Pseudogas
207 ! ------------------------------------------------------------------------------
208 
209  CASE ( gas_model_mixt_pseudo )
210 #ifdef SPEC
211  IF ( pregion%mixt%cvState /= cv_mixt_state_cons ) THEN
212  CALL errorstop(global,err_cv_state_invalid,__line__)
213  END IF ! pRegion%mixt%cvState
214 
215  DO icg = icgbeg,icgend
216  mmm = pgv(gv_mixt_mol,icg)
217  cpm = pgv(gv_mixt_cp ,icg)
218  gcm = mixtperf_r_m(mmm)
219  gm = mixtperf_g_cpr(cpm,gcm)
220 
221  r = pcv(cv_mixt_dens,icg)
222  ir = 1.0_rfreal/r
223  eo = ir*pcv(cv_mixt_ener,icg)
224 
225  cpg = 0.0_rfreal
226  yg = 0.0_rfreal
227  phip = 0.0_rfreal
228 
229  DO ispec = 1,pregion%specInput%nSpecies
230  pspectype => pregion%specInput%specType(ispec)
231 
232  ryi = pcvspec(ispec,icg)
233 
234  IF ( pspectype%discreteFlag .EQV. .true. ) THEN
235  phip = phip + ryi/pspectype%pMaterial%dens
236  ELSE
237  cpg = cpg + ir*ryi*pspectype%pMaterial%spht
238  yg = yg + ir*ryi
239  END IF ! pSpecType%discreteFlag
240  END DO ! iSpec
241 
242  cpg = cpg/yg
243 
244  vm2 = ir*ir*(pcv(cv_mixt_xmom,icg)*pcv(cv_mixt_xmom,icg) + &
245  pcv(cv_mixt_ymom,icg)*pcv(cv_mixt_ymom,icg) + &
246  pcv(cv_mixt_zmom,icg)*pcv(cv_mixt_zmom,icg))
247 
248  term = mixtperf_p_deogvm2(r,eo,gm,vm2)
249  pdv(dv_mixt_pres,icg) = cpm/cpg*term/(1.0_rfreal-phip)
250 
251  term = mixtperf_t_dpr(r,pdv(dv_mixt_pres,icg),gcm)
252  pdv(dv_mixt_temp,icg) = term*(1.0_rfreal-phip)
253 
254  term = mixtperf_c_grt(gm,gcm,pdv(dv_mixt_temp,icg))
255  pdv(dv_mixt_soun,icg) = term/(1.0_rfreal-phip)
256  END DO ! icg
257 #else
258  CALL errorstop(global,err_reached_default,__line__) ! Defensive coding
259 #endif
260 
261 ! ------------------------------------------------------------------------------
262 ! Mixture of gas, liquid, and vapor
263 ! ------------------------------------------------------------------------------
264 
265  CASE ( gas_model_mixt_gasliq )
266 #ifdef SPEC
267  IF ( pregion%mixt%cvState /= cv_mixt_state_cons ) THEN
268  CALL errorstop(global,err_cv_state_invalid,__line__)
269  END IF ! pRegion%mixt%cvState
270 
271  ro = global%refDensityLiq
272  po = global%refPressLiq
273  to = global%refTempLiq
274  bp = global%refBetaPLiq
275  bt = global%refBetaTLiq
276  cvl = global%refCvLiq
277 
278  gcg = mixtperf_r_m(pregion%specInput%specType(1)%pMaterial%molw)
279  cvg = mixtperf_cv_cpr(pregion%specInput%specType(1)%pMaterial%spht, &
280  gcg)
281 
282  gcv = mixtperf_r_m(pregion%specInput%specType(2)%pMaterial%molw)
283  cvv = mixtperf_cv_cpr(pregion%specInput%specType(2)%pMaterial%spht, &
284  gcv)
285 
286  DO icg = icgbeg,icgend
287  r = pcv(cv_mixt_dens,icg)
288  ir = 1.0_rfreal/r
289  eo = ir*pcv(cv_mixt_ener,icg)
290 
291  ryg = r*pcvspec(1,icg)
292  ryv = r*pcvspec(2,icg)
293  ryl = r - ryg - ryv
294 
295  vm2 = ir*ir*(pcv(cv_mixt_xmom,icg)*pcv(cv_mixt_xmom,icg) + &
296  pcv(cv_mixt_ymom,icg)*pcv(cv_mixt_ymom,icg) + &
297  pcv(cv_mixt_zmom,icg)*pcv(cv_mixt_zmom,icg))
298  cvm = (ryl*cvl + ryv*cvv + ryg*cvg)/r
299 
300  pdv(dv_mixt_temp,icg) = mixtperf_t_cveovm2(cvm,eo,vm2)
301 
302  cl2 = mixtliq_c2_bp(bp)
303  cv2 = mixtperf_c2_grt(1.0_rfreal,gcv,pdv(dv_mixt_temp,icg))
304  cg2 = mixtperf_c2_grt(1.0_rfreal,gcg,pdv(dv_mixt_temp,icg))
305  pdv(dv_mixt_pres,icg) = mixtgasliq_p(ryl,ryv,ryg,cl2,cv2,cg2,r, &
306  ro,po,to,bp,bt, &
307  pdv(dv_mixt_temp,icg))
308 
309  rl = mixtliq_d_dobpppobttto(ro,bp,bt,pdv(dv_mixt_pres,icg),po, &
310  pdv(dv_mixt_temp,icg),to)
311  rv = mixtperf_d_prt(pdv(dv_mixt_pres,icg),gcv, &
312  pdv(dv_mixt_temp,icg))
313  rg = mixtperf_d_prt(pdv(dv_mixt_pres,icg),gcg, &
314  pdv(dv_mixt_temp,icg))
315 
316  vfg = ryg/rg
317  vfv = ryv/rv
318  vfl = ryl/rl
319 
320  bl2 = -bt/bp
321  bv2 = rv*gcv
322  bg2 = rg*gcg
323 
324  pdv(dv_mixt_soun,icg) = mixtgasliq_c(cvm,r,pdv(dv_mixt_pres,icg), &
325  rl,rv,rg,vfl,vfv,vfg,cl2, &
326  cv2,cg2,bl2,bv2,bg2)
327  END DO ! icg
328 #else
329  CALL errorstop(global,err_reached_default,__line__) ! Defensive coding
330 #endif
331 
332 ! ------------------------------------------------------------------------------
333 ! Default
334 ! ------------------------------------------------------------------------------
335 
336  CASE default
337  CALL errorstop(global,err_reached_default,__line__)
338  END SELECT ! pRegion%mixtInput%gasModel
339 
340 ! ==============================================================================
341 ! Default
342 ! ==============================================================================
343 
344  CASE default
345  CALL errorstop(global,err_reached_default,__line__)
346  END SELECT ! pRegion%mixtInput%fluidModel
347 
348 ! ******************************************************************************
349 ! End
350 ! ******************************************************************************
351 
352  CALL deregisterfunction(global)
353 
354 END SUBROUTINE rflu_setdependentvars
355 
356 ! ******************************************************************************
357 !
358 ! RCS Revision history:
359 !
360 ! $Log: RFLU_SetDependentVars.F90,v $
361 ! Revision 1.11 2008/12/06 08:44:13 mtcampbe
362 ! Updated license.
363 !
364 ! Revision 1.10 2008/11/19 22:17:26 mtcampbe
365 ! Added Illinois Open Source License/Copyright
366 !
367 ! Revision 1.9 2006/08/16 19:16:39 haselbac
368 ! Bug fix: bad check-in, declarations missing
369 !
370 ! Revision 1.8 2006/08/15 15:23:19 haselbac
371 ! Bug fix: dv was computed incorrectly for pseudo-gas
372 !
373 ! Revision 1.7 2006/04/07 15:19:16 haselbac
374 ! Removed tabs
375 !
376 ! Revision 1.6 2006/03/26 20:21:40 haselbac
377 ! Added support for GL model
378 !
379 ! Revision 1.5 2005/11/14 16:55:17 haselbac
380 ! Added support for pseudo-gas model
381 !
382 ! Revision 1.4 2005/11/10 02:14:49 haselbac
383 ! Added SELECT CASE on gasModel
384 !
385 ! Revision 1.3 2005/04/15 15:06:20 haselbac
386 ! Added range arguments, removed pGrid declaration
387 !
388 ! Revision 1.2 2004/11/14 19:41:20 haselbac
389 ! Added setting of dv for incompressible fluid model
390 !
391 ! Revision 1.1 2004/10/19 19:23:53 haselbac
392 ! Initial revision
393 !
394 ! ******************************************************************************
395 
396 
397 
398 
399 
400 
401 
unsigned char r() const
Definition: Color.h:68
real(rfreal) function mixtperf_p_deogvm2(D, Eo, G, Vm2)
Definition: MixtPerf_P.F90:39
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
subroutine rflu_setdependentvars(pRegion, icgBeg, icgEnd)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
real(rfreal) function mixtperf_d_prt(P, R, T)
Definition: MixtPerf_D.F90:71
real(rfreal) function mixtgasliq_p(DYl, DYv, DYg, Cl2, Cv2, Cg2, D, Dz, Po, To, Bp, Bt, T)
real(rfreal) function mixtperf_c2_grt(G, R, T)
Definition: MixtPerf_C.F90:101
real(rfreal) function mixtliq_c2_bp(Bp)
Definition: MixtLiq_C.F90:54
real(rfreal) function mixtperf_t_dpr(D, P, R)
Definition: MixtPerf_T.F90:85
real(rfreal) function mixtliq_d_dobpppobttto(Dz, Bp, Bt, P, Po, T, To)
Definition: MixtLiq_D.F90:40
real(rfreal) function mixtperf_c_grt(G, R, T)
Definition: MixtPerf_C.F90:86
real(rfreal) function mixtgasliq_c(Cvm, D, P, Dl, Dv, Dg, VFl, VFv, VFg, Cl2, Cv2, Cg2, Bl2, Bv2, Bg2)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
real(rfreal) function mixtperf_t_cveovm2(Cv, Eo, Vm2)
Definition: MixtPerf_T.F90:70
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39
real(rfreal) function mixtperf_cv_cpr(Cp, R)
Definition: MixtPerf_Cv.F90:39
unsigned char g() const
Definition: Color.h:69