Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/scf/xc/libxc/libxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "libxc.hpp"
#ifdef BUILD_LIBXC
#include "xc.h"
#include "xc_funcs.h"
#endif

namespace scf::xc::libxc {
Expand Down
10 changes: 4 additions & 6 deletions tests/cxx/integration_tests/xc/libxc_energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float_type>();
auto aos = test_scf::he_aos();
Expand All @@ -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<float_type>();
auto aos = test_scf::h2_aos();
Expand Down
10 changes: 4 additions & 6 deletions tests/cxx/integration_tests/xc/libxc_potential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float_type>();
auto aos = test_scf::he_aos();
Expand All @@ -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<float_type>();
auto aos = test_scf::h2_aos();
Expand Down
12 changes: 12 additions & 0 deletions tests/cxx/test_scf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <filesystem>
#include <scf/scf.hpp>
#include <simde/simde.hpp>

Expand Down Expand Up @@ -300,4 +301,15 @@ inline auto he_xc(chemist::qm_operator::xc_functional func) {
auto rho = he_density<FloatType>();
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
12 changes: 4 additions & 8 deletions tests/cxx/unit_tests/xc/aos_on_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<chemist::Molecule>();
Expand All @@ -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<chemist::Molecule>();
Expand Down
8 changes: 4 additions & 4 deletions tests/cxx/unit_tests/xc/density2grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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<chemist::Molecule>();
Expand All @@ -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<chemist::Molecule>();
Expand Down
6 changes: 2 additions & 4 deletions tests/cxx/unit_tests/xc/gau2grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<chemist::Molecule>();
Expand Down
1 change: 1 addition & 0 deletions tests/cxx/unit_tests/xc/libxc/libxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "../../../test_scf.hpp"
#include "xc.h"
#include "xc_funcs.h"
#include <scf/xc/libxc/libxc.hpp>

TEST_CASE("to_libxc_codes") {
Expand Down