MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
condrad.f90
Go to the documentation of this file.
1 
8 module condrad
9  use constants
10  use ioutils
11  implicit none
12  private
13  public equcond,cond,alpha,sigma
14  !lapack variables
15  character :: trans='n'
16  character(len=30) :: fmt='(2x,A,1x,es9.3,1x,A)'
17  integer, parameter :: kl=1,ku=1,ldab=2*kl+ku+1,nrhs=1
18  integer :: info
19  integer, dimension(:), allocatable :: tipiv,gipiv
20  real(dp), dimension(:), allocatable :: trhs,grhs
21  real(dp), dimension(:,:), allocatable :: tmatrix,gmatrix
22  !end of lapack variables
23  real(dp) :: dz
24  real(dp), dimension(:), allocatable :: tvec,qcon,qrad,qtot,gqrad
25  real(dp), dimension(:), allocatable :: cond
26  real(dp), dimension(:,:), allocatable :: alpha
27  real(dp), dimension(:,:), allocatable :: sigma
28 contains
29 !********************************BEGINNING*************************************
33 subroutine equcond
34  integer :: i,maxiter=20,fi
35  real(dp) :: tol=1e-5_dp,res
36  write(*,*) 'Conduction-Radiation:'
37  write(mfi,*) 'Conduction-Radiation:'
38  dz=dfoam/nz
39  allocate(tmatrix(ldab,nz),gmatrix(ldab,nbox*nz),tipiv(nz),gipiv(nbox*nz),&
40  trhs(nz),grhs(nbox*nz),tvec(nz),qcon(nz),qrad(nz),qtot(nz),gqrad(nz))
41  forall (i=1:nz)
42  tvec(i)=temp1+(i-1)*(temp2-temp1)/(nz-1) !initial temperature profile
43  end forall
44  call make_tmatrix
45  call dgbtrf(nz,nz,kl,ku,tmatrix,ldab,tipiv,info)
46  call make_gmatrix
47  call dgbtrf(nbox*nz,nbox*nz,kl,ku,gmatrix,ldab,gipiv,info)
48  do i=1,maxiter
49  call make_trhs
50  call dgbtrs(trans,nz,kl,ku,nrhs,tmatrix,ldab,tipiv,trhs,nz,info)
51  res=abs(maxval(trhs-tvec))
52  write(*,'(5x,A,1x,I2,A,1x,es9.3)') 'iteration:',i, ', residual:',res
53  write(mfi,'(5x,A,1x,I2,A,1x,es9.3)') 'iteration:',i, ', residual:',res
54  tvec=trhs
55  if (res<tol) exit
56  enddo
57  call heatflux
58  eqc=sum(qtot)/nz*dfoam/(temp1-temp2)
59  rcontr=sum(qrad)/sum(qtot)
60  gcontr=(1-rcontr)*kgas/(kgas+ksol)
61  scontr=(1-rcontr)*ksol/(kgas+ksol)
62  kgas=gcontr*eqc
63  ksol=scontr*eqc
64  krad=rcontr*eqc
65  write(*,fmt) 'equivalent conductivity:',eqc*1e3_dp,'mW/m/K'
66  write(*,fmt) 'contribution of gas:',gcontr*1e2_dp,'%'
67  write(*,fmt) 'contribution of solid:',scontr*1e2_dp,'%'
68  write(*,fmt) 'contribution of radiation:',rcontr*1e2_dp,'%'
69  write(mfi,fmt) 'equivalent conductivity:',eqc*1e3_dp,'mW/m/K'
70  write(mfi,fmt) 'contribution of gas:',gcontr*1e2_dp,'%'
71  write(mfi,fmt) 'contribution of solid:',scontr*1e2_dp,'%'
72  write(mfi,fmt) 'contribution of radiation:',rcontr*1e2_dp,'%'
73  open(newunit(fi),file='foamConductivity.out')
74  write(fi,*) eqc
75  close(fi)
76  deallocate(tmatrix,gmatrix,tipiv,gipiv,trhs,grhs,tvec,qcon,qrad,qtot,gqrad)
77 end subroutine equcond
78 !***********************************END****************************************
79 
80 
81 !********************************BEGINNING*************************************
83 subroutine make_gmatrix
84  integer :: i,j,k,l
85  gmatrix=0
86  gipiv=0
87  l=0
88  do k=1,nbox
89  l=l+1
90  do i=2,nz-1
91  l=l+1
92  j=l
93  gmatrix(kl+ku+1+l-j,j)=2/((alpha(i,k)+sigma(i,k))*dz) + &
94  3*alpha(i,k)*dz
95  j=l-1
96  gmatrix(kl+ku+1+l-j,j)=-1/((alpha(i,k)+sigma(i,k))*dz)
97  j=l+1
98  gmatrix(kl+ku+1+l-j,j)=-1/((alpha(i,k)+sigma(i,k))*dz)
99  enddo
100  l=l+1
101  i=(k-1)*nz+1
102  j=i
103  gmatrix(kl+ku+1+i-j,j)=1/((alpha(1,k)+sigma(1,k))*dz) + &
104  3*alpha(1,k)*dz + &
105  9*emi1/(2-emi1)*alpha(1,k)/4/(alpha(1,k)+sigma(1,k))
106  j=i+1
107  gmatrix(kl+ku+1+i-j,j)=-1/((alpha(1,k)+sigma(1,k))*dz) - &
108  3*emi1/(2-emi1)*alpha(1,k)/4/(alpha(1,k)+sigma(1,k))
109  i=nz*k
110  j=i-1
111  gmatrix(kl+ku+1+i-j,j)=-1/((alpha(nz,k)+sigma(nz,k))*dz) - &
112  3*emi2/(2-emi2)*alpha(nz,k)/4/(alpha(nz,k)+sigma(nz,k))
113  j=i
114  gmatrix(kl+ku+1+i-j,j)=1/((alpha(nz,k)+sigma(nz,k))*dz) + &
115  3*alpha(nz,k)*dz + &
116  9*emi2/(2-emi2)*alpha(nz,k)/4/(alpha(nz,k)+sigma(nz,k))
117  enddo
118 end subroutine make_gmatrix
119 !***********************************END****************************************
120 
121 
122 !********************************BEGINNING*************************************
124 subroutine make_grhs
125  integer :: i,j,k
126  k=0
127  do i=1,nbox
128  do j=1,nz
129  k=k+1
130  grhs(k)=12*effn**2*sigmab*alpha(j,i)*tvec(j)**4*dz*fbepbox(i)
131  enddo
132  j=(i-1)*nz+1
133  grhs(j)=grhs(j) + 6*emi1/(2-emi1)*alpha(1,i)*effn**2*sigmab*temp1**4/&
134  (alpha(1,i)+sigma(1,i))*fbepbox(i)
135  j=nz*i
136  grhs(j)=grhs(j) + 6*emi2/(2-emi2)*alpha(nz,i)*effn**2*sigmab*temp2**4/&
137  (alpha(nz,i)+sigma(nz,i))*fbepbox(i)
138  enddo
139 end subroutine make_grhs
140 !***********************************END****************************************
141 
142 
143 !********************************BEGINNING*************************************
145 subroutine make_tmatrix
146  integer :: i,j
147  tmatrix=0
148  tipiv=0
149  i=1
150  j=i
151  tmatrix(kl+ku+1+i-j,j)=(cond(i) + &
152  cond(i)*cond(i+1)/(cond(i)+cond(i+1)))*2/dz
153  j=i+1
154  tmatrix(kl+ku+1+i-j,j)=-cond(i)*cond(i+1)/(cond(i)+cond(i+1))*2/dz
155  do i=2,nz-1
156  j=i-1
157  tmatrix(kl+ku+1+i-j,j)=-cond(i-1)*cond(i)/(cond(i-1)+cond(i))*2/dz
158  j=i
159  tmatrix(kl+ku+1+i-j,j)=(cond(i-1)*cond(i)/(cond(i-1)+cond(i)) + &
160  cond(i)*cond(i+1)/(cond(i)+cond(i+1)))*2/dz
161  j=i+1
162  tmatrix(kl+ku+1+i-j,j)=-cond(i)*cond(i+1)/(cond(i)+cond(i+1))*2/dz
163  enddo
164  i=nz
165  j=i-1
166  tmatrix(kl+ku+1+i-j,j)=-cond(i-1)*cond(i)/(cond(i-1)+cond(i))*2/dz
167  j=i
168  tmatrix(kl+ku+1+i-j,j)=(cond(i-1)*cond(i)/(cond(i-1)+cond(i)) + &
169  cond(i))*2/dz
170 end subroutine make_tmatrix
171 !***********************************END****************************************
172 
173 
174 !********************************BEGINNING*************************************
176 subroutine make_trhs
177  call make_gqrad
178  trhs=gqrad
179  trhs(1)=trhs(1)+2*cond(1)*temp1/dz
180  trhs(nz)=trhs(nz)+2*cond(nz)*temp2/dz
181 end subroutine make_trhs
182 !***********************************END****************************************
183 
184 
185 !********************************BEGINNING*************************************
187 subroutine make_gqrad
188  integer :: i,j,k
189  call make_grhs
190  call dgbtrs(trans,nbox*nz,kl,ku,nrhs,gmatrix,ldab,gipiv,grhs,nbox*nz,info)
191  k=0
192  gqrad=0
193  do i=1,nbox
194  do j=1,nz
195  k=k+1
196  gqrad(j)=gqrad(j) + alpha(j,i)*grhs(k)*dz - &
197  4*effn**2*sigmab*alpha(j,i)*tvec(j)**4*dz*fbepbox(i)
198  enddo
199  enddo
200 end subroutine make_gqrad
201 !***********************************END****************************************
202 
203 
204 !********************************BEGINNING*************************************
206 subroutine heatflux
207  integer :: i,j,k
208  qcon(1)=-2*cond(1)*cond(2)/(cond(1)+cond(2))*(tvec(2)-tvec(1))/dz
209  do i=2,nz
210  qcon(i)=-2*cond(i-1)*cond(i)/(cond(i-1)+cond(i))*(tvec(i)-tvec(i-1))/dz
211  enddo
212  qrad=0
213  k=0
214  do i=1,nbox
215  j=(i-1)*nz+1
216  qrad(1)=qrad(1)-(grhs(j+1)-grhs(j))/(3*(alpha(1,i)+sigma(1,i))*dz)
217  k=k+1
218  do j=2,nz
219  k=k+1
220  qrad(j)=qrad(j)-(grhs(k)-grhs(k-1))/(3*(alpha(j,i)+sigma(j,i))*dz)
221  enddo
222  enddo
223  qtot=qcon+qrad
224 end subroutine heatflux
225 !***********************************END****************************************
226 end module condrad