      real*8 function vli3_at(r)
      implicit none
      !
      ! All distances in atomic units
      !
      real*8 r(3),cos1,cos2,cos3
      real*8 C,v,rp,coef,rp3,angfac
      parameter (coef=10000d0)
      
      vli3_at = 1.0d0/coef
      C = 170100d0
      cos1 = 0d0
      cos2 = 0d0
      cos3 = 0d0
      rp = r(1)*r(2)*r(3)
      rp3=rp**3
      if(rp.lt.1d-10) then
          if(abs(r(1)).lt.1d-10) cos1 = 1d0
          if(abs(r(2)).lt.1d-10) cos2 = 1d0
          if(abs(r(3)).lt.1d-10) cos3 = 1d0            
      else 
          cos1 = (r(2)**2+r(3)**2-r(1)**2)/(2*r(2)*r(3))
          cos2 = (r(1)**2+r(3)**2-r(2)**2)/(2*r(1)*r(3))
          cos3 = (r(2)**2+r(1)**2-r(3)**2)/(2*r(2)*r(1))
      end if

      
      angfac = (1d0+3d0*cos1*cos2*cos3)
      vli3_at=C/(coef*C+rp3)*angfac
!      write(*,*) r,vli3_at
      
      return
      end
