Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BcondInflowPerf.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 inflow boundary condition for one cell.
26 !
27 ! Description: The subsonic boundary condition is based on the extrapolation of
28 ! the Riemann invariant from the interior field (Holmes, D.G.: Inviscid 2D
29 ! Solutions on Unstructured, Adaptive Grids. VKI Lecture Series 1989-06, 1989).
30 ! The supersonic inflow boundary condition computes the conservative variables
31 ! from given velocity components, density and pressure.
32 !
33 ! Input: bcOptType = boundary treatment: subsonic, supersonic, or mixed
34 ! bcOptFixed = whether _computed_ inflow angle should be fixed or not
35 ! ptot = given total pressure
36 ! ttot = given total temperature
37 ! betah = given inlet angle wrp. to y-axis
38 ! betav = given inlet angle wrp. to z-axis
39 ! sx/y/zn = components of normalized face vector (outward facing)
40 ! cpgas = specific heat at constant pressure (boundary cell)
41 ! mm = molecular mass at boundary cell
42 ! rl = given density
43 ! ru/v/wl = given velocity components
44 !
45 ! Output: rr = density at boundary
46 ! ru/v/wr = density * velocity components at boundary
47 ! rer = density * total internal energy at boundary
48 ! pr = pressure at boundary
49 !
50 ! Notes:
51 ! 1. This condition is valid only for thermally and calorically perfect
52 ! gas.
53 ! 2. Important to avoid division by MakeNonZero(sl) when computing eta
54 ! because that computation can become undefined for reservoir inflow
55 ! conditions, i.e., for a vanishing velocity vector.
56 !
57 !******************************************************************************
58 !
59 ! $Id: BcondInflowPerf.F90,v 1.3 2008/12/06 08:44:08 mtcampbe Exp $
60 !
61 ! Copyright: (c) 2002-2004 by the University of Illinois
62 !
63 !******************************************************************************
64 
65 SUBROUTINE bcondinflowperf(bcOptType,bcOptFixed,ptot,ttot,betah,betav,mach, &
66  sxn,syn,szn,cpgas,mm,rl,rul,rvl,rwl,rr,rur,rvr, &
67  rwr,rer,pr)
68 
69  USE moddatatypes
70  USE modparameters
71  USE modtools, ONLY : makenonzero
78 
79  IMPLICIT NONE
80 
81 ! ... parameters
82  INTEGER, INTENT(IN) :: bcoptfixed,bcopttype
83 
84  REAL(RFREAL), INTENT(IN) :: betah, betav, cpgas, mach, mm, sxn, syn, szn, &
85  ptot, rl, rul, rvl, rwl, ttot
86  REAL(RFREAL), INTENT(OUT) :: rer, rr, rur, rvr, rwr, pr
87 
88 ! ... local variables
89  REAL(RFREAL) :: al, ar, a02, cp, disc, eta, g, gm1, igm1, ql, rgas, rm, &
90  sl, sr , tr, ul, ur, vl, vr, wl, wr
91 
92 !******************************************************************************
93 ! gas properties
94 
95  rgas = mixtperf_r_m(mm)
96  g = mixtperf_g_cpr(cpgas,rgas)
97 
98 ! subsonic or mixed -----------------------------------------------------------
99 
100  IF ( bcopttype == bcopt_subsonic .OR. bcopttype == bcopt_mixed ) THEN
101  gm1 = g - 1.0_rfreal
102  igm1 = 1.0_rfreal/gm1
103 
104  ul = rul/rl
105  vl = rvl/rl
106  wl = rwl/rl
107 
108  a02 = mixtperf_c2_grt(g,rgas,ttot)
109 
110  al = mixtperf_c_co2guvw(a02,g,ul,vl,wl) ! make al consistent with a02
111  ql = ul*sxn + vl*syn + wl*szn
112 
113 ! - subsonic
114 
115  IF ( abs(ql) < al ) THEN
116  sl = sqrt(ul*ul + vl*vl + wl*wl)
117 
118  IF ( bcoptfixed == bcopt_fixed_no ) THEN
119  IF ( sl > 1.0e-6_rfreal ) THEN ! Avoid ill-defined angle computation
120  eta = ql/sl
121  ELSE
122  eta = -1.0_rfreal
123  END IF ! sl
124  ELSE
125  eta = -1.0_rfreal
126  END IF ! bcOptFixed
127 
128  rm = al - 0.5_rfreal*gm1*ql
129  disc = 0.5_rfreal*gm1*eta**2* &
130  (a02/(rm*rm)*(1.0_rfreal + 0.5_rfreal*gm1*eta**2) - 1.0_rfreal)
131 
132  IF ( disc < 0.0_rfreal ) THEN ! discriminant cannot be negative
133  ar = sqrt(a02)
134  tr = ttot
135  pr = ptot
136  sr = 0.0_rfreal
137  ELSE
138  ar = rm/(1.0_rfreal + 0.5_rfreal*gm1*eta*eta)*(1.0_rfreal+sqrt(disc))
139 
140  tr = mixtperf_t_cgr(ar,g,rgas)
141  pr = mixtperf_p_gpotto(g,ptot,tr,ttot)
142  sr = mixtperf_vm_c2co2g(ar*ar,a02,g)
143  END IF ! disc
144 
145  rr = mixtperf_d_prt( pr,rgas,tr )
146  ur = sr*cos(betah)*cos(betav)
147  vr = sr*sin(betah)
148  wr = sr*cos(betah)*sin(betav)
149 
150  rer = rr*mixtperf_eo_dgpvm(rr,g,pr,sr)
151  rur = rr*ur
152  rvr = rr*vr
153  rwr = rr*wr
154 
155 ! - supersonic
156 
157  ELSE
158  IF ( bcopttype == bcopt_mixed ) THEN
159  pr = mixtperf_p_gmapo(g,mach,ptot)
160  tr = mixtperf_t_gmato(g,mach,ttot)
161  rr = mixtperf_d_prt(pr,rgas,tr)
162  ar = mixtperf_c_grt(g,rgas,tr)
163 
164  ur = mach*ar*cos(betah)*cos(betav)
165  vr = mach*ar*sin(betah)
166  wr = mach*ar*cos(betah)*sin(betav)
167 
168  rer = rr*mixtperf_eo_dgpuvw(rr,g,pr,ur,vr,wr)
169  rur = rr*ur
170  rvr = rr*vr
171  rwr = rr*wr
172  END IF ! bcOptType
173  END IF ! ql < al
174 
175 ! supersonic ------------------------------------------------------------------
176 
177  ELSE ! bcOptType == BCOPT_SUPERSONIC
178  pr = mixtperf_p_gmapo(g,mach,ptot)
179  tr = mixtperf_t_gmato(g,mach,ttot)
180  rr = mixtperf_d_prt(pr,rgas,tr)
181  ar = mixtperf_c_grt(g,rgas,tr)
182 
183  ur = mach*ar*cos(betah)*cos(betav)
184  vr = mach*ar*sin(betah)
185  wr = mach*ar*cos(betah)*sin(betav)
186 
187  rer = rr*mixtperf_eo_dgpuvw(rr,g,pr,ur,vr,wr)
188  rur = rr*ur
189  rvr = rr*vr
190  rwr = rr*wr
191  END IF ! bcOptType
192 
193 END SUBROUTINE bcondinflowperf
194 
195 !******************************************************************************
196 !
197 ! RCS Revision history:
198 !
199 ! $Log: BcondInflowPerf.F90,v $
200 ! Revision 1.3 2008/12/06 08:44:08 mtcampbe
201 ! Updated license.
202 !
203 ! Revision 1.2 2008/11/19 22:17:22 mtcampbe
204 ! Added Illinois Open Source License/Copyright
205 !
206 ! Revision 1.1 2004/12/01 16:47:56 haselbac
207 ! Initial revision after changing case
208 !
209 ! Revision 1.7 2004/01/29 22:52:36 haselbac
210 ! Added bcOptFixed, fixed bug, clean-up
211 !
212 ! Revision 1.6 2003/12/04 03:22:56 haselbac
213 ! Fixed bug in formulation, added partial fix for eta
214 !
215 ! Revision 1.5 2003/11/20 16:40:35 mdbrandy
216 ! Backing out RocfluidMP changes from 11-17-03
217 !
218 ! Revision 1.2 2002/06/22 00:49:50 jblazek
219 ! Modified interfaces to BC routines.
220 !
221 ! Revision 1.1 2002/06/10 21:19:34 haselbac
222 ! Initial revision
223 !
224 !******************************************************************************
225 
226 
227 
228 
229 
230 
real(rfreal) function mixtperf_eo_dgpvm(D, G, P, Vm)
Definition: MixtPerf_E.F90:55
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
real(rfreal) function mixtperf_c_dgp(D, G, P)
Definition: MixtPerf_C.F90:56
real(rfreal) function mixtperf_t_cgr(C, G, R)
Definition: MixtPerf_T.F90:40
real(rfreal) function mixtperf_po_cgpuvw(C, G, P, U, V, W)
Definition: MixtPerf_P.F90:130
real(rfreal) function mixtperf_d_prt(P, R, T)
Definition: MixtPerf_D.F90:71
double sqrt(double d)
Definition: double.h:73
real(rfreal) function mixtperf_vm_c2co2g(C2, Co2, G)
Definition: MixtPerf_Vm.F90:39
real(rfreal) function mixtperf_c_co2guvw(Co2, G, U, V, W)
Definition: MixtPerf_C.F90:40
real(rfreal) function mixtperf_c2_grt(G, R, T)
Definition: MixtPerf_C.F90:101
NT & sin
real(rfreal) function mixtperf_po_gptto(G, P, T, To)
Definition: MixtPerf_P.F90:115
subroutine bcondinflowperf(bcOptType, bcOptFixed, ptot, ttot, betah, betav, mach, sxn, syn, szn, cpgas, mm, rl, rul, rvl, rwl, rr, rur, rvr, rwr, rer, pr)
real(rfreal) function mixtperf_c_grt(G, R, T)
Definition: MixtPerf_C.F90:86
real(rfreal) function mixtperf_t_gmato(G, Ma, To)
Definition: MixtPerf_T.F90:100
real(rfreal) function mixtperf_eo_dgpuvw(D, G, P, U, V, W)
Definition: MixtPerf_E.F90:40
real(rfreal) function mixtperf_co2_cguvw(C, G, U, V, W)
Definition: MixtPerf_C.F90:116
real(rfreal) function mixtperf_p_gpotto(G, Po, T, To)
Definition: MixtPerf_P.F90:100
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39
NT & cos
unsigned char g() const
Definition: Color.h:69
real(rfreal) function makenonzero(x)
Definition: ModTools.F90:85
real(rfreal) function mixtperf_p_gmapo(G, Ma, Po)
Definition: MixtPerf_P.F90:69