m_tetrainteg.F

Go to the documentation of this file.
00001 ! The MIT License (MIT)
00002 ! Copyright (c) 2016, Yoshiro Nohara, Takeo Fujiwara, and University of Tokyo.
00003 !
00004 ! Permission is hereby granted, free of charge, to any person
00005 ! obtaining a copy of this software and associated documentation
00006 ! files (the "Software"), to deal in the Software without restriction,
00007 ! including without limitation the rights to use, copy, modify, merge,
00008 ! publish, distribute, sublicense, and/or sell copies of the Software,
00009 ! and to permit persons to whom the Software is furnished to do so,
00010 ! subject to the following conditions:
00011 !
00012 ! The above copyright notice and this permission notice shall be
00013 ! included in all copies or substantial portions of the Software.
00014 !
00015 ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00016 ! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00017 ! OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00018 ! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00019 ! HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00020 ! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021 ! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00022 ! IN THE SOFTWARE.
00023 !
00024 !     This program uses the generalized tetrahedron method and implements
00025 !     an efficient tool in the GW-LMTO package developed by Fujiwara group
00026 !     in University of Tokyo. The algorithm of the generalized tetrahedron
00027 !     method is written in the following published papers:
00028 !
00029 !     [Generalized tetrahedron method] Takeo Fujiwara, Susumu Yamamoto, and
00030 !     Yasushi Ishii, J. Phys. Soc. Jpn. 72, No.4, 777-780 (2003).
00031 !     (cond.mat/0211159)
00032 !
00033 !     [GW-LMTO package] Yoshiro Nohara, Susumu Yamamoto, and Takeo Fujiwara,
00034 !     Phys. Rev. B 79, 195110 (2009)
00035 !
00036 !     One can use this part of the program package in one's developed code
00037 !     on the condition of citing these two papers and mentioning the name of
00038 !     `the generalized tetrahedron method'  in the published paper.
00039       module m_tetrainteg
00040       implicit none
00041       private
00042 
00043       public :: ttritg_mkidx
00044       public :: ttritg_sum
00045       public :: ttritg_simple
00046       public :: ttritg_search
00047       public :: ttritg_sub1normal
00048       public :: ttritg_sub1simple
00049       public :: ttritg_sub1g30g20
00050       public :: ttritg_sub1g30g21
00051       public :: ttritg_sub1g30
00052       public :: ttritg_sub2normal
00053       public :: ttritg_sub2simple
00054       public :: ttritg_sub2g30g20
00055       public :: ttritg_sub2g30g10
00056       public :: ttritg_sub2g30g21
00057       public :: ttritg_sub2g30
00058       public :: ttritg_sub2g10
00059 
00060 
00061       integer, parameter, public :: ttritg_vtx=4
00062       integer, parameter, public :: ttritg_div=6
00063       integer, parameter :: nvtx=ttritg_vtx
00064       integer, parameter :: ndiv=ttritg_div
00065       integer, parameter, public :: ttritg_tbl1(nvtx,ndiv)
00066      $                       =reshape((/1,2,3,6
00067      $                                 ,1,3,5,6
00068      $                                 ,3,5,6,7
00069      $                                 ,2,3,4,6
00070      $                                 ,3,4,6,8
00071      $                                 ,3,6,7,8/)
00072      $                               ,(/nvtx,ndiv/))
00073 
00074       contains
00075 
00076       subroutine ttritg_search(dmna,dmnr,n1,n2,n3,n4,imt1,fk,gk,xo
00077      $                        ,dtgt,drg1,drg2,dout)
00078       real(8), intent(in) :: dmna,dmnr
00079       integer, intent(in) :: n1,n2,n3,n4
00080       integer, intent(in) :: imt1(nvtx,n1*n2*n3*ndiv)
00081       complex(8), intent(in) :: fk(n1*n2*n3,n4)
00082       complex(8), intent(in) :: gk(n1*n2*n3,n4)
00083       complex(8), intent(inout) :: xo(n1*n2*n3)
00084       real(8), intent(in) :: dtgt,drg1,drg2
00085       real(8), intent(out):: dout
00086       integer :: i1,i2,i3
00087       real(8) :: d1,d2,d3,d4,d5,d6
00088       logical :: b1,b2,b3
00089       complex(8) :: ca1(nvtx),ca2(1)
00090       complex(8), allocatable :: ca3(:)
00091       d3=drg1
00092       d4=drg2
00093       xo=0.d0
00094       ca2=d3
00095       do i1=1,n4
00096         call ttritg_sum(dmna,dmnr,n1,n2,n3,imt1
00097      $                 ,fk(:,i1),gk(:,i1),1,ca2,ca1,xo)
00098       end do
00099       d1=abs(dimag(sum(xo)))
00100       xo=0.d0
00101       ca2=d4
00102       do i1=1,n4
00103         call ttritg_sum(dmna,dmnr,n1,n2,n3,imt1
00104      $                 ,fk(:,i1),gk(:,i1),1,ca2,ca1,xo)
00105       end do
00106       d2=abs(dimag(sum(xo)))
00107 #ifdef MPI
00108 #else
00109       write(*,"(a,2g25.16)")"#ttritg_search: d1,d2=",d1,d2
00110 #endif
00111       if((d1-dtgt)*(dtgt-d2).lt.0.d0) 
00112      $  call errexec("bad drg1,drg2,dtgt")
00113       b1=.false.
00114       do while(.not.b1)
00115         d6=(d3+d4)*.5d0
00116         b1=abs(d4-d6).lt.1.d-15.or.abs((d4-d6)/(d4+d6))*2.d0.lt.1.d-15
00117         xo=0.d0
00118         ca2=d6
00119 !$OMP PARALLEL PRIVATE(ca1,ca3)
00120         allocate(ca3(n1*n2*n3)); ca3=(0.d0,0.d0)
00121 !$OMP DO
00122         do i1=1,n4
00123           call ttritg_sum(dmna,dmnr,n1,n2,n3,imt1
00124      $                   ,fk(:,i1),gk(:,i1),1,ca2,ca1,ca3)
00125         end do
00126 !$OMP END DO
00127 !$OMP CRITICAL
00128         xo=xo+ca3
00129 !$OMP END CRITICAL
00130         deallocate(ca3)
00131 !$OMP END PARALLEL
00132         d5=abs(dimag(sum(xo)))
00133         if((d1-dtgt)*(dtgt-d5).ge.0.d0)then
00134           d4=d6
00135         else
00136           d3=d6
00137         end if
00138 #ifdef MPI
00139 #else
00140         write(*,"(a,2g25.16)")"#ttritg_search: d6,d5=",d6,d5
00141 #endif
00142       end do
00143       dout=d6
00144       end subroutine
00145 
00146       subroutine ttritg_simple(dmna,dmnr,n1,n2,n3,imt1,fk,gk,xo)
00147       real(8), intent(in) :: dmna,dmnr
00148       integer, intent(in) :: n1
00149       integer, intent(in) :: n2
00150       integer, intent(in) :: n3
00151       integer, intent(in) :: imt1(nvtx,n1*n2*n3*ndiv)
00152       complex(8), intent(in) :: fk(n1*n2*n3)
00153       complex(8), intent(in) :: gk(n1*n2*n3)
00154       complex(8), intent(inout) :: xo(n1*n2*n3)
00155       complex(8) :: ca1(nvtx),ca2(1)
00156       ca2=(0.d0,0.d0)
00157       call ttritg_sum(dmna,dmnr,n1,n2,n3,imt1,fk,gk
00158      $                ,1,ca2,ca1,xo)
00159       end subroutine
00160 
00161       subroutine ttritg_sum(dmna,dmnr,n1,n2,n3,imt1,fk,gk,ne,em,ca1,xo)
00162       real(8), intent(in) :: dmna,dmnr
00163       integer, intent(in) :: n1
00164       integer, intent(in) :: n2
00165       integer, intent(in) :: n3
00166       integer, intent(in) :: imt1(nvtx,n1*n2*n3*ndiv)
00167       complex(8), intent(in) :: fk(n1*n2*n3)
00168       complex(8), intent(in) :: gk(n1*n2*n3)
00169       integer, intent(in) :: ne
00170       complex(8), intent(in) :: em(ne)
00171       complex(8), intent(  out) :: ca1(ne*nvtx)
00172       complex(8), intent(inout) :: xo(ne,n1*n2*n3)
00173       integer :: i1,i2,i3,i4,i5,i6,i7
00174       if(n1.eq.1.and.n2.eq.1.and.n3.eq.1)then
00175         xo(:,1)=xo(:,1)+fk(1)*log((gk(1)+em)/(-1.d0))
00176         return
00177       end if
00178       do i1=1,n1*n2*n3*ndiv
00179         call calc(dmna,dmnr,imt1(:,i1),n1*n2*n3
00180      $           ,fk
00181      $           ,gk,ne,em,ca1
00182      $           ,xo)
00183       end do
00184       end subroutine
00185 
00186       subroutine calc(dmna,dmnr,ia1,nnn,fk,gk,ne,em,ca1,xo)
00187       real(8), intent(in) :: dmna,dmnr
00188       integer, intent(in) :: ia1(nvtx)
00189       integer, intent(in) :: nnn
00190       complex(8), intent(in) :: fk(nnn)
00191       complex(8), intent(in) :: gk(nnn)
00192       integer, intent(in) :: ne
00193       complex(8), intent(in) :: em(ne)
00194       complex(8), intent(  out) :: ca1(ne,nvtx)
00195       complex(8), intent(inout) :: xo(ne,nnn)
00196       integer :: i1,i2,i3,i4,i5,i6
00197       integer :: ia2(4),ia3(4),ia4(4)
00198       complex(8) :: geq1,geq2
00199       call chk1(dmna,dmnr,nnn,gk,ia1,ia2,ia3,ia4,i3)
00200       select case(sum(ia2))
00201       case(0)
00202         call ttritg_sub2normal(
00203      $             gk(ia4(2)),gk(ia4(1)),gk(ia4(3)),gk(ia4(4))
00204      $            ,ne,em,ca1(:,1))
00205         call ttritg_sub2normal(
00206      $             gk(ia4(1)),gk(ia4(2)),gk(ia4(3)),gk(ia4(4))
00207      $            ,ne,em,ca1(:,2))
00208         call ttritg_sub2normal(
00209      $             gk(ia4(1)),gk(ia4(3)),gk(ia4(2)),gk(ia4(4))
00210      $            ,ne,em,ca1(:,3))
00211         call ttritg_sub2normal(
00212      $             gk(ia4(1)),gk(ia4(4)),gk(ia4(2)),gk(ia4(3))
00213      $            ,ne,em,ca1(:,4))
00214           xo(:,ia4(1))=xo(:,ia4(1))+fk(ia4(1))*ca1(:,1)
00215           xo(:,ia4(2))=xo(:,ia4(2))+fk(ia4(2))*ca1(:,2)
00216           xo(:,ia4(3))=xo(:,ia4(3))+fk(ia4(3))*ca1(:,3)
00217           xo(:,ia4(4))=xo(:,ia4(4))+fk(ia4(4))*ca1(:,4)
00218       case(2)
00219           geq1=sum(gk(ia3(1:2)))/2.d0
00220           call ttritg_sub2g10   (
00221      $             geq1      ,geq1      ,gk(ia4(1)),gk(ia4(2))
00222      $            ,ne,em,ca1(:,1))
00223           call ttritg_sub2g30   (
00224      $             geq1      ,gk(ia4(1)),gk(ia4(2)),geq1      
00225      $            ,ne,em,ca1(:,2))
00226           call ttritg_sub2g30   (
00227      $             geq1      ,gk(ia4(2)),gk(ia4(1)),geq1      
00228      $            ,ne,em,ca1(:,3))
00229           xo(:,ia3(1))=xo(:,ia3(1))+fk(ia3(1))*ca1(:,1)
00230           xo(:,ia3(2))=xo(:,ia3(2))+fk(ia3(2))*ca1(:,1)
00231           xo(:,ia4(1))=xo(:,ia4(1))+fk(ia4(1))*ca1(:,2)
00232           xo(:,ia4(2))=xo(:,ia4(2))+fk(ia4(2))*ca1(:,3)
00233       case(3)
00234           geq1=sum(gk(ia3(1:3)))/3.d0
00235           call ttritg_sub2g30g10(
00236      $             geq1      ,geq1      ,gk(ia4(1)),geq1      
00237      $            ,ne,em,ca1(:,1))
00238           call ttritg_sub2g30g20(
00239      $             geq1      ,gk(ia4(1)),geq1      ,geq1      
00240      $            ,ne,em,ca1(:,2))
00241           xo(:,ia3(1))=xo(:,ia3(1))+fk(ia3(1))*ca1(:,1)
00242           xo(:,ia3(2))=xo(:,ia3(2))+fk(ia3(2))*ca1(:,1)
00243           xo(:,ia3(3))=xo(:,ia3(3))+fk(ia3(3))*ca1(:,1)
00244           xo(:,ia4(1))=xo(:,ia4(1))+fk(ia4(1))*ca1(:,2)
00245       case(4)
00246         select case(i3)
00247         case(2)
00248           geq1=sum(gk(ia3(1:2)))/2.d0; geq2=sum(gk(ia3(3:4)))/2.d0
00249           call ttritg_sub2g30g21(
00250      $             geq2      ,geq1      ,geq1      ,geq2      
00251      $            ,ne,em,ca1(:,1))
00252           call ttritg_sub2g30g21(
00253      $             geq1      ,geq2      ,geq2      ,geq1      
00254      $            ,ne,em,ca1(:,2))
00255           xo(:,ia3(1))=xo(:,ia3(1))+fk(ia3(1))*ca1(:,1)
00256           xo(:,ia3(2))=xo(:,ia3(2))+fk(ia3(2))*ca1(:,1)
00257           xo(:,ia3(3))=xo(:,ia3(3))+fk(ia3(3))*ca1(:,2)
00258           xo(:,ia3(4))=xo(:,ia3(4))+fk(ia3(4))*ca1(:,2)
00259         case(3:6)
00260           geq1=sum(gk(ia3(1:4)))/4.d0
00261           call ttritg_sub2simple(
00262      $             geq1      ,geq1      ,geq1      ,geq1      
00263      $            ,ne,em,ca1(:,1))
00264           xo(:,ia3(1))=xo(:,ia3(1))+ca1(:,1)*fk(ia3(1))
00265           xo(:,ia3(2))=xo(:,ia3(2))+ca1(:,1)*fk(ia3(2))
00266           xo(:,ia3(3))=xo(:,ia3(3))+ca1(:,1)*fk(ia3(3))
00267           xo(:,ia3(4))=xo(:,ia3(4))+ca1(:,1)*fk(ia3(4))
00268         case default
00269           call errexec("bad i3")
00270         end select
00271       case default
00272         call errexec("bad sum ia2")
00273       end select
00274       end subroutine
00275 
00276       subroutine ttritg_sub1simple(h0,h1,h2,h3,ne,em,x0)
00277       complex(8), intent(in) :: h0,h1,h2,h3
00278       integer, intent(in) :: ne
00279       complex(8), intent(in) :: em(ne)
00280       complex(8), intent(out) :: x0(ne)
00281       x0=log((h0+em)/(-1.d0))/6.d0
00282       end subroutine
00283 
00284       subroutine ttritg_sub1g30g21(h0,h1,h2,h3,ne,em,x0)
00285       complex(8), intent(in) :: h0,h1,h2,h3
00286       integer, intent(in) :: ne
00287       complex(8), intent(in) :: em(ne)
00288       complex(8), intent(out) :: x0(ne)
00289       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00290       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00291       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00292       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00293       gmn1=min(-g0,-g1); gmx1=max(-g0,-g1)
00294       x0=
00295      $     +g0**2*(g0-3.d0*g1)*log((h0+em)/(h1+em))
00296      $     -min(max(dble(em),gmn1),gmx1)*(6.d0*g0*g1
00297      $     +min(max(dble(em),gmn1),gmx1)*(3.d0*(g0+g1)
00298      $     +min(max(dble(em),gmn1),gmx1)*2.d0))
00299      $        *log((-h0-em)/(-h1-em))
00300       x0=x0/(6.d0*g01**3)
00301       x0=x0-log((-1.d0)/(h1+em))/6.d0
00302       end subroutine
00303 
00304       subroutine ttritg_sub1g30g20(h0,h1,h2,h3,ne,em,x0)
00305       complex(8), intent(in) :: h0,h1,h2,h3
00306       integer, intent(in) :: ne
00307       complex(8), intent(in) :: em(ne)
00308       complex(8), intent(out) :: x0(ne)
00309       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00310       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00311       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00312       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00313       gmn1=min(-g0,-g1); gmx1=max(-g0,-g1)
00314       x0=-(g1+min(max(dble(em),gmn1),gmx1))**3*log((-h1-em)/(-h0-em))
00315       x0=x0/(6.d0*g01**3)+log(-h0-em)/6.d0
00316       end subroutine
00317 
00318       subroutine ttritg_sub1g30   (h0,h1,h2,h3,ne,em,x0)
00319       complex(8), intent(in) :: h0,h1,h2,h3
00320       integer, intent(in) :: ne
00321       complex(8), intent(in) :: em(ne)
00322       complex(8), intent(out) :: x0(ne)
00323       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00324       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00325       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00326       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00327       gmn1=min(-g0,-g1); gmx1=max(-g0,-g1)
00328       gmn2=min(-g1,-g2); gmx2=max(-g1,-g2)
00329       x0=
00330      $ -g12*(g0+min(max(dble(em),gmn1),gmx1))**2
00331      $        *(g0**2-2.d0*g0*(g1+g2)
00332      $         +3.d0*g1*g2+(-2.d0*g0+g1+g2)
00333      $         *min(max(dble(em),gmn1),gmx1))*log((h0+em)/(h1+em))
00334      $ +g01**2*(
00335      $         +(g2+min(max(dble(em),gmn2),gmx2))**3
00336      $          *log((-h2-em)/(-h1-em))
00337      $         +(g0**2*g1-g0**2*g2-2.d0*g0*g1*g2+2.d0*g0*g2**2+g1*g2**2)
00338      $          *log((-1.d0)/(h1+em)))
00339      $ +g01**2*g2**3*log(-h1-em)
00340       x0=-x0/(6.d0*g01**2*g02**2*g12)
00341       end subroutine
00342 
00343       subroutine ttritg_sub1normal(h0,h1,h2,h3,ne,em,x0)
00344       complex(8), intent(in) :: h0,h1,h2,h3
00345       integer, intent(in) :: ne
00346       complex(8), intent(in) :: em(ne)
00347       complex(8), intent(out) :: x0(ne)
00348       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00349       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00350       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00351       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00352       gmn1=min(-g0,-g1); gmx1=max(-g0,-g1)
00353       gmn2=min(-g1,-g3); gmx2=max(-g1,-g3)
00354       gmn3=min(-g1,-g2); gmx3=max(-g1,-g2)
00355       x0=
00356      $  +g12*g13*g23*(g0+min(max(dble(em),gmn1),gmx1))**3
00357      $   *log((h0+em)/(h1+em))
00358      $  -g01*g02*g12*(g3+min(max(dble(em),gmn2),gmx2))**3
00359      $   *log((-h3-em)/(-h1-em))
00360      $  +g01*g03*g13*(g2+min(max(dble(em),gmn3),gmx3))**3
00361      $   *log((-h2-em)/(-h1-em))
00362      $  +g01*g23*(g03*g1*g2**2+g12*g3*(g2*g03+g3*g0))*log(-h1-em)
00363      $  -g01*g23
00364      $   *(g0**2*(g1*(g1-g2-g3)+g2*g3)
00365      $    +g0*g1*(g2*g3-g1*(g2+g3))+g1**2*g2*g3)*log((-1.d0)/(h1+em))
00366       x0=x0/(6.d0*(g01*g12*g23*g13*g02*g03))
00367       end subroutine
00368 
00369       subroutine ttritg_sub2simple(h0,h1,h2,h3,ne,em,x0)
00370       complex(8), intent(in) :: h0,h1,h2,h3
00371       integer, intent(in) :: ne
00372       complex(8), intent(in) :: em(ne)
00373       complex(8), intent(out) :: x0(ne)
00374       x0=log((h0+em)/(-1.d0))/24.d0
00375       end subroutine
00376 
00377       subroutine ttritg_sub2g30g20(h0,h1,h2,h3,ne,em,x0)
00378       complex(8), intent(in) :: h0,h1,h2,h3
00379       integer, intent(in) :: ne
00380       complex(8), intent(in) :: em(ne)
00381       complex(8), intent(out) :: x0(ne)
00382       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00383       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00384       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00385       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00386       gmn1=min(-g0,-g1); gmx1=max(-g0,-g1)
00387       x0=
00388      $  -(g1+min(max(dble(em),gmn1),gmx1))**3
00389      $   *(4.d0*g0-g1+3.d0*min(max(dble(em),gmn1),gmx1))
00390      $   *log((-h1-em)/(-h0-em))
00391       x0=x0/(24.d0*g01**4)+log(-h0-em)/24.d0
00392       end subroutine
00393 
00394       subroutine ttritg_sub2g30g21(h0,h1,h2,h3,ne,em,x0)
00395       complex(8), intent(in) :: h0,h1,h2,h3
00396       integer, intent(in) :: ne
00397       complex(8), intent(in) :: em(ne)
00398       complex(8), intent(out) :: x0(ne)
00399       call ttritg_sub2g30g20(h1,h0,h1,h1,ne,em,x0)
00400       end subroutine
00401 
00402       subroutine ttritg_sub2g30g10(h0,h1,h2,h3,ne,em,x0)
00403       complex(8), intent(in) :: h0,h1,h2,h3
00404       integer, intent(in) :: ne
00405       complex(8), intent(in) :: em(ne)
00406       complex(8), intent(out) :: x0(ne)
00407       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00408       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00409       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00410       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00411       gmn1=min(-g0,-g2); gmx1=max(-g0,-g2)
00412       x0=(g2+min(max(dble(em),gmn1),gmx1))**4*log((h2+em)/(h0+em))
00413      $  -g02**4*log((-1.d0)/(h0+em))
00414       x0=x0/(24.d0*g02**4)
00415       end subroutine
00416 
00417       subroutine ttritg_sub2g10   (h0,h1,h2,h3,ne,em,x0)
00418       complex(8), intent(in) :: h0,h1,h2,h3
00419       integer, intent(in) :: ne
00420       complex(8), intent(in) :: em(ne)
00421       complex(8), intent(out) :: x0(ne)
00422       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00423       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00424       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00425       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00426       gmn1=min(-g0,-g2); gmx1=max(-g0,-g2)
00427       gmn2=min(-g0,-g3); gmx2=max(-g0,-g3)
00428       x0=-g03**3*(g2+min(max(dble(em),gmn1),gmx1))**4
00429      $    *log((h2+em)/(h0+em))
00430      $   +g02**3*(g3+min(max(dble(em),gmn2),gmx2))**4
00431      $    *log((h3+em)/(h0+em))
00432       x0=x0/(24.d0*g02**3*g03**3*g23)-log((-1.d0)/(h0+em))/24.d0
00433       end subroutine
00434 
00435       subroutine ttritg_sub2g30   (h0,h1,h2,h3,ne,em,x0)
00436       complex(8), intent(in) :: h0,h1,h2,h3
00437       integer, intent(in) :: ne
00438       complex(8), intent(in) :: em(ne)
00439       complex(8), intent(out) :: x0(ne)
00440       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00441       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00442       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00443       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00444       gmn1=min(-g0,-g1); gmx1=max(-g0,-g1)
00445       gmn2=min(-g0,-g2); gmx2=max(-g0,-g2)
00446       x0=
00447      $  +g02**2*(g1+min(max(dble(em),gmn1),gmx1))**3
00448      $   *(g12*(3.d0*g0-g1)-g2*g01
00449      $    +(2.d0*g02-3.d0*g01)*min(max(dble(em),gmn1),gmx1))
00450      $                     *log((-h1-em)/(-h0-em))
00451      $  +g01**3*(g2+min(max(dble(em),gmn2),gmx2))**4
00452      $   *log((-h2-em)/(-h0-em))
00453       x0=x0/(24.d0*g01**3*g02**2*g12**2)+log(-h0-em)/24.d0
00454       end subroutine
00455 
00456       subroutine ttritg_sub2normal(h0,h1,h2,h3,ne,em,x0)
00457       complex(8), intent(in) :: h0,h1,h2,h3
00458       integer, intent(in) :: ne
00459       complex(8), intent(in) :: em(ne)
00460       complex(8), intent(out) :: x0(ne)
00461       real(8) :: g0,g1,g2,g3,g01,g02,g03,g12,g13,g23
00462       real(8) :: gmn1,gmx1,gmn2,gmx2,gmn3,gmx3
00463       g0=dble(h0); g1=dble(h1); g2=dble(h2); g3=dble(h3)
00464       gmn1=min(-g1,-g2); gmx1=max(-g1,-g2)
00465       gmn2=min(-g1,-g3); gmx2=max(-g1,-g3)
00466       gmn3=min(-g0,-g1); gmx3=max(-g0,-g1)
00467       g01=g0-g1; g02=g0-g2; g03=g0-g3; g12=g1-g2; g13=g1-g3; g23=g2-g3
00468       x0=-g01**2*g03*g13**2*(g2+min(max(dble(em),gmn1),gmx1))**4
00469      $    *log((h2+em)/(h1+em))
00470      $   +g01**2*g02*g12**2*(g3+min(max(dble(em),gmn2),gmx2))**4
00471      $    *log((h3+em)/(h1+em))
00472      $   -g12**2*g13**2*g23*min(max(dble(em),gmn3),gmx3)
00473      $    *(2.d0*g0+min(max(dble(em),gmn3),gmx3))
00474      $    *(2.d0*g0**2+min(max(dble(em),gmn3),gmx3)
00475      $    *(2.d0*g0+min(max(dble(em),gmn3),gmx3)))
00476      $    *log((-h1-em)/(-h0-em))
00477      $ +g12**2*g13**2*g23*(
00478      $   (g01*(2.d0*g0*g1*g03-g0*g2*g13+g1*g2*g3)
00479      $   +g02*g0**2*(g23+2.d0*g3)+g12*g0*g1*g03
00480      $   +g0**2*g2*g23+g0*g1*g2*g3
00481      $   )*log((-1.d0)/(h1+em))+g0**4*log(-h0-em)
00482      $                    )
00483       x0=x0/(24.d0*g01**2*g02*g12**2*g03*g13**2*g23)
00484       end subroutine
00485 
00486 
00487 
00488 
00489 
00490       subroutine chk1(dmna,dmnr,nnn,gk,ia1,ia2,ia3,ia4,i3)
00491       real(8), intent(in) :: dmna,dmnr
00492       integer, intent(in) :: nnn
00493       complex(8), intent(in) :: gk(nnn)
00494       integer, intent(in) :: ia1(4)
00495       integer, intent(out):: ia2(4)
00496       integer, intent(out):: ia3(4)
00497       integer, intent(out):: ia4(4)
00498       integer, intent(out):: i3
00499       integer :: i1,i2,i4,i5
00500       real(8) :: d1,d2
00501       i3=0
00502       i4=0
00503       ia2=0
00504       ia3=0
00505       do i1=1,3
00506         do i2=i1+1,4
00507           d1=abs(dble(gk(ia1(mod(i1,4)+1))-gk(ia1(mod(i2,4)+1))))
00508           d2=abs(dble(gk(ia1(mod(i1,4)+1))+gk(ia1(mod(i2,4)+1))))*.5d0
00509           if(d1.lt.dmna.or.d1/d2.lt.dmnr)then
00510             i3=i3+1
00511             if(ia2(mod(i1,4)+1).eq.0)then
00512               i4=i4+1
00513               ia3(i4)=ia1(mod(i1,4)+1)
00514               ia2(mod(i1,4)+1)=1
00515             end if
00516             if(ia2(mod(i2,4)+1).eq.0)then
00517               i4=i4+1
00518               ia3(i4)=ia1(mod(i2,4)+1)
00519               ia2(mod(i2,4)+1)=1
00520             end if
00521           else
00522           end if
00523         end do
00524       end do
00525       i5=0
00526       ia4=0
00527       do i1=1,4
00528         if(ia2(mod(i1,4)+1).eq.0) then
00529           i5=i5+1
00530           ia4(i5)=ia1(mod(i1,4)+1)
00531         end if
00532       end do
00533       if(sum(ia2).ne.i4) call errexec("bad ia2 and i4")
00534       if(i4+i5.ne.4)     call errexec("bad i4 and i5")
00535       end subroutine
00536 
00537       !subroutine ttritg_mkidx(n1,n2,n3,idx1)
00538       subroutine ttritg_mkidx(n1,n2,n3,idx1,bvec1,bvec2,bvec3)
00539       integer, intent(in) :: n1
00540       integer, intent(in) :: n2
00541       integer, intent(in) :: n3
00542       integer, intent(out):: idx1(nvtx,n1*n2*n3*ndiv)
00543       real(8), intent(in), optional :: bvec1(3),bvec2(3),bvec3(3)
00544       real(8) :: bvec(3,3)
00545       integer :: i1,i2,i3,i4,i5,i6,i7
00546       integer :: imt1(8,8)
00547       integer :: ia1(8)
00548       if(n1.eq.1.and.n2.eq.1.and.n3.eq.1)return
00549 !--
00550 !      imt1(:,1)=(/0,1,n1,n1+1,n1*n2,n1*n2+1,n1*n2+n1,n1*n2+n1+1/)
00551 !      imt1(:,2)=imt1(:,1)-(/0,n1,0,n1,0,n1,0,n1/)
00552 !      imt1(:,3)=imt1(:,1)
00553 !     $                -(/0,0,n1*n2,n1*n2,0,0,n1*n2,n1*n2/)
00554 !      imt1(:,4)=imt1(:,3)-(/0,n1,0,n1,0,n1,0,n1/)
00555 !      imt1(:,5)=imt1(:,1)
00556 !     $                -(/0,0,0,0,n1*n2*n3,n1*n2*n3,n1*n2*n3,n1*n2*n3/)
00557 !      imt1(:,6)=imt1(:,2)
00558 !     $                -(/0,0,0,0,n1*n2*n3,n1*n2*n3,n1*n2*n3,n1*n2*n3/)
00559 !      imt1(:,7)=imt1(:,3)
00560 !     $                -(/0,0,0,0,n1*n2*n3,n1*n2*n3,n1*n2*n3,n1*n2*n3/)
00561 !      imt1(:,8)=imt1(:,4)
00562 !     $                -(/0,0,0,0,n1*n2*n3,n1*n2*n3,n1*n2*n3,n1*n2*n3/)
00563 !      i6=0
00564 !      i4=0
00565 !      do i3=1,n3
00566 !      do i2=1,n2
00567 !      do i1=1,n1
00568 !        i4=i4+1
00569 !        i5=1
00570 !        if (i1.eq.n1) i5=i5+1
00571 !        if (i2.eq.n2) i5=i5+2
00572 !        if (i3.eq.n3) i5=i5+4
00573 !        ia1=i4+imt1(:,i5)
00574 !        do i7=1,ndiv
00575 !          i6=i6+1
00576 !          idx1(:,i6)=ia1(ttritg_tbl1(:,i7))
00577 !        end do
00578 !      end do
00579 !      end do
00580 !      end do
00581 !      if (i4.ne.n1*n2*n3     ) call errexec("bad i4")
00582 !      if (i6.ne.n1*n2*n3*ndiv) call errexec("bad i6")
00583 !--
00584       bvec=reshape((/1d0,0d0,0d0,0d0,1d0,0d0,0d0,0d0,1d0/),(/3,3/))
00585       if(present(bvec1))bvec(:,1)=bvec1
00586       if(present(bvec2))bvec(:,2)=bvec2
00587       if(present(bvec3))bvec(:,3)=bvec3
00588       call libtetrabzinitialize(bvec,(/n1,n2,n3/),idx1)
00589       end subroutine
00590         
00591       subroutine errexec(smsg)
00592       character(*), intent(in) :: smsg
00593       integer :: i(1:1)
00594       integer :: j
00595       j=0
00596       write(*,"(a)")"#ERROR in ttritg_: "//smsg
00597       i(j)=0
00598       write(*,"('#errexec cannot stop')")
00599       write(*,"('#please use debug option')")
00600       stop
00601       end subroutine
00602 
00603 !!!FROM LIBTETRABZ, MIT License, Copyright (c) 2014 Mitsuaki Kawamura!!!
00604       subroutine libtetrabzinitialize(bvec,ng,indx1)
00605       real(8), intent(in   ) :: bvec(3,3)
00606       integer, intent(in   ) :: ng(3)
00607       integer, intent(  out) :: indx1(4,*)
00608       integer :: nk,nt, ivvec(3,4,6), ikv(3)
00609       integer :: itype, i1, i2, i3, it, ii, divvec(4,4), ivvec0(4)
00610       real(8) :: l(4), bvec2(3,3), bvec3(3,4)
00611       nk = product(ng(1:3))
00612       nt = nk * 6
00613       do i1 = 1, 3
00614         bvec2(1:3,i1) = bvec(1:3,i1) / dble(ng(i1))
00615       end do
00616       bvec3(1:3,1) = -bvec2(1:3,1) + bvec2(1:3,2) + bvec2(1:3,3)
00617       bvec3(1:3,2) =  bvec2(1:3,1) - bvec2(1:3,2) + bvec2(1:3,3)
00618       bvec3(1:3,3) =  bvec2(1:3,1) + bvec2(1:3,2) - bvec2(1:3,3)
00619       bvec3(1:3,4) =  bvec2(1:3,1) + bvec2(1:3,2) + bvec2(1:3,3)
00620       ! length of delta bvec
00621       do i1 = 1, 4
00622         l(i1) = dot_product(bvec3(1:3,i1),bvec3(1:3,i1))
00623       end do
00624       itype = minloc(l(1:4),1)
00625       ! start & last
00626       ivvec0(1:4) = (/ 0, 0, 0, 0 /)
00627       divvec(1:4,1) = (/ 1, 0, 0, 0 /)
00628       divvec(1:4,2) = (/ 0, 1, 0, 0 /)
00629       divvec(1:4,3) = (/ 0, 0, 1, 0 /)
00630       divvec(1:4,4) = (/ 0, 0, 0, 1 /)
00631       ivvec0(itype) = 1
00632       divvec(itype, itype) = - 1
00633       ! Corners of tetrahedra
00634       it = 0
00635       do i1 = 1, 3
00636         do i2 = 1, 3
00637           if(i2 == i1) cycle
00638           do i3 = 1, 3
00639             if(i3 == i1 .or. i3 == i2) cycle
00640             it = it + 1
00641             ivvec(1:3,1,it) = ivvec0(1:3)
00642             ivvec(1:3,2,it) = ivvec(1:3,1,it) + divvec(1:3,i1)
00643             ivvec(1:3,3,it) = ivvec(1:3,2,it) + divvec(1:3,i2)
00644             ivvec(1:3,4,it) = ivvec(1:3,3,it) + divvec(1:3,i3)
00645           end do
00646         end do
00647       end do
00648 !     allocate(indx1(20, 6 * nk), indx2(20, 6 * nk), indx3(20 * 6 * nk))
00649       nt = 0
00650       do i3 = 1, ng(3)
00651         do i2  = 1, ng(2)
00652           do i1 = 1, ng(1)
00653             do it = 1, 6
00654               nt = nt + 1
00655               do ii = 1, 4
00656                 ikv(1:3) = (/i1, i2, i3/) + ivvec(1:3,ii,it) - 1
00657                 ikv(1:3) = modulo(ikv(1:3), ng(1:3))
00658                 indx1(ii,nt) = 1 + ikv(1) + ng(1) * ikv(2) 
00659      $                                    + ng(1) * ng(2) * ikv(3)
00660               end do
00661             end do
00662           end do
00663         end do
00664       end do
00665       end subroutine
00666 !!!FROM LIBTETRABZ, MIT License, Copyright (c) 2014 Mitsuaki Kawamura!!!
00667         
00668       end module

Generated on 17 Nov 2020 for respack by  doxygen 1.6.1