diff --git a/src/scf/xc/libxc/libxc.cpp b/src/scf/xc/libxc/libxc.cpp index de4e76b..2269d4b 100644 --- a/src/scf/xc/libxc/libxc.cpp +++ b/src/scf/xc/libxc/libxc.cpp @@ -17,6 +17,7 @@ #include "libxc.hpp" #ifdef BUILD_LIBXC #include "xc.h" +#include "xc_funcs.h" #endif namespace scf::xc::libxc { diff --git a/tests/cxx/integration_tests/xc/libxc_energy.cpp b/tests/cxx/integration_tests/xc/libxc_energy.cpp index 5ca2daf..9a21259 100644 --- a/tests/cxx/integration_tests/xc/libxc_energy.cpp +++ b/tests/cxx/integration_tests/xc/libxc_energy.cpp @@ -30,11 +30,10 @@ TEST_CASE("LibXCEnergy") { mm.change_submod("LibXC Energy", "Integration grid", "Grid From File"); auto& mod = mm.at("LibXC Energy"); + auto path = test_scf::get_test_directory_path(); + SECTION("He") { - // Assumes build directory is under root and we are running from the - // build directory - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/he_grid.txt"; + path += "/he_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); auto rho = test_scf::he_density(); auto aos = test_scf::he_aos(); @@ -53,8 +52,7 @@ TEST_CASE("LibXCEnergy") { } SECTION("H2") { - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/h2_grid.txt"; + path += "/h2_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); auto rho = test_scf::h2_density(); auto aos = test_scf::h2_aos(); diff --git a/tests/cxx/integration_tests/xc/libxc_potential.cpp b/tests/cxx/integration_tests/xc/libxc_potential.cpp index 570e825..4f85498 100644 --- a/tests/cxx/integration_tests/xc/libxc_potential.cpp +++ b/tests/cxx/integration_tests/xc/libxc_potential.cpp @@ -30,11 +30,10 @@ TEST_CASE("LibXCPotential") { mm.change_submod("LibXC Potential", "Integration grid", "Grid From File"); auto& mod = mm.at("LibXC Potential"); + auto path = test_scf::get_test_directory_path(); + SECTION("He") { - // Assumes build directory is under root and we are running from the - // build directory - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/he_grid.txt"; + path += "/he_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); auto rho = test_scf::he_density(); auto aos = test_scf::he_aos(); @@ -53,8 +52,7 @@ TEST_CASE("LibXCPotential") { } SECTION("H2") { - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/h2_grid.txt"; + path += "/h2_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); auto rho = test_scf::h2_density(); auto aos = test_scf::h2_aos(); diff --git a/tests/cxx/test_scf.hpp b/tests/cxx/test_scf.hpp index 74766ff..4fc8175 100644 --- a/tests/cxx/test_scf.hpp +++ b/tests/cxx/test_scf.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -300,4 +301,15 @@ inline auto he_xc(chemist::qm_operator::xc_functional func) { auto rho = he_density(); return simde::type::XC_e_type(func, es, rho); } + +inline std::filesystem::path get_test_directory_path() { + auto path = std::filesystem::current_path().parent_path(); + // Spack testing hack + if(path.string().find("spack") != std::string::npos) { + path += "/spack-src"; + } + path += "/tests"; + return path; +} + } // namespace test_scf diff --git a/tests/cxx/unit_tests/xc/aos_on_grid.cpp b/tests/cxx/unit_tests/xc/aos_on_grid.cpp index 9022d93..01418f1 100644 --- a/tests/cxx/unit_tests/xc/aos_on_grid.cpp +++ b/tests/cxx/unit_tests/xc/aos_on_grid.cpp @@ -30,11 +30,10 @@ TEST_CASE("AOsOnGrid") { scf::load_modules(mm); auto& mod = mm.at("AOs on a grid"); + auto path = test_scf::get_test_directory_path(); + SECTION("He STO-3G on a realistic grid") { - // Assumes build directory is under root and we are running from the - // build directory - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/he_grid.txt"; + path += "/he_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); using grid_pt = simde::MolecularGrid; auto he = test_scf::make_he(); @@ -51,10 +50,7 @@ TEST_CASE("AOsOnGrid") { } SECTION("H2 STO-3G on a realistic grid") { - // Assumes build directory is under root and we are running from the - // build directory - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/h2_grid.txt"; + path += "/h2_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); using grid_pt = simde::MolecularGrid; auto h2 = test_scf::make_h2(); diff --git a/tests/cxx/unit_tests/xc/density2grid.cpp b/tests/cxx/unit_tests/xc/density2grid.cpp index 122aa2a..0cb2e3c 100644 --- a/tests/cxx/unit_tests/xc/density2grid.cpp +++ b/tests/cxx/unit_tests/xc/density2grid.cpp @@ -29,6 +29,8 @@ TEST_CASE("Density2Grid") { scf::load_modules(mm); auto& mod = mm.at("Density2Grid"); + auto path = test_scf::get_test_directory_path(); + chemist::Grid grid; // Value doesn't matter for this test b/c of submodule SECTION("Fake AOs on a grid") { @@ -48,8 +50,7 @@ TEST_CASE("Density2Grid") { SECTION("He STO-3G") { // Get the grid - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/he_grid.txt"; + path += "/he_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); using grid_pt = simde::MolecularGrid; auto he = test_scf::make_he(); @@ -66,8 +67,7 @@ TEST_CASE("Density2Grid") { SECTION("H2 STO-3G") { // Get the grid - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/h2_grid.txt"; + path += "/h2_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); using grid_pt = simde::MolecularGrid; auto he = test_scf::make_h2(); diff --git a/tests/cxx/unit_tests/xc/gau2grid.cpp b/tests/cxx/unit_tests/xc/gau2grid.cpp index 57938c0..1ce3186 100644 --- a/tests/cxx/unit_tests/xc/gau2grid.cpp +++ b/tests/cxx/unit_tests/xc/gau2grid.cpp @@ -86,10 +86,8 @@ TEST_CASE("Gau2Grid") { } SECTION("A single s Gaussian on a realistic grid") { - // Assumes build directory is under root and we are running from the - // build directory - auto path = std::filesystem::current_path().parent_path(); - path += "/tests/he_grid.txt"; + auto path = test_scf::get_test_directory_path(); + path += "/he_grid.txt"; mm.change_input("Grid From File", "Path to Grid File", path); using grid_pt = simde::MolecularGrid; auto he = test_scf::make_he(); diff --git a/tests/cxx/unit_tests/xc/libxc/libxc.cpp b/tests/cxx/unit_tests/xc/libxc/libxc.cpp index b395da5..85b1095 100644 --- a/tests/cxx/unit_tests/xc/libxc/libxc.cpp +++ b/tests/cxx/unit_tests/xc/libxc/libxc.cpp @@ -16,6 +16,7 @@ #include "../../../test_scf.hpp" #include "xc.h" +#include "xc_funcs.h" #include TEST_CASE("to_libxc_codes") {