33 SUBROUTINE dft_nmft_units
40 use eos_polar
, only: f_polar, phi_polar
46 INTEGER :: i, j, kk, converg
47 INTEGER :: discret, fa, outpt, irc, maxiter, ih
49 REAL,
DIMENSION(-NDFT:NDFT) :: zp, rhop, rhop_o
50 REAL,
DIMENSION(-NDFT:NDFT) :: df_drho_tot, f_tot
51 REAL,
DIMENSION(-NDFT:NDFT) :: df_drho_att, f_att
52 REAL,
DIMENSION(2) :: rhob
53 REAL :: f_disp_1pt, f_disp_pcsaft
54 REAL :: mu_disp_1pt, mu_disp_pcsaft
55 REAL :: zges(np), pbulk
56 REAL :: msegm, delta_st, tanhfac
57 REAL :: end_x, steps, my0
58 REAL :: f_int_z, mu_int_z
59 REAL :: f_int_r, mu_int_r
60 REAL :: f_int2_z, mu_int2_z, mu_int3_z
61 REAL :: f_int2_r, mu_int2_r, mu_int3_r
66 REAL :: surftens(0:200), st_macro(200)
67 REAL :: f01, f02, f03, f04, f05
68 REAL :: c1_con, c2_con
70 REAL :: tsav, psav, tc, pc, rhoc
71 REAL :: density(np), w(np,nc), lnphi(np,nc)
74 REAL,
DIMENSION(-NDFT:NDFT) ::
lambda, rhobar, phi_dn0, phi_dn1
75 REAL,
DIMENSION(-NDFT:NDFT) :: phi_dn2, phi_dn3, phi_dn4, phi_dn5
76 REAL,
DIMENSION(0:5,-NDFT:NDFT) :: ni
78 REAL :: f_ch, df_drho_ch
79 REAL :: f_fmt, df_drho_fmt
80 REAL :: mu_assoc, f_assoc
81 REAL :: fres_polar, fdd, fqq, fdq
82 REAL :: mu_polar, fdd_rk, fqq_rk, fdq_rk, z3_rk
91 CALL set_default_eos_numerical
102 d_hs = parame(1,2) * ( 1.0 - 0.12*exp( -3.0*parame(1,3)/t ) )
103 dhs_st = d_hs/parame(1,2)
104 z3t_st = pi/6.0* parame(1,1) * d_hs**3
106 IF ( ncomp /= 1 )
THEN 107 write (*,*)
'SPECIFY ONLY ONE COMPONENT IN THE INPUT-FILE:' 108 write (*,*)
' ./input_file/INPUT.INP' 111 OPEN (68,file =
'./output_file/DFT_profiles.xlo')
112 OPEN (69,file =
'./output_file/DFT_sigma.xlo')
113 OPEN (71,file =
'./output_file/DFT_iteration.xlo')
114 OPEN (72,file =
'./output_file/DFT_h.xlo')
129 box_l_no_unit = 160.0
131 dzp = box_l_no_unit /
REAL(discret) 132 fa = nint( parame(1,2) / dzp + 1 )
155 CALL rdf_matrix_units (msegm)
162 diagram_for_various_t_loop:
DO 172 IF ( eos >= 4 ) val_init(4) = 1.e-3
188 DO WHILE ( converg == 0 )
190 CALL phase_equilib( end_x, steps, converg )
191 IF ( converg /= 1 )
THEN 193 val_init(3) = t - 10.0
194 IF ( val_conv(4) /= 0.0 ) val_init(4) = val_conv(4) / 4.0
199 WRITE (*,*)
'no VLE found' 200 IF ( val_init(3) <= 10.0 )
RETURN 205 rhob(1) = dense(1)/z3t_st
206 rhob(2) = dense(2)/z3t_st
207 WRITE (*,*)
'temperature ',t,p/1.e5
208 WRITE (*,*)
'densities ',rhob(1), rhob(2)
209 WRITE (*,*)
'dense ',dense(1),dense(2)
213 CALL si_dens ( density, w )
220 CALL fugacity (lnphi)
221 my0 = lnphi(1,1) + log( rhob(1) )
222 zges(1) = p / ( rgas*t*density(1) ) * mm(1)/1000.0
223 zges(2) = p / ( rgas*t*density(2) ) * mm(1)/1000.0
225 pbulk = zges(1) * rhob(1)
226 WRITE (*,*)
'chem. potentials', lnphi(1,1) + log( rhob(1) ), &
227 lnphi(2,1) + log( rhob(2) )
230 IF (num == 2)
WRITE (*,*)
'enter an estimate for crit. temp.' 231 IF (num == 2)
READ (*,*) tc
235 IF ( eos < 4 )
CALL critical (tc,pc,rhoc)
239 WRITE (*,
'(a,3(f16.4))')
'critical point',tc, pc/1.e5, rhoc
245 CALL perturbation_parameter
258 irc = nint(rc*parame(1,2)/dzp) + 1
259 tanhfac = -2.3625*t/tc + 2.4728
261 DO i = -irc, (discret+irc)
262 zp(i) =
REAL(i) * dzp
264 DO i = -irc, (discret+irc)
265 rhop(i) = tanh(-(zp(i)-zp(int(discret/2))) / parame(1,2) *tanhfac) * (rhob(1)-rhob(2))/2.0 &
266 + (rhob(1)+rhob(2))/2.0
288 dft_convergence_loop:
DO 294 CALL aux_chain ( discret, fa, dzp, d_hs, zp, rhop, rhobar,
lambda )
296 CALL fmt_dens ( discret, fa, dzp, d_hs, zp, rhop, ni, &
297 phi_dn0, phi_dn1, phi_dn2, phi_dn3, phi_dn4, phi_dn5 )
312 f_fmt = - ni(0,i)*log(zs) + ni(1,i)*ni(2,i)/zs - ni(4,i)*ni(5,i)/zs &
313 + (ni(2,i)**3 -3.0*ni(2,i)*ni(5,i)*ni(5,i)) *(ni(3,i)+zs*zs*log(zs)) &
314 /36.0/pi/zs/zs/ni(3,i)**2
316 CALL df_fmt_dr ( i, fa, dzp, d_hs, zp, phi_dn0, &
317 phi_dn1, phi_dn2, phi_dn3, phi_dn4, phi_dn5, df_drho_fmt )
323 CALL df_chain_dr ( i, fa, dzp, d_hs, zp, rhop,
lambda, &
324 rhobar, z3t_st, f_ch, df_drho_ch )
340 DO j = (i-irc), (i+irc)
341 zz1 = abs( zp(j) - zp(i) )
343 IF ( zz1 < rc*parame(1,2) )
THEN 344 IF ( zz1 >= rc*parame(1,2) - dzp ) dz_local = rc*parame(1,2) - zz1
345 CALL dft_rad_int_units ( i, j, ih, zz1, rhop, f_int_r, mu_int_r, &
346 f_int2_r, mu_int2_r, mu_int3_r )
355 f_int_z = f_int_z + dz_local * (rhop(j)* f_int_r + f01)/2.0
356 mu_int_z = mu_int_z + dz_local * (rhop(j)*mu_int_r + f02)/2.0
357 f_int2_z = f_int2_z + dz_local * ( f_int2_r + f03)/2.0
358 mu_int2_z= mu_int2_z+ dz_local * (mu_int2_r + f04)/2.0
359 mu_int3_z= mu_int3_z+ dz_local * (mu_int3_r + f05)/2.0
360 f01 = rhop(j)* f_int_r
361 f02 = rhop(j)* mu_int_r
372 CALL cutoff_corrections_units ( i, irc, rhop, rhob, f_int_z, mu_int_z, f_int2_z, mu_int2_z )
379 z3 = rhop(i) * z3t_st
381 c1_con= 1.0/ ( 1.0 + parame(1,1)*(8.0*z3-2.0*z3**2 )/zms**4 &
382 + (1.0 - parame(1,1))*(20.0*z3-27.0*z3**2 &
383 + 12.0*z3**3 -2.0*z3**4 ) /(zms*(2.0-z3))**2 )
384 c2_con= - c1_con*c1_con &
385 * ( parame(1,1)*(-4.0*z3**2 +20.0*z3+8.0)/zms**5 &
386 + (1.0 - parame(1,1)) *(2.0*z3**3 +12.0*z3**2 -48.0*z3+40.0) &
387 / (zms*(2.0-z3))**3 )
388 mu_int2_z = mu_int2_z /4.0 * ( 2.0*rhop(i)*c1_con + rhop(i)*z3*c2_con )
389 mu_int3_z = mu_int3_z /4.0 *rhop(i)*rhop(i)*c1_con
390 f_int2_z = f_int2_z /4.0 *rhop(i)*rhop(i)*c1_con
419 df_drho_att(i) = 2.0*pi*parame(1,1)**2 * parame(1,3)/t * mu_int_z
420 f_att(i) = pi*parame(1,1)**2 *parame(1,3)/t*rhop(i)*f_int_z
424 IF (subtract1 ==
'2PT')
THEN 425 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)
426 f_att(i) = f_att(i) -2.0*pi*parame(1,1)**3 *(parame(1,3)/t)**2 *f_int2_z
437 dense(1) = rhop(i) * z3t_st
442 call only_one_term_eos_numerical (
'disp_term',
'PT1 ' )
443 call fugacity ( lnphi )
444 call restore_previous_eos_numerical
445 f_disp_1pt = fres*rhop(i)
446 mu_disp_1pt = lnphi(1,1)
448 call only_one_term_eos_numerical (
'disp_term',
'PC-SAFT ' )
449 call fugacity ( lnphi )
450 call restore_previous_eos_numerical
451 f_disp_pcsaft = fres*rhop(i)
452 mu_disp_pcsaft = lnphi(1,1)
458 call f_polar ( fdd, fqq, fdq )
459 call phi_polar ( 1, z3_rk, fdd_rk, fqq_rk, fdq_rk )
460 fres_polar = ( fdd + fqq + fdq ) * rhop(i)
461 mu_polar = fdd_rk + fqq_rk + fdq_rk
465 IF ( sum( nint(parame(1:ncomp,12)) ) > 0)
THEN 466 call only_one_term_eos_numerical (
'hb_term ',
'TPT1_Chap' )
467 call fugacity ( lnphi )
468 call restore_previous_eos_numerical
469 f_assoc = fres*rhop(i)
470 mu_assoc = lnphi(1,1)
475 df_drho_att(i)= df_drho_att(i) + ( mu_disp_pcsaft - mu_disp_1pt ) + mu_assoc + mu_polar
476 f_att(i) = f_att(i) + ( f_disp_pcsaft - f_disp_1pt ) + f_assoc + fres_polar
488 df_drho_tot(i) = log( rhop(i) ) + df_drho_fmt + df_drho_ch + df_drho_att(i)
489 f_tot(i) = f_fmt + f_ch + f_att(i)
493 IF ( mod(i, outpt) == 0 )
write(*,
'(i7,2(G15.6))') i,rhop(i), my0 - df_drho_tot(i)
506 rhop(i) = rhop(i) * exp( my0 - df_drho_tot(i) )
507 rhop(i) = rhop_o(i) + (rhop(i)-rhop_o(i))*damppic
508 dev = dev + ( (rhop(i)-rhop_o(i))*parame(1,2)**3 )**2
517 f_tot(i) = f_tot(i) + rhop(i)*( log(rhop(i))-1.0 )
518 delta_f = f_tot(i) - (rhop(i)*my0 - pbulk)
519 free = free + delta_f*dzp
521 surftens(kk) = kbol * t *1.e20*1000.0 *free
527 st_macro(kk) = surftens(kk) / ( 1.0 + 3.0/8.0/pi *t/tc &
528 * (1.0/2.55)**2 / (0.0674*parame(1,1)+0.0045) )
532 IF ( kk > 1 ) delta_st = abs( surftens(kk)-surftens(kk-1) ) / surftens(kk)
534 WRITE (*,*)
'-----------------------------------------------------------' 535 WRITE (*,*)
' # error-sum intrinsic ST total ST' 536 WRITE (*,
'(i3,3(F16.8))') kk, dev, surftens(kk), st_macro(kk)
537 WRITE (*,*)
'-----------------------------------------------------------' 538 WRITE (71,
'(i3,4(E18.8))') kk, dev, surftens(kk), st_macro(kk)
545 IF ( dev < maxdev .OR. delta_st < 1.e-8 )
THEN 546 EXIT dft_convergence_loop
548 IF ( kk > maxiter )
THEN 549 WRITE(*,*)
' no convergence in ',maxiter,
' steps' 550 EXIT dft_convergence_loop
554 ENDDO dft_convergence_loop
559 WRITE(68,
'(i3,6(f18.8))') 0, zp(0)-zp(int(discret/2)), rhop(0), t, &
560 val_conv(4)/1.e5, density(1), density(2)
562 IF ( mod(i, outpt) == 0 )
WRITE (68,
'(i6,3(f18.12))') i,zp(i)-zp(int(discret/2)), &
563 rhop(i), -( df_drho_tot(i)-my0 )
574 WRITE (*,*)
'SUMMARY FOR A SINGLE TEMPERATURE' 576 WRITE (*,*)
'Temp. [K], Pressure [bar] ',t,val_conv(4)/1.e5
577 WRITE (*,*)
'Critical point Temp., Press. ',tc,pc/1.e5
578 WRITE (*,*)
'Density [kg/m**3] ',density(1),density(2)
579 WRITE (*,*)
'Dimensionless Density (rho*) ',rhob(1),rhob(2)
580 WRITE (*,*)
'Excess Grand Potential ',free
581 WRITE (*,*)
'Intrinsic Interf. Tension [mN/m] ',surftens(kk-1)
582 WRITE (*,*)
'Macroscop.Interf. Tension [mN/m] ',st_macro(kk-1)
583 WRITE (*,*)
'============================================================' 585 WRITE (69,
'(9(f18.10))') t, val_conv(4)/1.e5, &
586 rhob(1),rhob(2),surftens(kk-1),st_macro(kk-1),free,dev
594 IF ( (t+8.0) <= tc )
THEN 596 IF ( (t+15.0) <= tc ) t = t + 5.0
597 IF ( (t+25.0) <= tc ) t = t + 10.0
598 IF ( (t+45.0) <= tc ) t = t + 20.0
606 d_hs = parame(1,2) * ( 1.0 - 0.12*exp( -3.0*parame(1,3)/t ) )
607 z3t_st = pi/6.0* parame(1,1) * d_hs**3
608 dhs_st = d_hs/parame(1,2)
609 CALL rdf_matrix_units (msegm)
611 EXIT diagram_for_various_t_loop
614 EXIT diagram_for_various_t_loop
617 ENDDO diagram_for_various_t_loop
618 WRITE (69,
'(7(f18.10))') tc, pc/1.e5, rhoc, rhoc, 0., 0., 0.
620 END SUBROUTINE dft_nmft_units
630 SUBROUTINE cutoff_corrections_units ( i, irc, rhop, rhob, f_int_z, mu_int_z, f_int2_z, mu_int2_z )
637 INTEGER,
INTENT(IN) :: i
638 INTEGER,
INTENT(IN) :: irc
639 REAL,
DIMENSION(-NDFT:NDFT),
INTENT(IN) :: rhop
640 REAL,
DIMENSION(2),
INTENT(IN) :: rhob
641 REAL,
INTENT(IN OUT) :: f_int_z, f_int2_z
642 REAL,
INTENT(IN OUT) :: mu_int_z, mu_int2_z
645 REAL :: cutoffz, cutoffz2, rhotemp
648 cutoffz = ( 4.0/90.0 * rc**-9 - 1.0/3.0 * rc**-3 ) * parame(1,2)**3
649 cutoffz2 = ( 16.0/22.0/21.0 * rc**-21 - 2.0/15.0 * rc**-15 + 16.0/90.0 * rc**-9 ) * parame(1,2)**3
650 IF ( abs( rhop(i+irc)-rhob(2) ) > 1.e-5 )
THEN 651 rhotemp = rhop(i+irc)
653 f_int_z = f_int_z + rhotemp*cutoffz
654 mu_int_z = mu_int_z + rhotemp*cutoffz
655 f_int2_z = f_int2_z + cutoffz2
656 mu_int2_z= mu_int2_z+ cutoffz2
658 f_int_z = f_int_z + rhob(2)*cutoffz
659 mu_int_z = mu_int_z + rhob(2)*cutoffz
660 f_int2_z = f_int2_z + cutoffz2
661 mu_int2_z= mu_int2_z+ cutoffz2
663 IF ( abs( rhop(i-irc)-rhob(1) ) > 1.e-3 )
THEN 664 rhotemp = rhop(i-irc)
666 f_int_z = f_int_z + rhotemp*cutoffz
667 mu_int_z = mu_int_z + rhotemp*cutoffz
668 f_int2_z = f_int2_z + cutoffz2
669 mu_int2_z= mu_int2_z+ cutoffz2
671 f_int_z = f_int_z + rhob(1)*cutoffz
672 mu_int_z = mu_int_z + rhob(1)*cutoffz
673 f_int2_z = f_int2_z + cutoffz2
674 mu_int2_z= mu_int2_z+ cutoffz2
677 END SUBROUTINE cutoff_corrections_units
697 SUBROUTINE dft_rad_int_units (i,j,ih,zz_1,rhop,f_int_r,my_int_r, &
698 f_int2_r,my_int2_r,my_int3_r)
705 INTEGER,
INTENT(IN) :: i
706 INTEGER,
INTENT(IN) :: j
707 INTEGER,
INTENT(IN OUT) :: ih
708 REAL,
INTENT(IN) :: zz_1
709 REAL,
INTENT(IN) :: rhop(-ndft:ndft)
710 REAL,
INTENT(OUT) :: f_int_r
711 REAL,
INTENT(OUT) :: my_int_r
712 REAL,
INTENT(OUT) :: f_int2_r
713 REAL,
INTENT(OUT) :: my_int2_r
714 REAL,
INTENT(OUT) :: my_int3_r
722 REAL :: fint0, fint0_2, fint1, fint1_2
723 REAL :: myint0, myint0_2, myint0_3, myint1
724 REAL :: myint1_2, myint1_3
725 REAL :: dg_drho, dg_dr
726 REAL :: rad, xg, rdf, rho_bar, ua, rs
727 REAL :: analytic1, analytic2, tau_rs
733 fint0_2 = rc * tau_cut*tau_cut
734 myint0 = rc * tau_cut
735 myint0_2 = rc * tau_cut*tau_cut
755 IF ( rs > rc )
WRITE (*,*)
'error !!!!' 756 analytic1 = 0.4*rs**-10 - 0.4*rc**-10 - rs**-4 + rc**-4
757 analytic2 = 16.0/22.0 * (rs**-22 - rc**-22 ) - 2.0*rs**-16 +2.0*rc**-16 +1.6*rs**-10 - 1.6*rc**-10
758 f_int_r = f_int_r + analytic1
759 f_int2_r = f_int2_r + analytic2
760 my_int_r = my_int_r + analytic1
761 my_int2_r= my_int2_r+ analytic2
762 IF ( rs == zz1 )
GO TO 10
763 tau_rs = 4.0 * ( rs**-12 - rs**-6 )
765 fint0_2 = rs * tau_rs*tau_rs
767 myint0_2= rs * tau_rs*tau_rs
769 k = 0 + nint( (rc-rs)/dzr )
779 DO WHILE ( rad /= max( 1.0, zz1 ) )
783 IF ( rad - dzr_local <= max( 1.0, zz1 ) )
THEN 784 dzr_local = rad - max( 1.0, zz1 )
785 rad = max( 1.0, zz1 )
787 rad = rad - dzr_local
791 ua = 4.0 * ( rad**-12 -rad**-6 )
793 rho_bar = ( rhop(i) + rhop(j) )/2.0 * sig_ij**3
796 IF ( rad <= rg )
THEN 797 CALL bi_cub_spline (rho_bar,xg,ya,x1a,x2a,y1a,y2a,y12a, &
798 c_bicub,rdf,dg_drho,dg_dr,den_step,ih,k)
799 dg_drho = dg_drho * parame(1,2)**3
802 fint1 = rdf * rad * ua
803 fint1_2 = rdf * rad * ua * ua
804 myint1 = rad * (rdf + 0.5*rhop(i)*dg_drho) * ua
805 myint1_2 = rdf * rad * ua * ua
806 myint1_3 = dg_drho * rad * ua * ua
808 f_int_r = f_int_r + dzr_local * (fint1 + fint0)/2.0
809 f_int2_r = f_int2_r + dzr_local * (fint1_2 + fint0_2)/2.0
810 my_int_r = my_int_r + dzr_local * (myint1 + myint0)/2.0
811 my_int2_r= my_int2_r+ dzr_local * (myint1_2 + myint0_2)/2.0
812 my_int3_r= my_int3_r+ dzr_local * (myint1_3 + myint0_3)/2.0
834 analytic1 = 4.0/10.0*rc**-10 - rc**-4
835 analytic2 = 16.0/22.0*rc**-22 - 2.0*rc**-16 + 1.6*rc**-10
836 f_int_r = f_int_r + analytic1
837 f_int2_r = f_int2_r + analytic2
838 my_int_r = my_int_r + analytic1
839 my_int2_r= my_int2_r+ analytic2
841 f_int_r = f_int_r * sig_ij*sig_ij
842 f_int2_r = f_int2_r * sig_ij*sig_ij
843 my_int_r = my_int_r * sig_ij*sig_ij
844 my_int2_r= my_int2_r* sig_ij*sig_ij
846 END SUBROUTINE dft_rad_int_units
853 SUBROUTINE rdf_matrix_units (msegm)
860 REAL,
INTENT(IN) :: msegm
864 REAL :: rdf, rad, xg, rho_rdf, z3
871 rho_rdf = 1.e-5 + (1.0) *
REAL(i-1) /
REAL(den_step-1) 872 rho_rdf = rho_rdf / msegm
877 do while ( rad - 1.e-8 > 0.95 )
882 z3 = rho_rdf * msegm * pi/6.0 * dhs_st**3
884 IF ( xg <= rg .AND. z3 > 0.0 )
CALL rdf_int ( z3, msegm, xg, rdf )
885 IF ( xg <= rg .AND. z3 > 0.0 ) ya(i,k) = rdf
894 if ( xg > 1.0 ) stop
'rdf_matrix_units: 0.95*sigma is too high for lower bound' 896 WRITE (*,*)
' done with calculating g(r)',dhs_st
899 CALL bicub_derivative ( ya, x1a, x2a, y1a, y2a, y12a, den_step, kmax )
900 CALL bicub_c ( ya, x1a, x2a, y1a, y2a, y12a, c_bicub, den_step, kmax )
902 END SUBROUTINE rdf_matrix_units
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains constant...
double lambda
Latent heat of blowing agent, J/kg.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW Module DFT_MODULE This module...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...