Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
update_py.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 MODULE update_py
24  USE data_py
25 
26 CONTAINS
27 
28  SUBROUTINE burn_get_burning_rate1d (bp,delt,P,To,Tn,Qc,Qc_old,Qr,Qr_old, &
29  rhoc,toa,rb,fr,bflag,tnp1,tflame,coor)
30 
31  IMPLICIT NONE
32 
33  include 'mpif.h'
34 !----------------------------------------------------------------------------
35 
36 ! Dummy Variables
37 !
38  TYPE(parameter_structure),POINTER :: bp
39 
40  REAL(DBL),INTENT(IN) :: delt,p,to,rhoc
41  REAL(DBL),INTENT(IN) :: qc,qc_old,qr,qr_old
42  REAL(DBL), INTENT (INOUT) :: toa, rb, fr
43  INTEGER,INTENT(INOUT) :: bflag
44  REAL(DBL),INTENT(OUT) :: tflame
45  REAL(DBL),INTENT(IN) :: tn(:)
46  REAL(DBL),INTENT(OUT) :: tnp1(:)
47  REAL(DBL),INTENT(IN) :: coor(3)
48 !
49 ! Local Variables
50 !
51  INTEGER :: i, nx
52  REAL(DBL) :: rb_old
53  REAL(DBL) :: first,second
54  REAL(DBL) :: add,coe,rhs
55  INTEGER :: ierror
56  TYPE(work_structure) :: bw
57 !------------------------------------------------------------------
58 
59 ! CHECK the input for divergence
60 
61  IF ( .true. .AND. (.NOT. (p > bp%P_range(1) .AND. p < bp%P_range(2)) )) THEN
62  write(*,*)"INPUT PRESSURE OUT OF RANGE",p,bp%P_range
63  CALL mpi_abort(bp%comm, 1, ierror)
64  stop
65  ENDIF
66 !
67 ! convert input variables
68 !
69  bw%P = p*pa2atm
70  bw%rhoc = rhoc*kgmc2gcc
71  bw%Qc = qc*j_msq2cal_cmsq
72  bw%Qcprime = qr*j_msq2cal_cmsq
73  bw%Ts = tn(1)
74  bw%To = to
75  bw%lamc = bw%rhoc * bp%alfac * bp%C
76  nx = bp%numx
77 
78  CALL mfun(bp,bw)
79 
80 !! rb_old = bw%rb
81  rb_old = merge(bw%rb, zero, bw%Ts >= bp%Tignition)
82 
83  DO i=2,nx-1
84 
85  first = (tn(i+1)-tn(i-1))*bp%delz2inv
86  second = (tn(i+1)-2.0d0*tn(i)+tn(i-1))*bp%delzsqinv
87 
88  tnp1(i)=tn(i)+delt*( &
89  (bw%alfa_eff*bp%zxx(i) - rb_old*bp%zx(i)) * first &
90  + bw%alfa_eff*bp%zx(i)**2 * second)
91  ENDDO
92 
93 
94 
95  tnp1(nx)=to
96 
97  bw%ignited = (bw%Ts > bp%Tignition)
98 
99  CALL gfun(bp,bw)
100 
101 ! update suface B.C. for this iteration
102  coe = three + two*bw%fsprime*bp%dx1;
103  rhs = two*bp%dx1*(bw%fs - bw%fsprime*bw%Ts);
104  add = four*tnp1(2) - one*tnp1(3);
105  ! third coe = 11.0d0 + fsprime*6.0*dx1;
106  ! third rhs = 6.0*dx1*(fs - fsprime*Ts)
107  ! third add = 18.0*Tnp1(2)-9.0*Tnp1(3)+2.0*Tnp1(4)
108  bw%Ts=(add-rhs)/coe
109 
110  bw%ignited = (bw%Ts > bp%Tignition)
111  bflag = merge(1,0,bw%ignited)
112  if(bw%ignited) THEN
113  CALL tfun(bp,bw)
114  else
115 !! bw%Tstar = bw%Ts
116  bw%Tstar = bp%Tstar0 !temporary fix, it will have to be changed if NS simulations
117  endif
118 
119  tnp1(1)=bw%Ts
120 
121 ! EVALUATE burning rate
122 
123  CALL mfun(bp,bw)
124  bw%rb = merge(bw%rb, zero, bw%Ts >= bp%Tignition)
125 !
126 ! CONVERT the output back to MKS
127 !
128  rb = bw%rb / m2cm
129  tflame = bw%Tstar
130 
131 !
132 ! CHECK the output for divergence
133 !
134  IF (.true. .AND. (.NOT. (rb > bp%rb_range(1) .AND. rb < bp%rb_range(2)) )) THEN
135  write(*,*)"OUTPUT RB OUT OF RANGE",rb,bp%rb_range
136  do i = 1,nx
137  write(*,*)i,bp%x(i),tnp1(i),tn(i)
138  enddo
139  CALL mpi_abort(bp%comm, 1, ierror)
140  stop
141  ENDIF
142  IF (.true. .AND. (.NOT. (tflame > bp%Tf_range(1) .AND. tflame < bp%Tf_range(2)) )) THEN
143  write(*,*)"OUTPUT TFLAME OUT OF RANGE",tflame,bp%Tf_range,bflag,bw%Ts,p
144  do i = 1,nx
145  write(*,*)i,bp%x(i),tnp1(i),tn(i)
146  enddo
147  CALL mpi_abort(bp%comm, 1, ierror)
148  stop
149  ENDIF
150 
151 
152 !--------------------------------------------------------------------------------
153  RETURN
154  END SUBROUTINE burn_get_burning_rate1d
155 !****************************************************************************
156 
157 
158 !*****************************************************************************
159  SUBROUTINE gfun(bp,bw)
160 
161  IMPLICIT NONE
162 
163 !--------------------------------------------------------------------------------
164 ! Dummy variables:
165  TYPE(parameter_structure),POINTER :: bp
166  TYPE(work_structure), INTENT(INOUT) :: bw
167 
168 ! Local Variables
169  REAL(DBL) :: expterm,invtsq,tstar,tmp1,tmp2,dy !Tstar is not passed back
170  INTEGER :: jj,kk
171 !---------------------------------------------------------------------------------
172 
173  bw%c1 = -log(bp%a_p/bp%Ac*(bw%P/bp%Pref)**bp%n_p)/bp%ec_ru !a_p==capk
174  bw%c2 = one / bp%Tstar0
175  bw%c3 = two * bp%ec_ru / bp%eg_ru
176 
177  IF(bw%ignited) THEN
178 
179  if(bp%TABUSE == 0) then
180  bw%c4 = bp%Tstar0 - bw%To
181  bw%c5 = bp%Ac / bp%alfac
182  bw%c6 = - bp%ec_ru
183 
184  bw%Ts0 = one/bw%c1
185  bw%Tslimit = one/( bw%c1 - bw%c2/bw%c3 ) * 0.99 !99% of blow off temp.
186 
187  invtsq = one / bw%Ts**2
188  expterm = bw%c5 * exp(bw%c6 / bw%Ts)
189  tstar = one/(bw%c2-bw%c3*(bw%c1-one/bw%Ts))
190 
191  if ( bw%Ts > bw%Ts0 .AND. bw%Ts > bw%Tslimit ) tstar = bp%Tstar0
192  bw%fs = expterm * ( bw%c4 + bw%Ts-tstar )
193  bw%fsprime = bw%c6 * bw%fs * invtsq &
194  + expterm * (one - bw%c3 * tstar**2 * invtsq)
195 
196  else
197 
198  jj = 0;kk = 0;
199  call polin2(bp,bp%TABLE%tsurf00,bp%TABLE%press00,bp%TABLE%heatflux00,&
200  bp%TABLE%nx_table,bp%TABLE%ny_table,bw%Ts,bw%p,bw%fs,jj,kk)
201  call polin2(bp,bp%TABLE%tsurf00, bp%TABLE%press00, bp%TABLE%heatflux00,&
202  bp%TABLE%nx_table, bp%TABLE%ny_table, bw%Ts+half*bp%TABLE&
203  %small_1, bw%p, tmp2,jj,kk)
204  call polin2(bp,bp%TABLE%tsurf00, bp%TABLE%press00, bp%TABLE%heatflux00,&
205  bp%TABLE%nx_table, bp%TABLE%ny_table, bw%Ts-half*bp%TABLE&
206  %small_1, bw%p, tmp1,jj,kk)
207  bw%fsprime = (tmp2-tmp1) / bp%TABLE%small_1
208  endif
209 
210  ELSE
211 
212  bw%fs = bw%Qc/bw%lamc
213  bw%fsprime = bw%Qcprime / bw%lamc
214 
215  ENDIF
216 
217 !------------------------------------------------------------------------------------
218  RETURN
219  END SUBROUTINE gfun
220 !*****************************************************************************
221 
222 !*****************************************************************************
223  SUBROUTINE mfun(bp,bw)
224 
225 !--------------------------------------------------------------------------------------
226  IMPLICIT NONE
227 ! Dummy variables:
228  TYPE(parameter_structure),POINTER :: bp
229  TYPE(work_structure), INTENT(INOUT) :: bw
230  INTEGER :: jj,kk
231  REAL(DBL) :: dy
232 !--------------------------------------------------------------------------------------
233 
234 
235 ! Mass Flux over Density
236 
237  if(bp%TABUSE == 0) then
238  bw%rb = bp%Ac * exp( - bp%ec_ru / bw%Ts)
239  bw%alfa_eff = bp%alfac
240  else
241  jj = 0;kk = 0;
242  call polin2(bp,bp%TABLE%tsurf00,bp%TABLE%press00,bp%TABLE%rb00, &
243  bp%TABLE%nx_TABLE,bp%TABLE%ny_table,bw%Ts,bw%p,bw%rb,jj,kk)
244  call polin2(bp,bp%TABLE%tsurf00,bp%TABLE%press00,bp%TABLE%alph00, &
245  bp%TABLE%nx_TABLE,bp%TABLE%ny_table,bw%Ts,bw%p,bw%alfa_eff,jj,kk)
246  endif
247 
248 !---------------------------------------------------------------------------------------
249  RETURN
250  END SUBROUTINE mfun
251 !*****************************************************************************
252 
253 
254 !*****************************************************************************
255  SUBROUTINE tfun(bp,bw)
256  IMPLICIT NONE
257 
258 !--------------------------------------------------------------------------------------
259 ! Dummy variables:
260  TYPE(parameter_structure),POINTER :: bp
261  TYPE(work_structure), INTENT(INOUT) :: bw
262  INTEGER :: jj,kk
263 !-------------------------------------------------------------------------------------
264 
265 
266 ! FLAME TEMPERATURE, Temperature of the injected gas
267 
268  if (bp%TABUSE == 0) then
269  bw%Tstar = one/ ( bw%c2 - bw%c3 * (bw%c1-one/bw%Ts) )
270  if ( bw%Ts > bw%Ts0 .AND. bw%Ts > bw%Tslimit ) bw%Tstar = bp%Tstar0
271  else
272  jj =0;kk = 0;
273  call polin2(bp,bp%TABLE%tsurf00,bp%TABLE%press00,bp%TABLE%Tgas00,&
274  bp%TABLE%nx_table,bp%TABLE%ny_table,bw%Ts,bw%p,bw%Tstar,jj,kk)
275  endif
276 
277 
278 !-----------------------------------------------------------------------------------------------
279  RETURN
280  END SUBROUTINE tfun
281 !*****************************************************************************
282 
283 END MODULE update_py
284 
285 
286 
287 
288 
289 
subroutine gfun(bp, bw)
Definition: update_py.f90:159
void zero()
Sets all entries to zero (more efficient than assignement).
NT rhs
subroutine mfun(bp, bw)
Definition: update_py.f90:223
subroutine tfun(bp, bw)
Definition: update_py.f90:255
static void add(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for addition.
Definition: op3args.C:221
blockLoc i
Definition: read.cpp:79
subroutine polin2(bp, x1a, x2a, y12a, m, n, x1, x2, y, j, k)
Definition: data_py.f90:106
NT dy
subroutine burn_get_burning_rate1d(bp, delt, P, To, Tn, Qc, Qc_old, Qr, Qr_old, rhoc, Toa, rb, fr, bflag, Tnp1, Tflame, coor)
Definition: update_py.f90:28
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to merge
Definition: roccomf90.h:20