Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert h5 orbs from spherical to Cartesian #4364

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMake/run_pyscf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ function(SOFTLINK_H5 SOURCE TARGET PREFIX FILENAME TEST_NAME)
set_tests_properties(LINK_${SOURCE}_TO_${TARGET} PROPERTIES DEPENDS ${SOURCE})
set_property(TEST LINK_${SOURCE}_TO_${TARGET} APPEND PROPERTY LABELS "converter")
endfunction()

function(RUN_PYSCF_S2C BASE_NAME H5_INPUT TEST_NAME)
set(MY_WORKDIR ${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME})
add_test(NAME ${TEST_NAME} COMMAND python3 ${qmcpack_SOURCE_DIR}/src/QMCTools/PyscfSphToCart.py
-o ${MY_WORKDIR}/${H5_INPUT}_cart.h5 ${MY_WORKDIR}/${H5_INPUT}_sph.h5)
set_property(
TEST ${TEST_NAME}
APPEND
PROPERTY LABELS "converter;s2c")
endfunction()
64 changes: 64 additions & 0 deletions examples/solids/pyscf-inputs/he2_1x1x1_ae/he2_1x1x1_sph2cart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python

'''
Gamma point Hartree-Fock/DFT

The 2-electron integrals are computed using Poisson solver with FFT by default.
In most scenario, it should be used with pseudo potential.
'''

# Note import path which is different to molecule code
from pyscf.pbc import gto, scf, dft
from pyscf import gto as Mgto
import numpy as np

l_to_char = 'spdfghi'

def bas_str(l):
return f'''
O {l.upper()}
10 0.2
3 0.8
1 0.4
'''
def bas_str_n(n):
return bas_str(l_to_char[n])

def mkcell(l):
cell = gto.Cell()
alat = 6.0
clat = 20.0
cell.a = np.array([
[alat, 0, 0],
[-0.5*alat, 0.5*alat*np.sqrt(3.0), 0],
[0, 0, clat]])
cell.atom = [
['He', [0.59*alat, 0.1, 0.5*clat]],
['He', [0.35*alat, 0.25*np.sqrt(3.0)*alat, 0.5*clat]]]

cell.basis = {'He': Mgto.parse(''.join(bas_str(i) for i in l))}
cell.verbose = 0
cell.cart = False
cell.build()
return cell

def runscf(l):
cell = mkcell(l)
mf = scf.RHF(cell).density_fit(auxbasis='weigend')
mf.conv_tol = 1e-12
ehf = mf.kernel()
#import sys
#sys.path.append(f'{QMCROOT}/src/QMCTools')
from PyscfToQmcpack import savetoqmcpack
savetoqmcpack(cell,mf,title=f'he_{l}_sph')
#from PyscfSphToCart import qmch5
#qh5 = qmch5(f'he_{l}_sph.h5')
#qh5.generate_h5(newpath = f'he_{l}_cart.h5')
return

# add higher l when supported in QMCPACK
#for lbas in 'pdfghi':
for lbas in 'pdfgh':
# run scf with 'sp', 'sd', 'sf', ... basis
# need 2+ shells at a time to verify correct relative normalization between shells of different l
runscf('s'+lbas)
344 changes: 344 additions & 0 deletions src/QMCTools/PyscfSphToCart.py

Large diffs are not rendered by default.

174 changes: 172 additions & 2 deletions tests/pyscf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ include("${qmcpack_SOURCE_DIR}/CMake/run_pyscf.cmake")
set(LAST_TEST_NAME "NONE")
set(PYSCF_TEST_NAME "NONE")

