From c3edc80f941ed79829397f97c454de0908174043 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Fri, 18 Jul 2025 12:41:46 -0500 Subject: [PATCH 1/4] Atomic Density Matrix Property Type --- .../chemical_system/atomic_density_matrix.hpp | 52 +++++++++++++++++++ .../simde/chemical_system/chemical_system.hpp | 3 +- .../export_chemical_system.hpp | 4 +- .../chemical_system/atomic_density_matrix.cpp | 23 ++++++++ .../chemical_system/test_chemical_system.py | 17 +++++- 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 include/simde/chemical_system/atomic_density_matrix.hpp create mode 100644 tests/cxx/unit_tests/chemical_system/atomic_density_matrix.cpp diff --git a/include/simde/chemical_system/atomic_density_matrix.hpp b/include/simde/chemical_system/atomic_density_matrix.hpp new file mode 100644 index 00000000..5aea1f0b --- /dev/null +++ b/include/simde/chemical_system/atomic_density_matrix.hpp @@ -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. + */ + +#pragma once +#include "simde/types.hpp" +#include + +namespace simde { + +/** @brief The property for a module that returns an atom based on an + * identifying feature (e.g. symbol or atomic number). + */ +template +DECLARE_TEMPLATED_PROPERTY_TYPE(AtomicDensityMatrix, InputType); + +template +TEMPLATED_PROPERTY_TYPE_INPUTS(AtomicDensityMatrix, InputType) { + using input_t = const InputType&; + auto rv = pluginplay::declare_input().add_field("Atom ID"); + rv.at("Atom ID").set_description("The identifying feature of the atom"); + return rv; +} + +template +TEMPLATED_PROPERTY_TYPE_RESULTS(AtomicDensityMatrix, InputType) { + std::string result_name = "Atomic Density Matrix"; + auto rv = pluginplay::declare_result().add_field(result_name); + rv.at(result_name).set_description("The requested Atomic Density Matrix"); + return rv; +} + +/// Typedef for a module that returns density matrices based on atomic number +using AtomicDensityMatrixFromZ = AtomicDensityMatrix; + +/// Typedef for a module that returns density matrices from a string (e.g. +/// atomic symbol) +using AtomicDensityMatrixFromSym = AtomicDensityMatrix; + +} // namespace simde diff --git a/include/simde/chemical_system/chemical_system.hpp b/include/simde/chemical_system/chemical_system.hpp index 55d77c8a..78ca949b 100644 --- a/include/simde/chemical_system/chemical_system.hpp +++ b/include/simde/chemical_system/chemical_system.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NWChemEx-Project + * 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. @@ -17,5 +17,6 @@ #pragma once #include #include +#include #include #include diff --git a/src/python/chemical_system/export_chemical_system.hpp b/src/python/chemical_system/export_chemical_system.hpp index 9c016a0d..efc098fc 100644 --- a/src/python/chemical_system/export_chemical_system.hpp +++ b/src/python/chemical_system/export_chemical_system.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023 NWChemEx-Project + * 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. @@ -24,6 +24,8 @@ namespace simde { inline void export_chemical_system(python_module_reference m) { EXPORT_PROPERTY_TYPE(AtomFromZ, m); EXPORT_PROPERTY_TYPE(AtomFromSym, m); + EXPORT_PROPERTY_TYPE(AtomicDensityMatrixFromZ, m); + EXPORT_PROPERTY_TYPE(AtomicDensityMatrixFromSym, m); EXPORT_PROPERTY_TYPE(SymbolFromZ, m); EXPORT_PROPERTY_TYPE(ZFromSymbol, m); EXPORT_PROPERTY_TYPE(MoleculeFromString, m); diff --git a/tests/cxx/unit_tests/chemical_system/atomic_density_matrix.cpp b/tests/cxx/unit_tests/chemical_system/atomic_density_matrix.cpp new file mode 100644 index 00000000..cbd7871d --- /dev/null +++ b/tests/cxx/unit_tests/chemical_system/atomic_density_matrix.cpp @@ -0,0 +1,23 @@ +/* + * 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. + */ + +#include "../test_property_type.hpp" +#include + +TEST_CASE("Atomic Density Matrix") { + test_property_type( + {"Atom ID"}, {"Atomic Density Matrix"}); +} diff --git a/tests/python/unit_tests/chemical_system/test_chemical_system.py b/tests/python/unit_tests/chemical_system/test_chemical_system.py index 5673c2c7..9455516f 100644 --- a/tests/python/unit_tests/chemical_system/test_chemical_system.py +++ b/tests/python/unit_tests/chemical_system/test_chemical_system.py @@ -1,4 +1,4 @@ -# Copyright 2023 NWChemEx-Project +# 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. @@ -31,6 +31,21 @@ def setUp(self): self.input_labels = ['Atom ID'] self.result_labels = ['Atom'] +class TestAtomicDensityMatrixFromZ(BaseTestPropertyType): + + def setUp(self): + self.pt = simde.AtomicDensityMatrixFromZ() + self.input_labels = ['Atom ID'] + self.result_labels = ['Atomic Density Matrix'] + + +class TestAtomicDensityMatrixFromSym(BaseTestPropertyType): + + def setUp(self): + self.pt = simde.AtomicDensityMatrixFromSym() + self.input_labels = ['Atom ID'] + self.result_labels = ['Atomic Density Matrix'] + class testSymbolFromZ(BaseTestPropertyType): From 765318fd31c077604e7d89dd65fba5cb42dc05b4 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Tue, 22 Jul 2025 01:35:00 -0500 Subject: [PATCH 2/4] Initial Density Property Type --- include/simde/density/density.hpp | 18 +++++++++ include/simde/density/initial_density.hpp | 38 +++++++++++++++++++ include/simde/simde.hpp | 1 + .../unit_tests/density/initial_density.cpp | 24 ++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 include/simde/density/density.hpp create mode 100644 include/simde/density/initial_density.hpp create mode 100644 tests/cxx/unit_tests/density/initial_density.cpp diff --git a/include/simde/density/density.hpp b/include/simde/density/density.hpp new file mode 100644 index 00000000..f96c2d90 --- /dev/null +++ b/include/simde/density/density.hpp @@ -0,0 +1,18 @@ +/* + * 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. + */ + +#pragma once +#include \ No newline at end of file diff --git a/include/simde/density/initial_density.hpp b/include/simde/density/initial_density.hpp new file mode 100644 index 00000000..b1ae6d81 --- /dev/null +++ b/include/simde/density/initial_density.hpp @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#pragma once +#include "simde/types.hpp" +#include + +namespace simde { + +/** @brief The property for a module that returns an initial Electronic density + */ +DECLARE_PROPERTY_TYPE(InitialDensity); + +PROPERTY_TYPE_INPUTS(InitialDensity) { + using hamiltonian_type = const type::hamiltonian&; + return pluginplay::declare_input().template add_field( + "Hamiltonian"); +} + +PROPERTY_TYPE_RESULTS(InitialDensity) { + using density_type = simde::type::decomposable_e_density; + return pluginplay::declare_result().add_field("Density"); +} + +} // namespace simde diff --git a/include/simde/simde.hpp b/include/simde/simde.hpp index c5edf0ab..b0308471 100644 --- a/include/simde/simde.hpp +++ b/include/simde/simde.hpp @@ -17,6 +17,7 @@ #pragma once #include #include +#include #include #include #include diff --git a/tests/cxx/unit_tests/density/initial_density.cpp b/tests/cxx/unit_tests/density/initial_density.cpp new file mode 100644 index 00000000..e364fe7c --- /dev/null +++ b/tests/cxx/unit_tests/density/initial_density.cpp @@ -0,0 +1,24 @@ +/* + * Copyright 2022 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 "../test_property_type.hpp" +#include + +using init_density = simde::InitialDensity; + +TEST_CASE("Initial Density") { + test_property_type({"Hamiltonian"}, {"Density"}); +} From 839a33cc954490e4215b9c9904cc45a3656387c9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 24 Jul 2025 21:19:09 +0000 Subject: [PATCH 3/4] Committing clang-format changes --- tests/python/unit_tests/chemical_system/test_chemical_system.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/python/unit_tests/chemical_system/test_chemical_system.py b/tests/python/unit_tests/chemical_system/test_chemical_system.py index 9455516f..fcd7b144 100644 --- a/tests/python/unit_tests/chemical_system/test_chemical_system.py +++ b/tests/python/unit_tests/chemical_system/test_chemical_system.py @@ -31,6 +31,7 @@ def setUp(self): self.input_labels = ['Atom ID'] self.result_labels = ['Atom'] + class TestAtomicDensityMatrixFromZ(BaseTestPropertyType): def setUp(self): From 698011e3764910364c10dc58ebc4b0f2fbd51074 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Fri, 25 Jul 2025 10:16:32 -0500 Subject: [PATCH 4/4] No need to change license header year --- include/simde/chemical_system/chemical_system.hpp | 2 +- src/python/chemical_system/export_chemical_system.hpp | 2 +- tests/python/unit_tests/chemical_system/test_chemical_system.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/simde/chemical_system/chemical_system.hpp b/include/simde/chemical_system/chemical_system.hpp index 78ca949b..dc74bdd5 100644 --- a/include/simde/chemical_system/chemical_system.hpp +++ b/include/simde/chemical_system/chemical_system.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2025 NWChemEx-Project + * Copyright 2022 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/python/chemical_system/export_chemical_system.hpp b/src/python/chemical_system/export_chemical_system.hpp index efc098fc..36a0a67b 100644 --- a/src/python/chemical_system/export_chemical_system.hpp +++ b/src/python/chemical_system/export_chemical_system.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2025 NWChemEx-Project + * Copyright 2023 NWChemEx-Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/python/unit_tests/chemical_system/test_chemical_system.py b/tests/python/unit_tests/chemical_system/test_chemical_system.py index fcd7b144..340ce62a 100644 --- a/tests/python/unit_tests/chemical_system/test_chemical_system.py +++ b/tests/python/unit_tests/chemical_system/test_chemical_system.py @@ -1,4 +1,4 @@ -# Copyright 2025 NWChemEx-Project +# Copyright 2023 NWChemEx-Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.