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
10 changes: 7 additions & 3 deletions cxx/include/chemcache/chemcache_mm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
#include <pluginplay/pluginplay.hpp>

namespace chemcache {
/** @brief Loads the modules contained in the ChemCache module collection into
* the provided ModuleManager instance.
/** @brief The ChemCache plugin.
*
* Load it into a ModuleManager with `mm.load_plugin<chemcache::ChemCache>()`
* (`mm.load_plugin(chemcache.ChemCache())` from Python). The plugin's name is
* "chemcache". All of the plugin's default submodules are provided by the
* plugin itself, so it does not need other plugins to be loaded.
*/
void load_modules(pluginplay::ModuleManager& mm);
DECLARE_PLUGIN(ChemCache);

} // namespace chemcache
16 changes: 7 additions & 9 deletions cxx/src/chemcache/atoms/atoms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@ DECLARE_MODULE(Z_from_sym);

namespace atom_mods {

inline void set_defaults(pluginplay::ModuleManager& mm) {
inline void set_defaults(pluginplay::ModuleMap& modules) {
// Default submodules within this subcollection will be set here
}

inline void load_modules(pluginplay::ModuleManager& mm) {
// Modules will be added to the ModuleManager here
mm.add_module<atoms_average>("Atom");
mm.add_module<atoms_isotope>("Atom Isotope");
mm.add_module<sym_from_Z>("Symbol from Z");
mm.add_module<Z_from_sym>("Z from Symbol");

set_defaults(mm);
inline void load_modules(pluginplay::ModuleMap& modules) {
// Modules will be added to the plugin here
modules.add_module<atoms_average>("Atom");
modules.add_module<atoms_isotope>("Atom Isotope");
modules.add_module<sym_from_Z>("Symbol from Z");
modules.add_module<Z_from_sym>("Z from Symbol");
}

} // namespace atom_mods
Expand Down
14 changes: 6 additions & 8 deletions cxx/src/chemcache/bases/bases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ DECLARE_MODULE(sto_dash_3g_atom_basis);

namespace bases_mods {

inline void set_defaults(pluginplay::ModuleManager& mm) {
inline void set_defaults(pluginplay::ModuleMap& modules) {
// Default submodules within this subcollection will be set here
mm.change_submod("sto-3g", "Atomic Basis", "sto-3g atomic basis");
modules.change_submod("sto-3g", "Atomic Basis", "sto-3g atomic basis");
}

inline void load_modules(pluginplay::ModuleManager& mm) {
// Modules will be added to the ModuleManager here
mm.add_module<molecular_basis>("sto-3g");
mm.add_module<sto_dash_3g_atom_basis>("sto-3g atomic basis");

set_defaults(mm);
inline void load_modules(pluginplay::ModuleMap& modules) {
// Modules will be added to the plugin here
modules.add_module<molecular_basis>("sto-3g");
modules.add_module<sto_dash_3g_atom_basis>("sto-3g atomic basis");
}

} // namespace bases_mods
Expand Down
27 changes: 15 additions & 12 deletions cxx/src/chemcache/chemcache_mm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@

namespace chemcache {

inline void set_defaults(pluginplay::ModuleManager& mm) {
// Default submodules between collections can be set here
mm.change_submod("NWX Molecules", "Atoms", "Atom");
}
PLUGIN_CTOR(ChemCache) {
set_name("chemcache");

void load_modules(pluginplay::ModuleManager& mm) {
// Add subcollection load calls here
atom_mods::load_modules(mm);
bases_mods::load_modules(mm);
density_mods::load_modules(mm);
hydrocarbons::load_modules(mm);
molecule_mods::load_modules(mm);
// The defaults refer to modules from more than one subcollection, so all
// modules are added before any defaults are set
atom_mods::load_modules(modules());
bases_mods::load_modules(modules());
density_mods::load_modules(modules());
hydrocarbons::load_modules(modules());
molecule_mods::load_modules(modules());

set_defaults(mm);
atom_mods::set_defaults(modules());
bases_mods::set_defaults(modules());
density_mods::set_defaults(modules());
hydrocarbons::set_defaults(modules());
molecule_mods::set_defaults(modules());
change_submod("NWX Molecules", "Atoms", "Atom");
}

} // namespace chemcache
20 changes: 9 additions & 11 deletions cxx/src/chemcache/density/density.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@ DECLARE_MODULE(sto_dash_3g_atom_density_matrix);

namespace density_mods {

inline void set_defaults(pluginplay::ModuleManager& mm) {
inline void set_defaults(pluginplay::ModuleMap& modules) {
// Default submodules within this subcollection will be set here
mm.change_submod("sto-3g SAD density", "Atomic Basis",
"sto-3g atomic basis");
mm.change_submod("sto-3g SAD density", "Atomic Density",
"sto-3g atomic density matrix");
modules.change_submod("sto-3g SAD density", "Atomic Basis",
"sto-3g atomic basis");
modules.change_submod("sto-3g SAD density", "Atomic Density",
"sto-3g atomic density matrix");
}

inline void load_modules(pluginplay::ModuleManager& mm) {
// Modules will be added to the ModuleManager here
mm.add_module<sad_density>("sto-3g SAD density");
mm.add_module<sto_dash_3g_atom_density_matrix>(
inline void load_modules(pluginplay::ModuleMap& modules) {
// Modules will be added to the plugin here
modules.add_module<sad_density>("sto-3g SAD density");
modules.add_module<sto_dash_3g_atom_density_matrix>(
"sto-3g atomic density matrix");

set_defaults(mm);
}

} // namespace density_mods
Expand Down
2 changes: 1 addition & 1 deletion cxx/src/chemcache/export_chemcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

namespace chemcache {

EXPORT_PLUGIN(chemcache, m) {}
EXPORT_PLUGIN(chemcache, ChemCache, m) {}

} // namespace chemcache
7 changes: 3 additions & 4 deletions cxx/src/chemcache/hydrocarbons/hydrocarbons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ namespace chemcache::hydrocarbons {

DECLARE_MODULE(StraightChainAlkane);

inline void set_defaults(pluginplay::ModuleManager& mm) {
inline void set_defaults(pluginplay::ModuleMap& modules) {
// Default submodules within this subcollection will be set here
}

inline void load_modules(pluginplay::ModuleManager& mm) {
mm.add_module<StraightChainAlkane>("Straight Chain Alkane");
set_defaults(mm);
inline void load_modules(pluginplay::ModuleMap& modules) {
modules.add_module<StraightChainAlkane>("Straight Chain Alkane");
}

} // namespace chemcache::hydrocarbons
10 changes: 4 additions & 6 deletions cxx/src/chemcache/molecules/molecules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ DECLARE_MODULE(default_molecules);

namespace molecule_mods {

inline void set_defaults(pluginplay::ModuleManager& mm) {
inline void set_defaults(pluginplay::ModuleMap& modules) {
// Default submodules within this subcollection will be set here
}

inline void load_modules(pluginplay::ModuleManager& mm) {
// Modules will be added to the ModuleManager here
mm.add_module<default_molecules>("NWX Molecules");

set_defaults(mm);
inline void load_modules(pluginplay::ModuleMap& modules) {
// Modules will be added to the plugin here
modules.add_module<default_molecules>("NWX Molecules");
}

} // namespace molecule_mods
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ requires = [
# [project].dependencies; leave the floors unbounded so the newest
# release is always resolved.
"nwchemex-nwxcmake>=0.1.0",
"nwchemex-simde>=0.0.77",
"nwchemex-simde>=0.0.85",
]
build-backend = "scikit_build_core.build"

Expand All @@ -38,7 +38,7 @@ dependencies = [
# registries and breaks cross-module type exchange.
"pybind11==3.1.0",
"nwchemex-nwxcmake>=0.1.0",
"nwchemex-simde>=0.0.77",
"nwchemex-simde>=0.0.85",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/unit_tests/atoms/Z_from_sym.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using Catch::Matchers::Message;

TEST_CASE("Z from Symbol") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& z_mod = mm.at("Z From Symbol");

SECTION("sto-3g Hydrogen") {
Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/unit_tests/atoms/atoms_average.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using Catch::Matchers::Message;

TEST_CASE("Atom") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& atom_mod = mm.at("Atom");
atomic_number_t Z;

Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/unit_tests/atoms/atoms_isotope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using Catch::Matchers::Message;

TEST_CASE("Atom Isotope") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& atom_mod = mm.at("Atom Isotope");

SECTION("Hydrogen-2") {
Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/unit_tests/atoms/sym_from_Z.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using Catch::Matchers::Message;

TEST_CASE("Symbol from Z") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& sym_mod = mm.at("Symbol from Z");
atomic_number_t Z;

Expand Down
4 changes: 2 additions & 2 deletions tests/cxx/unit_tests/bases/bases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using Catch::Matchers::Message;

TEST_CASE("Atomic Basis Set") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& atom_bs_mod = mm.at("sto-3g atomic basis");

SECTION("sto-3g Hydrogen") {
Expand Down Expand Up @@ -79,7 +79,7 @@ TEST_CASE("Atomic Basis Set") {

TEST_CASE("Molecular Basis Set") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& mol_bs_mod = mm.at("sto-3g");

atom_t h1{"H", 1, 0.0, 1.0, 1.0, 1.0};
Expand Down
4 changes: 2 additions & 2 deletions tests/cxx/unit_tests/density/density.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using Catch::Matchers::Message;

TEST_CASE("sto-3g atomic density matrix") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& atom_dm_mod = mm.at("sto-3g atomic density matrix");
auto rt = mm.get_runtime();

Expand Down Expand Up @@ -71,7 +71,7 @@ TEST_CASE("sto-3g atomic density matrix") {

TEST_CASE("SAD Density") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& sad_mod = mm.at("sto-3g SAD density");
auto rt = mm.get_runtime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ using pt = simde::MoleculeFromString;

TEST_CASE("StraightChainAlkane") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& mod = mm.at("Straight Chain Alkane");

auto methane = mod.run_as<pt>(std::string("1"));
Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/unit_tests/molecules/molecules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using Catch::Matchers::Message;

TEST_CASE("NWX Molecules") {
pluginplay::ModuleManager mm;
chemcache::load_modules(mm);
mm.load_plugin<chemcache::ChemCache>();
auto& mol_mod = mm.at("NWX Molecules");

SECTION("Water") {
Expand Down
53 changes: 53 additions & 0 deletions tests/cxx/unit_tests/test_chemcache_mm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2026 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.
*/

#include "catch.hpp"
#include "chemcache/chemcache.hpp"

TEST_CASE("ChemCache plugin") {
chemcache::ChemCache plugin;
const auto& modules = plugin.get_modules();

SECTION("Identity") {
REQUIRE(plugin.name() == "chemcache");
// Every default comes from the plugin itself
REQUIRE(plugin.preferred_providers().empty());
}

SECTION("Modules from each subcollection") {
REQUIRE(modules.count("Atom"));
REQUIRE(modules.count("sto-3g"));
REQUIRE(modules.count("sto-3g SAD density"));
REQUIRE(modules.count("Straight Chain Alkane"));
REQUIRE(modules.count("NWX Molecules"));
}

SECTION("Defaults set within and across subcollections") {
REQUIRE(modules.has_submod("sto-3g", "Atomic Basis"));
REQUIRE(modules.has_submod("sto-3g SAD density", "Atomic Basis"));
REQUIRE(modules.has_submod("sto-3g SAD density", "Atomic Density"));
REQUIRE(modules.has_submod("NWX Molecules", "Atoms"));
}

SECTION("Can be loaded into a ModuleManager") {
pluginplay::ModuleManager mm;
mm.load_plugin<chemcache::ChemCache>();
REQUIRE(mm.has_plugin("chemcache"));
REQUIRE(mm.size() == modules.size());
REQUIRE(mm.at("NWX Molecules").submods().at("Atoms").value() ==
mm.at("Atom"));
}
}
4 changes: 2 additions & 2 deletions tests/python/unit_tests/test_atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import unittest

from chemcache import load_modules
from chemcache import ChemCache
from chemist import Atom
from pluginplay import ModuleManager
from simde import AtomFromZ, SymbolFromZ, ZFromSymbol
Expand Down Expand Up @@ -55,4 +55,4 @@ def test_Z_from_sym(self):

def setUp(self):
self.mm = ModuleManager()
load_modules(self.mm)
self.mm.load_plugin(ChemCache())
4 changes: 2 additions & 2 deletions tests/python/unit_tests/test_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import unittest

from chemcache import load_modules
from chemcache import ChemCache
from chemist import Atom, Molecule, PointD, ShellType
from chemist.basis_set import AOBasisSetD, AtomicBasisSetD, ShellD
from pluginplay import ModuleManager
Expand Down Expand Up @@ -57,4 +57,4 @@ def _h(self, r):

def setUp(self):
self.mm = ModuleManager()
load_modules(self.mm)
self.mm.load_plugin(ChemCache())
4 changes: 2 additions & 2 deletions tests/python/unit_tests/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import unittest

from chemcache import load_modules
from chemcache import ChemCache
from chemist import Atom, Molecule
from pluginplay import ModuleManager
from simde import MoleculeFromString
Expand Down Expand Up @@ -45,4 +45,4 @@ def test_nwx_molecules(self):

def setUp(self):
self.mm = ModuleManager()
load_modules(self.mm)
self.mm.load_plugin(ChemCache())
Loading
Loading