diff --git a/CMake/macros.cmake b/CMake/macros.cmake index a4242bfc4c..2ff98054fa 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -408,7 +408,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS) #MESSAGE("check command = ${CHECK_CMD}") add_test( NAME ${TEST_NAME} - COMMAND ${CHECK_CMD} + COMMAND ${Python3_EXECUTABLE} ${CHECK_CMD} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME}") set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${FULL_NAME}) set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS "QMCPACK-checking-results") @@ -536,7 +536,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS) ${SCALAR_ERROR}) add_test( NAME ${TEST_NAME} - COMMAND ${CHECK_CMD} + COMMAND ${Python3_EXECUTABLE} ${CHECK_CMD} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME}") set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${FULL_NAME}) set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS "QMCPACK-checking-results") @@ -595,7 +595,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS) add_test( NAME "${test_name}" - COMMAND ${check_cmd} ${ARGN} + COMMAND ${Python3_EXECUTABLE} ${check_cmd} ${ARGN} WORKING_DIRECTORY "${work_dir}") # make test depend on the run diff --git a/CMake/test_labels.cmake b/CMake/test_labels.cmake index 88c3e18f93..4f561c3054 100644 --- a/CMake/test_labels.cmake +++ b/CMake/test_labels.cmake @@ -6,7 +6,7 @@ function(ADD_TEST_LABELS TEST_NAME TEST_LABELS) else() set(SUCCESS FALSE) execute_process( - COMMAND ${qmcpack_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX} + COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX} ${QMC_MIXED_PRECISION} OUTPUT_VARIABLE TEST_LABELS_TEMP RESULT_VARIABLE SUCCESS) diff --git a/CMake/unit_test.cmake b/CMake/unit_test.cmake index 70f12f7f79..7e0eaf9d74 100644 --- a/CMake/unit_test.cmake +++ b/CMake/unit_test.cmake @@ -36,3 +36,21 @@ function(ADD_UNIT_TEST TESTNAME PROCS THREADS TEST_BINARY) APPEND PROPERTY LABELS "unit") endfunction() + +# Add a test to see if the target output exists in the desired location in the build directory. +function(add_test_target_in_output_location TARGET_NAME_TO_TEST EXE_DIR_RELATIVE_TO_BUILD) + + # obtain BASE_NAME + get_target_property(BASE_NAME ${TARGET_NAME_TO_TEST} OUTPUT_NAME) + if(NOT BASE_NAME) + set(BASE_NAME ${TARGET_NAME_TO_TEST}) + endif() + + set(TESTNAME build_output_${TARGET_NAME_TO_TEST}_exists) + add_test(NAME ${TESTNAME} COMMAND ls ${qmcpack_BINARY_DIR}/bin/${BASE_NAME}) + + set_property( + TEST ${TESTNAME} + APPEND + PROPERTY LABELS "unit;deterministic") +endfunction() diff --git a/docs/hamiltonianobservable.rst b/docs/hamiltonianobservable.rst index c65b5f5d92..768afb084a 100644 --- a/docs/hamiltonianobservable.rst +++ b/docs/hamiltonianobservable.rst @@ -327,7 +327,7 @@ attributes: +-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+ | ``format``:math:`^r` | text | xml/table | table | Select file format | +-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+ - | ``algorithm``:math:`^o` | text | batched/non-batched | depends | Choose NLPP algorithm | + | ``algorithm``:math:`^o` | text | batched/non-batched | batched | Choose NLPP algorithm | +-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+ | ``DLA``:math:`^o` | text | yes/no | no | Use determinant localization approximation | +-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+ @@ -359,9 +359,7 @@ Additional information: These elements specify individual file names and formats (both the FSAtom XML and CASINO tabular data formats are supported). -- **algorithm** The default value is ``batched`` when OpenMP offload - is enabled and``non-batched`` otherwise. - The ``non-batched`` algorithm evaluates the ratios of +- **algorithm** The ``non-batched`` algorithm evaluates the ratios of wavefunction components together for each quadrature point and then one point after another. The ``batched`` algorithm evaluates the ratios of quadrature points together for each wavefunction component and diff --git a/src/QMCApp/CMakeLists.txt b/src/QMCApp/CMakeLists.txt index 3aa6c7af7f..61b669ae8d 100644 --- a/src/QMCApp/CMakeLists.txt +++ b/src/QMCApp/CMakeLists.txt @@ -56,4 +56,5 @@ if(USE_OBJECT_TARGET) platform_omptarget_LA) endif() +add_test_target_in_output_location(qmcpack bin) install(TARGETS qmcpack RUNTIME DESTINATION bin) diff --git a/src/QMCHamiltonians/ECPotentialBuilder.cpp b/src/QMCHamiltonians/ECPotentialBuilder.cpp index 3b92d51abf..b87d0807a3 100644 --- a/src/QMCHamiltonians/ECPotentialBuilder.cpp +++ b/src/QMCHamiltonians/ECPotentialBuilder.cpp @@ -71,20 +71,13 @@ bool ECPotentialBuilder::put(xmlNodePtr cur) OhmmsAttributeSet pAttrib; pAttrib.add(ecpFormat, "format", {"table", "xml"}); - pAttrib.add(NLPP_algo, "algorithm", {"", "batched", "non-batched"}); + pAttrib.add(NLPP_algo, "algorithm", {"batched", "non-batched"}); pAttrib.add(use_DLA, "DLA", {"no", "yes"}); pAttrib.add(pbc, "pbc", {"yes", "no"}); pAttrib.add(forces, "forces", {"no", "yes"}); pAttrib.add(physicalSO, "physicalSO", {"yes", "no"}); pAttrib.put(cur); - if (NLPP_algo.empty()) -#ifdef ENABLE_OFFLOAD - NLPP_algo = "batched"; -#else - NLPP_algo = "non-batched"; -#endif - bool doForces = (forces == "yes") || (forces == "true"); if (use_DLA == "yes") app_log() << " Using determinant localization approximation (DLA)" << std::endl; diff --git a/src/QMCHamiltonians/tests/test_ion_derivs.cpp b/src/QMCHamiltonians/tests/test_ion_derivs.cpp index 70cde0aa1d..8ecbce00c6 100644 --- a/src/QMCHamiltonians/tests/test_ion_derivs.cpp +++ b/src/QMCHamiltonians/tests/test_ion_derivs.cpp @@ -20,6 +20,7 @@ #include "QMCHamiltonians/tests/MinimalHamiltonianPool.h" #include "ParticleIO/XMLParticleIO.h" #include "Utilities/RandomGenerator.h" +#include "QMCWaveFunctions/TWFFastDerivWrapper.h" namespace qmcplusplus { @@ -766,9 +767,9 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") REQUIRE(psi != nullptr); //end incantation -// TWFPrototype twf; + TWFFastDerivWrapper twf; -// psi->initialize_TWF_Prototype(elec, twf); + psi->initializeTWFFastDerivWrapper(elec, twf); SPOSet::ValueVector_t values; SPOSet::GradVector_t dpsi; SPOSet::ValueVector_t d2psi; @@ -833,7 +834,7 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") X.push_back(upmat); X.push_back(dnmat); -// twf.get_M(elec, matlist); + twf.getM(elec, matlist); OperatorBase* kinop = ham.getHamiltonian(KINETIC); @@ -851,17 +852,17 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") minv.push_back(dnmat); -// twf.get_M(elec, matlist); +// twf.getM(elec, matlist); std::vector> dB_gs; std::vector> dM_gs; std::vector tmp_gs; -// twf.get_gs_matrix(B, B_gs); -// twf.get_gs_matrix(matlist, M_gs); -// twf.invert_M(M_gs, minv); -// twf.build_X(minv, B_gs, X); + twf.getGSMatrices(B, B_gs); + twf.getGSMatrices(matlist, M_gs); + twf.invertMatrices(M_gs, minv); + twf.buildX(minv, B_gs, X); for (int id = 0; id < matlist.size(); id++) { -// int ptclnum = twf.num_particles(id); +// int ptclnum = twf.numParticles(id); int ptclnum = (id==0 ? Nup : Ndn); //hard coded until twf interface comes online. ValueMatrix_t gs_m; gs_m.resize(ptclnum, ptclnum); @@ -887,18 +888,18 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") { for (int idim = 0; idim < OHMMS_DIM; idim++) { -// twf.wipe_matrix(dB[idim]); -// twf.wipe_matrix(dM[idim]); + twf.wipeMatrices(dB[idim]); + twf.wipeMatrices(dM[idim]); } -// twf.get_igrad_M(elec, ions, ionid, dM); + twf.getIonGradM(elec, ions, ionid, dM); // kinop->evaluateOneBodyOpMatrixForceDeriv(elec, ions, twf, ionid, dB); for (int idim = 0; idim < OHMMS_DIM; idim++) { -// twf.get_gs_matrix(dB[idim], dB_gs[idim]); -// twf.get_gs_matrix(dM[idim], dM_gs[idim]); -// fkin_complex[ionid][idim] = twf.compute_gs_derivative(minv, X, dM_gs[idim], dB_gs[idim]); + twf.getGSMatrices(dB[idim], dB_gs[idim]); + twf.getGSMatrices(dM[idim], dM_gs[idim]); + fkin_complex[ionid][idim] = twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]); } convertToReal(fkin_complex[ionid], fkin[ionid]); } @@ -906,7 +907,7 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") ValueType keval = 0.0; RealType keobs = 0.0; -// keval = twf.trAB(minv, B_gs); + keval = twf.trAB(minv, B_gs); convertToReal(keval, keobs); // CHECK(keobs == Approx(9.1821937928e+00)); #if defined(MIXED_PRECISION) @@ -933,12 +934,12 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") app_log() << " Evaluated. Calling evaluteOneBodyOpMatrix\n"; -// twf.wipe_matrix(B); -// twf.wipe_matrix(B_gs); -// twf.wipe_matrix(X); +// twf.wipeMatrices(B); +// twf.wipeMatrices(B_gs); +// twf.wipeMatrices(X); // nlppop->evaluateOneBodyOpMatrix(elec, twf, B); -// twf.get_gs_matrix(B, B_gs); -// twf.build_X(minv, B_gs, X); +// twf.getGSMatrices(B, B_gs); +// twf.buildX(minv, B_gs, X); ValueType nlpp = 0.0; RealType nlpp_obs = 0.0; @@ -955,18 +956,18 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]") { for (int idim = 0; idim < OHMMS_DIM; idim++) { -// twf.wipe_matrix(dB[idim]); -// twf.wipe_matrix(dM[idim]); +// twf.wipeMatrices(dB[idim]); +// twf.wipeMatrices(dM[idim]); } -// twf.get_igrad_M(elec, ions, ionid, dM); +// twf.getIonGradM(elec, ions, ionid, dM); // nlppop->evaluateOneBodyOpMatrixForceDeriv(elec, ions, twf, ionid, dB); for (int idim = 0; idim < OHMMS_DIM; idim++) { -// twf.get_gs_matrix(dB[idim], dB_gs[idim]); -// twf.get_gs_matrix(dM[idim], dM_gs[idim]); -// fnlpp_complex[ionid][idim] = twf.compute_gs_derivative(minv, X, dM_gs[idim], dB_gs[idim]); +// twf.getGSMatrices(dB[idim], dB_gs[idim]); +// twf.getGSMatrices(dM[idim], dM_gs[idim]); +// fnlpp_complex[ionid][idim] = twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]); } convertToReal(fnlpp_complex[ionid], fnlpp[ionid]); } diff --git a/src/QMCTools/CMakeLists.txt b/src/QMCTools/CMakeLists.txt index c4a25f406a..f4915d8ef2 100644 --- a/src/QMCTools/CMakeLists.txt +++ b/src/QMCTools/CMakeLists.txt @@ -53,8 +53,10 @@ if(USE_OBJECT_TARGET) target_link_libraries(qmcfinitesize qmcparticle qmcutil) endif() -install(TARGETS convert4qmc qmc-extract-eshdf-kvectors qmc-get-supercell qmc-check-affinity convertpw4qmc qmcfinitesize - RUNTIME DESTINATION bin) +foreach(EXE_TARGET convert4qmc qmc-extract-eshdf-kvectors qmc-get-supercell qmc-check-affinity convertpw4qmc qmcfinitesize) + add_test_target_in_output_location(${EXE_TARGET} bin) + install(TARGETS ${EXE_TARGET} RUNTIME DESTINATION bin) +endforeach() add_subdirectory(ppconvert) diff --git a/src/QMCTools/ppconvert/src/CMakeLists.txt b/src/QMCTools/ppconvert/src/CMakeLists.txt index feb4e2d2c8..56f0767bd4 100644 --- a/src/QMCTools/ppconvert/src/CMakeLists.txt +++ b/src/QMCTools/ppconvert/src/CMakeLists.txt @@ -9,3 +9,6 @@ target_sources( "${CMAKE_CURRENT_SOURCE_DIR}/ParserClass.cc") target_link_libraries(ppconvert common platform_LA) + +add_test_target_in_output_location(ppconvert bin) +install(TARGETS ppconvert RUNTIME DESTINATION bin) diff --git a/src/QMCWaveFunctions/CMakeLists.txt b/src/QMCWaveFunctions/CMakeLists.txt index e4dd11965d..bb93070ca0 100644 --- a/src/QMCWaveFunctions/CMakeLists.txt +++ b/src/QMCWaveFunctions/CMakeLists.txt @@ -169,6 +169,7 @@ set(FERMION_SRCS SPOSetBuilderFactory.cpp TrialWaveFunction.cpp TWFdispatcher.cpp + TWFFastDerivWrapper.cpp WaveFunctionFactory.cpp) if(ENABLE_CUDA) diff --git a/src/QMCWaveFunctions/Fermion/DiracDeterminant.cpp b/src/QMCWaveFunctions/Fermion/DiracDeterminant.cpp index 9d3d0ce750..df3bc21357 100644 --- a/src/QMCWaveFunctions/Fermion/DiracDeterminant.cpp +++ b/src/QMCWaveFunctions/Fermion/DiracDeterminant.cpp @@ -21,6 +21,7 @@ #include "CPU/SIMD/simd.hpp" #include "Numerics/DeterminantOperators.h" #include "Numerics/MatrixOperators.h" +#include "QMCWaveFunctions/TWFFastDerivWrapper.h" namespace qmcplusplus { @@ -344,6 +345,12 @@ void DiracDeterminant::copyFromBuffer(ParticleSet& P, WFBufferType& buf updateEng.initializeInv(psiM); } +template +void DiracDeterminant::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const +{ + twf.addGroup(P, P.getGroupID(FirstIndex), Phi.get()); +} + /** return the ratio only for the iat-th partcle move * @param P current configuration * @param iat the particle thas is being moved diff --git a/src/QMCWaveFunctions/Fermion/DiracDeterminant.h b/src/QMCWaveFunctions/Fermion/DiracDeterminant.h index b5a2bb317b..98833a997a 100644 --- a/src/QMCWaveFunctions/Fermion/DiracDeterminant.h +++ b/src/QMCWaveFunctions/Fermion/DiracDeterminant.h @@ -76,6 +76,10 @@ class DiracDeterminant : public DiracDeterminantBase void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override; + /** Finds the SPOSet associated with this determinant, and registers it with WFN wrapper + */ + void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const final; + /** return the ratio only for the iat-th partcle move * @param P current configuration * @param iat the particle thas is being moved diff --git a/src/QMCWaveFunctions/Fermion/DiracDeterminantBase.h b/src/QMCWaveFunctions/Fermion/DiracDeterminantBase.h index 703e22b1ab..d5940eca90 100644 --- a/src/QMCWaveFunctions/Fermion/DiracDeterminantBase.h +++ b/src/QMCWaveFunctions/Fermion/DiracDeterminantBase.h @@ -85,6 +85,10 @@ class DiracDeterminantBase : public WaveFunctionComponent inline void reportStatus(std::ostream& os) final {} + virtual void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const override + { + APP_ABORT("DiracDeterminantBase::registerTWFFastDerivWrapper must be overridden\n"); + } // expose CPU interfaces using WaveFunctionComponent::evaluateDerivatives; using WaveFunctionComponent::evaluateGL; diff --git a/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.cpp b/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.cpp index 48b2f6691c..659e84145f 100644 --- a/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.cpp +++ b/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.cpp @@ -16,6 +16,7 @@ #include "CPU/BLAS.hpp" #include "OhmmsPETE/OhmmsMatrix.h" #include "Numerics/MatrixOperators.h" +#include "QMCWaveFunctions/TWFFastDerivWrapper.h" #include "CPU/SIMD/simd.hpp" #include @@ -956,6 +957,12 @@ void DiracDeterminantBatched::evaluateDerivatives(ParticleSet& P, Phi->evaluateDerivatives(P, active, dlogpsi, dhpsioverpsi, FirstIndex, LastIndex); } +template +void DiracDeterminantBatched::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const +{ + twf.addGroup(P, P.getGroupID(FirstIndex), Phi.get()); +} + template std::unique_ptr DiracDeterminantBatched::makeCopy(std::shared_ptr&& spo) const { diff --git a/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.h b/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.h index cd54383bfe..bce47738ea 100644 --- a/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.h +++ b/src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.h @@ -29,6 +29,9 @@ namespace qmcplusplus { +//forward declaration +class TWFFastDerivWrapper; + template> class DiracDeterminantBatched : public DiracDeterminantBase { @@ -209,6 +212,7 @@ class DiracDeterminantBatched : public DiracDeterminantBase void releaseResource(ResourceCollection& collection, const RefVectorWithLeader& wfc_list) const override; + void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const override; /** cloning function * @param tqp target particleset * @param spo spo set diff --git a/src/QMCWaveFunctions/Fermion/SlaterDet.cpp b/src/QMCWaveFunctions/Fermion/SlaterDet.cpp index 8a2a1bc514..e12be8c8ba 100644 --- a/src/QMCWaveFunctions/Fermion/SlaterDet.cpp +++ b/src/QMCWaveFunctions/Fermion/SlaterDet.cpp @@ -253,4 +253,12 @@ std::unique_ptr SlaterDet::makeClone(ParticleSet& tqp) co return myclone; } +void SlaterDet::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const +{ + for (int i = 0; i < Dets.size(); ++i) + { + Dets[i]->registerTWFFastDerivWrapper(P, twf); + } +} + } // namespace qmcplusplus diff --git a/src/QMCWaveFunctions/Fermion/SlaterDet.h b/src/QMCWaveFunctions/Fermion/SlaterDet.h index e72337dd4d..6c2315e821 100644 --- a/src/QMCWaveFunctions/Fermion/SlaterDet.h +++ b/src/QMCWaveFunctions/Fermion/SlaterDet.h @@ -18,6 +18,7 @@ #ifndef QMCPLUSPLUS_SLATERDETERMINANT_WITHBASE_H #define QMCPLUSPLUS_SLATERDETERMINANT_WITHBASE_H #include "QMCWaveFunctions/Fermion/DiracDeterminantBase.h" + #include namespace qmcplusplus @@ -28,6 +29,7 @@ namespace qmcplusplus // then change SlaterDet to SlaterDet // and SlaterDeterminantWithBackflow to SlaterDet // and remove all virtuals and inline them +class TWFFastDerivWrapper; class SlaterDet : public WaveFunctionComponent { @@ -53,6 +55,8 @@ class SlaterDet : public WaveFunctionComponent void reportStatus(std::ostream& os) override; + void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const override; + LogValueType evaluateLog(const ParticleSet& P, ParticleSet::ParticleGradient_t& G, ParticleSet::ParticleLaplacian_t& L) override; diff --git a/src/QMCWaveFunctions/TWFFastDerivWrapper.cpp b/src/QMCWaveFunctions/TWFFastDerivWrapper.cpp new file mode 100644 index 0000000000..a26eb645cf --- /dev/null +++ b/src/QMCWaveFunctions/TWFFastDerivWrapper.cpp @@ -0,0 +1,266 @@ +////////////////////////////////////////////////////////////////////////////////////// +// This file is distributed under the University of Illinois/NCSA Open Source License. +// See LICENSE file in top directory for details. +// +// Copyright (c) 2021 QMCPACK developers. +// +// File developed by: Raymond Clay III, rclay@sandia.gov, Sandia National Laboratories +// +// File created by: Raymond Clay III, rclay@sandia.gov, Sandia National Laboratories +////////////////////////////////////////////////////////////////////////////////////// + +#include "QMCWaveFunctions/TWFFastDerivWrapper.h" +#include "Numerics/DeterminantOperators.h" +#include +namespace qmcplusplus +{ + +TWFFastDerivWrapper::IndexType TWFFastDerivWrapper::getTWFGroupIndex(const IndexType gid) +{ + IndexType return_group_index(-1); + for (IndexType i = 0; i < groups_.size(); i++) + if (gid == groups_[i]) + return_group_index=i; + + assert(return_group_index != -1); + + return return_group_index; +} + +void TWFFastDerivWrapper::addGroup(const ParticleSet& P, const IndexType gid, SPOSet* spo) +{ + if (std::find(groups_.begin(), groups_.end(), gid) == groups_.end()) + { + groups_.push_back(gid); + spos_.push_back(spo); + } +} + +void TWFFastDerivWrapper::getM(const ParticleSet& P, std::vector& mvec) +{ + IndexType ngroups = spos_.size(); + for (IndexType i = 0; i < ngroups; i++) + { + const IndexType gid = groups_[i]; + const IndexType first = P.first(i); + const IndexType last = P.last(i); + const IndexType nptcls = last - first; + const IndexType norbs = spos_[i]->getOrbitalSetSize(); + GradMatrix_t tmpgmat; + ValueMatrix_t tmplmat; + tmpgmat.resize(nptcls, norbs); + tmplmat.resize(nptcls, norbs); + spos_[i]->evaluate_notranspose(P, first, last, mvec[i], tmpgmat, tmplmat); + } +} + +void TWFFastDerivWrapper::getEGradELaplM(const ParticleSet& P, + std::vector& mvec, + std::vector& gmat, + std::vector& lmat) +{ + IndexType ngroups = mvec.size(); + for (IndexType i = 0; i < ngroups; i++) + { + const IndexType gid = groups_[i]; + const IndexType first = P.first(i); + const IndexType last = P.last(i); + const IndexType nptcls = last - first; + const IndexType norbs = spos_[i]->getOrbitalSetSize(); + spos_[i]->evaluate_notranspose(P, first, last, mvec[i], gmat[i], lmat[i]); + } +} + +void TWFFastDerivWrapper::getIonGradM(const ParticleSet& P, + const ParticleSet& source, + const int iat, + std::vector>& dmvec) +{ + IndexType ngroups = dmvec[0].size(); + for (IndexType i = 0; i < ngroups; i++) + { + const IndexType gid = groups_[i]; + const IndexType first = P.first(i); + const IndexType last = P.last(i); + const IndexType nptcls = last - first; + const IndexType norbs = spos_[i]->getOrbitalSetSize(); + + GradMatrix_t grad_phi; + + grad_phi.resize(nptcls, norbs); + + spos_[i]->evaluateGradSource(P, first, last, source, iat, grad_phi); + + for (IndexType idim = 0; idim < OHMMS_DIM; idim++) + for (IndexType iptcl = 0; iptcl < nptcls; iptcl++) + for (IndexType iorb = 0; iorb < norbs; iorb++) + { + dmvec[idim][i][iptcl][iorb] += grad_phi[iptcl][iorb][idim]; + } + } +} + +void TWFFastDerivWrapper::getIonGradIonGradELaplM(const ParticleSet& P, + const ParticleSet& source, + int iat, + std::vector>& dmvec, + std::vector>& dlmat) +{ + IndexType ngroups = dmvec[0].size(); + for (IndexType i = 0; i < ngroups; i++) + { + const IndexType gid = groups_[i]; + const IndexType first = P.first(i); + const IndexType last = P.last(i); + const IndexType nptcls = last - first; + const IndexType norbs = spos_[i]->getOrbitalSetSize(); + + GradMatrix_t grad_phi; + HessMatrix_t grad_grad_phi; + GradMatrix_t grad_lapl_phi; + + grad_phi.resize(nptcls, norbs); + grad_grad_phi.resize(nptcls, norbs); + grad_lapl_phi.resize(nptcls, norbs); + + spos_[i]->evaluateGradSource(P, first, last, source, iat, grad_phi, grad_grad_phi, grad_lapl_phi); + + for (IndexType idim = 0; idim < OHMMS_DIM; idim++) + for (IndexType iptcl = 0; iptcl < nptcls; iptcl++) + for (IndexType iorb = 0; iorb < norbs; iorb++) + { + dmvec[idim][i][iptcl][iorb] += grad_phi[iptcl][iorb][idim]; + dlmat[idim][i][iptcl][iorb] += grad_lapl_phi[iptcl][iorb][idim]; + } + } +} + +TWFFastDerivWrapper::ValueType TWFFastDerivWrapper::computeGSDerivative(const std::vector& Minv, + const std::vector& X, + const std::vector& dM, + const std::vector& dB) +{ + IndexType nspecies = Minv.size(); + ValueType dval = 0.0; + for (int id = 0; id < nspecies; id++) + { + int ptclnum = Minv[id].rows(); + ValueType dval_id = 0.0; + for (int i = 0; i < ptclnum; i++) + for (int j = 0; j < ptclnum; j++) + { + //Tr[M^{-1} dB - X * dM ] + dval_id += Minv[id][i][j] * dB[id][j][i] - X[id][i][j] * dM[id][j][i]; + } + dval += dval_id; + } + return dval; +} + +void TWFFastDerivWrapper::invertMatrices(const std::vector& M, std::vector& Minv) +{ + IndexType nspecies = M.size(); + for (IndexType id = 0; id < nspecies; id++) + { + assert(M[id].cols() == M[id].rows()); + Minv[id] = M[id]; + invert_matrix(Minv[id]); + } +} + +void TWFFastDerivWrapper::buildX(const std::vector& Minv, + const std::vector& B, + std::vector& X) +{ + IndexType nspecies = Minv.size(); + + for (IndexType id = 0; id < nspecies; id++) + { + int ptclnum = Minv[id].rows(); + assert(Minv[id].rows()==Minv[id].cols()); + ValueMatrix_t tmpmat; + X[id].resize(ptclnum, ptclnum); + tmpmat.resize(ptclnum, ptclnum); + //(B*A^-1) + for (int i = 0; i < ptclnum; i++) + for (int j = 0; j < ptclnum; j++) + for (int k = 0; k < ptclnum; k++) + { + tmpmat[i][j] += B[id][i][k] * Minv[id][k][j]; + } + //A^{-1}*B*A^{-1} + for (int i = 0; i < ptclnum; i++) + for (int j = 0; j < ptclnum; j++) + for (int k = 0; k < ptclnum; k++) + { + X[id][i][j] += Minv[id][i][k] * tmpmat[k][j]; + } + } +} + +void TWFFastDerivWrapper::wipeMatrices(std::vector& A) +{ + + for (IndexType id = 0; id < A.size(); id++) + { + A[id] = 0.0; + } +} + +TWFFastDerivWrapper::ValueType TWFFastDerivWrapper::trAB(const std::vector& A, const std::vector& B) +{ + IndexType nspecies = A.size(); + assert(A.size() == B.size()); + ValueType val = 0.0; + //Now to compute the kinetic energy + for (IndexType id = 0; id < nspecies; id++) + { + int ptclnum = A[id].rows(); + ValueType val_id = 0.0; + assert(A[id].cols() == B[id].rows() && A[id].rows() == B[id].cols()); + for (int i = 0; i < A[id].rows(); i++) + for (int j = 0; j < A[id].cols(); j++) + { + val_id += A[id][i][j] * B[id][j][i]; + } + val += val_id; + } + + return val; +} + +void TWFFastDerivWrapper::getGSMatrices(const std::vector& A, std::vector& Aslice) +{ + IndexType nspecies = A.size(); + Aslice.resize(nspecies); + for (IndexType id = 0; id < nspecies; id++) + { + IndexType ptclnum = A[id].rows(); + Aslice[id].resize(ptclnum, ptclnum); + for (IndexType i = 0; i < ptclnum; i++) + for (IndexType j = 0; j < ptclnum; j++) + Aslice[id][i][j] = A[id][i][j]; + } +} + + +TWFFastDerivWrapper::IndexType TWFFastDerivWrapper::getRowM(const ParticleSet& P, const IndexType iel, ValueVector_t& val) +{ + IndexType gid = P.getGroupID(iel); + IndexType sid = getTWFGroupIndex(gid); + + GradVector_t tempg; + ValueVector_t templ; + + IndexType norbs = spos_[sid]->getOrbitalSetSize(); + + tempg.resize(norbs); + templ.resize(norbs); + + spos_[sid]->evaluateVGL(P, iel, val, tempg, templ); + + return sid; +} + + +} // namespace qmcplusplus diff --git a/src/QMCWaveFunctions/TWFFastDerivWrapper.h b/src/QMCWaveFunctions/TWFFastDerivWrapper.h new file mode 100644 index 0000000000..f0ad56097f --- /dev/null +++ b/src/QMCWaveFunctions/TWFFastDerivWrapper.h @@ -0,0 +1,229 @@ +////////////////////////////////////////////////////////////////////////////////////// +// This file is distributed under the University of Illinois/NCSA Open Source License. +// See LICENSE file in top directory for details. +// +// Copyright (c) 2021 QMCPACK developers. +// +// File developed by: Raymond Clay III, rclay@sandia.gov, Sandia National Laboratories +// +// File created by: Raymond Clay III, rclay@sandia.gov, Sandia National Laboratories +////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef QMCPLUSPLUS_TWFFASTDERIVWRAPPER_H +#define QMCPLUSPLUS_TWFFASTDERIVWRAPPER_H + +#include "QMCWaveFunctions/WaveFunctionComponent.h" +#include "QMCWaveFunctions/SPOSet.h" +#include "Configuration.h" +#include "Particle/ParticleSet.h" +namespace qmcplusplus +{ +/** + * TWFFastDerivWrapper is a wrapper class for TrialWavefunction that provides separate and low level access to the Jastrow and + * SPOSet objects. This is so that observables can be recast in matrix form and their derivatives taken efficiently. + * Currently this is hard coded for ground state slater jastrow wave functions, but generalization to + * arbitrary occupations and multideterminants are straightforward and will come online as the code is tested and validated. + * + * Please see : J. Chem. Phys. 144, 194105 (2016) https://doi.org/10.1063/1.4948778 for implementation details and formalism. + */ +class TWFFastDerivWrapper +{ +public: + using ValueMatrix_t = SPOSet::ValueMatrix_t; + using GradMatrix_t = SPOSet::GradMatrix_t; + using HessMatrix_t = SPOSet::HessMatrix_t; + using IndexType = QMCTraits::IndexType; + using RealType = QMCTraits::RealType; + using ValueType = QMCTraits::ValueType; + + using ValueVector_t = SPOSet::ValueVector_t; + using GradVector_t = SPOSet::GradVector_t; + + + /** @brief Add a particle group. + * + * Here, a "group" corresponds to a subset of particles which are antisymmetric with + * respect to eachother. TWFFastDerivWrapper ensures that there is a binding between the groupid + * in ParticleSet and the SPOSet associated with that particle group. This function stores + * the ParticleSet groupid and SPOSet in a vector for lookup and communication with QMCPACK conventions, + * but is agnostic to the order of group registration or evaluation. + * + * @param[in] P. ParticleSet + * @param[in] groupid. ParticleSet groupid to which SPOSet corresponds. + * @param[in] spo. Pointer to SPOSet. + * @return void. + */ + void addGroup(const ParticleSet& P, const IndexType groupid, SPOSet* spo); + inline void addJastrow(WaveFunctionComponent* j) { jastrow_list_.push_back(j); }; + + /** @brief Takes particle set groupID and returns the TWF internal index for it. + * + * ParticleSet groups can be registered in whichever order. However, the internal indexing + * of TWFFastDerivWrapper keeps track on a first-come, first serve basis. That is, if I register + * particle groups 3, 1, and 0 in that order, then the internal indexing goes like + * 0->3, 1->1, 2->0. Thus, this function looks up where in the internal indexing scheme + * ParticleSet gid is located. This is necessary, since the matrix list data structures follow + * the internal TWF indexing. + * + * @param[in] gid. ParticleSet group ID to look up. + * @return The corresponding internal groupID. + */ + IndexType getTWFGroupIndex(const IndexType gid); + + /** @ingroup Query functions + * @{ + * @brief These are query functions to the internal state of various groups and SPOSet info. + * All group indices will refer to the internal group indices. Convert from ParticleSet to + * TWF group first! + * + * Source of truth for orbital sizes will be the individual SPOSets. Particle group sizes + * will be ParticleSet in conjunction with groupID maps. + */ + inline IndexType numGroups() { return spos_.size(); }; + SPOSet* getSPOSet(const IndexType sid) { return spos_[sid]; }; + inline IndexType numOrbitals(const IndexType sid) { return spos_[sid]->size(); }; + /** @} */ + + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + //These are convenience functions/wrappers to SPOSet calls. Idea being that observables just need // + //to make calls to this object to build the auxiliary matrices required for fast derivative computation.// + //On the other hand, it wouldn't be unreasonable to make the observables do the SPOSet calls themselves.// + ////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** @brief Returns the non-rectangular slater matrices M_ij=phi_j(r_i) (N_particle x N_orbs) for each species group. + * + * @param[in] P particle set. + * @param[in,out] mmat Output vector of slater matrices. Each vector entry corresponds to a different particle group. + * @return Void + */ + void getM(const ParticleSet& P, std::vector& mmat); + + /** @brief Returns value of all orbitals (relevant to given species/group) at a particular particle coordinate. + * + * @param[in] P particle set. + * @param[in] iel particle ID. + * @param[in,out] val Vector of phi_i(r_iel) for all i=0,Norbs. + * @return Void + */ + IndexType getRowM(const ParticleSet& P, const IndexType iel, ValueVector_t& val); + + + /** @brief Returns value, gradient, and laplacian matrices for all orbitals and all particles, species by species. + * + * @param[in] P particle set. + * @param[in,out] mvec Slater matrix M_ij=phi_j(r_i) for each species group. + * @param[in,out] gmat electron gradient of slater matrix [G_ij]_a = d/dr_a,i phi_j(r_i). a=x,y,z + * @param[in,out] lmat electron laplacian of slater matrix [L_ij] = \nabla^2_i phi_j(r_i). + * @return Void + */ + void getEGradELaplM(const ParticleSet& P, + std::vector& mvec, + std::vector& gmat, + std::vector& lmat); + + /** @brief Returns x,y,z components of ion gradient of slater matrices. + * + * @param[in] P particle set. + * @param[in] source ion particle set. + * @param[in]*** iat ion ID w.r.t. which to take derivative. + * @param[in,out] dmvec Slater matrix d/dR_{iat,a} M_ij=d/dR_{iat,a} phi_j(r_i) for each species group. First index is a=x,y,z. + * @return Void + */ + void getIonGradM(const ParticleSet& P, + const ParticleSet& source, + const int iat, + std::vector>& dmvec); + + /** @brief Returns x,y,z components of ion gradient of slater matrices and their laplacians.. + * + * @param[in] P particle set. + * @param[in] source ion particle set. + * @param[in] iat ion ID w.r.t. which to take derivative. + * @param[in,out] dmvec Slater matrix d/dR_{iat,a} M_ij=d/dR_{iat,a} phi_j(r_i) for each species group. + * First index is a=x,y,z. + * @param[in,out] dlmat Slater matrix d/dR_{iat,a} L_ij=d/dR_{iat,a} \nabla^2_i phi_j(r_i) for each species group. + * First index is a=x,y,z. + * @return Void + */ + void getIonGradIonGradELaplM(const ParticleSet& P, + const ParticleSet& source, + int iat, + std::vector>& dmvec, + std::vector>& dlmat); + + + /** @brief Takes sub matrices of full SPOSet quantities (evaluated on all particles and all orbitals), consistent with ground + * state occupations. + * + * @param[in] A non-rectangular matrices of SPOSet derived quantities, evaluated on all orbitals and all particles. + * @param[in,out] Aslice square matrices consistent with a ground state occupation. + * @return Void + */ + void getGSMatrices(const std::vector& A, std::vector& Aslice); + + /** @brief Calculates derivative of observable via Tr[M^{-1} dB - X * dM ]. Consistent with ground state occupation. + * + * @param[in] Minv. inverse of slater matrices for ground state occupations. + * @param[in] X. X=M^-1 B M^-1. B observable matrix, and is consistent with ground state occupation. + * @param[in] dM. Target derivative of M, and is consistent with ground state occupation. + * @param[in] dB. Target derivative of B, and is consistent with ground state occupation. + * @return Derivative of O psi/psi = Tr[M^{-1} dB - X * dM ] + */ + ValueType computeGSDerivative(const std::vector& Minv, + const std::vector& X, + const std::vector& dM, + const std::vector& dB); + + ////////////////////////////////////////////////////////////////////////////////////////////// + //And now we just have some helper functions for doing useful math on our lists of matrices.// + ////////////////////////////////////////////////////////////////////////////////////////////// + + /** @brief Helper function that inverts all slater matrices in our species list. + * + * @param[in] M. List of slater matrices for each species. These are square and consistent with some occupation. + * @param[in,out] Minv. The species by species list of inverted matrices from M. + * @return Void. + */ + void invertMatrices(const std::vector& M, std::vector& Minv); + + /** @brief Build the auxiliary X=M^-1 B M^-1 matrix. + * + * @param[in] Minv. List of slater matrix inverses M^-1 for a given occupation. + * @param[in] B. Observable auxiliary matrix for a given occupation. + * @param[in,out] X. M^-1*B*M^-1 is stored in this list of matrices. + * @return Void. + */ + void buildX(const std::vector& Minv, + const std::vector& B, + std::vector& X); + + /** @brief Goes through a list of matrices and zeros them out. Does this in place. + * + * @param[in,out] A. The list of matrices to be zeroed out. After call, A is all zeros. + * @return Void. + */ + void wipeMatrices(std::vector& A); + + /** @brief Returns Tr(A*B). Actually, we assume a block diagonal structure, so this is + * really Sum_i Tr(A_i*B_i), where i is the species index. + * + * @param[in] A. Vector of matrices A. + * @param[in] B. Vector of matrices B. + * @return Value of Sum_i Tr(A_i*B_i). + */ + ValueType trAB(const std::vector& A, const std::vector& B); + + +private: + std::vector spos_; + std::vector groups_; + std::vector psi_M_; + std::vector psi_M_inv_; + std::vector jastrow_list_; + +}; + +/**@}*/ +} // namespace qmcplusplus +#endif diff --git a/src/QMCWaveFunctions/TrialWaveFunction.cpp b/src/QMCWaveFunctions/TrialWaveFunction.cpp index 2756fbb3b4..c0cc3972d9 100644 --- a/src/QMCWaveFunctions/TrialWaveFunction.cpp +++ b/src/QMCWaveFunctions/TrialWaveFunction.cpp @@ -1340,5 +1340,21 @@ RefVector TrialWaveFunction::extractLRefList( return l_list; } +void TrialWaveFunction::initializeTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const +{ + for (int i = 0; i < Z.size(); ++i) + { + if (Z[i]->is_fermionic) + { + //OK, so this is a hack only for SlaterDeterminant objects. + //Needs a bit of logic and protection before this reaches production. + //SlaterDet* det = dynamic_cast(Z[i].get()); + //det->registerTWFFastDerivWrapper(P, twf); + Z[i]->registerTWFFastDerivWrapper(P,twf); + } + else //Is Jastrow, so do nothing right now. + {} + } +} } // namespace qmcplusplus diff --git a/src/QMCWaveFunctions/TrialWaveFunction.h b/src/QMCWaveFunctions/TrialWaveFunction.h index de93c5cbe0..83a5a4a7b6 100644 --- a/src/QMCWaveFunctions/TrialWaveFunction.h +++ b/src/QMCWaveFunctions/TrialWaveFunction.h @@ -29,6 +29,7 @@ #include "Utilities/TimerManager.h" #include "type_traits/template_types.hpp" #include "Containers/MinimalContainers/RecordArray.hpp" +#include "QMCWaveFunctions/TWFFastDerivWrapper.h" #ifdef QMC_CUDA #include "type_traits/CUDATypes.h" #endif @@ -168,6 +169,9 @@ class TrialWaveFunction */ void reportStatus(std::ostream& os); + /** Initialize a TWF wrapper for fast derivative evaluation + */ + void initializeTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const; /** evalaute the log (internally gradients and laplacian) of the trial wavefunction. gold reference */ RealType evaluateLog(ParticleSet& P); @@ -539,6 +543,8 @@ class TrialWaveFunction ///a list of WaveFunctionComponents constituting many-body wave functions std::vector> Z; + /// For now, TrialWaveFunction will own the wrapper. + TWFFastDerivWrapper twf_prototype; /// timers at TrialWaveFunction function call level TimerList_t TWF_timers_; /// timers at WaveFunctionComponent function call level diff --git a/src/QMCWaveFunctions/WaveFunctionComponent.cpp b/src/QMCWaveFunctions/WaveFunctionComponent.cpp index a9263db81a..1be1705bab 100644 --- a/src/QMCWaveFunctions/WaveFunctionComponent.cpp +++ b/src/QMCWaveFunctions/WaveFunctionComponent.cpp @@ -226,4 +226,11 @@ void WaveFunctionComponent::evaluateDerivRatios(VirtualParticleSet& VP, evaluateRatios(VP, ratios); } +void WaveFunctionComponent::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const +{ + std::ostringstream o; + o << "WaveFunctionComponent::registerTWFFastDerivWrapper is not implemented by " << ClassName; + APP_ABORT(o.str()); +} + } // namespace qmcplusplus diff --git a/src/QMCWaveFunctions/WaveFunctionComponent.h b/src/QMCWaveFunctions/WaveFunctionComponent.h index 2e920e757e..ae15f4a371 100644 --- a/src/QMCWaveFunctions/WaveFunctionComponent.h +++ b/src/QMCWaveFunctions/WaveFunctionComponent.h @@ -50,7 +50,7 @@ struct NLjob class WaveFunctionComponent; struct DiffWaveFunctionComponent; class ResourceCollection; - +class TWFFastDerivWrapper; /**@defgroup WaveFunctionComponent group * @brief Classes which constitute a many-body trial wave function * @@ -170,6 +170,10 @@ class WaveFunctionComponent : public QMCTraits /** print the state, e.g., optimizables */ virtual void reportStatus(std::ostream& os) = 0; + /** Register the component with the TWFFastDerivWrapper wrapper. + */ + virtual void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const; + /** evaluate the value of the WaveFunctionComponent from scratch * \param[in] P active ParticleSet * \param[out] G Gradients, \f$\nabla\ln\Psi\f$ diff --git a/tests/afqmc/workflow/CMakeLists.txt b/tests/afqmc/workflow/CMakeLists.txt index 845116b0e7..bce7c406dd 100644 --- a/tests/afqmc/workflow/CMakeLists.txt +++ b/tests/afqmc/workflow/CMakeLists.txt @@ -10,7 +10,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS set(TESTNAME "converter_test_pyscf_${test_name}") add_test( NAME ${TESTNAME} - COMMAND ${TESTDIR}/scf.py gen_test_data + COMMAND ${Python3_EXECUTABLE} ${TESTDIR}/scf.py gen_test_data WORKING_DIRECTORY ${TESTDIR}) set_property( TEST ${TESTNAME} @@ -23,7 +23,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS add_test( NAME ${TESTNAME} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${NPROC_INT} ${MPIEXEC_PREFLAGS} - ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/pyscf_to_afqmc.py ${ARGN} + ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/pyscf_to_afqmc.py ${ARGN} WORKING_DIRECTORY ${TESTDIR}) set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_pyscf_${test_name}") set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc") @@ -32,7 +32,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS set(TESTNAME "converter_test_hamiltonian_consistency_${test_name}") add_test( NAME ${TESTNAME} - COMMAND ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/test_afqmc_input.py --input afqmc.h5 + COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/test_afqmc_input.py --input afqmc.h5 WORKING_DIRECTORY ${TESTDIR}) set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_pyscf_to_afqmc_${test_name}") set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc") @@ -41,7 +41,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS set(TESTNAME "converter_test_gen_input_${test_name}") add_test( NAME ${TESTNAME} - COMMAND "${TESTDIR}/gen_input.py" + COMMAND ${Python3_EXECUTABLE} ${TESTDIR}/gen_input.py WORKING_DIRECTORY ${TESTDIR}) set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_hamiltonian_consistency_${test_name}") set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc") @@ -64,7 +64,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS set(TESTNAME "converter_test_qmcpack_obs_${test_name}") add_test( NAME ${TESTNAME} - COMMAND ${TESTDIR}/reference/test_obs.py + COMMAND ${Python3_EXECUTABLE} ${TESTDIR}/reference/test_obs.py WORKING_DIRECTORY ${TESTDIR}) set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_qmcpack_${test_name}-16-1") set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc") diff --git a/tests/converter/CMakeLists.txt b/tests/converter/CMakeLists.txt index e636e0627e..1d563ab41a 100644 --- a/tests/converter/CMakeLists.txt +++ b/tests/converter/CMakeLists.txt @@ -12,7 +12,7 @@ function(ADD_CONVERTER_TEST test_name) string(REPLACE ";" " " EXE_NAME "${EXE_NAME}") endif() add_test(NAME converter_${test_name} - COMMAND "${CMAKE_CURRENT_BINARY_DIR}/converter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe + COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/converter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe "${EXE_NAME}" --h5diff "${HDF5_DIFF_EXECUTABLE}") set_tests_properties(converter_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " FAIL" @@ -25,7 +25,7 @@ function(ADD_PWCONVERTER_TEST test_name) "${CMAKE_CURRENT_BINARY_DIR}/${test_name}") set(EXE_NAME $) add_test(NAME converter_${test_name} - COMMAND "${CMAKE_CURRENT_BINARY_DIR}/pwconverter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe + COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/pwconverter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe "${EXE_NAME}" --h5diff "${HDF5_DIFF_EXECUTABLE}") set_tests_properties(converter_${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION " FAIL" diff --git a/tests/molecules/C2_pp/vmc_long_pp_msdj-XML-traditional.xml b/tests/molecules/C2_pp/vmc_long_pp_msdj-XML-traditional.xml index c9b68b37a7..86e36c42d6 100644 --- a/tests/molecules/C2_pp/vmc_long_pp_msdj-XML-traditional.xml +++ b/tests/molecules/C2_pp/vmc_long_pp_msdj-XML-traditional.xml @@ -9,7 +9,7 @@ - + diff --git a/tests/molecules/C2_pp/vmc_short_pp_msdj-XML-traditional.xml b/tests/molecules/C2_pp/vmc_short_pp_msdj-XML-traditional.xml index a1c96ddc00..daa37c0c2c 100644 --- a/tests/molecules/C2_pp/vmc_short_pp_msdj-XML-traditional.xml +++ b/tests/molecules/C2_pp/vmc_short_pp_msdj-XML-traditional.xml @@ -9,7 +9,7 @@ - + diff --git a/tests/molecules/He_param/CMakeLists.txt b/tests/molecules/He_param/CMakeLists.txt index 8448d08562..fdac7a2c51 100644 --- a/tests/molecules/He_param/CMakeLists.txt +++ b/tests/molecules/He_param/CMakeLists.txt @@ -39,7 +39,7 @@ if(NOT QMC_CUDA) # but we need to write a file there before that runs set(TDIR "${CMAKE_CURRENT_BINARY_DIR}/He_param_grad_load-1-16") file(MAKE_DIRECTORY ${TDIR}) - execute_process(COMMAND ${qmcpack_SOURCE_DIR}/tests/molecules/He_param/convert_vp_format.py ${SDIR}/he_vp_opt.txt ${complex_flag} -o ${TDIR}/he_vp_opt.h5) + execute_process(COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/molecules/He_param/convert_vp_format.py ${SDIR}/he_vp_opt.txt ${complex_flag} -o ${TDIR}/he_vp_opt.h5) list(APPEND HE_BSPLINE_OPT_PARAM jud_0 0.00000124 0.0014) # scalar name, value, error list(APPEND HE_BSPLINE_OPT_PARAM jud_1 -0.000273 0.00097) diff --git a/tests/performance/C-graphite/CMakeLists.txt b/tests/performance/C-graphite/CMakeLists.txt index b3ec9e1650..34d97b5fa1 100644 --- a/tests/performance/C-graphite/CMakeLists.txt +++ b/tests/performance/C-graphite/CMakeLists.txt @@ -40,7 +40,7 @@ function(ADD_C_GRAPHITE_TEST TEST_NAME TEST_DIR INPUT_FILE H5_FILE) set_tests_properties(${TEST_NAME} PROPERTIES PROCESSORS ${TOT_PROCS} PROCESSOR_AFFINITY TRUE) if(ENABLE_TIMERS) - add_test(NAME "${TEST_NAME}-time" COMMAND ../process_perf.py ${INPUT_FILE}) + add_test(NAME "${TEST_NAME}-time" COMMAND ${Python3_EXECUTABLE} ../process_perf.py ${INPUT_FILE}) set_tests_properties("${TEST_NAME}-time" PROPERTIES LABELS "performance") set_tests_properties("${TEST_NAME}-time" PROPERTIES WORKING_DIRECTORY "${WDIR}") set_tests_properties("${TEST_NAME}-time" PROPERTIES DEPENDS ${TEST_NAME}) diff --git a/tests/performance/C-molecule/CMakeLists.txt b/tests/performance/C-molecule/CMakeLists.txt index a2daa7a23a..af3a3265f7 100644 --- a/tests/performance/C-molecule/CMakeLists.txt +++ b/tests/performance/C-molecule/CMakeLists.txt @@ -36,7 +36,7 @@ if(NOT QMC_CUDA) separate_arguments(ADJUST_INPUT) execute_process( - COMMAND ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT} + COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT} ${TEST_DIR}/${INPUT_FILE} WORKING_DIRECTORY "${qmcpack_BINARY_DIR}/tests/performance/C-molecule") set(PROCS 1) @@ -55,7 +55,7 @@ if(NOT QMC_CUDA) set_tests_properties(${TEST_NAME} PROPERTIES PROCESSORS ${TOT_PROCS} PROCESSOR_AFFINITY TRUE) if(ENABLE_TIMERS) - add_test(NAME "${TEST_NAME}-time" COMMAND ../process_perf.py ${INPUT_FILE}) + add_test(NAME "${TEST_NAME}-time" COMMAND ${Python3_EXECUTABLE} ../process_perf.py ${INPUT_FILE}) set_tests_properties("${TEST_NAME}-time" PROPERTIES LABELS "performance") set_tests_properties("${TEST_NAME}-time" PROPERTIES WORKING_DIRECTORY "${WDIR}") set_tests_properties("${TEST_NAME}-time" PROPERTIES DEPENDS ${TEST_NAME}) diff --git a/tests/performance/NiO/CMakeLists.txt b/tests/performance/NiO/CMakeLists.txt index 470bf1e797..fe5b2f5924 100644 --- a/tests/performance/NiO/CMakeLists.txt +++ b/tests/performance/NiO/CMakeLists.txt @@ -34,7 +34,7 @@ function( maybe_symlink("${QMC_DATA}/NiO/${H5_FILE}" "${WDIR}/../${H5_FILE}") separate_arguments(ADJUST_INPUT) - execute_process(COMMAND ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT} + execute_process(COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT} ${TEST_DIR}/${INPUT_FILE} WORKING_DIRECTORY "${qmcpack_BINARY_DIR}/tests/performance/NiO") set(TEST_NAME ${TEST_NAME}-${PROCS}-${THREADS}) @@ -57,7 +57,7 @@ function( endif() if(ENABLE_TIMERS) - add_test(NAME "${TEST_NAME}-time" COMMAND ../process_perf.py ${INPUT_FILE}) + add_test(NAME "${TEST_NAME}-time" COMMAND ${Python3_EXECUTABLE} ../process_perf.py ${INPUT_FILE}) set_tests_properties("${TEST_NAME}-time" PROPERTIES LABELS "performance") set_tests_properties("${TEST_NAME}-time" PROPERTIES WORKING_DIRECTORY "${WDIR}") set_tests_properties("${TEST_NAME}-time" PROPERTIES DEPENDS ${TEST_NAME}) diff --git a/tests/solids/diamondC_1x1x1_pp/det_qmc_short_kspace.in.xml b/tests/solids/diamondC_1x1x1_pp/det_qmc_short_kspace.in.xml index 7d48844d58..d89ca29ec2 100644 --- a/tests/solids/diamondC_1x1x1_pp/det_qmc_short_kspace.in.xml +++ b/tests/solids/diamondC_1x1x1_pp/det_qmc_short_kspace.in.xml @@ -89,7 +89,7 @@ - + diff --git a/tests/solids/diamondC_1x1x1_pp/qmc_long_kspace.in.xml b/tests/solids/diamondC_1x1x1_pp/qmc_long_kspace.in.xml index 4cb101b4a7..81d06c3661 100644 --- a/tests/solids/diamondC_1x1x1_pp/qmc_long_kspace.in.xml +++ b/tests/solids/diamondC_1x1x1_pp/qmc_long_kspace.in.xml @@ -88,7 +88,7 @@ - + diff --git a/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace.in.xml b/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace.in.xml index 3ab48bf458..61aaa22ac5 100644 --- a/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace.in.xml +++ b/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace.in.xml @@ -88,7 +88,7 @@ - + diff --git a/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace_4_4.in.xml b/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace_4_4.in.xml index fc991203bc..6b4d0e8411 100644 --- a/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace_4_4.in.xml +++ b/tests/solids/diamondC_1x1x1_pp/qmc_short_kspace_4_4.in.xml @@ -88,7 +88,7 @@ - + diff --git a/tests/solids/diamondC_2x1x1_pp/CMakeLists.txt b/tests/solids/diamondC_2x1x1_pp/CMakeLists.txt index f58ba3c328..07bf69e540 100644 --- a/tests/solids/diamondC_2x1x1_pp/CMakeLists.txt +++ b/tests/solids/diamondC_2x1x1_pp/CMakeLists.txt @@ -629,7 +629,7 @@ if(NOT QMC_CUDA) list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "kinetic" "19.21103034 0.0005") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "potential" "-41.26295939 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "eeenergy" "-6.68405093 0.00003") - list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "ionion" "-25.55133345 0.000001") + list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "ionion" "-25.55133345 0.000002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "localecp" "-10.92577863 0.0002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "nonlocalecp" "1.89820362 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "flux" "-0.31336816 0.001") @@ -639,7 +639,7 @@ if(NOT QMC_CUDA) list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "kinetic" "19.77013829 0.0005") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "potential" "-41.07144136 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "eeenergy" "-6.35883147 0.00003") - list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "ionion" "-25.55133345 0.000001") + list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "ionion" "-25.55133345 0.000002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "localecp" "-10.53491810 0.0002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "nonlocalecp" "1.37364166 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "flux" "-9.80945206 0.001") @@ -650,7 +650,7 @@ if(NOT QMC_CUDA) list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "kinetic" "19.21031605 0.0005") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "potential" "-41.26295995 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "eeenergy" "-6.68405093 0.00003") - list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "ionion" "-25.55133345 0.000001") + list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "ionion" "-25.55133345 0.000002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "localecp" "-10.92577863 0.0002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "nonlocalecp" "1.89820306 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "flux" "-0.31142934 0.001") @@ -660,7 +660,7 @@ if(NOT QMC_CUDA) list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "kinetic" "19.76116869 0.0005") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "potential" "-41.07144191 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "eeenergy" "-6.35883147 0.00003") - list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "ionion" "-25.55133345 0.000001") + list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "ionion" "-25.55133345 0.000002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "localecp" "-10.53491810 0.0002") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "nonlocalecp" "1.37364111 0.0001") list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS2_SCALARS "flux" "-9.79154968 0.001")