40 use eos_polar
, only: f_polar, phi_polar
47 REAL FUNCTION dens_invers2 ( rhob, mu_rho )
49 REAL,
INTENT(IN) :: rhob(2)
50 REAL,
INTENT(IN OUT) :: mu_rho
51 END FUNCTION dens_invers2
53 SUBROUTINE dens_inv_coeff2 ( rhob )
55 REAL,
INTENT(IN) :: rhob(2)
56 END SUBROUTINE dens_inv_coeff2
60 INTEGER :: i, j, kk, converg
61 INTEGER :: discret, fa, outpt, irc, maxiter, ih
63 REAL,
DIMENSION(-NDFT:NDFT) :: zp, rhop, rhop_o
64 REAL,
DIMENSION(-NDFT:NDFT) :: df_drho_tot, f_tot
65 REAL,
DIMENSION(-NDFT:NDFT) :: df_drho_att, f_att
66 REAL,
DIMENSION(2) :: rhob
67 REAL :: f_disp_1pt, f_disp_pcsaft
68 REAL :: mu_disp_1pt, mu_disp_pcsaft
69 REAL :: zges(np), pbulk
70 REAL :: msegm, delta_st, tanhfac
71 REAL :: end_x, steps, my0
72 REAL :: f_int_z, mu_int_z
73 REAL :: f_int_r, mu_int_r
74 REAL :: f_int2_z, mu_int2_z, mu_int3_z
75 REAL :: f_int2_r, mu_int2_r, mu_int3_r
79 REAL :: surftens(0:200), st_macro(200)
80 REAL :: f01, f02, f03, f04, f05
81 REAL :: c1_con, c2_con
83 REAL :: tsav, psav, tc, pc, rhoc
84 REAL :: density(np), w(np,nc), lnphi(np,nc)
87 REAL,
DIMENSION(-NDFT:NDFT) ::
lambda, rhobar, phi_dn0, phi_dn1
88 REAL,
DIMENSION(-NDFT:NDFT) :: phi_dn2, phi_dn3, phi_dn4, phi_dn5
89 REAL,
DIMENSION(0:5,-NDFT:NDFT) :: ni
90 REAL :: f_ch, df_drho_ch
92 REAL :: z0, z1, z2, z3
93 REAL :: f_fmt, df_drho_fmt
94 REAL :: pn_pt(0:ndft), zs
95 REAL :: mu_assoc, f_assoc
96 REAL :: fres_polar, fdd, fqq, fdq
97 REAL :: mu_polar, fdd_rk, fqq_rk, fdq_rk, z3_rk
106 CALL set_default_eos_numerical
117 z3t_st = pi/6.0* parame(1,1) * ( 1.0 &
118 * ( 1.0 - 0.12*exp( -3.0*parame(1,3)/t ) ) )**3
119 d_hs = ( 1.0 - 0.12*exp( -3.0*parame(1,3)/t ) )
122 IF ( ncomp /= 1 )
THEN 123 write (*,*)
'SPECIFY ONLY ONE COMPONENT IN THE INPUT-FILE:' 124 write (*,*)
' ./input_file/INPUT.INP' 127 OPEN (68,file =
'./output_file/DFT_profiles.xlo')
128 OPEN (69,file =
'./output_file/DFT_sigma.xlo')
129 OPEN (71,file =
'./output_file/DFT_iteration.xlo')
130 OPEN (72,file =
'./output_file/DFT_h.xlo')
147 dzp = box_l_no_unit /
REAL(discret) 148 fa = nint( 1.0 / dzp )
149 WRITE (*,*) fa, 1.0/dzp
170 CALL rdf_matrix (msegm)
177 diagram_for_various_t_loop:
DO 187 IF ( eos >= 4 ) val_init(4) = 1.e-3
203 DO WHILE ( converg == 0 )
205 CALL phase_equilib( end_x, steps, converg )
206 IF ( converg /= 1 )
THEN 208 val_init(3) = t - 10.0
209 IF ( val_conv(4) /= 0.0 ) val_init(4) = val_conv(4) / 4.0
214 WRITE (*,*)
'no VLE found' 215 IF ( val_init(3) <= 10.0 )
RETURN 220 rhob(1) = dense(1)/z3t_st
221 rhob(2) = dense(2)/z3t_st
222 WRITE (*,*)
'temperature ',t,p/1.e5
223 WRITE (*,*)
'densities ',rhob(1), rhob(2)
224 WRITE (*,*)
'dense ',dense(1),dense(2)
230 CALL si_dens ( density, w )
239 CALL fugacity (lnphi)
240 my0 = lnphi(1,1) + log( rhob(1)/parame(1,2)**3 )
241 zges(1) = p / ( rgas*t*density(1) ) * mm(1)/1000.0
242 zges(2) = p / ( rgas*t*density(2) ) * mm(1)/1000.0
244 pbulk = zges(1) * rhob(1)
245 WRITE (*,*)
'chem. potentials', lnphi(1,1) + log( rhob(1)/parame(1,2)**3 ), &
246 lnphi(2,1) + log( rhob(2)/parame(1,2)**3 )
249 IF (num == 2)
WRITE (*,*)
'enter an estimate for crit. temp.' 250 IF (num == 2)
READ (*,*) tc
254 IF ( eos < 4 )
CALL critical (tc,pc,rhoc)
258 WRITE (*,
'(a,3(f16.4))')
'critical point',tc, pc/1.e5, rhoc
272 irc = nint(rc/dzp) + 1
273 tanhfac = -2.3625*t/tc + 2.4728
275 DO i = -irc, (discret+irc)
276 zp(i) =
REAL(i) * dzp
278 DO i = -irc, (discret+irc)
279 rhop(i) = tanh(-(zp(i)-zp(int(discret/2)))*tanhfac) * (rhob(1)-rhob(2))/2.0 &
280 + (rhob(1)+rhob(2))/2.0
302 dft_convergence_loop:
DO 308 CALL aux_chain ( discret, fa, dzp, d_hs, zp, rhop, rhobar,
lambda )
310 CALL fmt_dens ( discret, fa, dzp, d_hs, zp, rhop, ni, &
311 phi_dn0, phi_dn1, phi_dn2, phi_dn3, phi_dn4, phi_dn5 )
324 z0 = rhop(i) * pi/6.0 * parame(1,1)
325 z1 = rhop(i) * pi/6.0 * parame(1,1) * d_hs
326 z2 = rhop(i) * pi/6.0 * parame(1,1) * d_hs**2
327 z3 = rhop(i) * pi/6.0 * parame(1,1) * d_hs**3
329 gij = 1.0/zms + 3.0*(d_hs/2.0)*z2/zms/zms + 2.0*((d_hs/2.0)*z2)**2 /zms**3
330 dlngijdr = (1.0/zms/zms + 3.0*(d_hs/2.0)*z2*(1.0+z3)/z3/zms**3 &
331 + ((d_hs/2.0)*z2/zms/zms)**2 *(4.0+2.0*z3)/z3 ) /gij*z3t_st
339 f_fmt = - ni(0,i)*log(zs) + ni(1,i)*ni(2,i)/zs - ni(4,i)*ni(5,i)/zs &
340 + (ni(2,i)**3 -3.0*ni(2,i)*ni(5,i)*ni(5,i)) *(ni(3,i)+zs*zs*log(zs)) &
341 /36.0/pi/zs/zs/ni(3,i)**2
343 CALL df_fmt_dr ( i, fa, dzp, d_hs, zp, phi_dn0, &
344 phi_dn1, phi_dn2, phi_dn3, phi_dn4, phi_dn5, df_drho_fmt )
350 CALL df_chain_dr ( i, fa, dzp, d_hs, zp, rhop,
lambda, &
351 rhobar, z3t_st, f_ch, df_drho_ch )
367 DO j = (i-irc), (i+irc)
368 zz1 = abs( zp(j) - zp(i) )
369 IF ( zz1 <= rc-dzp+1.e-9 )
THEN 370 CALL dft_rad_int ( i, j, ih, zz1, rhop, f_int_r, mu_int_r, &
371 f_int2_r, mu_int2_r, mu_int3_r )
380 f_int_z = f_int_z + dzp * (rhop(j)* f_int_r + f01)/2.0
381 mu_int_z = mu_int_z + dzp * (rhop(j)*mu_int_r + f02)/2.0
382 f_int2_z = f_int2_z + dzp * ( f_int2_r + f03)/2.0
383 mu_int2_z= mu_int2_z+ dzp * (mu_int2_r + f04)/2.0
384 mu_int3_z= mu_int3_z+ dzp * (mu_int3_r + f05)/2.0
385 f01 = rhop(j)* f_int_r
386 f02 = rhop(j)* mu_int_r
396 CALL cutoff_corrections ( i, irc, rhop, rhob, f_int_z, mu_int_z, f_int2_z, mu_int2_z )
403 z3 = rhop(i) * z3t_st
405 c1_con= 1.0/ ( 1.0 + parame(1,1)*(8.0*z3-2.0*z3**2 )/zms**4 &
406 + (1.0 - parame(1,1))*(20.0*z3-27.0*z3**2 &
407 + 12.0*z3**3 -2.0*z3**4 ) /(zms*(2.0-z3))**2 )
408 c2_con= - c1_con*c1_con &
409 * ( parame(1,1)*(-4.0*z3**2 +20.0*z3+8.0)/zms**5 &
410 + (1.0 - parame(1,1)) *(2.0*z3**3 +12.0*z3**2 -48.0*z3+40.0) &
411 / (zms*(2.0-z3))**3 )
412 mu_int2_z = mu_int2_z /4.0 * ( 2.0*rhop(i)*c1_con + rhop(i)*z3*c2_con )
413 mu_int3_z = mu_int3_z /4.0 *rhop(i)*rhop(i)*c1_con
414 f_int2_z = f_int2_z /4.0 *rhop(i)*rhop(i)*c1_con
443 df_drho_att(i) = 2.0*pi*parame(1,1)**2 * parame(1,3)/t * mu_int_z
444 f_att(i) = pi*parame(1,1)**2 *parame(1,3)/t*rhop(i)*f_int_z
448 IF (subtract1 ==
'2PT')
THEN 449 df_drho_att(i)= df_drho_att(i) -2.0*pi*parame(1,1)**3 *(parame(1,3)/t)**2 *(mu_int2_z+mu_int3_z)
450 f_att(i) = f_att(i) -2.0*pi*parame(1,1)**3 *(parame(1,3)/t)**2 *f_int2_z
461 dense(1) = rhop(i) * z3t_st
466 call only_one_term_eos_numerical (
'disp_term',
'PT1 ' )
467 call fugacity ( lnphi )
468 call restore_previous_eos_numerical
471 f_disp_1pt = fres*rhop(i)
472 mu_disp_1pt = lnphi(1,1)
474 call only_one_term_eos_numerical (
'disp_term',
'PC-SAFT ' )
475 call fugacity ( lnphi )
476 call restore_previous_eos_numerical
477 f_disp_pcsaft = fres*rhop(i)
478 mu_disp_pcsaft = lnphi(1,1)
484 call f_polar ( fdd, fqq, fdq )
485 call phi_polar ( 1, z3_rk, fdd_rk, fqq_rk, fdq_rk )
486 fres_polar = ( fdd + fqq + fdq ) * rhop(i)
487 mu_polar = fdd_rk + fqq_rk + fdq_rk
491 IF ( sum( nint(parame(1:ncomp,12)) ) > 0)
THEN 492 call only_one_term_eos_numerical (
'hb_term ',
'TPT1_Chap' )
493 call fugacity ( lnphi )
494 call restore_previous_eos_numerical
495 f_assoc = fres*rhop(i)
496 mu_assoc = lnphi(1,1)
501 df_drho_att(i)= df_drho_att(i) + ( mu_disp_pcsaft - mu_disp_1pt ) + mu_assoc + mu_polar
502 f_att(i) = f_att(i) + ( f_disp_pcsaft - f_disp_1pt ) + f_assoc + fres_polar
512 df_drho_tot(i) = log( rhop(i)/parame(1,2)**3 ) + df_drho_fmt + df_drho_ch + df_drho_att(i)
513 f_tot(i) = f_fmt + f_ch + f_att(i)
517 IF ( mod(i, outpt) == 0 )
write(*,
'(i7,2(G15.6))') i,rhop(i), my0 - df_drho_tot(i)
530 rhop(i) = rhop(i) * exp( my0 - df_drho_tot(i) )
531 rhop(i) = rhop_o(i) + (rhop(i)-rhop_o(i))*damppic
532 dev = dev + (rhop(i)-rhop_o(i))**2
541 delta_f = f_tot(i) + rhop(i)*(log(rhop(i)/parame(1,2)**3 )-1.0) - (rhop(i)*my0 - pbulk)
543 free = free + delta_f*dzp
545 surftens(kk) = kbol * t *1.e20*1000.0 *free / parame(1,2)**2
551 st_macro(kk) = surftens(kk) / ( 1.0 + 3.0/8.0/pi *t/tc &
552 * (1.0/2.55)**2 / (0.0674*parame(1,1)+0.0045) )
556 IF ( kk > 1 ) delta_st = abs( surftens(kk)-surftens(kk-1) ) / surftens(kk)
558 WRITE (*,*)
'-----------------------------------------------------------' 559 WRITE (*,*)
' # error-sum intrinsic ST total ST' 560 WRITE (*,
'(i4,3F16.8)') kk, dev, surftens(kk), st_macro(kk)
561 WRITE (*,*)
'-----------------------------------------------------------' 562 WRITE (71,
'(i4,4G18.8)') kk, dev, surftens(kk), st_macro(kk)
569 IF ( dev < maxdev .OR. delta_st < 1.e-8 )
THEN 570 EXIT dft_convergence_loop
572 IF ( kk > maxiter )
THEN 573 WRITE(*,*)
' no convergence in ',maxiter,
' steps' 574 EXIT dft_convergence_loop
578 ENDDO dft_convergence_loop
583 WRITE(68,
'(i2,6f18.8)') 0, zp(0)-zp(int(discret/2)), rhop(0), t, &
584 val_conv(4)/1.e5, density(1), density(2)
586 IF ( mod(i, outpt) == 0 )
WRITE (68,
'(i6,3(f18.12))') i,zp(i)-zp(int(discret/2)), &
587 rhop(i), -( df_drho_tot(i)-my0 )
598 WRITE (*,*)
'SUMMARY FOR A SINGLE TEMPERATURE' 600 WRITE (*,*)
'Temp. [K], Pressure [bar] ',t,val_conv(4)/1.e5
601 WRITE (*,*)
'Critical point Temp., Press. ',tc,pc/1.e5
602 WRITE (*,*)
'Density [kg/m**3] ',density(1),density(2)
603 WRITE (*,*)
'Dimensionless Density (rho*) ',rhob(1),rhob(2)
604 WRITE (*,*)
'Excess Grand Potential ',free
605 WRITE (*,*)
'Intrinsic Interf. Tension [mN/m] ',surftens(kk-1)
606 WRITE (*,*)
'Macroscop.Interf. Tension [mN/m] ',st_macro(kk-1)
607 WRITE (*,*)
'============================================================' 609 WRITE (69,
'(9(f18.10))') t, val_conv(4)/1.e5, &
610 rhob(1),rhob(2),surftens(kk-1),st_macro(kk-1),free,dev
618 IF ( (t+8.0) <= tc )
THEN 620 IF ( (t+15.0) <= tc ) t = t + 5.0
621 IF ( (t+25.0) <= tc ) t = t + 10.0
622 IF ( (t+45.0) <= tc ) t = t + 20.0
630 z3t_st = pi/6.0 * parame(1,1) * ( 1.0 &
631 *( 1.0 - 0.12*exp(-3.0*parame(1,3)/t) ) )**3
632 d_hs = ( 1.0 - 0.12*exp(-3.0*parame(1,3)/t) )
634 CALL rdf_matrix (msegm)
636 EXIT diagram_for_various_t_loop
638 WRITE (69,
'(7(f18.10))') tc, pc/1.e5, rhoc, rhoc, 0., 0., 0.
640 EXIT diagram_for_various_t_loop
643 ENDDO diagram_for_various_t_loop
645 END SUBROUTINE dft_nmft2
654 SUBROUTINE cutoff_corrections ( i, irc, rhop, rhob, f_int_z, mu_int_z, f_int2_z, mu_int2_z )
660 INTEGER,
INTENT(IN) :: i
661 INTEGER,
INTENT(IN) :: irc
662 REAL,
DIMENSION(-NDFT:NDFT),
INTENT(IN) :: rhop
663 REAL,
DIMENSION(2),
INTENT(IN) :: rhob
664 REAL,
INTENT(IN OUT) :: f_int_z, f_int2_z
665 REAL,
INTENT(IN OUT) :: mu_int_z, mu_int2_z
668 REAL :: cutoffz, cutoffz2, rhotemp
671 cutoffz = 4.0/90.0 * rc**-9 - 1.0/3.0 * rc**-3
672 cutoffz2 = 16.0/22.0/21.0 * rc**-21 - 2.0/15.0 * rc**-15 + 16.0/90.0 * rc**-9
673 IF ( abs( rhop(i+irc)-rhob(2) ) > 1.e-5 )
THEN 674 rhotemp = rhop(i+irc)
676 f_int_z = f_int_z + rhotemp*cutoffz
677 mu_int_z = mu_int_z + rhotemp*cutoffz
678 f_int2_z = f_int2_z + cutoffz2
679 mu_int2_z= mu_int2_z+ cutoffz2
681 f_int_z = f_int_z + rhob(2)*cutoffz
682 mu_int_z = mu_int_z + rhob(2)*cutoffz
683 f_int2_z = f_int2_z + cutoffz2
684 mu_int2_z= mu_int2_z+ cutoffz2
686 IF ( abs( rhop(i-irc)-rhob(1) ) > 1.e-3 )
THEN 687 rhotemp = rhop(i-irc)
689 f_int_z = f_int_z + rhotemp*cutoffz
690 mu_int_z = mu_int_z + rhotemp*cutoffz
691 f_int2_z = f_int2_z + cutoffz2
692 mu_int2_z= mu_int2_z+ cutoffz2
694 f_int_z = f_int_z + rhob(1)*cutoffz
695 mu_int_z = mu_int_z + rhob(1)*cutoffz
696 f_int2_z = f_int2_z + cutoffz2
697 mu_int2_z= mu_int2_z+ cutoffz2
700 END SUBROUTINE cutoff_corrections
707 SUBROUTINE aux_chain (discret,fa,dzp,d_hs,zp,rhop,rhobar,lambda)
714 INTEGER,
INTENT(IN) :: discret
715 INTEGER,
INTENT(IN) :: fa
716 REAL,
INTENT(IN) :: dzp
717 REAL,
INTENT(IN) :: d_hs
718 REAL,
INTENT(IN) :: zp(-ndft:ndft)
719 REAL,
INTENT(IN) :: rhop(-ndft:ndft)
720 REAL,
INTENT(OUT) :: rhobar(-ndft:ndft)
721 REAL,
INTENT(OUT) ::
lambda(-ndft:ndft)
725 REAL :: int1, int2, zz1, xl, xh, dz = 0.0
726 REAL,
DIMENSION(100) :: y2, rx, ry1, ry2
746 DO i = (-fa), (discret+fa)
748 DO j = (i-fa), (i+fa)
749 IF ( zp(j+1) > (zp(i)-d_hs).AND.(zp(i)-d_hs) >= zp(j) )
THEN 750 dz = zp(j+1) - (zp(i)-d_hs)
753 ry2(1) = 0.5/d_hs*rhop(j) + ((zp(i)-d_hs)-zp(j))/dzp &
754 *( 0.5/d_hs*rhop(j+1) - 0.5/d_hs*rhop(j) )
755 ELSE IF ( zp(j) > (zp(i)-d_hs) .AND. zp(j) <= (zp(i)+d_hs) )
THEN 756 zz1 = abs( zp(j)-zp(i) )
758 ry1(nn) = 0.75/d_hs**3 * rhop(j) * (d_hs**2 -zz1*zz1)
759 ry2(nn) = 0.5/d_hs * rhop(j)
760 rx(nn) = rx(nn-1) + dz
762 IF ( (zp(i)+d_hs) < zp(j+1) )
THEN 763 dz = (zp(i)+d_hs) - zp(j)
765 rx(nn) = rx(nn-1) + dz
767 ry2(nn) = 0.5/d_hs*rhop(j) + ((zp(i)+d_hs)-zp(j))/dzp &
768 *( 0.5/d_hs*rhop(j+1) - 0.5/d_hs*rhop(j) )
774 CALL spline ( rx, ry1, nn, 1.e30, 1.e30, y2 )
775 CALL splint_integral ( rx, ry1, y2, nn, xl, xh, int1 )
777 CALL spline ( rx, ry2, nn, 1.e30, 1.e30, y2 )
778 CALL splint_integral ( rx, ry2, y2, nn, xl, xh, int2 )
782 END SUBROUTINE aux_chain
790 SUBROUTINE fmt_dens ( discret, fa, dzp, d_hs, zp, rhop, ni, &
791 phi_dn0, phi_dn1, phi_dn2, phi_dn3, phi_dn4, phi_dn5 )
799 INTEGER,
INTENT(IN OUT) :: discret
800 INTEGER,
INTENT(IN) :: fa
801 REAL,
INTENT(IN) :: dzp
802 REAL,
INTENT(IN) :: d_hs
803 REAL,
INTENT(IN) :: zp(-ndft:ndft)
804 REAL,
INTENT(IN) :: rhop(-ndft:ndft)
805 REAL,
INTENT(OUT) :: ni(0:5,-ndft:ndft)
806 REAL,
INTENT(OUT) :: phi_dn0(-ndft:ndft)
807 REAL,
INTENT(OUT) :: phi_dn1(-ndft:ndft)
808 REAL,
INTENT(OUT) :: phi_dn2(-ndft:ndft)
809 REAL,
INTENT(OUT) :: phi_dn3(-ndft:ndft)
810 REAL,
INTENT(OUT) :: phi_dn4(-ndft:ndft)
811 REAL,
INTENT(OUT) :: phi_dn5(-ndft:ndft)
815 REAL :: int2, int3, int5
816 REAL :: zz1, zs, d2, xl, xh, dz = 0.0
817 REAL,
DIMENSION(100) :: y2, hx, hy2, hy3, hy5
820 DO i = (-fa), (discret+fa)
823 DO j = (i-fa/2), (i+fa/2)
824 IF ( zp(j+1) > (zp(i)-d2) .AND. (zp(i)-d2) >= zp(j) )
THEN 825 dz = zp(j+1) - (zp(i)-d2)
827 hy2(1) = rhop(j) *parame(1,1) + ((zp(i)-d2)-zp(j))/dzp &
828 * ( rhop(j+1)*parame(1,1) - rhop(j)*parame(1,1) )
830 hy5(1) = rhop(j)*parame(1,1)*(zp(j)-zp(i)) +((zp(i)-d2)-zp(j))/dzp &
831 * ( rhop(j+1)*parame(1,1)*(zp(j+1)-zp(i)) &
832 - rhop(j) *parame(1,1)*(zp(j)-zp(i)) )
833 ELSE IF ( zp(j) > (zp(i)-d2) .AND. zp(j) <= (zp(i)+d2) )
THEN 836 hy2(nn) = rhop(j)*parame(1,1)
837 hy3(nn) = rhop(j)*parame(1,1) * ( d2**2 - zz1**2 )
838 hy5(nn) = rhop(j)*parame(1,1) * zz1
839 hx(nn) = hx(nn-1) + dz
841 IF ( (zp(i)+d2) < zp(j+1) )
THEN 842 dz = (zp(i)+d2) - zp(j)
844 hy2(nn) = rhop(j)*parame(1,1) + ((zp(i)+d2)-zp(j))/dzp &
845 * ( rhop(j+1)*parame(1,1) - rhop(j)*parame(1,1) )
847 hy5(nn) = rhop(j)*parame(1,1)*(zp(j)-zp(i)) +((zp(i)+d2)-zp(j))/dzp &
848 * ( rhop(j+1)*parame(1,1)*(zp(j+1)-zp(i)) &
849 - rhop(j)*parame(1,1)*(zp(j) -zp(i)) )
850 hx(nn) = hx(nn-1) + dz
856 CALL spline ( hx, hy2, nn, 1.e30, 1.e30, y2 )
857 CALL splint_integral ( hx, hy2, y2, nn, xl, xh, int2 )
858 CALL spline ( hx, hy3, nn, 1.e30, 1.e30, y2 )
859 CALL splint_integral ( hx, hy3, y2, nn, xl, xh, int3 )
860 CALL spline ( hx, hy5, nn, 1.e30, 1.e30, y2 )
861 CALL splint_integral ( hx, hy5, y2, nn, xl, xh, int5 )
862 ni(2,i) = pi * d_hs *int2
864 ni(5,i) = 2.0* pi *int5
865 ni(0,i) = ni(2,i) / (pi*d_hs**2 )
866 ni(1,i) = ni(2,i) / (2.0*pi*d_hs)
867 ni(4,i) = ni(5,i) / (2.0*pi*d_hs)
871 DO i = (-fa), (discret+fa)
873 phi_dn0(i) = - log(zs)
874 phi_dn1(i) = ni(2,i)/zs
875 phi_dn2(i) = ni(1,i)/zs + 3.0*(ni(2,i)*ni(2,i) - ni(5,i)*ni(5,i)) &
876 * (ni(3,i)+zs*zs*log(zs))/(36.0*pi*ni(3,i)*ni(3,i)*zs*zs)
877 phi_dn3(i) = ni(0,i)/zs + (ni(1,i)*ni(2,i)-ni(4,i)*ni(5,i))/zs/zs &
878 - (ni(2,i)**3 - 3.0*ni(2,i)*ni(5,i)*ni(5,i)) &
879 *( ni(3,i)*(ni(3,i)*ni(3,i)-5.0*ni(3,i)+2.0) &
880 + 2.0*zs**3 *log(zs) ) / ( 36.0*pi*(ni(3,i)*zs)**3 )
881 phi_dn4(i) = - ni(5,i)/zs
882 phi_dn5(i) = - ni(4,i)/zs - 6.0*ni(2,i)*ni(5,i) &
883 * (ni(3,i)+zs*zs*log(zs))/(36.0*pi*ni(3,i)*ni(3,i)*zs*zs)
886 END SUBROUTINE fmt_dens
893 SUBROUTINE df_fmt_dr ( i, fa, dzp, d_hs, zp, phi_dn0, &
894 phi_dn1, phi_dn2, phi_dn3, phi_dn4, phi_dn5, dF_drho_fmt )
902 INTEGER,
INTENT(IN) :: i
903 INTEGER,
INTENT(IN) :: fa
904 REAL,
INTENT(IN) :: dzp
905 REAL,
INTENT(IN) :: d_hs
906 REAL,
INTENT(IN) :: zp(-ndft:ndft)
907 REAL,
INTENT(IN) :: phi_dn0(-ndft:ndft)
908 REAL,
INTENT(IN) :: phi_dn1(-ndft:ndft)
909 REAL,
INTENT(IN) :: phi_dn2(-ndft:ndft)
910 REAL,
INTENT(IN) :: phi_dn3(-ndft:ndft)
911 REAL,
INTENT(IN) :: phi_dn4(-ndft:ndft)
912 REAL,
INTENT(IN) :: phi_dn5(-ndft:ndft)
913 REAL,
INTENT(OUT) :: df_drho_fmt
917 REAL :: int0, int1, int2, int3, int4, int5
918 REAL :: zz1, d2, xl, xh, dz = 0.0
919 REAL,
DIMENSION(100) :: y2, hx, hy0, hy1, hy2, hy3, hy4, hy5
925 DO j = (i-fa/2), (i+fa/2)
926 IF ( zp(j+1) > (zp(i)-d2).AND.(zp(i)-d2) >= zp(j) )
THEN 928 hy0(1) = phi_dn0(j) + ((zp(i)-d2)-zp(j))/dzp *( phi_dn0(j+1) - phi_dn0(j) )
929 hy1(1) = phi_dn1(j) + ((zp(i)-d2)-zp(j))/dzp *( phi_dn1(j+1) - phi_dn1(j) )
930 hy2(1) = phi_dn2(j) + ((zp(i)-d2)-zp(j))/dzp *( phi_dn2(j+1) - phi_dn2(j) )
932 hy4(1) = phi_dn4(j)*(zp(j)-zp(i)) +((zp(i)-d2)-zp(j))/dzp &
933 * ( phi_dn4(j+1)*(zp(j+1)-zp(i)) - phi_dn4(j)*(zp(j)-zp(i)) )
934 hy5(1) = phi_dn5(j)*(zp(j)-zp(i)) +((zp(i)-d2)-zp(j))/dzp &
935 * ( phi_dn5(j+1)*(zp(j+1)-zp(i)) - phi_dn5(j)*(zp(j)-zp(i)) )
936 dz = zp(j+1) - (zp(i)-d2)
937 ELSE IF ( zp(j) > (zp(i)-d2).AND.zp(j) <= (zp(i)+d2) )
THEN 943 hy3(nn) = phi_dn3(j) * ( d2**2 -zz1**2 )
944 hy4(nn) = phi_dn4(j) * zz1
945 hy5(nn) = phi_dn5(j) * zz1
946 hx(nn) = hx(nn-1) + dz
948 IF ( (zp(i)+d2) < zp(j+1) )
THEN 949 dz = (zp(i)+d2) - zp(j)
951 hx(nn) = hx(nn-1) + dz
952 hy0(nn) = phi_dn0(j) + ( (zp(i)+d2) - zp(j) ) / dzp &
953 * ( phi_dn0(j+1) - phi_dn0(j) )
954 hy1(nn) = phi_dn1(j) + ( (zp(i)+d2) - zp(j) ) / dzp &
955 * ( phi_dn1(j+1) - phi_dn1(j) )
956 hy2(nn) = phi_dn2(j) + ( (zp(i)+d2) - zp(j) ) / dzp &
957 * ( phi_dn2(j+1) - phi_dn2(j) )
959 hy4(nn) = phi_dn4(j) * (zp(j)-zp(i)) + ((zp(i)+d2)-zp(j)) / dzp &
960 * ( phi_dn4(j+1)*(zp(j+1)-zp(i)) -phi_dn4(j)*(zp(j)-zp(i)) )
961 hy5(nn) = phi_dn5(j) * (zp(j)-zp(i)) + ((zp(i)+d2)-zp(j))/dzp &
962 * ( phi_dn5(j+1)*(zp(j+1)-zp(i)) -phi_dn5(j)*(zp(j)-zp(i)) )
968 CALL spline ( hx, hy0, nn, 1.e30, 1.e30, y2 )
969 CALL splint_integral( hx, hy0, y2, nn, xl, xh, int0 )
970 CALL spline ( hx, hy1, nn, 1.e30, 1.e30, y2 )
971 CALL splint_integral( hx, hy1, y2, nn, xl, xh, int1 )
972 CALL spline ( hx, hy2, nn, 1.e30, 1.e30, y2 )
973 CALL splint_integral( hx, hy2, y2, nn ,xl, xh, int2 )
974 CALL spline ( hx, hy3, nn, 1.e30, 1.e30, y2 )
975 CALL splint_integral( hx, hy3, y2, nn, xl, xh, int3 )
976 CALL spline ( hx, hy4, nn, 1.e30, 1.e30, y2 )
977 CALL splint_integral( hx, hy4, y2, nn, xl, xh, int4 )
978 CALL spline ( hx, hy5, nn, 1.e30, 1.e30, y2 )
979 CALL splint_integral( hx, hy5, y2, nn, xl, xh, int5 )
990 int2 = pi * d_hs * int2
993 int5 = 2.0 * pi * int5
995 df_drho_fmt = (int0+int1+int2+int3+int4+int5)*parame(1,1)
997 END SUBROUTINE df_fmt_dr
1004 SUBROUTINE df_chain_dr ( i, fa, dzp, d_hs, zp, rhop, lambda, &
1005 rhobar, z3t_st, f_ch, dF_drho_ch )
1013 INTEGER,
INTENT(IN) :: i
1015 REAL,
INTENT(IN) :: dzp
1016 REAL,
INTENT(IN) :: d_hs
1017 REAL,
INTENT(IN) :: zp(-ndft:ndft)
1018 REAL,
INTENT(IN) :: rhop(-ndft:ndft)
1019 REAL,
INTENT(IN) ::
lambda(-ndft:ndft)
1020 REAL,
INTENT(IN) :: rhobar(-ndft:ndft)
1021 REAL,
INTENT(IN OUT) :: z3t_st
1022 REAL,
INTENT(OUT) :: f_ch
1023 REAL,
INTENT(OUT) :: df_drho_ch
1027 REAL :: zz1, xl, xh, dz=0.0
1028 REAL,
DIMENSION(100) :: y2, hx, hy0, hy1
1029 REAL :: ycorr, dlnydr, i_ch1, i_ch2
1034 DO j = (i-fa), (i+fa)
1035 IF ( zp(j+1) > (zp(i)-d_hs) .AND. zp(j)-1.e-11 <= (zp(i)-d_hs) )
THEN 1036 dz = zp(j+1) - (zp(i)-d_hs)
1039 hy1(1) = 0.5/d_hs*rhop(j)/
lambda(j) + ((zp(i)-d_hs)-zp(j))/dzp &
1040 * ( 0.5/d_hs*rhop(j+1)/
lambda(j+1) - 0.5/d_hs*rhop(j)/
lambda(j) )
1041 ELSE IF ( zp(j) > (zp(i)-d_hs).AND.zp(j)+1.e-11 < (zp(i)+d_hs) )
THEN 1044 CALL cavity ( d_hs, z3t_st, rhobar(j), ycorr, dlnydr )
1045 hy0(nn) = 0.75/d_hs**3 *rhop(j)*dlnydr*(d_hs*d_hs-zz1*zz1)
1046 hy1(nn) = 0.5/d_hs*rhop(j)/
lambda(j)
1047 hx(nn) = hx(nn-1) + dz
1049 IF ( zp(j+1)+1.e-11 >= (zp(i)+d_hs) )
THEN 1050 dz = (zp(i)+d_hs) - zp(j)
1053 hy1(nn) = 0.5/d_hs*rhop(j)/
lambda(j) +((zp(i)+d_hs)-zp(j))/dzp &
1054 * ( 0.5/d_hs*rhop(j+1)/
lambda(j+1)-0.5/d_hs*rhop(j)/
lambda(j) )
1055 hx(nn) = hx(nn-1) + dz
1061 CALL spline ( hx, hy0, nn, 1.e30, 1.e30, y2 )
1062 CALL splint_integral( hx, hy0, y2, nn, xl, xh, i_ch1 )
1063 CALL spline ( hx, hy1, nn, 1.e30, 1.e30, y2 )
1064 CALL splint_integral( hx, hy1, y2, nn, xl, xh, i_ch2 )
1079 CALL cavity ( d_hs, z3t_st, rhobar(i), ycorr, dlnydr )
1080 f_ch = rhop(i) * ( log(ycorr*
lambda(i)) -1.0 )
1081 f_ch = - ( parame(1,1) - 1.0 ) * f_ch
1082 f_ch = f_ch + ( parame(1,1) - 1.0 ) * rhop(i) * ( log(rhop(i)) - 1.0 )
1083 df_drho_ch= log( ycorr*
lambda(i) ) - 1.0 + i_ch1 + i_ch2
1084 df_drho_ch= - ( parame(1,1) - 1.0 ) * df_drho_ch
1085 df_drho_ch= df_drho_ch + ( parame(1,1) - 1.0 ) * log(rhop(i))
1087 END SUBROUTINE df_chain_dr
1094 SUBROUTINE cavity ( d_hs, z3t_st, rho, ycorr, dlnydr )
1101 REAL,
INTENT(IN) :: d_hs
1102 REAL,
INTENT(IN) :: z3t_st
1103 REAL,
INTENT(IN) :: rho
1104 REAL,
INTENT(OUT) :: ycorr
1105 REAL,
INTENT(OUT) :: dlnydr
1109 REAL :: z0, z1, z2, z3, zms
1110 REAL,
DIMENSION(nc,nc) :: dij_ab, gij, dgijdz
1120 z0 = pi / 6.0 * rho * parame(1,1)
1121 z1 = pi / 6.0 * rho * parame(1,1) * d_hs
1122 z2 = pi / 6.0 * rho * parame(1,1) * d_hs**2
1123 z3 = pi / 6.0 * rho * parame(1,1) * d_hs**3
1131 dij_ab(1,1) = d_hs / 2.0
1135 gij(i,j) = 1.0/zms + 3.0*dij_ab(i,j)*z2/zms/zms &
1136 + 2.0*(dij_ab(i,j)*z2)**2 /zms**3
1137 dgijdz(i,j)= 1.0/zms/zms + 3.0*dij_ab(i,j)*z2*(1.0+z3)/z3/zms**3 &
1138 + (dij_ab(i,j)*z2/zms/zms)**2 *(4.0+2.0*z3)/z3
1143 dlnydr = dgijdz(1,1) / gij(1,1) * z3t_st
1145 END SUBROUTINE cavity
1157 Module dft_inversion
1162 INTEGER :: no_step_l, no_step_h
1163 REAL :: mu_eta_div, den_min, den_max, den_div
1164 REAL,
DIMENSION(200) :: rho_array1, rho_array2
1165 REAL,
DIMENSION(200) :: mu_rho_array1, mu_rho_array2
1167 End Module dft_inversion
1178 SUBROUTINE dens_inv_coeff2 ( rhob )
1187 REAL,
INTENT(IN) :: rhob(2)
1192 REAL :: lnphi(np,nc)
1195 den_min = rhob(2)*z3t_st * 0.8
1196 den_max = rhob(1)*z3t_st * 1.1
1203 IF ( den_min < den_div )
THEN 1205 dense(1) = den_min + (den_div-den_min) *
REAL(i-1)/
REAL(no_step_l-1)
1206 densta(1) = dense(1)
1207 rho_array1(i) = dense(1)
1208 CALL fugacity (lnphi)
1209 mu_rho_array1(i) = exp( lnphi(1,1)+log(dense(1)/z3t_st / parame(1,2)**3 ) )
1211 mu_eta_div = mu_rho_array1(no_step_l)
1214 den_st = max( den_min, den_div )
1216 dense(1) = den_st + (den_max-den_st) *
REAL(i-1)/
REAL(no_step_h-1)
1217 densta(1) = dense(1)
1218 rho_array2(i) = dense(1)
1219 CALL fugacity (lnphi)
1220 mu_rho_array2(i) = lnphi(1,1) + log(dense(1)/z3t_st /parame(1,2)**3 )
1222 IF ( (mu_rho_array2(i)- mu_rho_array2(i-1)) < 0.0 )
THEN 1223 call paus (
'DENS_INV_COEFF2: derivative negative')
1228 END SUBROUTINE dens_inv_coeff2
1238 REAL FUNCTION dens_invers2 ( rhob, mu_rho )
1245 REAL,
INTENT(IN) :: rhob(2)
1246 REAL,
INTENT(IN OUT) :: mu_rho
1251 LOGICAL :: flag_exit
1261 IF ( exp(mu_rho) < mu_eta_div )
THEN 1264 DO WHILE (i < no_step_l .AND. .NOT. flag_exit)
1266 IF ( mu_rho_array1(i) > exp(mu_rho) )
THEN 1267 eta_i = rho_array1(i-1)+(rho_array1(i)-rho_array1(i-1)) &
1268 /(mu_rho_array1(i)-mu_rho_array1(i-1)) &
1269 *(exp(mu_rho)-mu_rho_array1(i-1))
1270 dens_invers2 = eta_i/z3t_st
1274 IF ( .NOT. flag_exit )
WRITE (*,*)
'error 1', exp(mu_rho), mu_eta_div
1278 IF ( exp(mu_rho) >= mu_eta_div )
THEN 1281 DO WHILE (i < no_step_h .AND. .NOT. flag_exit )
1283 IF ( mu_rho_array2(i) > mu_rho )
THEN 1284 eta_i = rho_array2(i-1)+(rho_array2(i)-rho_array2(i-1)) &
1285 /(mu_rho_array2(i)-mu_rho_array2(i-1)) *(mu_rho-mu_rho_array2(i-1))
1286 dens_invers2 = eta_i/z3t_st
1290 IF ( .NOT. flag_exit )
WRITE (*,*)
'error 2', mu_rho, mu_eta_div
1294 IF ( dens_invers2 < (rhob(2)*0.8) )
THEN 1295 WRITE (*,*)
'lower bound', dens_invers2, mu_rho
1296 dens_invers2 = rhob(2) * 0.8
1298 IF ( dens_invers2 > (rhob(1)*1.1) )
THEN 1299 WRITE (*,*)
'upper bound', dens_invers2, mu_rho
1300 dens_invers2 = rhob(1)
1303 END FUNCTION dens_invers2
1321 SUBROUTINE spline ( x, y, n, yp1, ypn, y2 )
1326 INTEGER,
INTENT(IN) :: n
1327 REAL,
INTENT(IN) :: x(n)
1328 REAL,
INTENT(IN) :: y(n)
1329 REAL,
INTENT(IN) :: yp1
1330 REAL,
INTENT(IN) :: ypn
1331 REAL,
INTENT(OUT) :: y2(n)
1334 INTEGER,
PARAMETER :: nmax = 500
1336 REAL :: p, qn,
sig, un, u(nmax)
1339 IF ( yp1 > 0.99e30 )
THEN 1344 u(1) = ( 3.0/(x(2)-x(1)) ) * ( (y(2)-y(1))/(x(2)-x(1))-yp1 )
1347 IF ( (x(i+1)-x(i)) == 0.0 .OR. (x(i)-x(i-1)) == 0.0 .OR. (x(i+1)-x(i-1)) == 0.0 )
THEN 1348 write (*,*)
'error in spline-interpolation' 1351 sig = (x(i)-x(i-1)) / (x(i+1)-x(i-1))
1352 p =
sig*y2(i-1) + 2.0
1353 y2(i) = (
sig-1.0) / p
1354 u(i) = ( 6.0 * ((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1))/(x(i)-x(i-1))) / (x(i+1)-x(i-1)) &
1355 -
sig * u(i-1) ) / p
1357 IF ( ypn > 0.99e30 )
THEN 1362 un = (3.0/(x(n)-x(n-1))) * (ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
1364 y2(n) = (un-qn*u(n-1)) / (qn*y2(n-1)+1.0)
1366 y2(k) = y2(k) * y2(k+1) + u(k)
1369 END SUBROUTINE spline
1381 SUBROUTINE splint ( xa, ya, y2a, n, x, y )
1387 INTEGER,
INTENT(IN) :: n
1388 REAL,
INTENT(IN) :: xa(n)
1389 REAL,
INTENT(IN) :: ya(n)
1390 REAL,
INTENT(IN) :: y2a(n)
1391 REAL,
INTENT(IN OUT) :: x
1392 REAL,
INTENT(OUT) :: y
1395 INTEGER :: k, khi, klo
1401 1
IF ( khi-klo > 1 )
THEN 1402 k = ( khi + klo ) / 2
1403 IF ( xa(k) > x )
THEN 1410 h = xa(khi) - xa(klo)
1411 IF ( h == 0.0 )
call paus (
'bad xa input in splint')
1412 a = ( xa(khi) - x ) / h
1413 b = ( x - xa(klo) ) / h
1414 y = a*ya(klo) + b*ya(khi) + ( (a**3-a)*y2a(klo)+(b**3-b)*y2a(khi) )*h**2 / 6.0
1416 END SUBROUTINE splint
1428 SUBROUTINE splint_integral ( xa, ya, y2a, n, xlo, xhi, integral )
1434 INTEGER,
INTENT(IN) :: n
1435 REAL,
INTENT(IN) :: xa(n)
1436 REAL,
INTENT(IN) :: ya(n)
1437 REAL,
INTENT(IN) :: y2a(n)
1438 REAL,
INTENT(IN) :: xlo
1439 REAL,
INTENT(IN) :: xhi
1440 REAL,
INTENT(OUT) :: integral
1443 INTEGER :: k, khi_l, klo_l, khi_h, klo_h
1444 REAL :: xl, xh = 0.0
1445 REAL :: h, int, x0, x1, y0, y1, y20, y21
1451 do while ( khi_l-klo_l > 1 )
1452 k = ( khi_l + klo_l ) / 2
1453 IF ( xa(k) > xlo )
THEN 1463 do while ( khi_h-klo_h > 1 )
1464 k = ( khi_h + klo_h ) / 2
1465 IF ( xa(k) > xhi )
THEN 1478 IF ( khi_h > khi_l )
THEN 1480 ELSE IF ( khi_h == khi_l )
THEN 1483 call paus (
'error in spline-integration')
1486 h = xa(khi_l) - xa(klo_l)
1487 IF ( h == 0.0 )
call paus (
'bad xa input in splint')
1504 int = -1.0/h * ( xl*((x1-.5*xl)*y0 + (0.5*xl-x0)*y1) &
1505 -y20/24.*(x1-xl)**4 + y20/6.*(0.5*xl*xl-x1*xl)*h*h &
1506 +y21/24.*(xl-x0)**4 - y21/6.*(0.5*xl*xl-x0*xl)*h*h )
1507 int = int + 1.0/h * ( xh*((x1-.5*xh)*y0 + (0.5*xh-x0)*y1) &
1508 -y20/24.*(x1-xh)**4 + y20/6.*(0.5*xh*xh-x1*xh)*h*h &
1509 +y21/24.*(xh-x0)**4 - y21/6.*(0.5*xh*xh-x0*xh)*h*h )
1511 integral = integral + int
1516 IF (khi_h /= (khi_l-1))
GO TO 3
1518 END SUBROUTINE splint_integral
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains constant...
double lambda
Latent heat of blowing agent, J/kg.
double sig
correlated to variance of initial distribution
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW Module DFT_MODULE This module...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...