13 public :: chain_dfdrho
20 Subroutine chain_aux(rhop,rhobar,lambda,user)
24 Use mod_dft
, Only: zp,dzp,fa
30 #include <finclude/petscsys.h> 34 petscscalar :: rhop(ncomp,user%gxs:user%gxe)
35 REAL,
INTENT(OUT) :: rhobar(user%gxs:user%gxe,ncomp)
36 REAL,
INTENT(OUT) ::
lambda(user%gxs:user%gxe,ncomp)
42 REAL :: zz,dz,xlo,xhi,integral_lamb,integral_rb
43 INTEGER,
parameter :: nmax = 800
44 REAL,
dimension(NMAX) :: x_int, lamb_int, rb_int
45 REAL,
dimension(NMAX) :: y2_lamb, y2_rb
46 REAL :: rhopjk,rhopjp1k
55 Do i = user%xs-fak,user%xe+fak
63 rhopjp1k = rhop(k,j+1)
66 If( ( zp(i)-zp(j+1) ) < dhsk .and. ( zp(i) - zp(j) ) >= dhsk )
Then 69 write(*,*)
'Surface Tension Code: n /=1 in Chain_aux' 74 dz = zp(j+1) - (zp(i) - dhsk)
78 lamb_int(n) = rhopjk + (rhopjp1k - rhopjk)/dzp * (dzp-dz)
82 Else If (zp(j) > (zp(i)-dhsk) .and. zp(j) <= (zp(i)+dhsk))
Then 85 x_int(n) = x_int(n-1) + dz
89 rb_int(n) = rhopjk * ( dhsk**2 - zz**2 )
91 If (zp(j) < (zp(i)+dhsk) .and. zp(j+1) >= (zp(i)+dhsk) )
Then 93 dz = zp(i) + dhsk - zp(j)
97 x_int(n) = x_int(n-1) + dz
99 lamb_int(n) = rhopjk + (rhopjp1k - rhopjk)/dzp * dz
116 write(*,*)
'Surface Tension Code: Increase NMAX in Chain_aux (also in AD Routine!!)' 120 call spline ( x_int, lamb_int, n, 1.e30, 1.e30, y2_lamb )
121 call spline ( x_int, rb_int, n, 1.e30, 1.e30, y2_rb )
123 call splint_integral ( x_int, lamb_int, y2_lamb, n, xlo, xhi, integral_lamb )
124 call splint_integral ( x_int, rb_int, y2_rb, n, xlo, xhi, integral_rb )
125 lambda(i,k) = 0.5 * integral_lamb / dhsk
126 rhobar(i,k) = 0.75 * integral_rb / dhsk**3
128 If(
lambda(i,k) < epsilon(dz) )
lambda(i,k) = epsilon(dz)
138 End Subroutine chain_aux
147 Subroutine chain_dfdrho(i,rhop,lambda,rhobar,dF_drho_CHAIN,f_ch,user)
151 Use mod_dft
, Only: zp,dzp,fa
156 #include <finclude/petscsys.h> 159 INTEGER,
INTENT(IN) :: i
161 petscscalar :: rhop(ncomp,user%gxs:user%gxe)
162 REAL,
INTENT(IN) :: rhobar(user%gxs:user%gxe,ncomp)
163 REAL,
INTENT(IN) ::
lambda(user%gxs:user%gxe,ncomp)
164 REAL,
INTENT(OUT) :: df_drho_chain(user%xs:user%xe,ncomp)
165 REAL,
INTENT(OUT) :: f_ch
172 REAL :: rhopjk,rhopjp1k,logrho,xlo,xhi
173 REAL :: ycorr(ncomp),dlny(ncomp,ncomp)
174 INTEGER,
parameter :: nmax = 800
175 REAL,
dimension(NMAX) :: x_int, int_1,int_2
176 REAL,
dimension(NMAX) :: y2_1, y2_2
177 REAL :: dz,zz,integral_1,integral_2
181 call cavity_mix(rhobar(i,1:ncomp),ycorr,dlny)
196 rhopjp1k = rhop(k,j+1)
198 If( ( zp(i)-zp(j+1) ) < dhsk .and. ( zp(i) - zp(j) ) >= dhsk )
Then 201 write(*,*)
'Surface Tension Code: n /=1 in Chain_dFdrho' 206 dz = zp(j+1) - (zp(i) - dhsk)
210 int_2(n) = rhopjk*
lambda(j,k) + (rhopjp1k*
lambda(j+1,k) - rhopjk*
lambda(j,k) )/dzp * (dzp-dz)
212 Else If (zp(j) > (zp(i)-dhsk) .and. zp(j) <= (zp(i)+dhsk))
Then 215 x_int(n) = x_int(n-1) + dz
218 int_1(n) = sum( ( parame(1:ncomp,1)-1.0 ) * rhop(1:ncomp,j)*dlny(1:ncomp,k) ) &
219 * 0.75/dhsk**3 * (dhsk**2-zz**2)
220 int_2(n) = rhopjk /
lambda(j,k)
222 If (zp(j) < (zp(i)+dhsk) .and. zp(j+1) >= (zp(i)+dhsk) )
Then 224 dz = zp(i) + dhsk - zp(j)
228 x_int(n) = x_int(n-1) + dz
230 int_2(n) = rhopjk*
lambda(j,k) + (rhopjp1k*
lambda(j+1,k) - rhopjk*
lambda(j,k) )/dzp * dz
246 write(*,*)
'Surface Tension Code: Increase NMAX in Chain_dFdrho (also in AD Routine!!)' 250 CALL spline ( x_int, int_1, n, 1.e30, 1.e30, y2_1 )
251 CALL splint_integral( x_int, int_1, y2_1, n, xlo, xhi, integral_1 )
252 CALL spline ( x_int, int_2, n, 1.e30, 1.e30, y2_2 )
253 CALL splint_integral( x_int, int_2, y2_2, n, xlo, xhi, integral_2 )
255 If(rhop(k,i) < epsilon(dz)) rhop = epsilon(dz)
257 df_drho_chain(i,k) = (parame(k,1) - 1.0)*log(rhop(k,i)) &
258 - (parame(k,1) - 1.0) * ( log(ycorr(k)*
lambda(i,k))-1.0 + 0.5*integral_2/dhsk ) - integral_1
261 f_ch = f_ch + ( parame(k,1) - 1.0 ) * rhop(k,i) * ( log(rhop(k,i)) - 1.0 ) &
262 - ( parame(k,1) - 1.0 ) * rhop(k,i) * ( log(ycorr(k)*
lambda(i,k)) - 1.0 )
281 End Subroutine chain_dfdrho
302 SUBROUTINE cavity_mix ( rhoi, ycorr, dlnydr )
310 REAL,
INTENT(IN) :: rhoi(ncomp)
311 REAL,
INTENT(OUT) :: ycorr(ncomp)
312 REAL,
INTENT(OUT) :: dlnydr(ncomp,ncomp)
316 REAL :: z0, z1, z2, z3, zms, z1_rk, z2_rk, z3_rk
317 REAL,
DIMENSION(ncomp,ncomp) :: dij_ab, gij, gij_rk
320 z0 = pi / 6.0 * sum( rhoi(1:ncomp) * parame(1:ncomp,1) )
321 z1 = pi / 6.0 * sum( rhoi(1:ncomp) * parame(1:ncomp,1) * dhs(1:ncomp) )
322 z2 = pi / 6.0 * sum( rhoi(1:ncomp) * parame(1:ncomp,1) * dhs(1:ncomp)**2 )
323 z3 = pi / 6.0 * sum( rhoi(1:ncomp) * parame(1:ncomp,1) * dhs(1:ncomp)**3 )
329 dij_ab(i,j)=dhs(i)*dhs(j)/(dhs(i)+dhs(j))
335 z1_rk = pi/6.0 * parame(k,1) * dhs(k)
336 z2_rk = pi/6.0 * parame(k,1) * dhs(k)*dhs(k)
337 z3_rk = pi/6.0 * parame(k,1) * dhs(k)**3
340 gij(i,j) = 1.0/zms + 3.0*dij_ab(i,j)*z2/zms/zms &
341 + 2.0*(dij_ab(i,j)*z2)**2 /zms**3
344 gij_rk(i,j) = z3_rk/zms/zms &
345 + 3.0*dij_ab(i,j)*(z2_rk+2.0*z2*z3_rk/zms)/zms/zms &
346 + dij_ab(i,j)**2 *z2/zms**3 *(4.0*z2_rk+6.0*z2*z3_rk/zms)
350 dlnydr(i,k) = gij_rk(i,i) / gij(i,i)
355 END SUBROUTINE cavity_mix
366 End Module mod_DFT_CHAIN
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains constant...
double lambda
Latent heat of blowing agent, J/kg.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
In this module, the application context is defined.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...