16 #include <finclude/petscsys.h> 17 #include <finclude/petscvec.h> 18 #include <finclude/petscvec.h90> 19 #include <finclude/petscdmda.h> 20 #include <finclude/petscdmda.h90> 21 #include <finclude/petscis.h> 22 #include <finclude/petscsnes.h> 23 #include <finclude/petscsnes.h90> 33 petscscalar,
pointer :: lx_v(:,:),lf_v(:,:)
40 call snesgetdm(snes,da,ierr)
41 call dmgetlocalvector(da,localx,ierr)
42 call dmglobaltolocalbegin(da,x,insert_values, &
44 call dmglobaltolocalend(da,x,insert_values,localx,ierr)
49 call dmdavecgetarrayf90(da,localx,lx_v,ierr)
50 call dmdavecgetarrayf90(da,f,lf_v,ierr)
58 call dmdavecrestorearrayf90(da,localx,lx_v,ierr)
59 call dmdavecrestorearrayf90(da,f,lf_v,ierr)
64 call dmrestorelocalvector(da,localx,ierr)
92 Use basic_variables, Only: ncomp,nc,np ,nphas,xi,dense,parame,ensemble_flag
94 Use mod_dft
, Only: fa,zp,dzp,free,pbulk, fa_disp, ab_disp
95 Use vle_var
, Only: rhob
104 petscscalar rhop(ncomp,user%gxs:user%gxe)
105 petscscalar f(ncomp,user%xs:user%xe)
113 REAL,
dimension(user%gxs:user%gxe) :: n0,n1,n2,n3,nv1,nv2
114 REAL,
dimension(user%gxs:user%gxe) :: phi_dn0,phi_dn1,phi_dn2,phi_dn3,phi_dnv1,phi_dnv2
115 REAL :: f_fmt,temp,zs
116 REAL,
dimension(user%xs:user%xe,ncomp) :: dF_drho_FMT
119 REAL,
dimension(user%gxs:user%gxe,ncomp) :: rhobar,lambda
121 REAL,
dimension(user%xs:user%xe,ncomp) :: dF_drho_CHAIN
124 REAL,
dimension(user%gxs:user%gxe,ncomp) :: rhop_wd,my_disp,df_disp_drk
125 REAL,
dimension(user%gxs:user%gxe) :: f_disp
126 REAL,
dimension(ncomp) :: dF_drho_disp
128 REAL,
DIMENSION(user%gxs:user%gxe,ncomp):: rhoi_disp,mydisp,dadisp_dr
129 REAL,
DIMENSION(user%gxs:user%gxe) :: adisp,rho_disp,rhop_sum
130 REAL :: dF_drho_att(ncomp)
131 INTEGER :: fa_psi_max,WDA_var
135 REAL :: fres_polar,fdd,fqq,fdq,mu_polar(nc)
136 REAL :: fdd_rk, fqq_rk, fdq_rk, z3_rk
141 REAL :: lnphi(np,nc), fres
143 REAL :: f_tot, delta_f
148 Do i= user%xs,user%xe
149 If( rhop(k,i) < epsilon(dhs) ) rhop(k,i) = epsilon(dhs)
153 DO i = user%gxs,user%gxe
154 rhop_sum(i) = sum( rhop(1:ncomp,i) )
160 call fmt_weighted_densities(rhop,n0,n1,n2,n3,nv1,nv2,phi_dn0,phi_dn1,phi_dn2,phi_dn3,phi_dnv1,phi_dnv2,user)
163 call chain_aux(rhop,rhobar,lambda,user)
171 fa_psi_max = maxval(fa_disp(1:ncomp))
172 call rhoi_disp_wd ( ngrid, fa_disp, fa_psi_max, ab_disp, rhop, rhoi_disp,user )
173 CALL a_disp_pcsaft ( ngrid, fa_disp, fa_psi_max, rhoi_disp, rho_disp, adisp, mydisp, dadisp_dr,user )
178 DO i = user%xs,user%xe
181 call fmt_dfdrho(i,fa,user,phi_dn0,phi_dn1,phi_dn2,phi_dn3,phi_dnv1,phi_dnv2,df_drho_fmt)
184 f_fmt = - n0(i)*temp + n1(i)*n2(i)/zs - nv1(i)*nv2(i)/zs &
185 + (n2(i)**3 -3.0*n2(i)*nv2(i)*nv2(i)) *(n3(i)+zs*zs*temp) &
186 /36.0/pi/zs/zs/n3(i)**2
189 call chain_dfdrho(i,rhop,lambda,rhobar,df_drho_chain,f_ch,user)
193 call df_disp_drho_wda( i, wda_var, fa_disp, ab_disp, rhop, rhop_sum, &
194 rhoi_disp, rho_disp, adisp, mydisp, dadisp_dr, df_drho_att,user )
196 if(wda_var == 1) adisp(i) = rho_disp(i) * adisp(i)
197 if(wda_var == 2) adisp(i) = rhop_sum(i) * adisp(i)
203 dense(1) = pi / 6.0 * sum( rhop(1:ncomp,i) * mseg(1:ncomp) * dhs(1:ncomp)**3 )
204 xi(1,1:ncomp) = rhop(1:ncomp,i) / sum( rhop(1:ncomp,i) )
206 IF ( sum( parame(1:ncomp,6) ) > 1.e-10 .OR. sum( parame(1:ncomp,7) ) > 1.e-10 )
THEN 208 rho = sum(rhop(1:ncomp,i))
209 x(1:ncomp) = xi(1,1:ncomp)
210 call f_polar ( fdd, fqq, fdq )
211 fres_polar = ( fdd + fqq + fdq ) * sum( rhop(1:ncomp,i) )
213 z3_rk = pi/6.0 * mseg(ik) * dhs(ik)**3
214 call phi_polar ( ik, z3_rk, fdd_rk, fqq_rk, fdq_rk )
215 mu_polar(ik) = fdd_rk + fqq_rk + fdq_rk
222 IF ( sum( nint(parame(1:ncomp,12)) ) > 0)
THEN 223 call only_one_term_eos_numerical (
'hb_term ',
'TPT1_Chap' )
224 call fugacity ( lnphi )
225 call restore_previous_eos_numerical
226 f_assoc = fres * sum( rhop(1:ncomp,i) )
227 mu_assoc(1:ncomp) = lnphi(1,1:ncomp)
230 f_tot = f_fmt + f_ch + adisp(i) + fres_polar + f_assoc &
231 + sum( rhop(1:ncomp,i)*( log(rhop(1:ncomp,i)/rhob(1,1:ncomp))-1.0 ) )
232 delta_f = f_tot - ( sum(rhop(1:ncomp,i)*chempot_res(1:ncomp)) - pbulk)
233 free = free + delta_f*dzp
238 f(k,i) = -(rhob(1,k) * exp(chempot_res(k)-df_drho_fmt(i,k)-df_drho_chain(i,k)-df_drho_att(k) &
239 -mu_polar(k) - mu_assoc(k)) - rhop(k,i))
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains constant...
subroutine formfunctionlocal(rhop, f, user, ierr)
This subroutine performs the local evaluation of the residual function. It calls the subroutines whic...
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
This module contains variables associated with the PETSc solver.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains the vari...
subroutine formfunction(snes, X, F, user, ierr)
The subroutine FormFunction is a wrapper function which takes care of handling the global PETSc data ...
In this module, the application context is defined.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...