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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if("${BUILD_TESTING}")
python_mpi_test(
unit_test_scf
"${PYTHON_TEST_DIR}/unit_tests/run_unit_tests.py"
SUBMODULES simde chemist pluginplay parallelzone
SUBMODULES simde chemist pluginplay parallelzone tensorwrapper
)

if("${INTEGRATION_TESTING}")
Expand Down
27 changes: 15 additions & 12 deletions tests/cxx/integration_tests/driver/scf_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ TEMPLATE_LIST_TEST_CASE("SCFDriver", "", test_scf::float_types) {
REQUIRE(approximately_equal(corr, e, 1E-6));
}
SECTION("DFT") {
auto func = chemist::qm_operator::xc_functional::PBE;
const auto RKS_op = "Restricted Kohn-Sham Op";
const auto rks_op = "Restricted One-Electron Kohn-Sham Op";
mm.change_input(RKS_op, "XC Potential", func);
mm.change_input(rks_op, "XC Potential", func);
mm.change_submod("Loop", "One-electron Fock operator", rks_op);
mm.change_submod("Loop", "Fock operator", RKS_op);
mm.change_submod("Core guess", "Build Fock Operator", rks_op);
const auto e = mm.template run_as<pt>("SCF Driver", aos, h2);
pcorr->set_elem({}, -1.15207);
simde::type::tensor corr(shape_corr, std::move(pcorr));
REQUIRE(approximately_equal(corr, e, 1E-5));
// GauXC not currently compatible with Uncertain values
if constexpr(!tensorwrapper::types::is_uncertain_v<float_type>) {
auto func = chemist::qm_operator::xc_functional::PBE;
const auto RKS_op = "Restricted Kohn-Sham Op";
const auto rks_op = "Restricted One-Electron Kohn-Sham Op";
mm.change_input(RKS_op, "XC Potential", func);
mm.change_input(rks_op, "XC Potential", func);
mm.change_submod("Loop", "One-electron Fock operator", rks_op);
mm.change_submod("Loop", "Fock operator", RKS_op);
mm.change_submod("Core guess", "Build Fock Operator", rks_op);
const auto e = mm.template run_as<pt>("SCF Driver", aos, h2);
pcorr->set_elem({}, -1.15207);
simde::type::tensor corr(shape_corr, std::move(pcorr));
REQUIRE(approximately_equal(corr, e, 1E-5));
}
}
}

Expand Down
52 changes: 52 additions & 0 deletions tests/python/integration_tests/driver/test_scf_driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2025 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import nux
import simde
import parallelzone as pz
import chemist
import pluginplay as pp
import nwchemex as nwx
import numpy as np
import unittest


class TestSCFDriver(unittest.TestCase):

def test_scf_driver(self):
# Property Types
mol_from_str = simde.MoleculeFromString()
mol_basis_set = simde.MolecularBasisSet()
ao_energy = simde.AOEnergy()

# Inputs
water = self.mm.at("NWX Molecules").run_as(mol_from_str, "water")
aos = self.mm.at('STO-3G').run_as(mol_basis_set, water)
sys = chemist.ChemicalSystem(water)

# Run module
egy = self.mm.run_as(ao_energy, "SCF Driver", aos, sys)
self.assertAlmostEqual(np.array(egy), -74.94208027122616, places=6)

def setUp(self):
self.mm = pp.ModuleManager(pz.runtime.RuntimeView())
nux.load_modules(self.mm)
nwx.load_modules(self.mm)
self.mm.change_submod("SCF Driver", "Hamiltonian",
"Born-Oppenheimer Approximation")
self.mm.change_submod("SCF integral driver", "Fundamental matrices",
"AO integral driver")
self.mm.change_submod("Diagonalization Fock update",
"Overlap matrix builder", "Overlap")
self.mm.change_submod("Loop", "Overlap matrix builder", "Overlap")
43 changes: 43 additions & 0 deletions tests/python/unit_tests/eigen_solver/test_eigen_generalized.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2025 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest
import pluginplay as pp
import parallelzone as pz
import scf
import simde
import tensorwrapper as tw
import numpy as np


class TestEigenGeneralized(unittest.TestCase):

def test_eigen_generalized(self):
# Property Type
pt = simde.GeneralizedEigenSolve()

# Inputs
A = tw.Tensor(np.array([[1.0, 2.0], [2.0, 3.0]]))
B = tw.Tensor(np.array([[1.0, 0.0], [0.0, 1.0]]))

# Run module
mod_name = "Generalized eigensolve via Eigen"
values, vector = self.mm.run_as(pt, mod_name, A, B)
test_values = np.array(values)
self.assertAlmostEqual(test_values[0], -0.236068, places=6)
self.assertAlmostEqual(test_values[1], 4.236068, places=6)

def setUp(self):
self.mm = pp.ModuleManager(pz.runtime.RuntimeView())
scf.load_modules(self.mm)
23 changes: 0 additions & 23 deletions tests/python/unit_tests/molecules.py

This file was deleted.