00001 subroutine source_virial_WL(sou_Tkin,sou_Pint,sou_Wgra)
00002 use phys_constant, only : long, pi
00003 use grid_parameter, only : nrg, ntg, npg, nrf, ntf, npf
00004 use def_metric, only : psi, alph, tfkijkij, &
00005 & bvxu, bvyu, bvzu, bvxd, bvyd, bvzd
00006 use def_metric_hij, only : hxxu, hxyu, hxzu, hyyu, hyzu, hzzu
00007 use def_ricci_tensor, only : rab
00008 use def_metric_on_SFC_WL, only : psif, alphf
00009 use def_matter, only : emd, utf
00010 use interface_grgrad_midpoint
00011 use interface_interpo_linear_type0
00012 use make_array_3d
00013 use make_array_4d
00014 implicit none
00015 integer :: irf, itf, ipf, ia, ib, irg, itg, ipg
00016 real(long) :: psifc, psifc6, alpfc, pi4inv
00017 real(long) :: emdfc, hhfc, prefc, rhofc, enefc, utfc
00018 real(long) :: alpgc, psigc, bvxgc, bvygc, bvzgc, gamu(3,3),
00019 hhxxu, hhxyu, hhxzu, hhyxu, hhyyu, hhyzu, &
00020 hhzxu, hhzyu, hhzzu, ric(3,3), ricsc, &
00021 psigc2, psigc6, alp2inv, psal2inv, aijaij, trkgc, &
00022 dapsi(3), daalph(3), dpsi2, dalph2, bvdal
00023 real(long), pointer :: sou_Tkin(:,:,:), sou_Pint(:,:,:), sou_Wgra(:,:,:)
00024 real(long), pointer :: dfdx(:,:,:), dfdy(:,:,:), dfdz(:,:,:)
00025 real(long), pointer :: grada(:,:,:,:), gradp(:,:,:,:)
00026
00027
00028
00029
00030
00031 call alloc_array3d(dfdx,1,nrg,1,ntg,1,npg)
00032 call alloc_array3d(dfdy,1,nrg,1,ntg,1,npg)
00033 call alloc_array3d(dfdz,1,nrg,1,ntg,1,npg)
00034 call alloc_array4d(grada,1,nrg,1,ntg,1,npg,1,3)
00035 call alloc_array4d(gradp,1,nrg,1,ntg,1,npg,1,3)
00036
00037 do ipf = 0, npf
00038 do itf = 0, ntf
00039 do irf = 0, nrf
00040
00041 emdfc = emd(irf,itf,ipf)
00042 call peos_q2hprho(emdfc, hhfc, prefc, rhofc, enefc)
00043 utfc = utf(irf,itf,ipf)
00044
00045 psifc = psif(irf,itf,ipf)
00046 alpfc = alphf(irf,itf,ipf)
00047 psifc6 = psifc**6
00048
00049 sou_Tkin(irf,itf,ipf)= 0.5d0*hhfc*rhofc*((alpfc*utfc)**2-1.0d0)*psifc6
00050 sou_Pint(irf,itf,ipf)= prefc*psifc6
00051
00052 end do
00053 end do
00054 end do
00055
00056 call grgrad_midpoint(psi,dfdx,dfdy,dfdz)
00057 gradp(1:nrg,1:ntg,1:npg,1) = dfdx(1:nrg,1:ntg,1:npg)
00058 gradp(1:nrg,1:ntg,1:npg,2) = dfdy(1:nrg,1:ntg,1:npg)
00059 gradp(1:nrg,1:ntg,1:npg,3) = dfdz(1:nrg,1:ntg,1:npg)
00060 call grgrad_midpoint(alph,dfdx,dfdy,dfdz)
00061 grada(1:nrg,1:ntg,1:npg,1) = dfdx(1:nrg,1:ntg,1:npg)
00062 grada(1:nrg,1:ntg,1:npg,2) = dfdy(1:nrg,1:ntg,1:npg)
00063 grada(1:nrg,1:ntg,1:npg,3) = dfdz(1:nrg,1:ntg,1:npg)
00064 pi4inv = 1.0d0/(4.0d0*pi)
00065
00066 do ipg = 1, npg
00067 do itg = 1, ntg
00068 do irg = 1, nrg
00069
00070 call interpo_linear_type0(psigc,psi,irg,itg,ipg)
00071 call interpo_linear_type0(alpgc,alph,irg,itg,ipg)
00072 call interpo_linear_type0(bvxgc,bvxu,irg,itg,ipg)
00073 call interpo_linear_type0(bvygc,bvyu,irg,itg,ipg)
00074 call interpo_linear_type0(bvzgc,bvzu,irg,itg,ipg)
00075 call interpo_linear_type0(hhxxu,hxxu,irg,itg,ipg)
00076 call interpo_linear_type0(hhxyu,hxyu,irg,itg,ipg)
00077 call interpo_linear_type0(hhxzu,hxzu,irg,itg,ipg)
00078 call interpo_linear_type0(hhyyu,hyyu,irg,itg,ipg)
00079 call interpo_linear_type0(hhyzu,hyzu,irg,itg,ipg)
00080 call interpo_linear_type0(hhzzu,hzzu,irg,itg,ipg)
00081 hhyxu = hhxyu
00082 hhzxu = hhxzu
00083 hhzyu = hhyzu
00084 gamu(1,1) = hhxxu + 1.0d0
00085 gamu(1,2) = hhxyu
00086 gamu(1,3) = hhxzu
00087 gamu(2,2) = hhyyu + 1.0d0
00088 gamu(2,3) = hhyzu
00089 gamu(3,3) = hhzzu + 1.0d0
00090 gamu(2,1) = gamu(1,2)
00091 gamu(3,1) = gamu(1,3)
00092 gamu(3,2) = gamu(2,3)
00093 psigc2 = psigc**2
00094 psigc6 = psigc**6
00095 alp2inv = 1.0d0/alpgc**2
00096 psal2inv= (psigc/alpgc)**2
00097 aijaij = tfkijkij(irg,itg,ipg)
00098 trkgc = 0.0d0
00099 ric(1,1) = rab(irg,itg,ipg,1)
00100 ric(1,2) = rab(irg,itg,ipg,2)
00101 ric(1,3) = rab(irg,itg,ipg,3)
00102 ric(2,2) = rab(irg,itg,ipg,4)
00103 ric(2,3) = rab(irg,itg,ipg,5)
00104 ric(3,3) = rab(irg,itg,ipg,6)
00105 ric(2,1) = ric(1,2)
00106 ric(3,1) = ric(1,3)
00107 ric(3,2) = ric(2,3)
00108 dapsi(1:3) = gradp(irg,itg,ipg,1:3)
00109 daalph(1:3) = grada(irg,itg,ipg,1:3)
00110
00111 dpsi2 = 0.0d0
00112 dalph2 = 0.0d0
00113 ricsc = 0.0d0
00114 do ib = 1, 3
00115 do ia = 1, 3
00116 dpsi2 = dpsi2 + gamu(ia,ib)*dapsi( ia)*dapsi( ib)
00117 dalph2 = dalph2+ gamu(ia,ib)*daalph(ia)*daalph(ib)
00118 ricsc = ricsc + gamu(ia,ib)*ric(ia,ib)
00119 end do
00120 end do
00121 bvdal = bvxgc*daalph(1) + bvygc*daalph(2) + bvzgc*daalph(3)
00122
00123 sou_Wgra(irg,itg,ipg) = pi4inv*(2.0d0*dpsi2 - psal2inv*dalph2 &
00124 & + 0.75d0*psigc6*(aijaij - 2.0d0*trkgc/3.0d0) &
00125 & + psigc6*alp2inv*trkgc*bvdal + 0.25*ricsc*psigc2)
00126
00127 end do
00128 end do
00129 end do
00130
00131 deallocate(dfdx)
00132 deallocate(dfdy)
00133 deallocate(dfdz)
00134 deallocate(grada)
00135 deallocate(gradp)
00136
00137 end subroutine source_virial_WL