Skip to content

Commit

Permalink
add real-space RMG converter to convert4qmc (#3351)
Browse files Browse the repository at this point in the history
* started adding RMG to convert4qmc

* replace raw pointer with std::unique_ptr for RMGParser in convert4qmc

* clang-format

* updated docs for RMG converter

* change supertwist handling in RMG converter

* added tests for RMG converter

* removed larger rmg converter test

* added spin-polarized RMG converter test

* add override for two RMGParser functions

* added RMG ctest (WIP)

* cleaned up RMG tests

* shortened rmg vmc test

* added rmg-diamond reference vals

* minor cleanup

* minor cleanup of cmake for RMG

Co-authored-by: Paul R. C. Kent <kentpr@ornl.gov>
  • Loading branch information
kgasperich and prckent authored Nov 3, 2021
1 parent 8876779 commit 2c533a4
Show file tree
Hide file tree
Showing 30 changed files with 14,446 additions and 6 deletions.
12 changes: 12 additions & 0 deletions CMake/FindRMG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Locate rmg-cpu
# Take RMG_BIN as hint for location

find_program(RMG_CPU_EXE rmg-cpu HINTS ${RMG_BIN})

set(RMG_FOUND FALSE)
if(RMG_CPU_EXE)
MESSAGE(STATUS "RMG_CPU_EXE=${RMG_CPU_EXE}")
set(RMG_FOUND TRUE)
endif()

mark_as_advanced(RMG_CPU_EXE RMG_FOUND)
4 changes: 4 additions & 0 deletions CMake/ctest_script.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ if(DEFINED QE_BIN)
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DQE_BIN='${QE_BIN}'")
endif()

if(DEFINED RMG_BIN)
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DRMG_BIN='${RMG_BIN}'")
endif()

if(DEFINED QMC_CUDA)
set(CTEST_OPTIONS "${CTEST_OPTIONS};-DQMC_CUDA=${QMC_CUDA}")
endif()
Expand Down
110 changes: 110 additions & 0 deletions CMake/run_rmg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# functions for RMG workflow test

if(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
function(ADD_RMG_TEST)

endfunction()
function(RUN_RMG_TEST)

endfunction()
else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)

function(
ADD_RMG_TEST
TESTNAME
NPROCS
NTHREADS
TEST_BINARY
WORKDIR
TEST_INPUT)
#if(HAVE_MPI)
# add_test(NAME ${TESTNAME} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${NPROCS} ${MPIEXEC_PREFLAGS}
# ${TEST_BINARY} ${TEST_INPUT})
#else(HAVE_MPI)
add_test(NAME ${TESTNAME} COMMAND ${TEST_BINARY} ${TEST_INPUT})
#endif(HAVE_MPI)
set_tests_properties(
${TESTNAME}
PROPERTIES ENVIRONMENT
"OMP_NUM_THREADS=${NTHREADS};RMG_NUM_THREADS=${NTHREADS}"
PROCESSORS
${NPROCS}
PROCESSOR_AFFINITY
TRUE
WORKING_DIRECTORY
${WORKDIR})
set_property(
TEST ${TESTNAME}
APPEND
PROPERTY LABELS "converter;rmg")
endfunction()

function(
ADD_RMG_CONVERT_TEST
TESTNAME
PREFIX
WORKDIR
TEST_INPUT)
add_test(NAME ${TESTNAME} COMMAND $<TARGET_FILE:convert4qmc> -rmg ${TEST_INPUT} -prefix ${PREFIX})
set_tests_properties(
${TESTNAME}
PROPERTIES
WORKING_DIRECTORY
${WORKDIR})
set_property(
TEST ${TESTNAME}
APPEND
PROPERTY LABELS "converter;rmg")
endfunction()

function(
RUN_RMG_TEST
BASE_NAME
SRC_DIR
NPROCS
NTHREADS
TEST_NAME)
set(FULL_NAME ${BASE_NAME}-np-${NPROCS})
set(${TEST_NAME}
${FULL_NAME}
PARENT_SCOPE)
set(MY_WORKDIR ${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME})
message(VERBOSE "Adding test ${FULL_NAME}")
copy_directory("${SRC_DIR}" "${MY_WORKDIR}")
message("workdir: ${MY_WORKDIR}")
add_rmg_test(${FULL_NAME}-scf ${NPROCS} ${NTHREADS} ${RMG_CPU_EXE} ${MY_WORKDIR} input)
softlink_h5_rmg_waves(${FULL_NAME} ${BASE_NAME})
add_rmg_convert_test(${FULL_NAME}-rmg2qmc ${BASE_NAME} ${MY_WORKDIR} ${BASE_NAME}.h5)
set_tests_properties(${FULL_NAME}-rmg2qmc PROPERTIES DEPENDS ${FULL_NAME}-scf)

endfunction()

endif(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)

function(SOFTLINK_H5_RMG_WAVES SOURCE PREFIX)
# set(${TEST_NAME}
# "LINK_${SOURCE}_h5_Waves"
# PARENT_SCOPE)
add_test(NAME LINK_${SOURCE}_h5_Waves COMMAND ${qmcpack_SOURCE_DIR}/tests/scripts/clean_and_link_h5.sh
${SOURCE}/Waves/wave.out.h5 ${SOURCE}/${PREFIX}.h5)
set_tests_properties(LINK_${SOURCE}_h5_Waves PROPERTIES DEPENDS ${SOURCE}-scf)
set_property(TEST LINK_${SOURCE}_h5_Waves APPEND PROPERTY LABELS "rmg")
endfunction()

function(SOFTLINK_RMG_INPUT SOURCE TARGET PREFIX TEST_NAME)
set(${TEST_NAME}
"LINK_${SOURCE}_TO_${TARGET}"
PARENT_SCOPE)
add_test(NAME LINK_${SOURCE}_TO_${TARGET} COMMAND ${qmcpack_SOURCE_DIR}/tests/scripts/clean_and_link_h5.sh
${SOURCE}/${PREFIX}.h5 ${SOURCE}-${TARGET}/${PREFIX}.h5)
set_tests_properties(LINK_${SOURCE}_TO_${TARGET} PROPERTIES DEPENDS ${SOURCE}-scf)
set_property(TEST LINK_${SOURCE}_TO_${TARGET} APPEND PROPERTY LABELS "rmg")
add_test(NAME COPY_${SOURCE}_XML_TO_${TARGET} COMMAND
bash -c "mkdir -p ${SOURCE}-${TARGET}; \
cp ${SOURCE}/${PREFIX}.structure.xml ${SOURCE}-${TARGET}/${PREFIX}.structure.xml ; \
cp ${SOURCE}/${PREFIX}.wfnoj.xml ${SOURCE}-${TARGET}/${PREFIX}.wfnoj.xml ; \
cp ${SOURCE}/*.qmcpp.xml ${SOURCE}-${TARGET}/")
set_tests_properties(COPY_${SOURCE}_XML_TO_${TARGET} PROPERTIES DEPENDS ${SOURCE}-scf)
set_property(TEST COPY_${SOURCE}_XML_TO_${TARGET} APPEND PROPERTY LABELS "rmg")
endfunction()

13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,19 @@ if(NOT QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
endif(QE_FOUND)
endif()

#-------------------------------------------------------------------
# Check if RMG executable available at RMG_BIN or on the PATH
#-------------------------------------------------------------------
if(NOT QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
include("CMake/FindRMG.cmake")
if(RMG_FOUND)
message(STATUS "Found and using RMG (rmg-cpu) at ${RMG_CPU_EXE}")
else(RMG_FOUND)
message(
STATUS "Did not find RMG (rmg-cpu). RMG tests will not be run.")
endif(RMG_FOUND)
endif()

######################################################################
message(STATUS "Ready to parse QMCPACK source tree")
######################################################################
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ make -j 8

```
QE_BIN Location of Quantum Espresso binaries including pw2qmcpack.x
RMG_BIN Location of RMG binary
QMC_DATA Specify data directory for QMCPACK performance and integration tests
QMC_INCLUDE Add extra include paths
QMC_EXTRA_LIBS Add extra link libraries
Expand Down
14 changes: 12 additions & 2 deletions docs/additional_tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ It is a small C++ executable that is built alongside the QMCPACK
executable and can be found in ``build/bin``.

To date, ``convert4qmc`` supports the following codes:
GAMESS :cite:`schmidt93`, PySCF :cite:`Sun2018` and QP2 :cite:`QP2` natively, and NWCHEM :cite:`NWCHEM`, TURBOMOLE :cite:`TURBOMOLE`, PSI4 :cite:`PSI4`, CFOUR 2.0beta :cite:`CFOUR`, ORCA 3.X - 4.X :cite:`ORCA`, DALTON2016 :cite:`DALTON2016`, MOLPRO :cite:`MOLPRO`, DIRAC :cite:`DIRAC`, and QCHEM 4.X :cite:`QCHEM` through the molden2qmc converter (see :ref:`molden2qmc`).
GAMESS :cite:`schmidt93`, PySCF :cite:`Sun2018` and QP2 :cite:`QP2` natively, and NWCHEM :cite:`NWCHEM`, TURBOMOLE :cite:`TURBOMOLE`, PSI4 :cite:`PSI4`, CFOUR 2.0beta :cite:`CFOUR`, ORCA 3.X - 4.X :cite:`ORCA`, DALTON2016 :cite:`DALTON2016`, MOLPRO :cite:`MOLPRO`, DIRAC :cite:`DIRAC`, RMG :cite:`RMG`, and QCHEM 4.X :cite:`QCHEM` through the molden2qmc converter (see :ref:`molden2qmc`).



Expand All @@ -71,7 +71,7 @@ General use of ``convert4qmc`` can be prompted by running with no options:

Defaults : -gridtype log -first 1e-6 -last 100 -size 1001 -ci required -threshold 0.01 -TargetState 0 -prefix sample

convert [-gaussian|gamess|-orbitals|-dirac]
convert [-gaussian|gamess|-orbitals|-dirac|-rmg]
filename
[-nojastrow -hdf5 -prefix title -addCusp -production -NbImages NimageX NimageY NimageZ]
[-psi_tag psi0 -ion_tag ion0 -gridtype log|log0|linear -first ri -last rf]
Expand Down Expand Up @@ -289,6 +289,8 @@ prefix ``Mysim`` and output files will be
+-----------------+----------------------------------------------------------------------------+
| ``-dirac`` | get spinors from DIRAC code |
+-----------------+----------------------------------------------------------------------------+
| ``-rmg`` | RMG code |
+-----------------+----------------------------------------------------------------------------+

Command line options
^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -693,6 +695,14 @@ Periodic boundary conditions with Gaussian orbitals from PySCF is fully supporte

QMCPACK can use the output of DIRAC to run spin-orbit calculations using single-particle spinor wave functions for single-determinant calculations (DFT or closed-shell Dirac HF) or multideterminant complete open-shell configuration interaction (COSCI) wavefunctions. In the case of COSCI, the desired ground or excited state can be requested with ``-TargetState x``.

- **RMG**

QMCPACK can use the HDF5 output of RMG DFT calculations. To generate this HDF5 output, set ``write_qmcpack_restart = "true"`` in the RMG input (file will be written to ``Waves/wave.out.h5``). ``convert4qmc`` will read the data from this HDF5 file and generate ``*.structure.xml``, ``*.wf{j,noj}.xml``, and ``*.qmc.in-wf{j,noj}.xml``. Pseudopotential files must be generated/moved manually by the user to ``X.qmcpp.xml``, where ``X`` is the appropriate element symbol (PP filename/path can be changed in the Hamiltonian section of ``*.qmc.in-wf{j,noj}.xml``).

::

convert4qmc -rmg wave.out.h5

.. _pw2qmcpack:

pw2qmcpack.x
Expand Down
3 changes: 3 additions & 0 deletions docs/bibs/additional_tools.bib
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,6 @@ @Misc{DIRAC
(available at \url{http://dx.doi.org/10.5281/zenodo.3572669},
see also \url{http://www.diracprogram.org})"}

@Misc{RMG,
note = "{RMG}, a real space multigrid DFT code, \url{https://github.com/RMGDFT/rmgdft}"}

5 changes: 3 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ are given in the referenced sections.

#. Run the cmake configure step and build with make
(:ref:`cmake` and :ref:`cmakequick`). Examples for common systems are given in :ref:`installexamples`. To activate workflow
tests for Quantum ESPRESSO or PYSCF, be sure to specify QE_BIN or ensure that the python modules are available when cmake is
run.
tests for Quantum ESPRESSO, RMG, or PYSCF, be sure to specify QE_BIN, RMG_BIN, or ensure that the python modules are
available when cmake is run.

#. Run the tests to verify QMCPACK
(:ref:`testing`).
Expand Down Expand Up @@ -326,6 +326,7 @@ the path to the source directory.
::

QE_BIN Location of Quantum ESPRESSO binaries including pw2qmcpack.x
RMG_BIN Location of RMG binary (rmg-cpu)
QMC_DATA Specify data directory for QMCPACK performance and integration tests
QMC_INCLUDE Add extra include paths
QMC_EXTRA_LIBS Add extra link libraries
Expand Down
Loading

0 comments on commit 2c533a4

Please sign in to comment.