run_pyscf_test(pyscf-diamond_1x1x1_pp_LCAO ${qmcpack_SOURCE_DIR}/examples/solids/pyscf-inputs diamondC_1x1x1_pp_LCAO
################################################################################

run_pyscf_test(pyscf-diamond_1x1x1_pp_LCAO ${qmcpack_SOURCE_DIR}/examples/solids/pyscf-inputs/diamondC_1x1x1_pp diamondC_1x1x1_pp_LCAO
PYSCF_TEST_NAME)

set_tests_properties(${PYSCF_TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION "successfully saved to QMCPACK HDF5")
Expand Down Expand Up @@ -44,7 +46,9 @@ if(${THIS_TEST_NAME})
PROPERTY LABELS "converter")
endif()

run_pyscf_test(pyscf-diamond_1x1x1_pp_Bspline ${qmcpack_SOURCE_DIR}/examples/solids/pyscf-inputs
################################################################################

run_pyscf_test(pyscf-diamond_1x1x1_pp_Bspline ${qmcpack_SOURCE_DIR}/examples/solids/pyscf-inputs/diamondC_1x1x1_pp
diamondC_1x1x1_pp_Bspline PYSCF_TEST_NAME)

set_tests_properties(${PYSCF_TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION "successfully saved to QMCPACK HDF5")
Expand All @@ -69,3 +73,169 @@ if(${THIS_TEST_NAME})
set_tests_properties(${THIS_TEST_NAME}-1-16 PROPERTIES DEPENDS ${LAST_TEST_NAME})
set_property(TEST ${THIS_TEST_NAME}-1-16 APPEND PROPERTY LABELS "converter")
endif()

################################################################################

# PYSCF_TEST_NAME set to pyscf-he2_1x1x1_sph2cart
# copy src dir to workdir
# add pyscf test: pyscf-he2_1x1x1_sph2cart
# python he2_1x1x1_sph2cart.py
run_pyscf_test(pyscf-he2_1x1x1_sph ${qmcpack_SOURCE_DIR}/examples/solids/pyscf-inputs/he2_1x1x1_ae
he2_1x1x1_sph2cart PYSCF_TEST_NAME)

set_property(TEST ${PYSCF_TEST_NAME} APPEND PROPERTY LABELS "s2c")

run_pyscf_s2c(${PYSCF_TEST_NAME} he_sp ${PYSCF_TEST_NAME}_sp_s2c)

softlink_h5(${PYSCF_TEST_NAME} he2_1x1x1_ae-vmc_sp_s2c_noj-1-16 he_sp_cart he_sp_cart.h5
LAST_TEST_NAME)

list(APPEND HE2_SP_SCALARS "totenergy" "-2.32676861 0.0863")
list(APPEND HE2_SP_SCALARS "kinetic" "16.23198428 0.1117")
list(APPEND HE2_SP_SCALARS "potential" "-18.55875289 0.1136")
list(APPEND HE2_SP_SCALARS "eeenergy" "4.59673345 0.0174")
list(APPEND HE2_SP_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SP_SCALARS "samples" "16000 0.0")

set(THIS_TEST_NAME "${PYSCF_TEST_NAME}-he2_1x1x1_ae-vmc_sp_s2c_noj")

qmc_run_and_check(
${THIS_TEST_NAME}
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sp_cart
he2_sp_cart.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SP_SCALARS # VMC
)

if(${THIS_TEST_NAME})
set_tests_properties(${THIS_TEST_NAME}-1-16 PROPERTIES DEPENDS ${LAST_TEST_NAME})
set_property(TEST ${THIS_TEST_NAME}-1-16 APPEND PROPERTY LABELS "converter")
endif()

run_pyscf_s2c(${PYSCF_TEST_NAME} he_sd ${PYSCF_TEST_NAME}_sd_s2c)

softlink_h5(${PYSCF_TEST_NAME} he2_1x1x1_ae-vmc_sd_s2c_noj-1-16 he_sd_cart he_sd_cart.h5
LAST_TEST_NAME)

list(APPEND HE2_SD_SCALARS "totenergy" "-2.32942007 0.0835")
list(APPEND HE2_SD_SCALARS "kinetic" "16.21547981 0.1067")
list(APPEND HE2_SD_SCALARS "potential" "-18.54489989 0.1189")
list(APPEND HE2_SD_SCALARS "eeenergy" "4.59377532 0.0184")
list(APPEND HE2_SD_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SD_SCALARS "samples" "16000 0.0")

set(THIS_TEST_NAME "${PYSCF_TEST_NAME}-he2_1x1x1_ae-vmc_sd_s2c_noj")

qmc_run_and_check(
${THIS_TEST_NAME}
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sd_cart
he2_sd_cart.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SD_SCALARS # VMC
)

if(${THIS_TEST_NAME})
set_tests_properties(${THIS_TEST_NAME}-1-16 PROPERTIES DEPENDS ${LAST_TEST_NAME})
set_property(TEST ${THIS_TEST_NAME}-1-16 APPEND PROPERTY LABELS "converter")
endif()

run_pyscf_s2c(${PYSCF_TEST_NAME} he_sf ${PYSCF_TEST_NAME}_sf_s2c)

softlink_h5(${PYSCF_TEST_NAME} he2_1x1x1_ae-vmc_sf_s2c_noj-1-16 he_sf_cart he_sf_cart.h5
LAST_TEST_NAME)

list(APPEND HE2_SF_SCALARS "totenergy" "-2.35068897 0.1249")
list(APPEND HE2_SF_SCALARS "kinetic" "16.20083403 0.1568")
list(APPEND HE2_SF_SCALARS "potential" "-18.55152300 0.1705")
list(APPEND HE2_SF_SCALARS "eeenergy" "4.59192604 0.0261")
list(APPEND HE2_SF_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SF_SCALARS "samples" "16000 0.0")

set(THIS_TEST_NAME "${PYSCF_TEST_NAME}-he2_1x1x1_ae-vmc_sf_s2c_noj")

qmc_run_and_check(
${THIS_TEST_NAME}
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sf_cart
he2_sf_cart.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SF_SCALARS # VMC
)

if(${THIS_TEST_NAME})
set_tests_properties(${THIS_TEST_NAME}-1-16 PROPERTIES DEPENDS ${LAST_TEST_NAME})
set_property(TEST ${THIS_TEST_NAME}-1-16 APPEND PROPERTY LABELS "converter")
endif()

run_pyscf_s2c(${PYSCF_TEST_NAME} he_sg ${PYSCF_TEST_NAME}_sg_s2c)

softlink_h5(${PYSCF_TEST_NAME} he2_1x1x1_ae-vmc_sg_s2c_noj-1-16 he_sg_cart he_sg_cart.h5
LAST_TEST_NAME)

list(APPEND HE2_SG_SCALARS "totenergy" "-2.30636188 0.1233")
list(APPEND HE2_SG_SCALARS "kinetic" "16.21415978 0.1493")
list(APPEND HE2_SG_SCALARS "potential" "-18.52052166 0.1655")
list(APPEND HE2_SG_SCALARS "eeenergy" "4.59711595 0.0251")
list(APPEND HE2_SG_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SG_SCALARS "samples" "16000 0.0")

set(THIS_TEST_NAME "${PYSCF_TEST_NAME}-he2_1x1x1_ae-vmc_sg_s2c_noj")

qmc_run_and_check(
${THIS_TEST_NAME}
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sg_cart
he2_sg_cart.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SG_SCALARS # VMC
)

if(${THIS_TEST_NAME})
set_tests_properties(${THIS_TEST_NAME}-1-16 PROPERTIES DEPENDS ${LAST_TEST_NAME})
set_property(TEST ${THIS_TEST_NAME}-1-16 APPEND PROPERTY LABELS "converter")
endif()

run_pyscf_s2c(${PYSCF_TEST_NAME} he_sh ${PYSCF_TEST_NAME}_sh_s2c)

softlink_h5(${PYSCF_TEST_NAME} he2_1x1x1_ae-vmc_sh_s2c_noj-1-16 he_sh_cart he_sh_cart.h5
LAST_TEST_NAME)

list(APPEND HE2_SH_SCALARS "totenergy" "-2.31529851 0.0837")
list(APPEND HE2_SH_SCALARS "kinetic" "16.21254352 0.1095")
list(APPEND HE2_SH_SCALARS "potential" "-18.52784203 0.1163")
list(APPEND HE2_SH_SCALARS "eeenergy" "4.59749106 0.0174")
list(APPEND HE2_SH_SCALARS "ionion" " 0.86420131 0.0001")
list(APPEND HE2_SH_SCALARS "samples" "16000 0.0")

set(THIS_TEST_NAME "${PYSCF_TEST_NAME}-he2_1x1x1_ae-vmc_sh_s2c_noj")

qmc_run_and_check(
${THIS_TEST_NAME}
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sh_cart
he2_sh_cart.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SH_SCALARS # VMC
)

if(${THIS_TEST_NAME})
set_tests_properties(${THIS_TEST_NAME}-1-16 PROPERTIES DEPENDS ${LAST_TEST_NAME})
set_property(TEST ${THIS_TEST_NAME}-1-16 APPEND PROPERTY LABELS "converter")
endif()
1 change: 1 addition & 0 deletions tests/solids/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_subdirectory("monoO_1x1x1_pp")
add_subdirectory("NiO_a4_e48_pp")
add_subdirectory("grapheneC_1x1_pp")
add_subdirectory("InSe_a4")
add_subdirectory("he2_1x1x1_ae")

if(QMC_COMPLEX)
add_subdirectory("bccMo_2x1x1_SOREP")
Expand Down
100 changes: 100 additions & 0 deletions tests/solids/he2_1x1x1_ae/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
if(NOT QMC_CUDA)

list(APPEND HE2_SP_SCALARS "totenergy" "-2.32676861 0.0863")
list(APPEND HE2_SP_SCALARS "kinetic" "16.23198428 0.1117")
list(APPEND HE2_SP_SCALARS "potential" "-18.55875289 0.1136")
list(APPEND HE2_SP_SCALARS "eeenergy" "4.59673345 0.0174")
list(APPEND HE2_SP_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SP_SCALARS "samples" "16000 0.0")

qmc_run_and_check(
short-he2_1x1x1_ae-vmc_gaussian-sp-sph_noj
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sp_sph
he2_sp_sph.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SP_SCALARS # VMC
)

list(APPEND HE2_SD_SCALARS "totenergy" "-2.32942007 0.0835")
list(APPEND HE2_SD_SCALARS "kinetic" "16.21547981 0.1067")
list(APPEND HE2_SD_SCALARS "potential" "-18.54489989 0.1189")
list(APPEND HE2_SD_SCALARS "eeenergy" "4.59377532 0.0184")
list(APPEND HE2_SD_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SD_SCALARS "samples" "16000 0.0")

qmc_run_and_check(
short-he2_1x1x1_ae-vmc_gaussian-sd-sph_noj
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sd_sph
he2_sd_sph.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SD_SCALARS # VMC
)

list(APPEND HE2_SF_SCALARS "totenergy" "-2.35068897 0.1249")
list(APPEND HE2_SF_SCALARS "kinetic" "16.20083403 0.1568")
list(APPEND HE2_SF_SCALARS "potential" "-18.55152300 0.1705")
list(APPEND HE2_SF_SCALARS "eeenergy" "4.59192604 0.0261")
list(APPEND HE2_SF_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SF_SCALARS "samples" "16000 0.0")

qmc_run_and_check(
short-he2_1x1x1_ae-vmc_gaussian-sf-sph_noj
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sf_sph
he2_sf_sph.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SF_SCALARS # VMC
)

list(APPEND HE2_SG_SCALARS "totenergy" "-2.30636188 0.1233")
list(APPEND HE2_SG_SCALARS "kinetic" "16.21415978 0.1493")
list(APPEND HE2_SG_SCALARS "potential" "-18.52052166 0.1655")
list(APPEND HE2_SG_SCALARS "eeenergy" "4.59711595 0.0251")
list(APPEND HE2_SG_SCALARS "ionion" "0.86420131 0.0001")
list(APPEND HE2_SG_SCALARS "samples" "16000 0.0")

qmc_run_and_check(
short-he2_1x1x1_ae-vmc_gaussian-sg-sph_noj
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sg_sph
he2_sg_sph.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SG_SCALARS # VMC
)

list(APPEND HE2_SH_SCALARS "totenergy" "-2.31529851 0.0837")
list(APPEND HE2_SH_SCALARS "kinetic" "16.21254352 0.1095")
list(APPEND HE2_SH_SCALARS "potential" "-18.52784203 0.1163")
list(APPEND HE2_SH_SCALARS "eeenergy" "4.59749106 0.0174")
list(APPEND HE2_SH_SCALARS "ionion" " 0.86420131 0.0001")
list(APPEND HE2_SH_SCALARS "samples" "16000 0.0")

qmc_run_and_check(
short-he2_1x1x1_ae-vmc_gaussian-sh-sph_noj
"${qmcpack_SOURCE_DIR}/tests/solids/he2_1x1x1_ae"
he2_sh_sph
he2_sh_sph.qmc.in-wfnoj.xml
1
16
TRUE
0
HE2_SH_SCALARS # VMC
)

else()
message(VERBOSE "Skipping Periodic LCAO as not supported by CUDA build (QMC_CUDA=1)")
endif()
Loading
Loading