Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ZN_calc_burning_rate.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 ! SUBROUTINE : ZN_calc_burning_rate
26 !
27 ! purpose : calculate burning rate
28 !
29 ! Authors : J. Weber, K.C. Tang, and M. Q. Brewster
30 !
31 ! Creation Date : Sep. 04, 2002
32 !
33 ! Modifications :
34 !
35 ! No. Date Authors Description
36 !
37 !
38 ! ---------------------------------------------------------------------------
39 !
40 ! arguments :
41 !
42 !
43 ! G_ZN : Global variables for Rocburn_1D_ZN
44 ! P : pressure (atm)
45 ! qr : radiant flux (cal/cm^2/s)
46 ! To : initial temperature (K)
47 ! rhoc : condensed phase density (g/cm^3)
48 ! qr_old : radiant flux at previous time step (cal/cm^2/s)
49 ! fr_old : fr at previous time step
50 ! Toa : apparent initial temperature (K)
51 ! rb : burning rate (cm/s)
52 ! Ts : surface temperature (K)
53 ! fr : fraction of radiation absorbed below surface reaction
54 ! zone
55 ! Tn : temperature profile at previous time step
56 ! Tnp1 : temperature profile
57 !
58 ! ---------------------------------------------------------------------------
59 !
60  SUBROUTINE zn_calc_burning_rate (G_ZN, delt, P, qr, To, rhoc, qr_old, fr_old, &
61  toa, rb, ts, fr, tn, tnp1)
62 
64 
65  IMPLICIT NONE
66 
67  include 'mpif.h'
68 
69  TYPE(g_burn_1d), POINTER :: g_zn
70  REAL(DBL), INTENT(IN) :: delt, p, qr, to, rhoc
71  REAL(DBL), INTENT(IN) :: qr_old, fr_old
72  REAL(DBL), INTENT(INOUT) :: toa
73  REAL(DBL), INTENT(INOUT) :: rb, ts, fr
74  REAL(DBL), INTENT(IN) :: tn(:)
75  REAL(DBL), INTENT(OUT) :: tnp1(:)
76 
77 !
78 ! ============================================================================
79 !
80 ! delcare local variables
81 !
82  INTEGER :: iter, itrmx, i, mpi_comm_rocburn
83  REAL(DBL) :: rblast, tslast
84  REAL(DBL) :: fs, rb_old
85  REAL(DBL) :: first(1:g_zn%nxmax), second(1:g_zn%nxmax)
86  REAL(DBL) :: da(1:g_zn%nxmax), db(1:g_zn%nxmax), dc(1:g_zn%nxmax)
87  INTEGER :: ierror
88 
89 !
90 ! ============================================================================
91 !
92 
93  IF(g_zn%Model_combustion == 3) THEN
94 !
95 ! Model_combustion = 3
96 !
97 ! rb=a*P**n
98 !
99 
100  rb=g_zn%a_p*p**g_zn%n_p
101  tnp1(1)=1000.0
102 
103  RETURN
104 
105  END IF
106 
107  rb_old = rb
108 
109  fs=rb*(ts-toa)/g_zn%alfac-fr_old*qr_old/g_zn%lamc
110 
111  DO iter=0,g_zn%itermax
112 
113 !
114 ! get 1st and 2nd derivatives at last time step (n)
115 ! with this iterations surface temperature B.C.
116 
117  CALL cmpct1(g_zn%nx,g_zn%delz,tn,first, da, db, dc)
118  CALL cmpct2(g_zn%nx,g_zn%delz,tn,second, da, db, dc)
119 
120 !
121 ! determine T profile at this time step (n+1) based on
122 ! properties a last time step (n) (explicit differencing)
123 !
124  DO i=2,g_zn%nx-1
125  tnp1(i)=tn(i)+delt*( &
126  (g_zn%alfac*g_zn%zxx(i)-rb_old*g_zn%zx(i))*first(i) + &
127  g_zn%alfac*g_zn%zx(i)**2*second(i) + &
128  fr_old*qr_old/rhoc/g_zn%C*g_zn%Ka*exp(g_zn%Ka*g_zn%x(i)))
129  END DO ! i
130 
131  tnp1(g_zn%nx)=g_zn%To
132 
133 
134 ! update suface B.C. for this iteration
135 ! Tnp1(1)=(48.0*Tnp1(2)-36.0*Tnp1(3)+16.0*Tnp1(4) ! 4th
136 ! + -3.0*Tnp1(5)-12.0*G_ZN%delz*fs/G_ZN%zx(1))/25.0 ! 4th
137  tnp1(1)=(18.0*tnp1(2)-9.0*tnp1(3)+2.0*tnp1(4) &
138  -6.0*g_zn%delz*fs/g_zn%zx(1))/11.0 ! 3rd
139 ! Tnp1(1)=(Tnp1(2)-G_ZN%delz*fs/G_ZN%zx(1)) ! 1st
140 
141 
142 
143  ts=tnp1(1)
144 ! Tn(1)=Tnp1(1)
145 
146 !
147 ! calculate rb, Toa, and fr for given P, qr, and Ts
148 !
149  CALL zn(p, qr, to, ts, toa, rb, fr)
150 
151 !
152 ! calculate fs for this iteration of (n+1)
153 !
154  fs=rb*(ts-toa)/g_zn%alfac-fr*qr/g_zn%lamc
155 
156  IF(iter.ge.1) THEN
157  IF(abs(ts-tslast).lt.g_zn%tol_Ts.and.abs(rb-rblast).lt.g_zn%tol_Ts) THEN
158  RETURN
159  END IF
160  END IF
161 
162  tslast=ts
163  rblast=rb
164 
165  END DO ! iter
166 
167  print *,' ROCBURN_ZN: rank=',g_zn%rank
168  print *,' ROCBURN_ZN: Error - burning rate: Maximum # of iterations '
169  print *,' ROCBURN_ZN: itrmx=', g_zn%itermax, 'reached'
170  print *,' ROCBURN_ZN: tol_Ts=',g_zn%tol_Ts
171  print *,' ROCBURN_ZN: Tn=',tn
172  print *,' ROCBURN_ZN: Tnp1=',tnp1
173  stop
174 
175 
176  CONTAINS
177 
178 ! ------------------------------------------------------------------------
179 ! INTERNAL PROCEDURES
180 ! ------------------------------------------------------------------------
181 !
182 !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
183 ! c
184 ! subroutine : ZN c
185 ! c
186 ! purpose : alculate rb,Toa given Ts,P,qr c
187 ! c
188 ! --------------------------------------------------------------------------- c
189 ! c
190 ! written by c
191 ! K.C. Tang and M.Q. Brewster c
192 ! c
193 ! Last modified : 09/14/2000 c
194 ! --------------------------------------------------------------------------- c
195 ! c
196 ! input : c
197 ! c
198 ! P : pressure (atm) c
199 ! qr : radiative heat flux (al/cm^2-s) c
200 ! To : propellant temperatuer at deep into the propellant (K) c
201 ! Ts : surface temperature (K) c
202 ! Toa : ZN temperature (K) for initial guess c
203 ! rb : burning rate (cm/s) for initial guess c
204 ! c
205 ! c
206 ! output : c
207 ! c
208 ! Toa : ZN temperature (K) c
209 ! rb : burning rate (cm/s) c
210 ! fr : transmissivity of surface reaction zone c
211 ! c
212 !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
213 !
214 
215 !
216  SUBROUTINE zn(P, qr, To, Ts, Toa, rb, fr)
217 
218  IMPLICIT NONE
219 
220  REAL(DBL) :: p, qr, to
221  REAL(DBL) :: ts, rb, toa, fr
222  REAL(DBL) :: tf
223  REAL(DBL) :: delta_t2, ag
224 
225 
226  REAL(DBL), parameter :: tol=1.d-5
227 
228 ! ============================================================================
229 !
230 ! delcare local variables
231 !
232 
233  REAL(DBL) :: j(2,2),xx(2),e(2)
234  REAL(DBL) :: xreac
235  REAL(DBL) :: term0, term1, term2, term3, term4, term5
236  REAL(DBL) :: xcd, da, xg
237 
238  integer iter
239 
240 
241  term1=g_zn%Ac*g_zn%R*(ts*rhoc)**2*g_zn%alfac*g_zn%C* &
242  exp(-g_zn%Ec/g_zn%R/ts)/g_zn%Ec
243 
244 
245 !
246 ! initial guess
247 !
248 
249  xx(1)=rb*rhoc
250  xx(2)=toa
251 
252  IF(g_zn% Model_combustion == 1) THEN
253 
254 ! Model_combustion = 1
255 !
256 ! WSB homogeneouse propellant combustion model
257 !
258 
259  ag=g_zn%Bg/(g_zn%R*g_zn%R)*g_zn%MW*g_zn%MW
260 
261 
262  DO iter=0,g_zn%itermax
263 
264 !
265 ! set up residual matrix and Jacobian derivative matrix for
266 ! Ibiricu and Williams condensed phase expression
267 
268  xreac=2.0*rhoc*g_zn%alfac*g_zn%R*ts/xx(1)/g_zn%Ec
269  term0=1.0-g_zn%Ka*xreac
270 
271  fr=dexp(-xreac*g_zn%Ka)
272  term2=g_zn%C*(ts-xx(2))-g_zn%Qc/2.0-fr*qr/xx(1)
273  term3=term1/term2
274 
275  e(1)=xx(1)**2-term3
276  j(1,1)=2.0*xx(1)+term3/term2*fr*qr/xx(1)**2*term0
277  j(1,2)=-term3*g_zn%C/term2
278 
279 !
280 ! set up residual matrix and Jacobian derivative matrix for
281 ! Ward-Son-Brewster gas phase expression
282 
283 
284  xcd=g_zn%lamg/g_zn%C/xx(1)
285  da=4.0*g_zn%Bg*g_zn%C/g_zn%lamg*(p*g_zn%MW*xcd/g_zn%R)**2
286  term4=(1.0+da)**0.5
287  xg=2.0*xcd/(term4-1.0)
288  term5=g_zn%Qc-g_zn%C*(ts-xx(2))
289  tf=(qr/xx(1)+g_zn%Qc+g_zn%Qg)/g_zn%C+xx(2)
290 
291  e(2)=(tf-ts)/xg+(qr+xx(1)*term5)/g_zn%lamg
292  j(2,1)=-qr/xg/xx(1)**2/g_zn%C-(tf-ts)/xg/xx(1)/term4+term5/g_zn%lamg
293  j(2,2)=1/xg+1/xcd
294 
295 !
296 ! update guesses for m and Toa using Newton-Rhapson
297 ! & guard against a negative (erroneus) rb solution
298 !
299  call newton(xx,j,e)
300  if(xx(1).lt.0.0) then
301  print *,' ROCBURN_ZN: rank=',g_zn%rank, &
302  ' rb negative xx(1)=',xx(1),' Ts=',ts
303  xx(1)=abs(xx(1))
304  end if
305 
306  if(abs(e(1)).lt.tol .and. abs(e(2)).lt.tol) then
307 
308 !
309 ! reset final converged values
310 !
311  rb=xx(1)/rhoc
312  toa=xx(2)
313  fr=dexp(-xreac*g_zn%Ka)
314  return
315 
316  end if
317  END DO ! iter
318 
319  WRITE(*,*) ' ROCBURN_ZN: in ZN rank=',g_zn%rank, &
320  ' Error-WSB: Maximum # of iterations reached'
321  stop
322 
323  end if
324 
325  if(g_zn%Model_combustion.eq.2) then
326 
327 ! Model_combustion = 2
328 !
329 ! Zeldovich-Novozhilov phenomenological model for composite
330 ! propellant
331 !
332 
333  DO iter=0,g_zn%itermax
334 
335 !
336 ! set up residual matrix and Jacobian derivative matrix for
337 ! Ibiricu and Williams condensed phase expression
338 
339  xreac=2.0*rhoc*g_zn%alfac*g_zn%R*ts/xx(1)/g_zn%Ec
340  term0=1.0-g_zn%Ka*xreac
341 
342  fr=dexp(-xreac*g_zn%Ka)
343  term2=g_zn%C*(ts-xx(2))-g_zn%Qc/2.0-fr*qr/xx(1)
344  term3=term1/term2
345 
346  e(1)=xx(1)**2-term3
347  j(1,1)=2.0*xx(1)+term3/term2*fr*qr/xx(1)**2*term0
348  j(1,2)=-term3*g_zn%C/term2
349 
350 !
351 ! set up residual matrix and Jacobian derivative matrix for
352 ! Ward-Son-Brewster gas phase expression
353 !
354 
355 
356  delta_t2 = ts - 300.0
357  e(2)=g_zn%a_T*((ts-xx(2)-qr/(xx(1)*g_zn%C))/delta_t2)**g_zn%n_T - &
358  rhoc*g_zn%a_p*p**g_zn%n_p/xx(1)
359  j(2,1)=rhoc*g_zn%a_p*p**g_zn%n_p/(xx(1)*xx(1))
360  j(2,2)=-g_zn%n_T*g_zn%a_T*(ts-xx(2)-qr/(xx(1)*g_zn%C))**(g_zn%n_T-1.0)/ &
361  (delta_t2**g_zn%n_T)
362 
363 
364 !
365 ! update guesses for m and Toa using Newton-Rhapson
366 ! & guard against a negative (erroneus) rb solution
367 !
368 
369  call newton(xx,j,e)
370 
371  if(xx(1).lt.0.0) then
372  print *,' ROCBURN_ZN: inside ZN rank=',g_zn%rank, &
373  ' rb negative xx(1)=',xx(1),' Ts=',ts
374  xx(1)=abs(xx(1))
375  end if
376 
377  if(abs(e(1)).lt.tol .and. abs(e(2)).lt.tol) then
378 
379 !
380 ! reset final converged values
381 !
382  rb=xx(1)/rhoc
383  toa=xx(2)
384  fr=dexp(-xreac*g_zn%Ka)
385  RETURN
386 
387  END IF
388  END DO ! iter
389 
390  WRITE(*,*) ' ROCBURN_ZN: in ZN rank=',g_zn%rank, &
391  ' Error-Composite: Maximum # of iterations reached'
392  stop
393 
394  end if
395 
396  IF(g_zn%Model_combustion == 3) THEN
397 
398 !
399 !
400 ! Model_combustion = 3
401 !
402 ! rb=a*P**n
403 !
404 
405  rb=g_zn%a_p*p**g_zn%n_p
406  tnp1(1)=1000.0
407 
408  RETURN
409 
410  END IF
411 
412  WRITE(*,*) ' ROCBURN_ZN: in ZN rank=',g_zn%rank, &
413  ' Error-ZN: No appropriate combustion model'
414  WRITE(*,*) ' ROCBURN_ZN: Combustion Model= ', g_zn%Model_combustion
415  stop
416 
417  END SUBROUTINE zn
418 
419 
420 
421 !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
422 ! c
423 ! subroutine : Newton c
424 ! c
425 ! c
426 ! Author: c
427 ! c
428 ! Paul Loner c
429 ! c
430 !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
431 ! c
432  SUBROUTINE newton(x,J,e)
433 
434  implicit none
435 
436  REAL(DBL) :: x(2),j(2,2),e(2),detj,delx(2),dum
437  integer i
438 
439  detj=j(1,1)*j(2,2)-j(2,1)*j(1,2)
440 
441  IF(detj.eq.0) then
442  print *,' ROCBURN_ZN: in Newton rank=',g_zn%rank, &
443  ' Error: singular matrix encountered'
444  print *,' ROCBURN_ZN: P=', p
445  print *,' ROCBURN_ZN: J=', j
446  stop
447  ENDIF
448 !
449 ! invert the 2x2 Jacobian matrix
450 !
451  dum=j(1,1)
452  j(1,1)=j(2,2)
453  j(2,2)=dum
454  j(1,1)=j(1,1)/detj
455  j(1,2)=-j(1,2)/detj
456  j(2,1)=-j(2,1)/detj
457  j(2,2)=j(2,2)/detj
458 !
459 ! multiply J^-1()*e() and update guesses
460 !
461  do i=1,2
462  delx(i)=j(i,1)*e(1)+j(i,2)*e(2)
463  x(i)=x(i)-delx(i)
464  end do ! i
465 
466  RETURN
467  END SUBROUTINE newton
468 
469 !***********************************************************************
470 !
471  SUBROUTINE cmpct1(imax,h,u,f, a, b, cc)
472 !
473 !***********************************************************************
474 ! Modifications:
475 !
476 ! No. Date Programmer Description
477 ! 001 May 03, 2001 K. C. Tang change memory allocation method for
478 ! temporary arrarys inside a
479 ! subroutine
480 
481  IMPLICIT NONE
482 
483  integer i,imax
484  REAL(DBL) :: h,u(imax),f(imax)
485 
486  REAL(DBL) :: a(:),b(:),cc(:)
487 
488 
489 ! set up equations for first derivatives
490 ! print *,' in cmpct1 imax=',imax,' h=',h,' u=',u,' f=',f
491 
492 ! ALLOCATE(a(imax))
493 ! ALLOCATE(b(imax))
494 ! ALLOCATE(cc(imax))
495 
496  a(1)=0.0
497  b(1)=1.0
498  cc(1)=0.0
499  f(1)=(-25.0*u(1)+48.0*u(2)-36.0*u(3)+16.0*u(4)-3.0*u(5))/(12.0*h) !4th
500 
501  do i=2,imax-1
502  a(i)=1.0
503  b(i)=4.0
504  cc(i)=1.0
505  f(i)=3.0*(u(i+1)-u(i-1))/h
506  end do ! i
507 
508  a(imax)=0.0
509  b(imax)=1.0
510  cc(imax)=0.0
511  f(imax)=0.0
512 
513 ! solve for first derivatives
514 
515  call tridg(imax,a,b,cc,f)
516 
517 ! DEALLOCATE(a)
518 ! DEALLOCATE(b)
519 ! DEALLOCATE(cc)
520  RETURN
521  END SUBROUTINE cmpct1
522 
523 
524 !***********************************************************************
525 !
526  SUBROUTINE cmpct2(imax,h,u,s, a, b, cc )
527 !
528 !***********************************************************************
529 ! Modifications:
530 !
531 ! No. Date Programmer Description
532 ! 001 May 03, 2001 K. C. Tang change memory allocation method for
533 ! temporary arrarys inside a
534 ! subroutine
535 
536  implicit none
537 
538  integer i,imax
539  REAL(DBL) :: h,h2,u(imax),s(imax)
540  REAL(DBL) :: a(:),b(:),cc(:)
541 ! REAL(DBL), ALLOCATABLE :: a(:),b(:),cc(:)
542 
543 
544  h2=h*h
545 
546 ! ALLOCATE(a(imax))
547 ! ALLOCATE(b(imax))
548 ! ALLOCATE(cc(imax))
549 
550 ! set up equations for second derivatives
551 
552  a(1)=0.0
553  b(1)=1.0
554  cc(1)=0.0
555  s(1)=(45.0*u(1)-154.0*u(2)+214.0*u(3)-156.0*u(4)+61.0*u(5)- &
556  10.0*u(6))/12.0/h2 ! 4th
557 
558  DO i=2,imax-1
559  a(i)=1.0
560  b(i)=10.0
561  cc(i)=1.0
562  s(i)=12.0*(u(i+1)-2.0*u(i)+u(i-1))/h2
563  END DO ! i
564 
565  a(imax)=0.0
566  b(imax)=1.0
567  cc(imax)=0.0
568  s(imax)=0.0
569 
570 ! solve for second derivatives
571 
572  call tridg(imax,a,b,cc,s)
573 
574 ! DEALLOCATE(a)
575 ! DEALLOCATE(b)
576 ! DEALLOCATE(cc)
577 
578  RETURN
579  END SUBROUTINE cmpct2
580 
581 
582 !***********************************************************************
583 !
584  SUBROUTINE tridg (imax,a,b,c,d)
585 !
586 ! solves a tridiagonal matrix equation of the form:
587 !
588 ! a(i)*u(i-1) + b(i)*u(i) + c(i)*u(i+1) = d(i)
589 !
590 ! using the Thomas algorithm.
591 !
592 !***********************************************************************
593 
594  IMPLICIT NONE
595 
596  INTEGER :: imax
597  REAL(DBL) :: a(:), b(:), c(:), d(:)
598 ! REAL(DBL), DIMENSION(imax) :: a, b, c, d
599 
600  INTEGER :: i
601 
602  DO i=2,imax
603  a(i)=a(i)/b(i-1)
604  b(i)=b(i)-a(i)*c(i-1)
605  d(i)=d(i)-a(i)*d(i-1)
606  END DO ! i
607 
608  d(imax)=d(imax)/b(imax)
609 
610  DO i=imax-1,1,-1
611  d(i)=(d(i)-c(i)*d(i+1))/b(i)
612  END DO ! i
613  RETURN
614  END SUBROUTINE tridg
615 
616 
617 ! -------------------------------------------------------------------
618 ! END OF INTERNAL PROCEDURES
619 ! -------------------------------------------------------------------
620 
621 
622  END SUBROUTINE zn_calc_burning_rate
623 
624 
625 
626 
627 
628 
const NT & d
subroutine tridg(imax, a, b, c, d)
double s
Definition: blastest.C:80
unsigned char b() const
Definition: Color.h:70
RT c() const
Definition: Line_2.h:150
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
subroutine zn(P, qr, To, Ts, Toa, rb, fr)
subroutine cmpct1(imax, h, u, f, a, b, cc)
subroutine newton(x, J, e)
virtual std::ostream & print(std::ostream &os) const
j indices j
Definition: Indexing.h:6
subroutine cmpct2(imax, h, u, s, a, b, cc)
subroutine zn_calc_burning_rate(G_ZN, delt, P, qr, To, rhoc, qr_old, fr_old, Toa, rb, Ts, fr, Tn, Tnp1)
RT a() const
Definition: Line_2.h:140