Commit b4fa1066 authored by Daniel Wortmann's avatar Daniel Wortmann

Added cmake tests for libxc, fixed implementation of libxc

parent 6ace9e6e
......@@ -14,6 +14,7 @@ include("cmake/tests/test_Wannier4.cmake")
include("cmake/tests/test_Wannier5.cmake")
include("cmake/tests/test_MAGMA.cmake")
include("cmake/tests/test_GPU.cmake")
include("cmake/tests/test_LibXC.cmake")
if (FLEUR_USE_MPI)
include("cmake/tests/test_SCALAPACK.cmake")
include("cmake/tests/test_ELPA.cmake")
......
......@@ -19,6 +19,7 @@ message("${Green} XML Library found : ${CReset} ${FLEUR_USE_XML}")
message("${Green} LAPACK Library found : ${CReset} ${FLEUR_USE_LAPACK}")
message("${Red}These Libraries are optional:${CReset}")
message("${Green} FFT from MKL found : ${CReset} ${FLEUR_USE_FFTMKL}")
message("${Green} LibXC Library found : ${CReset} ${FLEUR_USE_LIBXC}")
message("${Green} HDF5 Library found : ${CReset} ${FLEUR_USE_HDF5}")
message("${Green} Wannier90 1.2 Library found : ${CReset} ${FLEUR_USE_WANN}")
message("${Green} Wannier90-4 Library found : ${CReset} ${FLEUR_USE_WANN4}")
......
......@@ -2,6 +2,6 @@
set(CMAKE_Fortran_COMPILER mpif90)
#set(CMAKE_C_COMPILER mpiicc)
#Add include pathes
#set(FLEUR_Fortran_FLAGS "")
set(FLEUR_Fortran_FLAGS "-I/opt/include")
#Add linker stuff
set(FLEUR_LIBRARIES ${FLEUR_LIBRARIES} "-L/usr/lib;-L/usr/lib/x86_64-linux-gnu;-lxml2;-lscalapack-openmpi;-lblacsF77init-openmpi;-lblacs-openmpi;-llapack;-lblas")
set(FLEUR_LIBRARIES ${FLEUR_LIBRARIES} "-L/opt/lib;-lxcf03;-lxc;-L/usr/lib;-L/usr/lib/x86_64-linux-gnu;-lxml2;-lscalapack-openmpi;-lblacsF77init-openmpi;-lblacs-openmpi;-llapack;-lblas")
#Check if we can compile with LIBXC
try_compile(FLEUR_USE_LIBXC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/tests/test_LibXC.f90
LINK_LIBRARIES ${FLEUR_LIBRARIES}
)
message("Libxc Library found:${FLEUR_USE_LIBXC}")
if (FLEUR_USE_LIBXC)
set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_LIBXC")
set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_LIBXC")
endif()
PROGRAM test
USE xc_f03_lib_m
TYPE(xc_f03_func_t) :: xc_func
CALL xc_f03_func_init(xc_func, 2, XC_UNPOLARIZED)
END PROGRAM test
......@@ -82,7 +82,7 @@ SUBROUTINE r_inpXML(&
! ..
! .. Local Variables
REAL :: scpos ,zc
INTEGER ieq,i,k,na,n,ii
INTEGER ieq,i,k,na,n,ii,id_c,id_x
REAL s3,ah,a,hs2,rest,thetaj
LOGICAL l_hyb,l_sym,ldum
INTEGER :: ierr
......@@ -1112,8 +1112,18 @@ SUBROUTINE r_inpXML(&
IF (l_relcor) THEN
relcor = 'relativistic'
END IF
!Read in libxc parameters if present
xPathA = '/fleurInput/xcFunctional/libXC'
numberNodes = xmlGetNumberOfNodes(xPathA)
IF (numberNodes==1) THEN
id_x=evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/xcFunctional/libXC/@exchange'))
id_c=evaluateFirstOnly(xmlGetAttributeValue('/fleurInput/xcFunctional/libXC/@correlation'))
ELSE
id_x=0;id_c=0
ENDIF
!now initialize the xcpot variable
CALL setXCParameters(atoms,valueString,l_relcor,xcpot)
CALL setXCParameters(atoms,valueString,l_relcor,input%jspins,id_x,id_c,xcpot)
xPathA = '/fleurInput/calculationSetup/cutoffs/@GmaxXC'
numberNodes = xmlGetNumberOfNodes(xPathA)
......@@ -2007,20 +2017,21 @@ SUBROUTINE r_inpXML(&
END SUBROUTINE r_inpXML
SUBROUTINE setXCParameters(atoms,namex,relcor,xcpot)
SUBROUTINE setXCParameters(atoms,namex,relcor,jspins,id_x,id_c,xcpot)
USE m_juDFT
USE m_types
USE m_types_xcpot_inbuild
! USE m_types_xcpot_libxc
USE m_types_xcpot_libxc
IMPLICIT NONE
TYPE(t_atoms),INTENT(IN) :: atoms
CHARACTER(LEN=*), INTENT(IN) :: namex
LOGICAL, INTENT(IN) :: relcor
INTEGER, INTENT(IN) :: jspins,id_c,id_x
CLASS(t_xcpot),INTENT(OUT),ALLOCATABLE :: xcpot
IF (namex(1:6)=='libxc:') THEN
! ALLOCATE(t_xcpot_libxc::xcpot)
IF (namex(1:5)=='libxc') THEN
ALLOCATE(t_xcpot_libxc::xcpot)
ELSE
ALLOCATE(t_xcpot_inbuild::xcpot)
ENDIF
......@@ -2028,8 +2039,8 @@ SUBROUTINE setXCParameters(atoms,namex,relcor,xcpot)
SELECT TYPE(xcpot)
TYPE IS(t_xcpot_inbuild)
CALL xcpot%init(namex(1:4),relcor,atoms%ntype)
! TYPE IS(t_xcpot_libxc)
! CALL xcpot%init(namex)
TYPE IS(t_xcpot_libxc)
CALL xcpot%init(jspins,id_x,id_c)
END SELECT
......
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
......@@ -549,7 +550,7 @@
READ (UNIT=5,FMT=8050,END=99,ERR=99)&
& input%frcor,sliceplot%slice,input%ctail
input%coretail_lmax=99
input%kcrel=.false.
input%kcrel=0
BACKSPACE(5)
READ (UNIT=5,fmt='(A)') line
input%l_bmt= ( line(52:56)=='bmt=T' ).or.( line(52:56)=='bmt=t' )
......
This source diff could not be displayed because it is too large. You can view the blob instead.
set(fleur_F90 ${fleur_F90}
mpi/mpi_bc_xcpot.F90
mpi/setupMPI.F90)
if (${FLEUR_USE_MPI})
set(fleur_F90 ${fleur_F90}
mpi/mingeselle.F90
......@@ -11,6 +13,5 @@ if (${FLEUR_USE_MPI})
mpi/mpi_col_den.F90
mpi/mpi_make_groups.F90
mpi/mpi_dist_forcetheorem.F90
mpi/mpi_bc_xcpot.F90
)
endif()
......@@ -7,14 +7,15 @@ MODULE m_mpi_bc_xcpot
CONTAINS
SUBROUTINE mpi_bc_xcpot(xcpot,mpi)
USE m_types
USE m_types_xcpot_libxc
IMPLICIT NONE
CLASS(t_xcpot),ALLOCATABLE,INTENT(INOUT):: xcpot
TYPE(t_mpi),INTENT(IN) :: mpi
#ifdef CPP_MPI
LOGICAL :: l_relcor
CHARACTER(len=4):: namex
INTEGER :: ierr,n
LOGICAL :: l_relcor
CHARACTER(len=100):: namex
INTEGER :: ierr,n,i(3)
INCLUDE 'mpif.h'
IF (mpi%isize==1) RETURN !nothing to be done with only one PE
......@@ -23,6 +24,8 @@ CONTAINS
SELECT TYPE(xcpot)
TYPE IS (t_xcpot_inbuild)
n=1
TYPE IS (t_xcpot_libxc)
n=2
CLASS DEFAULT
CALL judft_error("Type could not be determined in mpi_bc_xcpot")
END SELECT
......@@ -34,6 +37,8 @@ CONTAINS
SELECT CASE(n)
CASE(1)
ALLOCATE(t_xcpot_inbuild::xcpot)
CASE(2)
ALLOCATE(t_xcpot_libxc::xcpot)
CASE DEFAULT
CALL judft_error("Type bcast failed in mpi_bc_xcpot")
END SELECT
......@@ -51,6 +56,14 @@ CONTAINS
CALL MPI_BCAST(n,1,MPI_INTEGER,0,mpi%mpi_comm,ierr)
IF (mpi%irank.NE.0) CALL xcpot%init(namex,l_relcor,n)
CALL MPI_BCAST(xcpot%lda_atom,n,MPI_LOGICAL,0,mpi%mpi_comm,ierr)
TYPE IS (t_xcpot_libxc)
IF (mpi%irank==0) THEN
i(1)=xcpot%jspins
i(2)=xcpot%func_id_x
i(3)=xcpot%func_id_c
ENDIF
CALL MPI_BCAST(i,3,MPI_INTEGER,0,mpi%mpi_comm,ierr)
IF (mpi%irank.NE.0) CALL xcpot%init(i(1),i(2),i(3))
END SELECT
#endif
END SUBROUTINE mpi_bc_xcpot
......
......@@ -16,10 +16,10 @@ MODULE m_types_xcpot_libxc
TYPE,EXTENDS(t_xcpot):: t_xcpot_libxc
#ifdef CPP_LIBXC
TYPE(xc_f03_func_t) :: xc_func
TYPE(xc_f03_func_info_t) :: xc_info
TYPE(xc_f03_func_t) :: xc_func_x,xc_func_c
TYPE(xc_f03_func_info_t) :: xc_info_x,xc_info_c
#endif
INTEGER :: func_id
INTEGER :: func_id_c,func_id_x,jspins
CONTAINS
PROCEDURE :: is_gga=>xcpot_is_gga
PROCEDURE :: is_hybrid=>xcpot_is_hybrid
......@@ -33,27 +33,29 @@ MODULE m_types_xcpot_libxc
PUBLIC t_xcpot_libxc
CONTAINS
SUBROUTINE xcpot_init(xcpot,name)
SUBROUTINE xcpot_init(xcpot,jspins,id_x,id_c)
USE m_judft
IMPLICIT NONE
CLASS(t_xcpot_libxc),INTENT(OUT) :: xcpot
CHARACTER(len=*),INTENT(IN) :: name
INTEGER,INTENT(IN) :: jspins,id_x,id_c
#ifdef CPP_LIBXC
INTEGER :: err
READ(name(7:),*,stat=err) xcpot%func_id
IF (err.NE.0) CALL judft_error("Error in specifying libxc xc-functional: '"//name//"' is not a valid specification")
IF (name(1:6).NE."libxc:") CALL judft_error("BUG:inconsistency in xcpot%init")
xcpot%jspins=jspins
xcpot%func_id_x=id_x
xcpot%func_id_c=id_c
IF (jspins==1) THEN
CALL xc_f03_func_init(xcpot%xc_func, xcpot%func_id, XC_UNPOLARIZED)
CALL xc_f03_func_init(xcpot%xc_func_x, xcpot%func_id_x, XC_UNPOLARIZED)
IF (xcpot%func_id_c>0) CALL xc_f03_func_init(xcpot%xc_func_c, xcpot%func_id_c, XC_UNPOLARIZED)
ELSE
CALL xc_f03_func_init(xcpot%xc_func, xcpot%func_id, XC_POLARIZED)
CALL xc_f03_func_init(xcpot%xc_func_x, xcpot%func_id_x, XC_POLARIZED)
IF (xcpot%func_id_c>0) CALL xc_f03_func_init(xcpot%xc_func_c, xcpot%func_id_c, XC_POLARIZED)
END IF
xcpot%xc_info=xc_f03_func_get_info(xcpot%xc_func)
PRINT * "TODO: some info and output on libxc functionals"
xcpot%xc_info_x=xc_f03_func_get_info(xcpot%xc_func_x)
IF (xcpot%func_id_c>0) xcpot%xc_info_c=xc_f03_func_get_info(xcpot%xc_func_c)
PRINT *, "TODO: some info and output on libxc functionals"
#else
CALL judft_error("You specified a libxc-exchange correlation potential but FLEUR is not linked against libxc",hint="Please recompile FLEUR with libxc support")
......@@ -65,7 +67,7 @@ CONTAINS
IMPLICIT NONE
CLASS(t_xcpot_libxc),INTENT(IN):: xcpot
#ifdef CPP_LIBXC
xcpot_is_gga=ANY((/XC_FAMILY_GGA, XC_FAMILY_HYB_GGA/)==xc_f03_func_info_get_family(xcpot%xc_info))
xcpot_is_gga=ANY((/XC_FAMILY_GGA, XC_FAMILY_HYB_GGA/)==xc_f03_func_info_get_family(xcpot%xc_info_x))
#endif
END FUNCTION xcpot_is_gga
......@@ -73,7 +75,7 @@ CONTAINS
IMPLICIT NONE
CLASS(t_xcpot_libxc),INTENT(IN):: xcpot
#ifdef CPP_LIBXC
xcpot_is_hybrid=ANY((/XC_FAMILY_HYB_MGGA, XC_FAMILY_HYB_GGA/)==xc_f03_func_info_get_family(xcpot%xc_info))
xcpot_is_hybrid=ANY((/XC_FAMILY_HYB_MGGA, XC_FAMILY_HYB_GGA/)==xc_f03_func_info_get_family(xcpot%xc_info_x))
#endif
END FUNCTION xcpot_is_hybrid
......@@ -84,7 +86,7 @@ CONTAINS
REAL:: a_ex
#ifdef CPP_LIBXC
a_ex=xc_f03_hyb_exx_coef(xcpot%xc_func)
a_ex=xc_f03_hyb_exx_coef(xcpot%xc_func_x)
#endif
END FUNCTION xcpot_get_exchange_weight
......@@ -100,18 +102,24 @@ CONTAINS
! optional arguments for GGA
TYPE(t_gradients),OPTIONAL,INTENT(IN)::grad
#ifdef CPP_LIBXC
REAL,ALLOCATABLE::vxc_temp(:,:)
REAL,ALLOCATABLE::vxc_tmp(:,:),vx_tmp(:,:),vsigma(:)
vx (:,:) = 0.0 !exchange potential not calculated....
!libxc uses the spin as a first index, hence we have to transpose....
ALLOCATE(vxc_tmp(SIZE(vxc,2),SIZE(vxc,1)))
ALLOCATE(vxc_tmp(SIZE(vxc,2),SIZE(vxc,1)));vxc_tmp=0.0
ALLOCATE(vx_tmp(SIZE(vx,2),SIZE(vx,1)));vx_tmp=0.0
IF (xcpot%is_gga()) THEN
IF (.NOT.PRESENT(grad)) CALL judft_error("Bug: You called get_vxc for a GGA potential without providing derivatives")
CALL xc_f03_gga_vxc(xc_func, SIZE(rh,1), TRANSPOSE(rh),grad%sigma,vxc_tmp)
ALLOCATE(vsigma(SIZE(grad%sigma)))
CALL xc_f03_gga_vxc(xcpot%xc_func_x, SIZE(rh,1), TRANSPOSE(rh),grad%sigma,vx_tmp,vsigma)
IF (xcpot%func_id_c>0) CALL xc_f03_gga_vxc(xcpot%xc_func_c, SIZE(rh,1), TRANSPOSE(rh),grad%sigma,vxc_tmp,vsigma)
ELSE !LDA potentials
CALL xc_f03_lda_vxc(xc_func, SIZE(rh,1), TRANSPOSE(rh), vxc_tmp)
CALL xc_f03_lda_vxc(xcpot%xc_func_x, SIZE(rh,1), TRANSPOSE(rh), vxc_tmp)
IF (xcpot%func_id_c>0) CALL xc_f03_lda_vxc(xcpot%xc_func_c, SIZE(rh,1), TRANSPOSE(rh), vxc_tmp)
ENDIF
vx=TRANSPOSE(vx_tmp)
vxc_tmp=vxc_tmp+vx_tmp
vxc=TRANSPOSE(vxc_tmp)
#endif
END SUBROUTINE xcpot_get_vxc
......@@ -128,9 +136,11 @@ CONTAINS
#ifdef CPP_LIBXC
IF (xcpot%is_gga()) THEN
IF (.NOT.PRESENT(grad)) CALL judft_error("Bug: You called get_vxc for a GGA potential without providing derivatives")
CALL xc_f03_gga_exc(xc_func, SIZE(rh,1), TRANSPOSE(rh),grad%sigma,exc)
CALL xc_f03_gga_exc(xcpot%xc_func_x, SIZE(rh,1), TRANSPOSE(rh),grad%sigma,exc)
IF (xcpot%func_id_c>0) CALL xc_f03_gga_exc(xcpot%xc_func_c, SIZE(rh,1), TRANSPOSE(rh),grad%sigma,exc)
ELSE !LDA potentials
CALL xc_f03_lda_exc(xc_func, SIZE(rh,1), TRANSPOSE(rh), exc)
CALL xc_f03_lda_exc(xcpot%xc_func_x, SIZE(rh,1), TRANSPOSE(rh), exc)
IF (xcpot%func_id_c>0) CALL xc_f03_lda_exc(xcpot%xc_func_c, SIZE(rh,1), TRANSPOSE(rh), exc)
ENDIF
#endif
END SUBROUTINE xcpot_get_exc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment