00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 module m_tetrahedron
00027 implicit none
00028 private
00029
00030 public :: ttrhdrn_mkidx
00031 public :: ttrhdrn_chi0
00032 public :: ttrhdrn_sum
00033 public :: ttrhdrn_simple
00034 public :: ttrhdrn_sub1normal
00035 public :: ttrhdrn_sub1simple
00036 public :: ttrhdrn_sub1g30g20
00037 public :: ttrhdrn_sub1g30g21
00038 public :: ttrhdrn_sub1g30
00039 public :: ttrhdrn_sub2normal
00040 public :: ttrhdrn_sub2simple
00041 public :: ttrhdrn_sub2g30g20
00042 public :: ttrhdrn_sub2g30g10
00043 public :: ttrhdrn_sub2g30g21
00044 public :: ttrhdrn_sub2g30
00045 public :: ttrhdrn_sub2g10
00046
00047
00048 integer, parameter, public :: ttrhdrn_vtx=4
00049 integer, parameter, public :: ttrhdrn_div=6
00050 integer, parameter :: nvtx=ttrhdrn_vtx
00051 integer, parameter :: ndiv=ttrhdrn_div
00052 integer, parameter, public :: ttrhdrn_tbl1(nvtx,ndiv)
00053 $ =reshape((/1,2,3,6
00054 $ ,1,3,5,6
00055 $ ,3,5,6,7
00056 $ ,2,3,4,6
00057 $ ,3,4,6,8
00058 $ ,3,6,7,8/)
00059 $ ,(/nvtx,ndiv/))
00060
00061 contains
00062
00063 subroutine ttrhdrn_simple(dmna,dmnr,n1,n2,n3,imt1,fk,gk,xo)
00064 real(8), intent(in) :: dmna,dmnr
00065 integer, intent(in) :: n1
00066 integer, intent(in) :: n2
00067 integer, intent(in) :: n3
00068 integer, intent(in) :: imt1(nvtx,n1*n2*n3*ndiv)
00069 complex(8), intent(in) :: fk(n1*n2*n3)
00070 complex(8), intent(in) :: gk(n1*n2*n3)
00071 complex(8), intent(inout) :: xo(n1*n2*n3)
00072 complex(8) :: ca1(nvtx),ca2(1)
00073 ca2=(0.d0,0.d0)
00074 call ttrhdrn_sum(dmna,dmnr,n1,n2,n3,imt1,fk,gk
00075 $ ,1,ca2,ca1,xo)
00076 end subroutine
00077
00078 subroutine ttrhdrn_sum(dmna,dmnr,n1,n2,n3,imt1,fk,gk,ne,em,ca1,xo)
00079 real(8), intent(in) :: dmna,dmnr
00080 integer, intent(in) :: n1
00081 integer, intent(in) :: n2
00082 integer, intent(in) :: n3
00083 integer, intent(in) :: imt1(nvtx,n1*n2*n3*ndiv)
00084 complex(8), intent(in) :: fk(n1*n2*n3)
00085 complex(8), intent(in) :: gk(n1*n2*n3)
00086 integer, intent(in) :: ne
00087 complex(8), intent(in) :: em(ne)
00088 complex(8), intent( out) :: ca1(ne*nvtx)
00089 complex(8), intent(inout) :: xo(ne,n1*n2*n3)
00090 integer :: i1,i2,i3,i4,i5,i6,i7
00091 do i1=1,n1*n2*n3*ndiv
00092 call calc(dmna,dmnr,imt1(:,i1),n1*n2*n3
00093 $ ,fk
00094 $ ,gk,ne,em,ca1
00095 $ ,xo)
00096 end do
00097 end subroutine
00098
00099 subroutine ttrhdrn_chi0(dmna,dmnr,n1,n2,n3,imt1
00100 $ ,e1,e2,f1,f2,delt,dsgn,ne,em,ca1,xo)
00101 real(8), intent(in) :: dmna,dmnr
00102 integer, intent(in) :: n1,n2,n3,imt1(nvtx,n1*n2*n3*ndiv)
00103 complex(8), intent(in) :: e1(n1*n2*n3),e2(n1*n2*n3)
00104 real(8), intent(in) :: f1,f2,delt,dsgn
00105 integer, intent(in) :: ne
00106 complex(8), intent(in) :: em(ne)
00107 complex(8), intent( out) :: ca1(ne*nvtx)
00108 complex(8), intent(inout) :: xo(ne,n1*n2*n3)
00109 integer :: i1,i2,i3,i4,i5,i6,i7
00110 real(8) :: ee1(4),ee2(4)
00111 complex(8) :: ffk(4),ggk(4),xxo(ne,4)
00112 integer, parameter :: ia1(4)=(/1,2,3,4/),nmax=99
00113
00114
00115
00116
00117 real(8) :: dwgt(4,4,nmax),dvol(nmax)
00118 do i1=1,n1*n2*n3*ndiv
00119 dwgt(:,:,1)=0.d0; do i2=1,4; dwgt(i2,i2,1)=1.d0; end do
00120 dvol(1)=1.d0; i2=1
00121 ee2=dble(e2(imt1(:,i1))); call ttct(f2,ee2,+1,nmax,i2,dwgt,dvol)
00122 ee1=dble(e1(imt1(:,i1))); call ttct(f1,ee1,-1,nmax,i2,dwgt,dvol)
00123 do i3=1,i2
00124 xxo=0.d0; ffk=dvol(i3)
00125 do i4=1,4
00126 ggk(i4)=-dcmplx(sum((ee2-ee1)*dwgt(:,i4,i3)),-delt)
00127 end do
00128 ffk=ffk*dsgn; ggk=ggk*dsgn
00129 call calc(dmna,dmnr,ia1,4
00130 $ ,ffk
00131 $ ,ggk,ne,em,ca1
00132 $ ,xxo)
00133 do i4=1,4; do i5=1,4
00134 xo(:,imt1(i5,i1))=xo(:,imt1(i5,i1))+xxo(:,i4)*dwgt(i5,i4,i3)
00135 end do; end do
00136 end do
00137 end do
00138
00139
00140
00141 end subroutine
00142
00143 subroutine ttct(dval,dvtx,imod,nmax,ntet,dwgt,dvol)
00144 real(8), intent(in) :: dval,dvtx(4)
00145 integer, intent(in) :: imod,nmax
00146 integer, intent(inout) :: ntet
00147 real(8), intent(inout) :: dwgt(4,4,nmax),dvol(nmax)
00148 logical :: bvtx0(4)
00149 logical :: b1
00150 integer :: i1,i2
00151 real(8) :: d1,d2
00152 real(8) :: dvtx0(4),dvol0
00153 integer :: itet
00154
00155
00156
00157
00158 logical :: bvtx(4,nmax),btsk(nmax)
00159 bvtx=.false.
00160 btsk=.false.
00161
00162 itet=0
00163 do while(itet.lt.ntet); itet=itet+1
00164 do i1=1,4; dvtx0(i1)=sum(dwgt(:,i1,itet)*dvtx(:)); end do
00165 dvol0=dvol(itet); bvtx0=bvtx(:,itet); b1=.false.
00166 do i1= 1,3; if(bvtx0(i1))cycle
00167 do i2=i1+1,4; if(bvtx0(i2))cycle
00168 b1=(dvtx0(i1)-dval)*(dval-dvtx0(i2)).gt.0.d0; if(b1)exit
00169 end do; if(b1)exit
00170 end do
00171 if(b1)then
00172
00173 d1=(dvtx0(i2)-dval)/(dvtx0(i2)-dvtx0(i1))
00174 d2=(dval-dvtx0(i1))/(dvtx0(i2)-dvtx0(i1))
00175 ntet=ntet+1; if(ntet.gt.nmax)stop "ntet.gt.nmax"
00176 bvtx(:,ntet)=bvtx(:,itet); dwgt(:,:,ntet)=dwgt(:,:,itet)
00177 bvtx(i1,ntet)=.true.
00178 dwgt(:,i1,ntet)=dwgt(:,i1,itet)*d1+dwgt(:,i2,itet)*d2
00179 dvol(ntet)=dvol(itet)*d1
00180 bvtx(i2,itet)=.true.
00181 dwgt(:,i2,itet)=dwgt(:,i1,itet)*d1+dwgt(:,i2,itet)*d2
00182 dvol(itet)=dvol(itet)*d2
00183 itet=itet-1
00184 else
00185 do i1=1,4; if(bvtx0(i1))cycle
00186 btsk(itet)=btsk(itet)
00187 $ .or.dble(imod)*(dvtx0(i1)-dval).gt.0.d0
00188
00189
00190 end do
00191 end if
00192 end do
00193
00194
00195 itet=0
00196 do i1=1,ntet; if(.not.btsk(i1))cycle
00197 itet=itet+1; dwgt(:,:,itet)=dwgt(:,:,i1);dvol(itet)=dvol(i1)
00198
00199
00200
00201
00202 end do; ntet=itet
00203
00204
00205
00206
00207 end subroutine
00208
00209 subroutine calc(dmna,dmnr,ia1,nnn,fk,gk,ne,em,ca1,xo)
00210 real(8), intent(in) :: dmna,dmnr
00211 integer, intent(in) :: ia1(nvtx)
00212 integer, intent(in) :: nnn
00213 complex(8), intent(in) :: fk(nnn)
00214 complex(8), intent(in) :: gk(nnn)
00215 integer, intent(in) :: ne
00216 complex(8), intent(in) :: em(ne)
00217 complex(8), intent( out) :: ca1(ne,nvtx)
00218 complex(8), intent(inout) :: xo(ne,nnn)
00219 integer :: i1,i2,i3,i4,i5,i6
00220 integer :: ia2(4),ia3(4),ia4(4)
00221 complex(8) :: geq1,geq2
00222 call chk1(dmna,dmnr,nnn,gk,ia1,ia2,ia3,ia4,i3)
00223 select case(sum(ia2))
00224 case(0)
00225 call ttrhdrn_sub2normal(
00226 $ gk(ia4(2)),gk(ia4(1)),gk(ia4(3)),gk(ia4(4))
00227 $ ,ne,em,ca1(:,1))
00228 call ttrhdrn_sub2normal(
00229 $ gk(ia4(1)),gk(ia4(2)),gk(ia4(3)),gk(ia4(4))
00230 $ ,ne,em,ca1(:,2))
00231 call ttrhdrn_sub2normal(
00232 $ gk(ia4(1)),gk(ia4(3)),gk(ia4(2)),gk(ia4(4))
00233 $ ,ne,em,ca1(:,3))
00234 call ttrhdrn_sub1normal(
00235 $ gk(ia4(1)),gk(ia4(4)),gk(ia4(2)),gk(ia4(3))
00236 $ ,ne,em,ca1(:,4))
00237 xo(:,ia4(1))=xo(:,ia4(1))+fk(ia4(1))*ca1(:,1)
00238 xo(:,ia4(2))=xo(:,ia4(2))+fk(ia4(2))*ca1(:,2)
00239 xo(:,ia4(3))=xo(:,ia4(3))+fk(ia4(3))*ca1(:,3)
00240 xo(:,ia4(4))=xo(:,ia4(4))+fk(ia4(4))
00241 $ *(ca1(:,4)-ca1(:,3)-ca1(:,2)-ca1(:,1))
00242 case(2)
00243 geq1=sum(gk(ia3(1:2)))/2.d0
00244 call ttrhdrn_sub2g10 (
00245 $ geq1 ,geq1 ,gk(ia4(1)),gk(ia4(2))
00246 $ ,ne,em,ca1(:,1))
00247 call ttrhdrn_sub2g30 (
00248 $ geq1 ,gk(ia4(1)),gk(ia4(2)),geq1
00249 $ ,ne,em,ca1(:,2))
00250 call ttrhdrn_sub1g30 (
00251 $ geq1 ,gk(ia4(2)),gk(ia4(1)),geq1
00252 $ ,ne,em,ca1(:,3))
00253 xo(:,ia3(1))=xo(:,ia3(1))+fk(ia3(1))*ca1(:,1)
00254 xo(:,ia3(2))=xo(:,ia3(2))+fk(ia3(2))*ca1(:,1)
00255 xo(:,ia4(1))=xo(:,ia4(1))+fk(ia4(1))*ca1(:,2)
00256 xo(:,ia4(2))=xo(:,ia4(2))+fk(ia4(2))
00257 $ *(ca1(:,3)-ca1(:,2)-ca1(:,1)-ca1(:,1))
00258 case(3)
00259 geq1=sum(gk(ia3(1:3)))/3.d0
00260 call ttrhdrn_sub2g30g10(
00261 $ geq1 ,geq1 ,gk(ia4(1)),geq1
00262 $ ,ne,em,ca1(:,1))
00263 call ttrhdrn_sub1g30g20(
00264 $ geq1 ,gk(ia4(1)),geq1 ,geq1
00265 $ ,ne,em,ca1(:,2))
00266 xo(:,ia3(1))=xo(:,ia3(1))+fk(ia3(1))*ca1(:,1)
00267 xo(:,ia3(2))=xo(:,ia3(2))+fk(ia3(2))*ca1(:,1)
00268 xo(:,ia3(3))=xo(:,ia3(3))+fk(ia3(3))*ca1(:,1)
00269 xo(:,ia4(1))=xo(:,ia4(1))+fk(ia4(1))
00270 $ *(ca1(:,2)-ca1(:,1)-ca1(:,1)-ca1(:,1))
00271 case(4)
00272 select case(i3)
00273 case(2)
00274 geq1=sum(gk(ia3(1:2)))/2.d0; geq2=sum(gk(ia3(3:4)))/2.d0
00275 call ttrhdrn_sub2g30g21(
00276 $ geq2 ,geq1 ,geq1 ,geq2
00277 $ ,ne,em,ca1(:,1))
00278 call ttrhdrn_sub1g30g21(
00279 $ geq1 ,geq2 ,geq2 ,geq1
00280 $ ,ne,em,ca1(:,2))
00281 xo(:,ia3(1))=xo(:,ia3(1))+fk(ia3(1))*ca1(:,1)
00282 xo(:,ia3(2))=xo(:,ia3(2))+fk(ia3(2))*ca1(:,1)
00283 xo(:,ia3(3))=xo(:,ia3(3))+fk(ia3(3))
00284 $ *(ca1(:,2)-ca1(:,1)-ca1(:,1))*.5d0
00285 xo(:,ia3(4))=xo(:,ia3(4))+fk(ia3(4))
00286 $ *(ca1(:,2)-ca1(:,1)-ca1(:,1))*.5d0
00287 case(3:6)
00288 geq1=sum(gk(ia3(1:4)))/4.d0
00289 call ttrhdrn_sub2simple(
00290 $ geq1 ,geq1 ,geq1 ,geq1
00291 $ ,ne,em,ca1(:,1))
00292 xo(:,ia3(1))=xo(:,ia3(1))+ca1(:,1)*fk(ia3(1))
00293 xo(:,ia3(2))=xo(:,ia3(2))+ca1(:,1)*fk(ia3(2))
00294 xo(:,ia3(3))=xo(:,ia3(3))+ca1(:,1)*fk(ia3(3))
00295 xo(:,ia3(4))=xo(:,ia3(4))+ca1(:,1)*fk(ia3(4))
00296 case default
00297 call errexec("bad i3")
00298 end select
00299 case default
00300 call errexec("bad sum ia2")
00301 end select
00302 end subroutine
00303
00304 subroutine ttrhdrn_sub1simple(g0,g1,g2,g3,ne,em,x0)
00305 complex(8), intent(in) :: g0,g1,g2,g3
00306 integer, intent(in) :: ne
00307 complex(8), intent(in) :: em(ne)
00308 complex(8), intent(out) :: x0(ne)
00309 x0=1.d0/((g0+em)*6.d0)
00310 end subroutine
00311
00312 subroutine ttrhdrn_sub1g30g21(g0,g1,g2,g3,ne,em,x0)
00313 complex(8), intent(in) :: g0,g1,g2,g3
00314 integer, intent(in) :: ne
00315 complex(8), intent(in) :: em(ne)
00316 complex(8), intent(out) :: x0(ne)
00317 x0= (.5d0*(g0+g1)+em)/(g0-g1)**2
00318 x0=x0- log((g0+em)/(g1+em))*(g0+em)*(g1+em)/(g0-g1)**3
00319 end subroutine
00320
00321 subroutine ttrhdrn_sub1g30g20(g0,g1,g2,g3,ne,em,x0)
00322 complex(8), intent(in) :: g0,g1,g2,g3
00323 integer, intent(in) :: ne
00324 complex(8), intent(in) :: em(ne)
00325 complex(8), intent(out) :: x0(ne)
00326 x0= (g0-3.d0*g1-2.d0*em)*.25d0/(g0-g1)**2
00327 x0=x0+ (g1+em)**2*log((g0+em)/(g1+em))*.5d0/(g0-g1)**3
00328 end subroutine
00329
00330 subroutine ttrhdrn_sub1g30 (g0,g1,g2,g3,ne,em,x0)
00331 complex(8), intent(in) :: g0,g1,g2,g3
00332 integer, intent(in) :: ne
00333 complex(8), intent(in) :: em(ne)
00334 complex(8), intent(out) :: x0(ne)
00335 x0= .5d0/(g0-g2)
00336 x0=x0- .5d0/((g0-g2)*(g0-g1))**2
00337 $ *(g0+em)
00338 $ *(-2.d0*(g1+em)*(g2+em)+(g0+em)*(g1+g2+2.d0*em))
00339 $ *log((g0+em)/(g1+em))
00340 x0=x0+ .5d0/(g0-g2)**2
00341 $ *(g2+em)**2*log((g1+em)/(g2+em))/(g1-g2)
00342 x0=x0+ .5d0/((g0-g2)*(g0-g1))
00343 $ *(g1+em)
00344 end subroutine
00345
00346 subroutine ttrhdrn_sub1normal(g0,g1,g2,g3,ne,em,x0)
00347 complex(8), intent(in) :: g0,g1,g2,g3
00348 integer, intent(in) :: ne
00349 complex(8), intent(in) :: em(ne)
00350 complex(8), intent(out) :: x0(ne)
00351
00352 x0= + (
00353 $ -(g1+em)**2*log((g1+em)/(g0+em)))
00354 $ /((g0-g2)*(g0-g3)*(g0-g1))*.5d0
00355
00356 x0=x0- ((g1+em)**2*log((g1+em)/(g0+em))
00357 $ -(g2+em)**2*log((g2+em)/(g0+em)))
00358 $ /((g0-g2)*(g1-g2)*(g2-g3))*.5d0
00359
00360 x0=x0+ ((g1+em)**2*log((g1+em)/(g0+em))
00361 $ -(g3+em)**2*log((g3+em)/(g0+em)))
00362 $ /((g1-g3)*(g0-g3)*(g2-g3))*.5d0
00363 end subroutine
00364
00365 subroutine ttrhdrn_sub2simple(g0,g1,g2,g3,ne,em,x0)
00366 complex(8), intent(in) :: g0,g1,g2,g3
00367 integer, intent(in) :: ne
00368 complex(8), intent(in) :: em(ne)
00369 complex(8), intent(out) :: x0(ne)
00370 x0=1.d0/((g0+em)*24.d0)
00371 end subroutine
00372
00373 subroutine ttrhdrn_sub2g30g20(g0,g1,g2,g3,ne,em,x0)
00374 complex(8), intent(in) :: g0,g1,g2,g3
00375 integer, intent(in) :: ne
00376 complex(8), intent(in) :: em(ne)
00377 complex(8), intent(out) :: x0(ne)
00378 x0= ((g0-g1)*(g0+2.d0*g1+3.d0*em)
00379 $ -6.d0*(g0+em)*(g1+em))
00380 $ /(12.d0*(g0-g1)**3)
00381 x0=x0+ (g0+em)*(g1+em)**2*log((g0+em)/(g1+em))
00382 $ /(g0-g1)**4*.5d0
00383 end subroutine
00384
00385 subroutine ttrhdrn_sub2g30g21(g0,g1,g2,g3,ne,em,x0)
00386 complex(8), intent(in) :: g0,g1,g2,g3
00387 integer, intent(in) :: ne
00388 complex(8), intent(in) :: em(ne)
00389 complex(8), intent(out) :: x0(ne)
00390 call ttrhdrn_sub2g30g20(g1,g0,g1,g1,ne,em,x0)
00391 end subroutine
00392
00393 subroutine ttrhdrn_sub2g30g10(g0,g1,g2,g3,ne,em,x0)
00394 complex(8), intent(in) :: g0,g1,g2,g3
00395 integer, intent(in) :: ne
00396 complex(8), intent(in) :: em(ne)
00397 complex(8), intent(out) :: x0(ne)
00398 x0= (2.d0*(g0+em)**2-7.d0*(g0+em)*(g2+em)+11.d0*(g2+em)**2)
00399 $ /(36.d0*(g0-g2)**3)
00400 x0=x0- (g2+em)**3*log((g0+em)/(g2+em))
00401 $ /(6.d0*(g0-g2)**4)
00402 end subroutine
00403
00404 subroutine ttrhdrn_sub2g10 (g0,g1,g2,g3,ne,em,x0)
00405 complex(8), intent(in) :: g0,g1,g2,g3
00406 integer, intent(in) :: ne
00407 complex(8), intent(in) :: em(ne)
00408 complex(8), intent(out) :: x0(ne)
00409 x0= (g0+em)*((g0+em)**2+5.d0*(g2+em)*(g3+em)
00410 $ -3.d0*(g0+em)*(g2+g3+2.d0*em))
00411 $ /(12.d0*(g0-g2)**2*(g0-g3)**2)
00412
00413
00414
00415 x0=x0- (g2+em)**3*log((g2+em)/(g0+em))/(6.d0*(g0-g2)**3*(g2-g3))
00416 x0=x0+ (g3+em)**3*log((g3+em)/(g0+em))/(6.d0*(g0-g3)**3*(g2-g3))
00417 end subroutine
00418
00419 subroutine ttrhdrn_sub2g30 (g0,g1,g2,g3,ne,em,x0)
00420 complex(8), intent(in) :: g0,g1,g2,g3
00421 integer, intent(in) :: ne
00422 complex(8), intent(in) :: em(ne)
00423 complex(8), intent(out) :: x0(ne)
00424 x0= ((g0+em)**2*(g1-g2)+(g1+em)**2*(g0-g2))
00425 $ /(6.d0*(g0-g2)*(g0-g1)**2*(g1-g2))
00426 x0=x0- (g0+em)**2*(2.d0*(g1+em)*(g0-g2)+(g2+em)*(g0-g1))
00427 $ *log((g0+em)/(g2+em))
00428 $ /(6.d0*(g0-g2)**2*(g0-g1)**3)
00429 x0=x0+ (g1+em)**2*(2.d0*(g0+em)*(g1-g2)-(g2+em)*(g0-g1))
00430 $ *log((g1+em)/(g2+em))
00431 $ /(6.d0*(g0-g1)**3*(g1-g2)**2)
00432
00433 end subroutine
00434
00435 subroutine ttrhdrn_sub2normal(g0,g1,g2,g3,ne,em,x0)
00436 complex(8), intent(in) :: g0,g1,g2,g3
00437 integer, intent(in) :: ne
00438 complex(8), intent(in) :: em(ne)
00439 complex(8), intent(out) :: x0(ne)
00440 x0=- (g1+em)**2/(6.d0*(g0-g1)*(g1-g2)*(g1-g3))
00441
00442
00443
00444
00445 x0=x0- (g2+em)**3*log((g2+em)/(g1+em))
00446 $ /(6.d0*(g0-g2)*(g1-g2)**2*(g2-g3))
00447 x0=x0+ (g3+em)**3*log((g3+em)/(g1+em))
00448 $ /(6.d0*(g0-g3)*(g1-g3)**2*(g2-g3))
00449 x0=x0+ (g0+em)**3*log((g0+em)/(g1+em))
00450 $ /(6.d0*(g0-g1)**2*(g0-g2)*(g0-g3))
00451 end subroutine
00452
00453
00454
00455
00456
00457 subroutine chk1(dmna,dmnr,nnn,gk,ia1,ia2,ia3,ia4,i3)
00458 real(8), intent(in) :: dmna,dmnr
00459 integer, intent(in) :: nnn
00460 complex(8), intent(in) :: gk(nnn)
00461 integer, intent(in) :: ia1(4)
00462 integer, intent(out):: ia2(4)
00463 integer, intent(out):: ia3(4)
00464 integer, intent(out):: ia4(4)
00465 integer, intent(out):: i3
00466 integer :: i1,i2,i4,i5
00467 real(8) :: d1,d2
00468 i3=0
00469 i4=0
00470 ia2=0
00471 ia3=0
00472 do i1=1,3
00473 do i2=i1+1,4
00474 d1=abs(gk(ia1(mod(i1,4)+1))-gk(ia1(mod(i2,4)+1)))
00475 d2=abs(gk(ia1(mod(i1,4)+1))+gk(ia1(mod(i2,4)+1)))*.5d0
00476 if(d1.lt.dmna.or.d1/d2.lt.dmnr)then
00477
00478 i3=i3+1
00479 if(ia2(mod(i1,4)+1).eq.0)then
00480 i4=i4+1
00481 ia3(i4)=ia1(mod(i1,4)+1)
00482 ia2(mod(i1,4)+1)=1
00483 end if
00484 if(ia2(mod(i2,4)+1).eq.0)then
00485 i4=i4+1
00486 ia3(i4)=ia1(mod(i2,4)+1)
00487 ia2(mod(i2,4)+1)=1
00488 end if
00489 else
00490 end if
00491 end do
00492 end do
00493 i5=0
00494 ia4=0
00495 do i1=1,4
00496 if(ia2(mod(i1,4)+1).eq.0) then
00497 i5=i5+1
00498 ia4(i5)=ia1(mod(i1,4)+1)
00499 end if
00500 end do
00501 if(sum(ia2).ne.i4) call errexec("bad ia2 and i4")
00502 if(i4+i5.ne.4) call errexec("bad i4 and i5")
00503 end subroutine
00504
00505 subroutine ttrhdrn_mkidx(n1,n2,n3,idx1,bvec1,bvec2,bvec3)
00506 integer, intent(in) :: n1
00507 integer, intent(in) :: n2
00508 integer, intent(in) :: n3
00509 integer, intent(out):: idx1(nvtx,n1*n2*n3*ndiv)
00510 real(8), intent(in), optional :: bvec1(3),bvec2(3),bvec3(3)
00511 real(8) :: bvec(3,3)
00512 integer :: i1,i2,i3,i4,i5,i6,i7
00513 integer :: imt1(8,8)
00514 integer :: ia1(8)
00515 bvec=reshape((/1d0,0d0,0d0,0d0,1d0,0d0,0d0,0d0,1d0/),(/3,3/))
00516 if(present(bvec1))bvec(:,1)=bvec1
00517 if(present(bvec2))bvec(:,2)=bvec2
00518 if(present(bvec3))bvec(:,3)=bvec3
00519 call libtetrabzinitialize(bvec,(/n1,n2,n3/),idx1)
00520 end subroutine
00521
00522
00523 subroutine libtetrabzinitialize(bvec,ng,indx1)
00524 real(8), intent(in ) :: bvec(3,3)
00525 integer, intent(in ) :: ng(3)
00526 integer, intent( out) :: indx1(4,*)
00527 integer :: nk,nt, ivvec(3,4,6), ikv(3)
00528 integer :: itype, i1, i2, i3, it, ii, divvec(4,4), ivvec0(4)
00529 real(8) :: l(4), bvec2(3,3), bvec3(3,4)
00530 nk = product(ng(1:3))
00531 nt = nk * 6
00532 do i1 = 1, 3
00533 bvec2(1:3,i1) = bvec(1:3,i1) / dble(ng(i1))
00534 end do
00535 bvec3(1:3,1) = -bvec2(1:3,1) + bvec2(1:3,2) + bvec2(1:3,3)
00536 bvec3(1:3,2) = bvec2(1:3,1) - bvec2(1:3,2) + bvec2(1:3,3)
00537 bvec3(1:3,3) = bvec2(1:3,1) + bvec2(1:3,2) - bvec2(1:3,3)
00538 bvec3(1:3,4) = bvec2(1:3,1) + bvec2(1:3,2) + bvec2(1:3,3)
00539
00540 do i1 = 1, 4
00541 l(i1) = dot_product(bvec3(1:3,i1),bvec3(1:3,i1))
00542 end do
00543 itype = minloc(l(1:4),1)
00544
00545 ivvec0(1:4) = (/ 0, 0, 0, 0 /)
00546 divvec(1:4,1) = (/ 1, 0, 0, 0 /)
00547 divvec(1:4,2) = (/ 0, 1, 0, 0 /)
00548 divvec(1:4,3) = (/ 0, 0, 1, 0 /)
00549 divvec(1:4,4) = (/ 0, 0, 0, 1 /)
00550 ivvec0(itype) = 1
00551 divvec(itype, itype) = - 1
00552
00553 it = 0
00554 do i1 = 1, 3
00555 do i2 = 1, 3
00556 if(i2 == i1) cycle
00557 do i3 = 1, 3
00558 if(i3 == i1 .or. i3 == i2) cycle
00559 it = it + 1
00560 ivvec(1:3,1,it) = ivvec0(1:3)
00561 ivvec(1:3,2,it) = ivvec(1:3,1,it) + divvec(1:3,i1)
00562 ivvec(1:3,3,it) = ivvec(1:3,2,it) + divvec(1:3,i2)
00563 ivvec(1:3,4,it) = ivvec(1:3,3,it) + divvec(1:3,i3)
00564 end do
00565 end do
00566 end do
00567
00568 nt = 0
00569 do i3 = 1, ng(3)
00570 do i2 = 1, ng(2)
00571 do i1 = 1, ng(1)
00572 do it = 1, 6
00573 nt = nt + 1
00574 do ii = 1, 4
00575 ikv(1:3) = (/i1, i2, i3/) + ivvec(1:3,ii,it) - 1
00576 ikv(1:3) = modulo(ikv(1:3), ng(1:3))
00577 indx1(ii,nt) = 1 + ikv(1) + ng(1) * ikv(2)
00578 $ + ng(1) * ng(2) * ikv(3)
00579 end do
00580 end do
00581 end do
00582 end do
00583 end do
00584 end subroutine
00585
00586
00587 subroutine errexec(smsg)
00588 character(*), intent(in) :: smsg
00589 integer :: i(1:1)
00590 integer :: j
00591 j=0
00592 write(*,"(a)")"#ERROR in ttrhdrn_ : "//smsg
00593 i(j)=0
00594 write(*,"('#errexec cannot stop')")
00595 write(*,"('#please use debug option')")
00596 stop
00597 end subroutine
00598
00599 end module