diff --git a/include/ghostfragment/equation/equation.hpp b/include/ghostfragment/equation/equation.hpp deleted file mode 100644 index a26eba03..00000000 --- a/include/ghostfragment/equation/equation.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -// #include -// #include - -// /** @brief Namespace for classes and methods pertaining to formulating -// composite -// * methods. -// * -// */ -// namespace ghostfragment::equation { - -// /** @brief Makes a Term where the chemical system and aos come from a -// fragmented -// * chemical system. -// * -// */ -// Term make_term(typename type::nmer_set::value_type nmer, -// typename type::fragmented_ao_set::value_type aos, -// std::size_t n_electrons, Term::coefficient_type coef); - -// } // namespace ghostfragment::equation diff --git a/include/ghostfragment/equation/expression.hpp b/include/ghostfragment/equation/expression.hpp deleted file mode 100644 index b86d0aa8..00000000 --- a/include/ghostfragment/equation/expression.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -#include -#include - -namespace ghostfragment::equation { -namespace detail_ { -class ExpressionPIMPL; -} - -/** @brief A set of terms. - * - * Expressions describe how to combine Term objects to compute a property of - * interest. - */ -class Expression { -public: - /// unsigned integral type for counting and offsets - using size_type = std::size_t; - - /// Type of the terms in the container - using term_type = Term; - - /// Read-only reference to a term - using const_term_reference = const term_type&; - - /// Ultimately a typedef of Term::coefficient_type - using coefficient_type = term_type::coefficient_type; - - /// Type of the class implementing the Expression class - using pimpl_type = detail_::ExpressionPIMPL; - - /// Type of a pointer to a pimpl_type object - using pimpl_pointer = std::unique_ptr; - - // ------------------------------------------------------------------------- - // -- Ctors, Assignment Operators, Dtor - // ------------------------------------------------------------------------- - - Expression() noexcept; - explicit Expression(pimpl_pointer pimpl) noexcept; - Expression(const Expression& other); - Expression(Expression&& other) noexcept; - Expression& operator=(const Expression& rhs); - Expression& operator=(Expression&& rhs) noexcept; - ~Expression() noexcept; - - // ------------------------------------------------------------------------- - // -- Getters - // ------------------------------------------------------------------------- - - /** @brief The number of terms in this expression. - * - * Expressions are essentially linear combinations of terms. This method - * returns the number of terms in *this. - * - * @return The number of terms. - * - * @throw None No throw guarantee. - */ - size_type size() const noexcept; - - /** @brief Returns the @p i-th term in *this. - * - * Expressions are essentially linear combinations of terms. This method - * is used to retrieve a term by offset. - * - * @param[in] i The zero-based offset of the requested term. @p i must be - * in the range [0, size()). - * - * @return A read-only reference to the requested term. - * - * @throw std::out_of_range if @p i is not in the range [0, size()). - * Strong throw guarantee. - */ - const_term_reference at(size_type i) const; - - // ------------------------------------------------------------------------- - // -- Setters - // ------------------------------------------------------------------------- - - /** @brief Adds @p term to *this - * - * This method behaves similar to `push_back` in that Expression behaves - * like a random access container and that @p term will be added on to - * the end of *this. This method does not check if @p term is already in - * *this. - * - * @param[in] term The piece of the linear expansion to add. - * - * @throw std::bad_alloc if there is a problem adding @p term to *this. - * Strong throw guarantee. - */ - void add_term(term_type term); - - // ------------------------------------------------------------------------- - // -- Utility methods - // ------------------------------------------------------------------------- - - /** @brief Determine if an Expression is empty. - * - * An Expression is empty if it has no terms in it. - * - * @return True if Expression is empty and false otherwise. - * - * @throw None no throw guarantee. - */ - bool empty() const noexcept; - - /** @brief Exchanges the state of @p other with the state of *this. - * - * @param[in,out] other The Expression we are swapping state with. After - * this method is called @p other will contain the - * state which was previously in *this. - */ - void swap(Expression& other) noexcept; - - /** @brief Determines if *this is value equal to @p rhs. - * - * Two Expression instances are equal if they both are empty, or if they - * are both non-empty and contain the same terms, in the same order. - * - * @param[in] rhs The Expression being compared to *this. - * - * @return True if @p rhs is value equal to *this and false otherwise. - * - * @throw None No throw guarantee. - */ - bool operator==(const Expression& rhs) const noexcept; - -private: - /// Code factorization for ensuring @p i is in range [0, size()) - void assert_bounds_(size_type i) const; - - /// The object implementing the Expression - pimpl_pointer m_pimpl_; -}; - -inline bool operator!=(const Expression& lhs, const Expression& rhs) { - return !(lhs == rhs); -} - -inline std::ostream& operator<<(std::ostream& os, const Expression& exp) { - if(exp.empty()) return os << "{ empty }"; - for(auto i = 0; i < exp.size(); ++i) os << exp.at(i) << std::endl; - return os; -} - -} // namespace ghostfragment::equation diff --git a/include/ghostfragment/equation/term.hpp b/include/ghostfragment/equation/term.hpp deleted file mode 100644 index 2fc1a02d..00000000 --- a/include/ghostfragment/equation/term.hpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 - -namespace ghostfragment::equation { -namespace detail_ { -class TermPIMPL; -} - -/** @brief Desribes a term in an expression - * - * Terms map to individual calculations. Superficially a Term is just a - * ChemicalSystem and a coefficient for scaling the result. - * - */ -class Term { -public: - /// Type of a Chemical System - using chemical_system_type = simde::type::chemical_system; - - /// Ultimately typedef of ChemicalSystem::molecule_t - using molecule_type = chemical_system_type::molecule_t; - - /// Type used to represent the molecular basis set - using ao_basis_set_type = simde::type::ao_basis_set; - - /// Unsigned integral type used for indexing and offsets - using size_type = std::size_t; - - /// Floating-point type of this term's scale factor - using coefficient_type = double; - - /// Type of the object implementing Term - using pimpl_type = detail_::TermPIMPL; - - /// Type of a pointer to the PIMPL - using pimpl_pointer = std::unique_ptr; - - // -- CTors, Assignment Operators, and DTor - - /** @brief Creates a null Term object. - * - * The instance resulting from the default ctor is largely a place holder. - * At the moment the only way to give a default constructed Term state is - * to assign to it. The resulting Term is empty. - * - * @throw None No throw guarantee - */ - Term() noexcept; - Term(pimpl_pointer pimpl) noexcept; - Term(const Term& other); - Term(Term&& other) noexcept; - Term& operator=(const Term& rhs); - Term& operator=(Term&& rhs) noexcept; - - /// Standard no-throw dtor - ~Term() noexcept; - - // -- Getters - - /** @brief Returns the set of nuclei in *this. - * - * Each Term has a set of nuclei, the number of electrons, and the AO - * basis set for the term. This method is used to retrieve the set of - * nuclei. - * - * @return The set of nuclei for this term. - * - * @throw std::runtime_error if *this has no PIMPL. Strong throw guarantee. - */ - molecule_type molecule() const; - - /** @brief Returns the number of electrons in the term - * - * Each Term has a set of nuclei, the number of electrons, and the AO - * basis set for the term. This method is used to retrieve the number of - * electrons. - * - * @throw None No throw guarantee. - */ - size_type n_electrons() const noexcept; - - /** @brief Returns the chemical system stored in *this - * - * Each Term has a set of nuclei, the number of electrons, and the AO - * basis set for the term. Together the nuclei and electrons constitute - * a ChemicalSystem. This method returns that ChemicalSystem. - * - * @return The ChemicalSystem associated with *this. - * - * @throw std::runtime_error if *this has no PIMPL. Strong throw guarantee. - */ - chemical_system_type chemical_system() const; - - /** @brief Returns the AO basis set associated with *this. - * - * Each Term has a set of nuclei, the number of electrons, and the AO - * basis set for the term. This method is used to retrieve the AO basis - * set. - * - * @return The AO basis set contained in *this. - * - * @throw std::runtime_error if *this has no PIMPL. Strong throw guarantee. - */ - ao_basis_set_type ao_basis_set() const; - - /** @brief The scale factor for this term. - * - * Terms are meant to be used as part of interactions. When a term shows - * up in an interaction it is weighted. This method returns the scale - * factor for this term. - * - * @return The scale factor - * - * @throw std::runtime_error if *this does not have a coefficent set. - * Strong throw guarantee. - */ - coefficient_type coefficient() const; - - // -- Utility methods - - /** @brief Determines if the Term's state has been set - * - * A term is empty if no part of its state (molecular system, - * AO basis, or coefficient) has been set. - * - * @return True if this Term is empty and false otherwise. - * - * @throw None no throw guarantee. - */ - bool empty() const noexcept; - - /** @brief Exchanges the state in *this with the state in @p other. - * - * @param[in,out] other The instance whose state is being swapped with the - * state in *this. After this call @p other will - * contain the state which was previously in *this. - * - * @throw None No throw guarantee. - */ - void swap(Term& other) noexcept; - - /** @brief Compares *this to @p rhs for value equality. - * - * Two Term instances are value equal if they are both empty, or if they - * both contain the same state. In comparing state the molecular system, - * AO basis set, and scaling coefficient are compared. N.B. all floating - * point comparisons are also value equality (i.e., floating point values - * are compared to machine epsilon). - * - * @param[in] rhs The Term being compared to *this. - * - * @throw None No throw guarantee - */ - bool operator==(const Term& rhs) const noexcept; - -private: - /// Code factorization for asserting that *this has a PIMPL - void assert_pimpl_() const; - - /// The object actually implementing this Term - pimpl_pointer m_pimpl_; -}; - -/** @brief Determines if two terms are different. - * - * @relates Term - * - * This method simply negates Term::operator==. See Term::operator== for the - * definition of value equality. - * - * @param[in] lhs The Term to the left of the operator. - * @param[in] rhs The Term to the right of the operator. - * - * @return False if @p lhs is value equal to @p rhs and true otherwise. - * - * @throw None No throw guarantee. - */ -inline bool operator!=(const Term& lhs, const Term& rhs) { - return !(lhs == rhs); -} - -std::ostream& operator<<(std::ostream& os, const Term& t); - -} // namespace ghostfragment::equation diff --git a/include/ghostfragment/ghostfragment.hpp b/include/ghostfragment/ghostfragment.hpp index 2503cba7..e468b0be 100644 --- a/include/ghostfragment/ghostfragment.hpp +++ b/include/ghostfragment/ghostfragment.hpp @@ -25,4 +25,3 @@ #include #include -#include diff --git a/include/ghostfragment/property_types/charge_multiplicity_assigner.hpp b/include/ghostfragment/property_types/charge_multiplicity_assigner.hpp deleted file mode 100644 index 23e0fad1..00000000 --- a/include/ghostfragment/property_types/charge_multiplicity_assigner.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -#include -#include -#include - -namespace ghostfragment::pt { - -struct ChargeMultiplicityAssignerTraits { - using frag_type = chemist::FragmentedNuclei; - using cap_type = std::vector; - using mol_type = chemist::Molecule; - - using charge_type = mol_type::charge_type; - using charge_result_type = std::vector; - - using size_type = mol_type::size_type; - using mult_result_type = std::vector; -}; - -DECLARE_PROPERTY_TYPE(ChargeMultiplicityAssigner); - -PROPERTY_TYPE_INPUTS(ChargeMultiplicityAssigner) { - using traits_type = ChargeMultiplicityAssignerTraits; - using frag_type = traits_type::frag_type; - using cap_type = traits_type::cap_type; - using mol_type = traits_type::mol_type; - - return pluginplay::declare_input() - .add_field("Fragments") - .template add_field("Set of caps") - .template add_field("The original molecule"); -} - -PROPERTY_TYPE_RESULTS(ChargeMultiplicityAssigner) { - using traits_type = ChargeMultiplicityAssignerTraits; - using charge_result_type = traits_type::charge_result_type; - using mult_result_type = traits_type::mult_result_type; - - return pluginplay::declare_result() - .add_field("Charge for each fragment") - .template add_field("Mult for each fragment"); -} - -} // namespace ghostfragment::pt diff --git a/include/ghostfragment/property_types/expression.hpp b/include/ghostfragment/property_types/expression.hpp deleted file mode 100644 index 457e5866..00000000 --- a/include/ghostfragment/property_types/expression.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -// #include - -// namespace ghostfragment::pt { - -// struct ExpressionTraits { -// using input_type = ghostfragment::NMerSystem; -// using result_type = ghostfragment::equation::Expression; -// }; - -// DECLARE_PROPERTY_TYPE(Expression); - -// PROPERTY_TYPE_INPUTS(Expression) { -// using traits_type = ExpressionTraits; -// using input_type = traits_type::input_type; - -// return pluginplay::declare_input().add_field("NMers"); -// } - -// PROPERTY_TYPE_RESULTS(Expression) { -// using traits_type = ExpressionTraits; -// using result_type = traits_type::result_type; - -// return pluginplay::declare_result().add_field("Expression"); -// } - -// } // namespace ghostfragment::pt diff --git a/include/ghostfragment/property_types/fragmenting/fragment_weights.hpp b/include/ghostfragment/property_types/fragmenting/fragment_weights.hpp new file mode 100644 index 00000000..b99db473 --- /dev/null +++ b/include/ghostfragment/property_types/fragmenting/fragment_weights.hpp @@ -0,0 +1,27 @@ +#pragma once +#include + +namespace ghostfragment::pt { + +struct FragmentWeightsTraits { + using chemical_system_type = chemist::ChemicalSystem; + using fragments_type = + chemist::fragmenting::FragmentedChemicalSystem; + using weight_type = double; + using weight_container = std::vector; +}; + +DECLARE_PROPERTY_TYPE(FragmentWeights); + +PROPERTY_TYPE_INPUTS(FragmentWeights) { + using fragments_type = typename FragmentWeightsTraits::fragments_type; + using input0_type = const fragments_type&; + return pluginplay::declare_input().add_field("Fragments"); +} + +PROPERTY_TYPE_RESULTS(FragmentWeights) { + using result_type = typename FragmentWeightsTraits::weight_container; + return pluginplay::declare_result().add_field("Weights"); +} + +} // namespace ghostfragment::pt diff --git a/include/ghostfragment/property_types/fragmenting/fragmented_molecule.hpp b/include/ghostfragment/property_types/fragmenting/fragmented_molecule.hpp deleted file mode 100644 index b535db5b..00000000 --- a/include/ghostfragment/property_types/fragmenting/fragmented_molecule.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -#include - -namespace ghostfragment::pt { - -/// Used to conveniently propagate types associated with FragmentedMolecule PT -struct FragmentedMoleculeTraits { - /// Expected input type of the molecular system - using system_type = chemist::FragmentedNuclei; - - /// How the fragmented system is returned. - using result_type = chemist::FragmentedMolecule; -}; - -/** @brief Property type for modules which fragment Molecule objects. - * - */ -DECLARE_PROPERTY_TYPE(FragmentedMolecule); - -PROPERTY_TYPE_INPUTS(FragmentedMolecule) { - using traits_type = FragmentedMoleculeTraits; - using input0_type = traits_type::system_type; - - return pluginplay::declare_input().add_field( - "FragmentedNuclei"); -} - -PROPERTY_TYPE_RESULTS(FragmentedMolecule) { - using traits_type = FragmentedMoleculeTraits; - using result_type = traits_type::result_type; - - return pluginplay::declare_result().add_field( - "Fragmented Molecule"); -} - -} // namespace ghostfragment::pt diff --git a/include/ghostfragment/property_types/input_queue.hpp b/include/ghostfragment/property_types/input_queue.hpp deleted file mode 100644 index 9ae55cd8..00000000 --- a/include/ghostfragment/property_types/input_queue.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -// #include - -// namespace ghostfragment::pt { - -// /// Used to conveniently propagate types associated with FragmentedMolecule -// PT struct InputQueueTraits { -// /// Expected input type of the molecular system -// using system_type = chemist::ChemicalSystem; - -// /// How the fragmented system is returned. -// using result_type = std::vector>; -// }; - -// /** @brief Property type for modules which fragment Molecule objects. -// * -// */ -// DECLARE_PROPERTY_TYPE(InputQueue); - -// PROPERTY_TYPE_INPUTS(InputQueue) { -// using traits_type = InputQueueTraits; -// using input0_type = traits_type::system_type; - -// return pluginplay::declare_input().add_field( -// "Input Chemical System"); -// } - -// PROPERTY_TYPE_RESULTS(InputQueue) { -// using traits_type = InputQueueTraits; -// using result_type = traits_type::result_type; - -// return pluginplay::declare_result().add_field( -// "Fragments and Weights"); -// } - -// } // namespace ghostfragment::pt diff --git a/include/ghostfragment/property_types/property_types.hpp b/include/ghostfragment/property_types/property_types.hpp deleted file mode 100644 index af1c16ef..00000000 --- a/include/ghostfragment/property_types/property_types.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include - -// /** @brief Namespace collecting all of the property types used throughout -// * GhostFragment. -// * -// * GhostFragment uses a number of property types. To protect the source code -// of -// * GhostFragment from upstream changes to those property types, and for -// * consistency, we typedef the property types we use in the pt namespace and -// * rely on the typedefs throughout GhostFragment. -// */ -// namespace ghostfragment::pt { - -// /// PT for assigning AOs to a nuclei -// using AtomicOrbitals = simde::AtomicOrbitals; - -// /// Traits associated with simde::FragmentedMolecule PT -// using frag_traits = simde::FragmentedTraits; - -// /// PT for fragmenting a Molecule object -// // using FragmentedMolecule = simde::FragmentedMolecule; - -// /// Traits associated with the PT for NMers -// using nmer_traits = simde::FragmentedTraits; - -// /// Property type for a module which computes N-Mers -// using NMers = simde::Fragmented; - -// /// Traits for property types -// using atom2ao_traits = simde::detail_::AtomToCenterTraits; - -// } // namespace ghostfragment::pt diff --git a/include/ghostfragment/property_types/subset_map.hpp b/include/ghostfragment/property_types/subset_map.hpp deleted file mode 100644 index cba1e89f..00000000 --- a/include/ghostfragment/property_types/subset_map.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 - -// namespace ghostfragment::pt { - -// template -// struct SubsetMapTraits { -// /// Type of the FamilyOfSets used for the keys -// using fos_key_type = chemist::set_theory::FamilyOfSets; - -// /// Type of the FamilyOfSets used for the values -// using fos_value_type = chemist::set_theory::FamilyOfSets; - -// /// Type of the key in the returned map -// using key_type = typename fos_key_type::value_type; - -// /// Type of the value in the returned map -// using value_type = typename fos_value_type::value_type; - -// using input0_type = const fos_key_type&; -// using input1_type = MappedType; -// using result_type = std::map; -// }; - -// template -// DECLARE_TEMPLATED_PROPERTY_TYPE(SubsetMap, Type2Fragment, MappedType); - -// template -// TEMPLATED_PROPERTY_TYPE_INPUTS(SubsetMap, Type2Fragment, MappedType) { -// using traits_type = SubsetMapTraits; -// using input0_type = typename traits_type::input0_type; -// using input1_type = typename traits_type::input1_type; - -// return pluginplay::declare_input() -// .add_field("Subsets") -// .template add_field("Object to map"); -// } - -// template -// TEMPLATED_PROPERTY_TYPE_RESULTS(SubsetMap, Type2Fragment, MappedType) { -// using traits_type = SubsetMapTraits; -// using result_type = typename traits_type::result_type; - -// return pluginplay::declare_result().add_field("map"); -// } - -// using Frag2AO = SubsetMap; -// using Frag2AOTraits = -// SubsetMapTraits; - -// } // namespace ghostfragment::pt diff --git a/src/ghostfragment/drivers/drivers.hpp b/src/ghostfragment/drivers/drivers.hpp index 7b6b2bb2..aa519b99 100644 --- a/src/ghostfragment/drivers/drivers.hpp +++ b/src/ghostfragment/drivers/drivers.hpp @@ -20,19 +20,14 @@ namespace ghostfragment::drivers { DECLARE_MODULE(Fragment); -// DECLARE_MODULE(FragmentBasedMethod); +DECLARE_MODULE(FragmentBasedMethod); DECLARE_MODULE(FragmentedChemicalSystem); -// DECLARE_MODULE(NeutralSinglet); -// DECLARE_MODULE(InputQueue); /// Loads all the modules in the Drivers library into the provided ModuleManager inline void load_modules(pluginplay::ModuleManager& mm) { mm.add_module("Fragment Driver"); - // // mm.add_module("Fragment Based Method"); mm.add_module("FragmentedChemicalSystem Driver"); - // // mm.add_module("NMerSystem Driver"); - // mm.add_module("Neutral Singlet"); - // mm.add_module("Input Queue"); + mm.add_module("Fragment Based Method"); } /// Sets the defaults for submodules in the Drivers library, when a suitable @@ -41,18 +36,15 @@ inline void set_defaults(pluginplay::ModuleManager& mm) { mm.change_submod("Fragment Driver", "Molecular graph", "Nuclear Graph"); mm.change_submod("Fragment Driver", "Molecular graph to fragments", "Bond-Based Fragmenter"); + mm.change_submod("Fragment Driver", "Intersection finder", "intersections"); mm.change_submod("Fragment Driver", "Find broken bonds", "Broken bonds"); mm.change_submod("Fragment Driver", "Cap broken bonds", "Weighted distance"); mm.change_submod("FragmentedChemicalSystem Driver", "Fragmenter", "Fragment Driver"); - // // mm.change_submod("FragmentedSystem Driver", "Atom to AO Mapper", - // // "AO Center to Atom Mapper"); - - // // mm.change_submod("Fragment Based Method", "Fragment Maker", - // // "FragmentedSystem Driver"); - // // mm.change_submod("Fragment Based Method", "N-Mer Maker", - // // "NMerSystem Driver"); + mm.change_submod("Fragment Based Method", "Subsystem former", + "FragmentedChemicalSystem Driver"); + mm.change_submod("Fragment Based Method", "Weighter", "GMBE Weights"); } } // namespace ghostfragment::drivers diff --git a/src/ghostfragment/drivers/engine.hpp b/src/ghostfragment/drivers/engine.hpp deleted file mode 100644 index f949eb71..00000000 --- a/src/ghostfragment/drivers/engine.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 -// #include - -// using input_type = std::vector>; -// using pt = simde::Energy; -// using mod_type = pluginplay::Module; - -// inline auto engine(const input_type& input, mod_type mod) { -// auto weighted_sum = 0.0; -// for(auto in : input) { -// weighted_sum += mod.run_as(in.first) * in.second; -// } - -// return weighted_sum; -// } diff --git a/src/ghostfragment/drivers/fragment.cpp b/src/ghostfragment/drivers/fragment.cpp index 2506aec4..13478cde 100644 --- a/src/ghostfragment/drivers/fragment.cpp +++ b/src/ghostfragment/drivers/fragment.cpp @@ -17,16 +17,18 @@ #include "drivers.hpp" #include #include +#include #include #include #include namespace ghostfragment::drivers { -using broken_bonds_pt = pt::BrokenBonds; -using cap_pt = pt::CappedFragments; -using frags_pt = pt::FragmentedNuclei; -using graph_pt = pt::NuclearGraph; -using graph2frags_pt = pt::NuclearGraphToFragments; +using broken_bonds_pt = pt::BrokenBonds; +using cap_pt = pt::CappedFragments; +using frags_pt = pt::FragmentedNuclei; +using intersections_pt = pt::Intersections; +using graph_pt = pt::NuclearGraph; +using graph2frags_pt = pt::NuclearGraphToFragments; const auto mod_desc = R"( Fragment Driver @@ -37,6 +39,7 @@ a chemist::FragmentedNuclei object. Generally speaking this occurs by: #. Determining the connectivity of the ChemicalSystem #. Fragmenting the resulting molecular graph +#. Find intersections for the fragments #. Determine if bonds were broken #. Cap the broken bonds @@ -48,6 +51,7 @@ MODULE_CTOR(Fragment) { add_submodule("Molecular graph"); add_submodule("Molecular graph to fragments"); + add_submodule("Intersection finder"); add_submodule("Find broken bonds"); add_submodule("Cap broken bonds"); } @@ -59,7 +63,10 @@ MODULE_RUN(Fragment) { const auto& graph = graph_mod.run_as(mol); auto& frags_mod = submods.at("Molecular graph to fragments"); - const auto& frags = frags_mod.run_as(graph); + const auto& frags_no_ints = frags_mod.run_as(graph); + + auto& intersect_mod = submods.at("Intersection finder"); + const auto& frags = intersect_mod.run_as(frags_no_ints); auto& bonds_mod = submods.at("Find broken bonds"); const auto& conns = graph.edges(); diff --git a/src/ghostfragment/drivers/fragment_based_method.cpp b/src/ghostfragment/drivers/fragment_based_method.cpp index 9a0e4c99..5ff4a939 100644 --- a/src/ghostfragment/drivers/fragment_based_method.cpp +++ b/src/ghostfragment/drivers/fragment_based_method.cpp @@ -14,70 +14,69 @@ * limitations under the License. */ -// #include "drivers.hpp" -// #include -// #include - -// namespace ghostfragment::drivers { - -// using my_pt = simde::AOEnergy; -// using frag_sys_pt = pt::FragmentedSystem; -// using nmer_sys_pt = pt::NMerSystem; -// using expression_pt = pt::Expression; - -// namespace { - -// const auto mod_desc = R"( -// Fragment-Based Method Driver -// ---------------------------- - -// )"; -// } - -// MODULE_CTOR(FragmentBasedMethod) { -// satisfies_property_type(); -// description(mod_desc); - -// add_submodule("Fragment Maker"); -// add_submodule("N-Mer Maker"); -// add_submodule("Expression generator"); -// add_submodule("energy method"); - -// unsigned int m(1); -// add_input("GMBE truncation order").set_default(m); -// } - -// MODULE_RUN(FragmentBasedMethod) { -// // Step 0: Unpack input -// const auto& [aos, sys] = my_pt::unwrap_inputs(inputs); -// const auto n = inputs.at("GMBE truncation order").value(); - -// // Stp 1: Create those fragments -// auto& frag_mod = submods.at("Fragment Maker"); -// const auto& [frags] = frag_mod.run_as(sys, aos.basis_set()); - -// // Step 2: Create those n-mers -// auto& nmer_mod = submods.at("N-Mer Maker"); -// const auto& [nmers] = nmer_mod.run_as(frags, n); - -// // Step 3: Create an expression -// auto& expr_mod = submods.at("Expression generator"); -// const auto& [expr] = expr_mod.run_as(nmers); - -// // Step 4: Run those terms -// double e = 0.0; -// auto& egy_mod = submods.at("energy method"); -// for(std::size_t term_index = 0; term_index < expr.size(); ++term_index) { -// const auto& term_i = expr.at(term_index); -// const auto sys_i = term_i.chemical_system(); -// const chemist::orbital_space::AOSpace aos_i(term_i.ao_basis_set()); -// const auto c_i = term_i.coefficient(); -// const auto [e_term_i] = egy_mod.run_as(aos_i, sys_i); -// e += c_i * e_term_i; -// } - -// auto rv = results(); -// return my_pt::wrap_results(rv, e); -// } - -// } // namespace ghostfragment::drivers +#include "drivers.hpp" +#include +#include +#include +#include +namespace ghostfragment::drivers { + +using my_pt = simde::TotalEnergy; +using ao_energy_pt = simde::AOEnergy; +using fragmenting_pt = pt::FragmentedChemicalSystem; +using fragmenting_traits = pt::FragmentedChemicalSystemTraits; +using chemical_system_type = typename fragmenting_traits::system_type; +using basis_set_pt = simde::MolecularBasisSet; +using weight_pt = pt::FragmentWeights; + +namespace { +const auto mod_desc = R"( +Fragment-Based Method Driver +---------------------------- + +)"; +} + +MODULE_CTOR(FragmentBasedMethod) { + description(mod_desc); + + satisfies_property_type(); + + add_submodule("Subsystem former"); + add_submodule("Weighter"); + add_submodule("Apply basis set"); + add_submodule("Energy method"); +} + +MODULE_RUN(FragmentBasedMethod) { + // Step 0: Unpack input + const auto& [sys] = my_pt::unwrap_inputs(inputs); + + // Step 1: Form subsystems + auto& subsystem_mod = submods.at("Subsystem former"); + const auto& subsystems = subsystem_mod.run_as(sys); + + // Step 2: Determine weights + auto& weight_mod = submods.at("weighter"); + const auto& weights = weight_mod.run_as(subsystems); + + auto& basis_mod = submods.at("Apply basis set"); + auto& energy_mod = submods.at("Energy method"); + + double energy = 0.0; + for(auto&& [c_i, sys_i] : iter::zip(weights, subsystems)) { + auto mol_i = sys_i.molecule().as_molecule(); + const auto& basis = basis_mod.run_as(mol_i); + + // This is a hack until views work with values + chemical_system_type sys_i_copy(mol_i); + + const auto e_i = energy_mod.run_as(basis, sys_i_copy); + energy += c_i * e_i; + } + + auto rv = results(); + return my_pt::wrap_results(rv, energy); +} + +} // namespace ghostfragment::drivers diff --git a/src/ghostfragment/drivers/input_queue.cpp b/src/ghostfragment/drivers/input_queue.cpp deleted file mode 100644 index 647a311c..00000000 --- a/src/ghostfragment/drivers/input_queue.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "drivers.hpp" - -// #include -// #include -// #include -// #include - -// namespace ghostfragment::drivers { - -// bool comparePairs(const std::pair, double>& a, -// const std::pair, double>& b) { -// return a.first < b.first; -// } - -// const auto mod_desc = R"( -// Input Queue -// -------------------------------- - -// This module takes as input a ChemicalSystem object, and returns a vector -// of pairs of ChemicalSystem objects along with their associated integer -// weights. The new ChemicalSystem objects are produced via fragmentation of -// the original ChemicalSystem, and subsequent use of the Intersection -// Finder module to produce all unique intersections of fragments and their -// weights. The module then returns the original fragments with weight one -// and all of the intersections with their corresponding weights as a vector -// of pairs. -// )"; - -// using my_pt = pt::InputQueue; -// using frag_pt = pt::FragmentedNuclei; -// using mol_pt = pt::FragmentedMolecule; - -// MODULE_CTOR(InputQueue) { -// description(mod_desc); - -// satisfies_property_type(); - -// add_submodule("Fragmentation"); -// add_submodule("FragtoMol"); -// } - -// MODULE_RUN(InputQueue) { -// using result_type = pt::InputQueueTraits::result_type; -// using input_type = pt::InputQueueTraits::system_type; -// using pair_type = std::pair; -// using return_type = std::vector; - -// const auto& [system] = my_pt::unwrap_inputs(inputs); - -// if(system == input_type()) { -// throw std::runtime_error("Wasn't expecting default construction"); -// } - -// // Fragments chemical system -// auto& frag_mod = submods.at("Fragmentation"); -// chemist::FragmentedNuclei frags = frag_mod.run_as(system); - -// // Converts FragmentedNuclei to FragmentedMolecule -// // (For intersection finder) -// auto& mol_mod = submods.at("FragtoMol"); -// chemist::FragmentedMolecule mol_frags = mol_mod.run_as(frags); - -// // Finds all intersections -// const auto& ints = ghostfragment::fragmenting::intersections(mol_frags); - -// // Stores weights and extracts indices from fragments -// std::vector weights; -// std::vector> indices; -// for(std::size_t i = 0; i < frags.size(); ++i) { -// weights.push_back(1); -// std::vector indx; -// for(const auto atom : frags[i]) { -// indx.push_back(atom); -// } -// indices.push_back(indx); -// } - -// // Adds intersections to vector of indices -// for(auto pair : ints) { -// std::vector indx; -// for(const auto& num : pair.first) { -// indx.push_back(num); -// } -// indices.push_back(indx); -// weights.push_back(pair.second); -// } - -// std::vector, double>> pairs; - -// for(std::size_t i = 0; i < indices.size(); ++i) { -// pairs.push_back(std::make_pair(indices[i], weights[i])); -// } - -// std::sort(pairs.begin(), pairs.end(), comparePairs); - -// // Combines all FragmentedNuclei, extracts weights -// chemist::FragmentedNuclei all_frags(system.molecule().nuclei()); -// std::vector all_weights; -// for(std::size_t i = 0; i < pairs.size(); ++i) { -// all_frags.add_fragment(pairs[i].first.begin(), pairs[i].first.end()); -// all_weights.push_back(pairs[i].second); -// } - -// // Converts FragmentedNuclei to FragmentedMolecule -// mol_frags = mol_mod.run_as(all_frags); - -// // Converts each fragment into a chemical system -// std::vector systems; -// for(const auto& frag : mol_frags) { -// chemist::Molecule mol(frag.charge(), frag.multiplicity(), {}); -// for(const auto& atom : frag) { -// mol.push_back(chemist::Atom(atom.name(), atom.Z(), atom.mass(), -// atom.x(), atom.y(), atom.z())); -// } -// systems.push_back(chemist::ChemicalSystem(mol)); -// } - -// // Associates systems with their respective weights -// return_type system_weights; -// for(std::size_t i = 0; i < systems.size(); ++i) { -// system_weights.push_back(pair_type(systems[i], all_weights[i])); -// } - -// auto rv = results(); -// return my_pt::wrap_results(rv, system_weights); -// } - -// } // namespace ghostfragment diff --git a/src/ghostfragment/drivers/neutral_singlet.cpp b/src/ghostfragment/drivers/neutral_singlet.cpp deleted file mode 100644 index 8121f0b5..00000000 --- a/src/ghostfragment/drivers/neutral_singlet.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "drivers.hpp" -// #include -// #include -// #include -// #include - -// using my_pt = ghostfragment::pt::ChargeMultiplicityAssigner; -// using traits_t = ghostfragment::pt::ChargeMultiplicityAssignerTraits; - -// namespace ghostfragment::drivers { - -// namespace { -// constexpr auto module_desc = R"""( -// ####################### -// Neutral Singlet Charge Assigner -// ####################### - -// This module assigns a charge of zero -// and a multiplicity of one to each input fragment. - -// The inputs to this module are fragments, a cap set, and the original -// molecule. -// )"""; -// } // end namespace - -// MODULE_CTOR(NeutralSinglet) { -// satisfies_property_type(); -// } - -// MODULE_RUN(NeutralSinglet) { -// const auto& [frags, caps, mol] = my_pt::unwrap_inputs(inputs); - -// using charge_result_type = traits_t::charge_result_type; -// using mult_result_type = traits_t::mult_result_type; -// // Charge vector is only populated with 0s -// charge_result_type charges(frags.size(), 0); -// mult_result_type multiplicities; - -// // Goes over every fragment and attempts -// // to set each one's multiplicity to one. -// for(auto frag_i = 0; frag_i < frags.size(); frag_i++) { -// // Keeps track of the number of electrons in each fragment -// auto num_electrons = 0; - -// // Adds the electrons from the original atoms in the fragment -// const auto& nukes = frags[frag_i]; -// for(auto atom_i = 0; atom_i < nukes.size(); atom_i++) { -// num_electrons += nukes[atom_i].Z(); -// } - -// // Adds the electrons from the caps in the fragment -// const auto& cap_set = caps[frag_i]; -// for(auto cap_i = 0; cap_i < cap_set.size(); cap_i++) { -// const auto& cap = cap_set[cap_i]; -// for(auto atom_i = 0; atom_i < cap.size(); atom_i++) { -// num_electrons += cap.cap_atom(atom_i).Z(); -// } -// } - -// // Even number of electrons which means multiplicity can be one. -// if(num_electrons % 2 == 0) { -// multiplicities.push_back(1); -// } - -// // With an odd number of electrons, a multiplicity of one is -// impossible else { -// throw std::runtime_error("An odd number of electrons cannot have -// multiplicity of one"); -// } -// } - -// auto rv = results(); -// return my_pt::wrap_results(rv, charges, multiplicities); -// } -// } // namespace ghostfragment::drivers diff --git a/src/ghostfragment/drivers/nmer_system.cpp b/src/ghostfragment/drivers/nmer_system.cpp deleted file mode 100644 index b82cbf0f..00000000 --- a/src/ghostfragment/drivers/nmer_system.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "drivers.hpp" -// #include - -// namespace ghostfragment::drivers { - -// using nmer_screener_pt = pt::NMerScreener; -// using my_pt = pt::NMerSystem; -// using traits_type = pt::NMerSystemTraits; - -// const auto mod_desc = R"()"; - -// MODULE_CTOR(NMerSystem) { -// description(mod_desc); - -// satisfies_property_type(); -// add_submodule("NMer Screener"); -// } - -// MODULE_RUN(NMerSystem) { -// using result_type = traits_type::result_type; - -// const auto& [frags, n] = my_pt::unwrap_inputs(inputs); -// const auto N = frags.nfrags(); - -// // Basic error checking -// if(N < n) -// throw std::runtime_error("Can not create " + std::to_string(n) + -// "-mers with only " + std::to_string(N) + -// " fragments."); - -// // n == 0 and n == 1 edge cases -// if(n < 2) { -// type::nmers nmers(frags.frags()); - -// if(n == 1) { -// for(std::size_t i = 0; i < N; ++i) { -// auto frag = nmers.new_subset(); -// frag.insert(i); -// nmers.insert(frag); -// } -// } -// auto rv = results(); -// result_type nmer_system(frags, nmers); -// return my_pt::wrap_results(rv, nmer_system); -// } - -// type::fragment_to_caps f2cap; -// for(auto frag_i = 0; frag_i < frags.nfrags(); ++frag_i) { -// const auto& frag = frags.fragment(frag_i); -// f2cap.emplace(frag, frags.caps(frag)); -// } - -// auto& nmer_mod = submods.at("NMer Screener"); -// const auto& [nmers] = nmer_mod.run_as(f2cap); - -// result_type nmer_system(frags, nmers); - -// auto rv = results(); -// return my_pt::wrap_results(rv, nmer_system); -// } - -// } // namespace ghostfragment::drivers diff --git a/src/ghostfragment/equation/detail_/expression_pimpl.hpp b/src/ghostfragment/equation/detail_/expression_pimpl.hpp deleted file mode 100644 index c76855a8..00000000 --- a/src/ghostfragment/equation/detail_/expression_pimpl.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 - -// namespace ghostfragment::equation::detail_ { - -// /// Implements the Expression class -// struct ExpressionPIMPL { -// /// Type of the class this PIMPL implements -// using parent_type = Expression; - -// /// Ultimately a typedef of Expression::term_type -// using term_type = parent_type::term_type; - -// /// Random access container filled with term_type objects -// using term_container = std::vector; - -// /// Type of pointer parent_type stores its PIMPL as -// using pimpl_pointer = parent_type::pimpl_pointer; - -// /// Makes a deep copy of this instance on the heap -// pimpl_pointer clone() const { -// return std::make_unique(*this); -// } - -// /// Compares the Terms in *this to those in @p rhs -// bool operator==(const ExpressionPIMPL& rhs) const noexcept; - -// /// Set of terms in the container -// term_container m_terms; -// }; - -// // -// ----------------------------------------------------------------------------- -// // -- Inline definitions -// // -// ----------------------------------------------------------------------------- - -// bool ExpressionPIMPL::operator==(const ExpressionPIMPL& rhs) const noexcept { -// return m_terms == rhs.m_terms; -// } - -// } // namespace ghostfragment::equation::detail_ diff --git a/src/ghostfragment/equation/detail_/term_pimpl.hpp b/src/ghostfragment/equation/detail_/term_pimpl.hpp deleted file mode 100644 index 2813ed6b..00000000 --- a/src/ghostfragment/equation/detail_/term_pimpl.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 - -// namespace ghostfragment::equation::detail_ { - -// struct TermPIMPL { -// /// Type of the class this PIMPL implements -// using parent_type = Term; - -// /// Type of object fragmented data comes from -// using nmer_system_type = NMerSystem; - -// /// Ultimately a typedef of NMerSystem::nmer_type -// using nmer_type = nmer_system_type::nmer_type; - -// /// Ultimately a typedef of Term::molecule_type -// using molecule_type = parent_type::molecule_type; - -// /// Ultimately a typedef of NMerSystem::ao_set_type -// using ao_set_type = nmer_system_type::ao_set_type; - -// /// Ultimately a typedef of Term::ao_basis_set_type -// using ao_basis_set_type = parent_type::ao_basis_set_type; - -// /// Ultimately a typedef of Term::size_type -// using size_type = parent_type::size_type; - -// /// Ultimately a typedef of Term::coefficient_type -// using coefficient_type = parent_type::coefficient_type; - -// /// Type of the pointer used to manage the lifetime of a TermPIMPl -// using pimpl_pointer = parent_type::pimpl_pointer; - -// TermPIMPL(nmer_type nmer, ao_set_type aos, size_type n_electrons, -// coefficient_type coef); - -// /** @brief Returns the set of nuclei contained in *this. -// * -// * @return The set of nuclei *this holds. -// */ -// molecule_type molecule() const; - -// /// Returns the AO basis set *this holds -// ao_basis_set_type ao_basis_set() const; - -// /// Makes a deep copy of *this -// pimpl_pointer clone() const; - -// /// Element-wise comparison -// bool operator==(const TermPIMPL& rhs) const noexcept; - -// nmer_type m_nmer; -// ao_set_type m_aos; -// size_type m_n_electrons; -// coefficient_type m_coef; -// }; - -// // -// ----------------------------------------------------------------------------- -// // -- Inline implementations -// // -// ----------------------------------------------------------------------------- - -// inline TermPIMPL::TermPIMPL(nmer_type nmer, ao_set_type aos, -// size_type n_electrons, coefficient_type coef) : -// m_nmer(std::move(nmer)), -// m_aos(std::move(aos)), -// m_n_electrons(n_electrons), -// m_coef(std::move(coef)) {} - -// inline typename TermPIMPL::molecule_type TermPIMPL::molecule() const { -// molecule_type mol; -// const auto& frags = m_nmer.object(); -// std::set m_indices; -// for(const auto& fragment_index : m_nmer) { -// const auto& frag = frags.at(fragment_index); -// m_indices.insert(frag.begin(), frag.end()); -// } - -// const auto& parent_mol = frags.object(); -// for(const auto atom_index : m_indices) -// mol.push_back(parent_mol.at(atom_index)); -// return mol; -// } - -// inline typename TermPIMPL::ao_basis_set_type TermPIMPL::ao_basis_set() const -// { -// ao_basis_set_type aos; -// const auto& parent_aos = m_aos.object(); -// for(const auto& ao_index : m_aos) { aos.add_center(parent_aos[ao_index]); -// } return aos; -// } - -// inline typename TermPIMPL::pimpl_pointer TermPIMPL::clone() const { -// return std::make_unique(*this); -// } - -// inline bool TermPIMPL::operator==(const TermPIMPL& rhs) const noexcept { -// return std::tie(m_nmer, m_aos, m_n_electrons, m_coef) == -// std::tie(rhs.m_nmer, rhs.m_aos, rhs.m_n_electrons, rhs.m_coef); -// } - -// } // namespace ghostfragment::equation::detail_ diff --git a/src/ghostfragment/equation/equation.cpp b/src/ghostfragment/equation/equation.cpp deleted file mode 100644 index 070a8a2b..00000000 --- a/src/ghostfragment/equation/equation.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "detail_/term_pimpl.hpp" -// #include - -// namespace ghostfragment::equation { - -// Term make_term(typename type::nmer_set::value_type nmer, -// typename type::fragmented_ao_set::value_type aos, -// std::size_t n_electrons, Term::coefficient_type coef) { -// using pimpl_type = detail_::TermPIMPL; - -// auto p = std::make_unique(std::move(nmer), std::move(aos), -// n_electrons, coef); - -// return Term(std::move(p)); -// } - -// } // namespace ghostfragment::equation diff --git a/src/ghostfragment/equation/expression.cpp b/src/ghostfragment/equation/expression.cpp deleted file mode 100644 index 25aed166..00000000 --- a/src/ghostfragment/equation/expression.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "detail_/expression_pimpl.hpp" - -// namespace ghostfragment::equation { - -// // -- Ctors, Assignment Operators, Dtor - -// Expression::Expression() noexcept = default; - -// Expression::Expression(pimpl_pointer pimpl) noexcept : -// m_pimpl_(std::move(pimpl)) {} - -// Expression::Expression(const Expression& other) : -// m_pimpl_(!other.empty() ? other.m_pimpl_->clone() : nullptr) {} - -// Expression::Expression(Expression&& other) noexcept = default; - -// Expression& Expression::operator=(const Expression& rhs) { -// if(this != &rhs) { Expression(rhs).swap(*this); } -// return *this; -// } - -// Expression& Expression::operator=(Expression&& rhs) noexcept = default; - -// Expression::~Expression() noexcept = default; - -// // -- Getters - -// Expression::size_type Expression::size() const noexcept { -// return !empty() ? m_pimpl_->m_terms.size() : 0; -// } - -// Expression::const_term_reference Expression::at(size_type i) const { -// assert_bounds_(i); -// return m_pimpl_->m_terms[i]; -// } - -// // -- Setters - -// void Expression::add_term(term_type term) { -// if(!m_pimpl_) std::make_unique().swap(m_pimpl_); -// m_pimpl_->m_terms.emplace_back(std::move(term)); -// } - -// // -- Utility - -// bool Expression::empty() const noexcept { return -// !static_cast(m_pimpl_); } - -// void Expression::swap(Expression& other) noexcept { -// m_pimpl_.swap(other.m_pimpl_); -// } - -// bool Expression::operator==(const Expression& rhs) const noexcept { -// // Check if one is empty and other isn't -// if(empty() != rhs.empty()) return false; - -// // Both are either empty or not empty, return if empty -// if(empty()) return true; - -// return std::tie(m_pimpl_->m_terms) == std::tie(rhs.m_pimpl_->m_terms); -// } - -// // -- Private Methods - -// void Expression::assert_bounds_(size_type i) const { -// if(i < size()) return; - -// throw std::out_of_range("Offset " + std::to_string(i) + -// " is not in the range [0, " + -// std::to_string(size()) + ")."); -// } - -// } // namespace ghostfragment::equation diff --git a/src/ghostfragment/equation/term.cpp b/src/ghostfragment/equation/term.cpp deleted file mode 100644 index a4d421bc..00000000 --- a/src/ghostfragment/equation/term.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "detail_/term_pimpl.hpp" - -// namespace ghostfragment::equation { - -// Term::Term() noexcept = default; - -// Term::Term(pimpl_pointer pimpl) noexcept : m_pimpl_(std::move(pimpl)) {} - -// Term::Term(const Term& other) : -// m_pimpl_(other.m_pimpl_ ? other.m_pimpl_->clone() : nullptr) {} - -// Term::Term(Term&& other) noexcept = default; - -// Term& Term::operator=(const Term& rhs) { -// if(this != &rhs) { Term(rhs).swap(*this); } -// return *this; -// } - -// Term& Term::operator=(Term&& rhs) noexcept = default; - -// Term::~Term() noexcept = default; - -// Term::molecule_type Term::molecule() const { -// assert_pimpl_(); -// return m_pimpl_->molecule(); -// } - -// Term::size_type Term::n_electrons() const noexcept { -// return empty() ? 0 : m_pimpl_->m_n_electrons; -// } - -// Term::chemical_system_type Term::chemical_system() const { -// auto mol = molecule(); -// const auto n_e = n_electrons(); -// return chemical_system_type(std::move(mol), n_e); -// } - -// Term::ao_basis_set_type Term::ao_basis_set() const { -// assert_pimpl_(); -// return m_pimpl_->ao_basis_set(); -// } - -// Term::coefficient_type Term::coefficient() const { -// assert_pimpl_(); -// return m_pimpl_->m_coef; -// } - -// // -- Utility Methods - -// bool Term::empty() const noexcept { return !static_cast(m_pimpl_); } - -// void Term::swap(Term& other) noexcept { m_pimpl_.swap(other.m_pimpl_); } - -// bool Term::operator==(const Term& rhs) const noexcept { -// // Check if one is empty and the other isn't -// if(empty() != rhs.empty()) return false; - -// // Either both filled, or both emtpy, return if latter -// if(empty()) return true; - -// return *m_pimpl_ == *rhs.m_pimpl_; -// } - -// // -- Private Methods - -// void Term::assert_pimpl_() const { -// if(!empty()) return; -// throw std::runtime_error("Term is empty. Did you default construct it or -// " -// "move from it?"); -// } - -// // -- Related Methods - -// std::ostream& operator<<(std::ostream& os, const Term& t) { -// if(t.empty()) return os << "{empty}"; -// return os << t.molecule() << std::endl << t.coefficient(); -// } - -// } // namespace ghostfragment::equation diff --git a/src/ghostfragment/expressions/expressions.hpp b/src/ghostfragment/expressions/expressions.hpp deleted file mode 100644 index 949b9a52..00000000 --- a/src/ghostfragment/expressions/expressions.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 - -// namespace ghostfragment::expressions { - -// // DECLARE_MODULE(MBE); - -// inline void load_modules(pluginplay::ModuleManager& mm) { -// // mm.add_module("Many-body expansion"); -// } - -// inline void set_defaults(pluginplay::ModuleManager& mm) {} - -// } // namespace ghostfragment::expressions diff --git a/src/ghostfragment/expressions/mbe.cpp b/src/ghostfragment/expressions/mbe.cpp deleted file mode 100644 index f7c0c6a1..00000000 --- a/src/ghostfragment/expressions/mbe.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "expressions.hpp" -// #include -// #include - -// using my_pt = ghostfragment::pt::Expression; -// using traits_type = ghostfragment::pt::ExpressionTraits; -// using nmers_type = traits_type::input_type; -// using nmer_type = nmers_type::nmer_type; -// using size_type = nmers_type::size_type; -// using vector_type = std::vector; -// using map_type = std::map; - -// namespace ghostfragment::expressions { - -// namespace { -// constexpr auto module_desc = R"""( -// ################### -// Many-Body Expansion -// ################### -// )"""; -// } - -// MODULE_CTOR(MBE) { -// satisfies_property_type(); - -// description(module_desc); -// } - -// void compute_intersections(const nmer_type& nmer, std::size_t i, -// const nmers_type& nmers, map_type& rv, -// int coef = 1) { -// // Input coef is for n things, interior of loop is for n + 1 things so we -// // need to flip the sign -// coef *= -1; -// for(std::size_t j = i; j < nmers.size(); ++j) { -// auto intersect = nmer ^ nmers.nmer(j); -// if(intersect.size() == 0) continue; -// compute_intersections(intersect, j + 1, nmers, rv, coef); -// rv.count(intersect) ? rv[intersect] += coef : rv[intersect] = coef; -// } -// } - -// MODULE_RUN(MBE) { -// const auto& [nmers] = my_pt::unwrap_inputs(inputs); - -// map_type coefs; -// for(size_type i = 0; i < nmers.size(); ++i) { -// const auto& nmer_i = nmers.nmer(i); -// coefs.count(nmer_i) ? ++coefs[nmer_i] : coefs[nmer_i] = 1; -// compute_intersections(nmer_i, i + 1, nmers, coefs); -// } - -// traits_type::result_type equation; -// const auto& frags = nmers.fragments(); -// for(const auto& [kmer, v] : coefs) { -// auto k_aos = nmers.ao_basis_set(kmer.begin(), kmer.end()); -// auto k_electrons = nmers.n_electrons(kmer.begin(), kmer.end()); -// auto t = equation::make_term(kmer, k_aos, k_electrons, double(v)); -// equation.add_term(std::move(t)); -// } - -// auto rv = results(); -// return my_pt::wrap_results(rv, equation); -// } - -// } // namespace ghostfragment::expressions diff --git a/src/ghostfragment/fragmenting/ao2atom.cpp b/src/ghostfragment/fragmenting/ao2atom.cpp deleted file mode 100644 index 0abca3d0..00000000 --- a/src/ghostfragment/fragmenting/ao2atom.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "fragmenting.hpp" -// #include -// #include -// #include - -// namespace ghostfragment::fragmenting { - -// using my_pt = simde::AtomToAO; - -// const auto mod_desc = R"( -// Center To Atom Mapper -// --------------------- - -// This module will map each center to the atom it is closest to. This algorithm -// is not suitable for use when centers are not atom-centered (*e.g.*, ghost -// atoms, and mid-bond functions). - -// )"; - -// MODULE_CTOR(AO2Atom) { -// description(mod_desc); - -// satisfies_property_type(); -// } - -// MODULE_RUN(AO2Atom) { -// using return_type = simde::atom_to_center_return_type; - -// const auto& [mol, aos] = my_pt::unwrap_inputs(inputs); - -// return_type atom2center(mol.size()); - -// for(std::size_t ao_i = 0; ao_i < aos.size(); ++ao_i) { -// // This will be the index of that atom that the basis function is -// // closest to -// std::size_t winner = 0; - -// // This is the distance to the winning atom. The default values is -// // many times larger than the observable universe... -// double dist = std::numeric_limits::max(); - -// const auto& ao = aos[ao_i]; -// for(std::size_t atom_i = 0; atom_i < mol.size(); ++atom_i) { -// const auto& ai = mol[atom_i]; -// double dx = ao.x() - ai.x(); -// double dy = ao.y() - ai.y(); -// double dz = ao.z() - ai.z(); -// double temp = std::sqrt(dx * dx + dy * dy + dz * dz); -// if(temp >= dist) continue; -// winner = atom_i; -// dist = temp; -// } -// atom2center[winner].insert(ao_i); -// } - -// auto rv = results(); -// return my_pt::wrap_results(rv, atom2center); -// } - -// } // namespace ghostfragment::fragmenting diff --git a/src/ghostfragment/fragmenting/fragmenting.hpp b/src/ghostfragment/fragmenting/fragmenting.hpp index 9d9648d8..216d1ded 100644 --- a/src/ghostfragment/fragmenting/fragmenting.hpp +++ b/src/ghostfragment/fragmenting/fragmenting.hpp @@ -22,27 +22,21 @@ namespace ghostfragment::fragmenting { DECLARE_MODULE(Cluster); DECLARE_MODULE(HeavyAtom); DECLARE_MODULE(NMers); -// DECLARE_MODULE(AO2Atom); -// DECLARE_MODULE(NucleiAO); -// DECLARE_MODULE(SystemAO); DECLARE_MODULE(BondBased); DECLARE_MODULE(IntersectionsByRecursion); -// DECLARE_MODULE(DimerMaker); +DECLARE_MODULE(GMBEWeights); inline void load_modules(pluginplay::ModuleManager& mm) { mm.add_module("Cluster Partition"); mm.add_module("Heavy Atom Partition"); mm.add_module("All nmers"); - mm.add_module("Intersections"); - // mm.add_module("AO Center to Atom Mapper"); - // mm.add_module("Nuclei-AO Fragmenter"); mm.add_module("Bond-Based Fragmenter"); - // mm.add_module("Dimer Maker"); + mm.add_module("Intersections"); + mm.add_module("GMBE Weights"); } inline void set_defaults(pluginplay::ModuleManager& mm) { mm.change_submod("Heavy Atom Partition", "Connectivity", "Covalent Radius"); - // mm.change_submod("Dimer Maker", "Fragmentation", "Fragment Driver"); } } // namespace ghostfragment::fragmenting diff --git a/src/ghostfragment/fragmenting/gmbe_weights.cpp b/src/ghostfragment/fragmenting/gmbe_weights.cpp new file mode 100644 index 00000000..2ce68478 --- /dev/null +++ b/src/ghostfragment/fragmenting/gmbe_weights.cpp @@ -0,0 +1,117 @@ +#include "fragmenting.hpp" +#include +#include + +namespace ghostfragment::fragmenting { + +using my_pt = pt::FragmentWeights; +using traits_type = pt::FragmentWeightsTraits; +using weight_container = typename traits_type::weight_container; +using fragmented_sys_type = typename traits_type::fragments_type; +using fragmented_mol_type = + typename fragmented_sys_type::fragmented_molecule_type; +using fragmented_nuclei_type = + typename fragmented_mol_type::fragmented_nuclei_type; +using nucleus_index_set = typename fragmented_nuclei_type::nucleus_index_set; +using index_type = typename nucleus_index_set::value_type; +using size_type = typename fragmented_nuclei_type::size_type; +using index_set = std::set; +using index_set_to_frag = std::map; +using length_to_map = std::map; + +namespace { + +const auto mod_desc = R"( +GMBE Fragment Weights +--------------------- + +Given the list of subsystems (subsystem being defined as either a fragment or an +intersection) this module will determine the weights of each subsystem. This +module will NOT add intersections to the input list. + +This module adopts the algorithm from DOI:10.1021/jp103074f. More specifically, +each subsystem with :math:`\eta` nuclei in it represents an :math:`eta`-body +interaction. Each :math:`\eta`-body interaction should only occur once when we +sum up the subsystems. Therefore the coefficient of the :math:`i`-th subsystem +is :math:`c_i = 1-\sum_{j\supset i}c_j` where the sum is over the weights of +the proper supersets of the :math:`i`-th subsystem. + +While the non-linear nature of the weights may seem troubling at first, we can +exploit the fact that a proper superset must have more members. More +specifically, if we start with the supersystem(s) with the most members we know +they have weights of 1 because they can't be subsets of any other subsystem. We +can then move on to the next largest subsystem(s) which can only be subsets of +the largest subsystem(s). The process then continues with the next largest +subsystem(s), so on and so forth. More formally: + +#. Sort subsystems by length (remembering their original offset) +#. Let :math:`\eta` be the length of the largest subsystem(s) +#. Set :math:`n` to :math:`\eta` +#. Let :math:`c^n_i` be the weight for the :math:`i`-th subsystem of length + :math:`n`; set :math:c^n_i: to 1.0. +#. Loop over subsystem lengths :math:`m` such that :math:`m>n`. + + #. Loop over subsystems of length :math:`m`, if the :math:`j`-th subsystem of + length :math:`m` is a supersystem of the :math:`i`-th subsystem of length + :math:`n` subtract :math:`c^m_j` from :math:`c^n_i` + +#. Set :math:`n` to :math:`n-1`. If :math:`n` is 0 terminate, otherwise return + to step 4. +)"; + +template +bool is_subset(const SetType& superset, const SetType& subset) { + return std::includes(superset.begin(), superset.end(), subset.begin(), + subset.end()); +} + +} // namespace + +MODULE_CTOR(GMBEWeights) { + description(mod_desc); + satisfies_property_type(); +} + +MODULE_RUN(GMBEWeights) { + const auto& [fragmented_sys] = my_pt::unwrap_inputs(inputs); + const auto& fragmented_molecule = fragmented_sys.fragmented_molecule(); + const auto& fragmented_nuclei = fragmented_molecule.fragmented_nuclei(); + + length_to_map sorted_frags; + std::set nnuclei; + for(size_type frag_i = 0; frag_i < fragmented_nuclei.size(); ++frag_i) { + auto buffer = fragmented_nuclei.nuclear_indices(frag_i); + index_set indices(buffer.begin(), buffer.end()); + sorted_frags[buffer.size()][indices] = frag_i; + nnuclei.insert(buffer.size()); + } + + weight_container weights(fragmented_nuclei.size(), 0.0); + + // N.B. use of rbegin/rend to start with largest fragment + auto subset_size = nnuclei.rbegin(); + auto smallest = nnuclei.rend(); + + while(subset_size != smallest) { + for(const auto& [subset, i] : sorted_frags[*subset_size]) { + // Final weight is equal to 1 minus the weight of each parent's + // weight + weights[i] = 1.0; + + // N.b. starting at the end again + auto parent_size = nnuclei.rbegin(); + while(parent_size != subset_size) { + for(const auto& [superset, j] : sorted_frags[*parent_size]) { + if(is_subset(superset, subset)) weights[i] -= weights[j]; + } + ++parent_size; + } + } + ++subset_size; + } + + auto rv = results(); + return my_pt::wrap_results(rv, weights); +} + +} // namespace ghostfragment::fragmenting diff --git a/src/ghostfragment/fragmenting/nuceli_ao.cpp b/src/ghostfragment/fragmenting/nuceli_ao.cpp deleted file mode 100644 index c9d294fc..00000000 --- a/src/ghostfragment/fragmenting/nuceli_ao.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "fragmenting.hpp" -// #include - -// using namespace ghostfragment::pt; - -// namespace ghostfragment::fragmenting { - -// using my_pt = Frag2AO; -// using atom2center_pt = simde::AtomToAO; - -// const auto mod_desc = R"( -// AOSpace/Molecule Partitioner -// ---------------------------- - -// This module serves as a driver of sorts for fragmenting a molecule and then -// assigning AO basis sets to the fragments. How fragments are formed, and how -// AOs are mapped to atoms is determined by submodules. This module then uses -// the results of the two submodules to associate each fragment with an AO basis -// set. - -// .. note:: - -// The AO basis set associated with each fragment is more akin to applying an -// atomic basis set to the fragment, than the AO basis set one would use for -// say performing a basis-set superposition error calculation. The exact -// details depend on the "Atom to Center" module though. -// )"; - -// MODULE_CTOR(NucleiAO) { -// satisfies_property_type(); - -// add_submodule("Atom to Center"); -// } - -// MODULE_RUN(NucleiAO) { -// const auto& [frags, aos] = my_pt::unwrap_inputs(inputs); -// const auto& mol = frags.object(); - -// // Step 1: Map atoms to AOs -// const auto& atom_ao = -// submods.at("Atom to Center").run_as(mol, aos); - -// typename Frag2AOTraits::fos_value_type fragged_aos(aos); -// typename Frag2AOTraits::result_type frag2aos; -// // Step 2: Apply basis functions to fragment -// for(const auto& fragi : frags) { -// auto new_set = fragged_aos.new_subset(); -// for(auto atomi : fragi) { -// for(auto centeri : atom_ao.at(atomi)) new_set.insert(centeri); -// } -// frag2aos.emplace(fragi, std::move(new_set)); -// } - -// auto rv = results(); -// return my_pt::wrap_results(rv, frag2aos); -// } - -// } // namespace ghostfragment::fragmenting diff --git a/src/ghostfragment/ghostfragment.cpp b/src/ghostfragment/ghostfragment.cpp index f6765561..0d36bf16 100644 --- a/src/ghostfragment/ghostfragment.cpp +++ b/src/ghostfragment/ghostfragment.cpp @@ -16,7 +16,6 @@ #include "capping/capping.hpp" #include "drivers/drivers.hpp" -#include "expressions/expressions.hpp" #include "fragmenting/fragmenting.hpp" #include "screening/screening.hpp" #include "topology/topology.hpp" @@ -28,14 +27,12 @@ void load_modules(pluginplay::ModuleManager& mm) { capping::load_modules(mm); topology::load_modules(mm); drivers::load_modules(mm); - // expressions::load_modules(mm); fragmenting::load_modules(mm); // screening::load_modules(mm); capping::set_defaults(mm); topology::set_defaults(mm); drivers::set_defaults(mm); - // expressions::set_defaults(mm); fragmenting::set_defaults(mm); // screening::set_defaults(mm); } diff --git a/src/ghostfragment/topology/distance.hpp b/src/ghostfragment/topology/distance.hpp deleted file mode 100644 index efe74ad1..00000000 --- a/src/ghostfragment/topology/distance.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 // for std::sqrt -// #include - -// namespace ghostfragment::detail_ { - -// inline auto atomic_distance(const simde::type::atom& ai, -// const simde::type::atom& aj) { -// return (ai.nucleus() - aj.nucleus()).magnitude(); -// } - -// } // namespace ghostfragment::detail_ diff --git a/tests/cxx/unit_tests/ghostfragment/caps.cpp b/tests/cxx/unit_tests/ghostfragment/caps.cpp deleted file mode 100644 index 08ff0725..00000000 --- a/tests/cxx/unit_tests/ghostfragment/caps.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// TEST_CASE("Caps") { -// ghostfragment::Caps defaulted; -// auto non_default = testing::caps_for_water_needing_caps(2).object(); - -// SECTION("size") { -// REQUIRE(defaulted.size() == 0); -// REQUIRE(non_default.size() == 4); -// } - -// SECTION("count") { -// REQUIRE_FALSE(defaulted.count(non_default[0])); - -// REQUIRE(non_default.count(non_default[0])); -// REQUIRE(non_default.count(non_default[1])); -// REQUIRE(non_default.count(non_default[2])); -// REQUIRE(non_default.count(non_default[3])); - -// auto copy = non_default[2]; -// copy.Z() = 3; -// REQUIRE_FALSE(non_default.count(copy)); -// } - -// SECTION("add_cap") { -// defaulted.add_cap(non_default[0], 0); -// REQUIRE(defaulted[0] == non_default[0]); -// REQUIRE(defaulted.replaced_atom(0) == 0); -// } - -// SECTION("operator[]") { -// REQUIRE(non_default[0] == non_default.nuclei()[0]); -// REQUIRE(non_default[1] == non_default.nuclei()[1]); -// REQUIRE(non_default[2] == non_default.nuclei()[2]); -// REQUIRE(non_default[3] == non_default.nuclei()[3]); -// } - -// SECTION("at") { -// REQUIRE_THROWS_AS(defaulted.at(0), std::out_of_range); -// REQUIRE(non_default.at(0) == non_default.nuclei()[0]); -// REQUIRE(non_default.at(1) == non_default.nuclei()[1]); -// REQUIRE(non_default.at(2) == non_default.nuclei()[2]); -// REQUIRE(non_default.at(3) == non_default.nuclei()[3]); -// REQUIRE_THROWS_AS(non_default.at(4), std::out_of_range); -// } - -// SECTION("replaced_atom") { -// REQUIRE_THROWS_AS(defaulted.replaced_atom(0), std::out_of_range); -// REQUIRE(non_default.replaced_atom(0) == 2); -// REQUIRE(non_default.replaced_atom(1) == 0); -// REQUIRE(non_default.replaced_atom(2) == 5); -// REQUIRE(non_default.replaced_atom(3) == 3); -// REQUIRE_THROWS_AS(non_default.replaced_atom(4), std::out_of_range); -// } - -// SECTION("nuclei") { -// using nuclei_type = ghostfragment::type::nuclei_set; -// REQUIRE(defaulted.nuclei() == nuclei_type{}); -// nuclei_type corr; -// corr.push_back(non_default[0]); -// corr.push_back(non_default[1]); -// corr.push_back(non_default[2]); -// corr.push_back(non_default[3]); -// REQUIRE(non_default.nuclei() == corr); -// } - -// SECTION("comparisons") { -// auto a0 = non_default[0]; -// auto a1 = non_default[1]; -// ghostfragment::Caps rhs; - -// // Defaulted instances are same -// REQUIRE(defaulted == rhs); -// REQUIRE_FALSE(defaulted != rhs); - -// // Defaulted is not the same as a filled -// REQUIRE(defaulted != non_default); -// REQUIRE_FALSE(defaulted == non_default); - -// defaulted.add_cap(a0, 0); -// rhs.add_cap(a1, 0); - -// // Differ by cap value -// REQUIRE(defaulted != rhs); -// REQUIRE_FALSE(defaulted == rhs); - -// // Differ by offset of replaced atom -// ghostfragment::Caps rhs2; -// rhs2.add_cap(a0, 1); -// REQUIRE(defaulted != rhs2); -// REQUIRE_FALSE(defaulted == rhs2); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/drivers/engine.cpp b/tests/cxx/unit_tests/ghostfragment/drivers/engine.cpp deleted file mode 100644 index 6c391168..00000000 --- a/tests/cxx/unit_tests/ghostfragment/drivers/engine.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include "hydrocarbon/hydrocarbon.h" -// #include -// #include -// #include -// #include - -// using namespace ghostfragment; -// using namespace testing; - -// using system_type = chemist::ChemicalSystem; -// using pair_type = std::pair; -// using input_type = std::vector; -// using energy_type = simde::Energy; - -// namespace { - -// system_type methane(hydrocarbon(1)); -// system_type ethane(hydrocarbon(2)); -// system_type propane(hydrocarbon(3)); - -// auto make_lambda() { -// return pluginplay::make_lambda([=](const auto& pair_in) { -// if(pair_in == methane) -// return 1.1; -// else if(pair_in == ethane) -// return -2.2; -// else if(pair_in == propane) -// return 3.3; -// else -// return 100.0; -// }); -// } - -// } // namespace - -// TEST_CASE("Engine") { -// SECTION("Empty System") { -// input_type input; -// float test = engine(input, make_lambda()); - -// float corr = 0.0; - -// REQUIRE(test == Approx(corr)); -// } - -// SECTION("One System") { -// input_type input{{methane, 1.0}}; -// float test = engine(input, make_lambda()); - -// float corr = 1.1; - -// REQUIRE(test == Approx(corr)); -// } - -// SECTION("Two Unique Systems") { -// input_type input{{methane, 1.0}, {ethane, 2.0}}; -// float test = engine(input, make_lambda()); - -// float corr = -3.3; - -// REQUIRE(test == Approx(corr)); -// } - -// SECTION("Two Equivalent Systems") { -// input_type input{{methane, 1.0}, {methane, 2.0}}; -// float test = engine(input, make_lambda()); - -// float corr = 3.3; - -// REQUIRE(test == Approx(corr)); -// } - -// SECTION("Three Unique Systems") { -// input_type input{{methane, 1.0}, {ethane, 2.0}, {propane, 3.0}}; -// float test = engine(input, make_lambda()); - -// float corr = 6.6; - -// REQUIRE(test == Approx(corr)); -// } - -// SECTION("Three Systems with One Pair") { -// input_type input{{methane, 1.0}, {methane, 2.0}, {propane, 3.0}}; -// float test = engine(input, make_lambda()); - -// float corr = 13.2; - -// REQUIRE(test == Approx(corr)); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/drivers/fragment.cpp b/tests/cxx/unit_tests/ghostfragment/drivers/fragment.cpp index e24fa945..fb0ef592 100644 --- a/tests/cxx/unit_tests/ghostfragment/drivers/fragment.cpp +++ b/tests/cxx/unit_tests/ghostfragment/drivers/fragment.cpp @@ -16,6 +16,7 @@ #include "../test_ghostfragment.hpp" #include +#include #include #include using namespace ghostfragment; @@ -23,6 +24,7 @@ using namespace testing; using frags_pt = pt::FragmentedNuclei; using graph_pt = pt::NuclearGraph; +using intersection_pt = pt::Intersections; using graph2frags_pt = pt::NuclearGraphToFragments; using broken_bonds_pt = pt::BrokenBonds; using cap_pt = pt::CappedFragments; @@ -50,6 +52,13 @@ auto make_g2frag_module(const graph_type& g, const frags_type& rv) { }); } +auto make_intersection_module(const frags_type& frags) { + return pluginplay::make_lambda([=](auto&& frags_in) { + REQUIRE(frags_in == frags); + return frags; + }); +} + auto make_bond_module(const frags_type& frags, const graph_type& conns, const broken_bonds_type& broken_bonds) { return pluginplay::make_lambda( @@ -84,6 +93,7 @@ TEST_CASE("Fragment Driver") { // Factor out so change_submod fits on one line const auto g2f_key = "Molecular graph to fragments"; + const auto int_key = "Intersection finder"; const auto bond_key = "Find broken bonds"; const auto cap_key = "Cap broken bonds"; @@ -96,6 +106,7 @@ TEST_CASE("Fragment Driver") { mod.change_submod("Molecular graph", make_graph_module(system, graph)); mod.change_submod(g2f_key, make_g2frag_module(graph, corr)); + mod.change_submod(int_key, make_intersection_module(corr)); mod.change_submod(bond_key, make_bond_module(corr, graph, bonds)); mod.change_submod(cap_key, make_cap_module(corr, bonds)); const auto& rv = mod.run_as(system); @@ -113,6 +124,7 @@ TEST_CASE("Fragment Driver") { mod.change_submod("Molecular graph", make_graph_module(system, graph)); mod.change_submod(g2f_key, make_g2frag_module(graph, corr)); + mod.change_submod(int_key, make_intersection_module(corr)); mod.change_submod(bond_key, make_bond_module(corr, graph, bonds)); mod.change_submod(cap_key, make_cap_module(corr, bonds)); const auto& rv = mod.run_as(system); @@ -129,6 +141,7 @@ TEST_CASE("Fragment Driver") { mod.change_submod("Molecular graph", make_graph_module(system, graph)); mod.change_submod(g2f_key, make_g2frag_module(graph, corr)); + mod.change_submod(int_key, make_intersection_module(corr)); mod.change_submod(bond_key, make_bond_module(corr, graph, bonds)); mod.change_submod(cap_key, make_cap_module(corr, bonds)); const auto& rv = mod.run_as(system); @@ -148,6 +161,7 @@ TEST_CASE("Fragment Driver") { mod.change_submod("Molecular graph", make_graph_module(system, graph)); mod.change_submod(g2f_key, make_g2frag_module(graph, corr)); + mod.change_submod(int_key, make_intersection_module(corr)); mod.change_submod(bond_key, make_bond_module(corr, graph, bonds)); mod.change_submod(cap_key, make_cap_module(corr, bonds)); const auto& rv = mod.run_as(system); diff --git a/tests/cxx/unit_tests/ghostfragment/drivers/fragment_based_method.cpp b/tests/cxx/unit_tests/ghostfragment/drivers/fragment_based_method.cpp index 1bb5eba6..f2810f4d 100644 --- a/tests/cxx/unit_tests/ghostfragment/drivers/fragment_based_method.cpp +++ b/tests/cxx/unit_tests/ghostfragment/drivers/fragment_based_method.cpp @@ -14,127 +14,97 @@ * limitations under the License. */ -// #include "../test_ghostfragment.hpp" -// #include +#include "../test_ghostfragment.hpp" +#include +#include +#include -// /* Testing Strategy: -// * -// * This tests the main driver for GhostFragment. The main driver dispatches -// * to four submodules which respectively: fragment, make n-mers, make the -// * expression, and finally run the calculations. We assume those submodules -// * are independently tested and known to work. Thus for the purposes of this -// * test we need to make sure the driver calls those submodules with the -// * correct inputs, and properly handles the results. To that end we create -// * four lambda modules: -// * -// * - frag_mod checks that the inputs to the FragmentBasedMethod driver are -// * forwarded to it correctly and then returns a set of fragments -// * - nmer_mod makes sure it's given the set of fragments from frag_mod and -// then -// * returns a set of n-mers -// * - expr_mod checks that it's given set of n-mers from nmer_mod and then -// * creates an expression which depends on the number of fragments and the -// * value of n -// * - egy_mod checks that its given one of the systems expr_mod makes and then -// * computes a double based on the index of that system -// * -// * For a system with n fragments truncated at order m the energy computed by -// * the driver (using the facade modules) should be: -// * -// * E = -m \sum_{i=1}^n i -// * = -m n(n + 1)/2 -// * -// * The driver module has one parameter, the truncation order of the MBE. By -// * looping over truncation orders we test that it is picked up correctly. -// */ +/* Testing Strategy: + * + * This tests the main driver for GhostFragment. The main driver dispatches + * to four submodules which respectively: fragment, compute weights, apply + * basis sets, and finally run the calculations. We assume those submodules + * are independently tested and known to work. Thus for the purposes of this + * test we need to make sure the driver calls those submodules with the + * correct inputs, and properly handles the results. This is easiest if we only + * have one fragment, which we also just assume is a water molecule. + * + * To that end we create four lambda modules: + * + * - frag_mod checks that the inputs to the FragmentBasedMethod driver are + * forwarded to it correctly and then returns a set of fragments + * - weight_mod checks that it was passed the fragments from frag_mod, then + * returns the weights. + * - basis_mod just returns a basis + * - egy_mod checks that its given one of the systems expr_mod makes and then + * computes a double based on the index of that system + * + * For a system with n fragments truncated at order m the energy computed by + + */ + +using namespace ghostfragment; +using namespace testing; -// using namespace ghostfragment; -// using namespace testing; +using my_pt = simde::TotalEnergy; +using ao_energy_pt = simde::AOEnergy; +using frag_sys_pt = pt::FragmentedChemicalSystem; +using frag_sys_traits = pt::FragmentedChemicalSystemTraits; +using chemical_system_type = typename frag_sys_traits::system_type; +using frag_sys_type = typename frag_sys_traits::result_type; +using frag_mol_type = typename frag_sys_type::fragmented_molecule_type; +using basis_set_pt = simde::MolecularBasisSet; +using basis_set_type = chemist::basis_set::AOBasisSetD; +using weights_pt = pt::FragmentWeights; -// using my_pt = simde::AOEnergy; -// using frag_sys_pt = pt::FragmentedSystem; -// using nmer_sys_pt = pt::NMerSystem; -// using expression_pt = pt::Expression; +// Checks that we pass in the correct system, returns a set of fragments +auto frag_mod(const chemical_system_type& sys, const frag_sys_type& frags) { + return pluginplay::make_lambda([=](auto&& sys_in) { + REQUIRE(sys == sys_in); + return frags; + }); +} -// // Checks that we pass in the correct system/AO pair, returns a set of -// fragments auto frag_mod(std::size_t n_waters) { -// return pluginplay::make_lambda([=](auto&& mol_in, -// auto&& aos_in) { -// simde::type::chemical_system s(testing::water(n_waters), 10 * -// n_waters); REQUIRE(mol_in == s); REQUIRE(aos_in == -// testing::sto3g(s.molecule())); return -// testing::fragmented_water_system(n_waters); -// }); -// } +// Checks we pass in fragments, returns a vector filled with 1s +auto weight_mod(const frag_sys_type& frags) { + return pluginplay::make_lambda([=](auto&& frags_in) { + REQUIRE(frags == frags_in); + return std::vector(frags.size(), 2.0); + }); +} -// auto nmer_mod(std::size_t n_waters, std::size_t m) { -// return pluginplay::make_lambda( -// [=](auto&& frags_in, auto&& m_in) { -// REQUIRE(frags_in == testing::fragmented_water_system(n_waters)); -// REQUIRE(m_in == m); -// return testing::water_nmer_system(n_waters, m); -// }); -// } +// Checks it was passed one of the frags +auto basis_mod(const chemical_system_type& sys, const basis_set_type& aos) { + return pluginplay::make_lambda([=](auto&& sys_in) { + REQUIRE(sys_in == sys.molecule()); + return aos; + }); +} -// auto expr_mod(std::size_t n_waters, std::size_t m) { -// using ghostfragment::equation::make_term; -// return pluginplay::make_lambda([=](auto&& nmer_in) { -// REQUIRE(nmer_in == testing::water_nmer_system(n_waters, m)); -// ghostfragment::pt::ExpressionTraits::result_type rv; -// auto frags = testing::water_nmer_system(n_waters, 1); -// for(std::size_t i = 0; i < n_waters; ++i) { -// const auto& w = frags.nmer(i); -// rv.add_term(make_term(w, frags.ao_basis_set(w), 10, m * 1.0)); -// } -// return rv; -// }); -// } +auto energy_mod(const chemical_system_type& sys, const basis_set_type& aos) { + return pluginplay::make_lambda( + [=](auto&& aos_in, auto&& sys_in) { + REQUIRE(sys == sys_in); + REQUIRE(aos == aos_in); + return -75.123456; // Just make up an energy... + }); +} -// auto egy_mod(std::size_t n_waters, std::size_t m) { -// using ghostfragment::equation::make_term; -// return pluginplay::make_lambda([=](auto&& aos_in, auto&& mol_in) { -// auto frags = testing::water_nmer_system(n_waters, 1); -// double egy = 0.0; -// for(std::size_t i = 0; i < n_waters; ++i) { -// const auto& w = frags.nmer(i); -// auto water = make_term(w, frags.ao_basis_set(w), 10, m * 1.0); -// if(water.molecule() == mol_in.molecule()) { -// REQUIRE(aos_in.basis_set() == water.ao_basis_set()); -// egy = (i + 1) * -1.0; -// } -// } -// REQUIRE(egy != 0.0); -// return egy; -// }); -// } +TEST_CASE("FragmentBasedMethod") { + auto mm = initialize(); + auto& mod = mm.at("Fragment Based Method"); -// TEST_CASE("FragmentBasedMethod") { -// auto mm = initialize(); -// auto& mod = mm.at("Fragment Based Method"); + chemical_system_type water(testing::water(1)); + frag_mol_type frag_mol(testing::water_fragmented_nuclei(1), 0, 1); + frag_sys_type frags(std::move(frag_mol)); + basis_set_type aos; -// // = -m n(n + 1)/2 -// for(std::size_t n = 1; n <= 4; ++n) { -// for(std::size_t m = 1; m <= n; ++m) { -// std::string name = -// std::to_string(n) + " water(s) " + std::to_string(m) + "body"; -// SECTION(name) { -// const std::size_t n_waters = n; -// auto mol = testing::water(n_waters); -// simde::type::chemical_system sys(mol, n_waters * 10); -// auto aos = -// chemist::orbital_space::AOSpace(testing::sto3g(mol)); + mod.change_submod("Subsystem former", frag_mod(water, frags)); + mod.change_submod("Weighter", weight_mod(frags)); + mod.change_submod("Apply basis set", basis_mod(water, aos)); + mod.change_submod("Energy method", energy_mod(water, aos)); -// mod.change_submod("Fragment Maker", frag_mod(n_waters)); -// mod.change_submod("N-Mer Maker", nmer_mod(n_waters, m)); -// mod.change_submod("Expression generator", -// expr_mod(n_waters, m)); -// mod.change_submod("energy method", egy_mod(n_waters, m)); -// unsigned int mu(m); -// mod.change_input("GMBE truncation order", mu); -// auto [e] = mod.run_as(aos, sys); -// double corr = -double(m * n * n + m * n) / 2.0; -// REQUIRE(e == corr); -// } -// } -// } -// } + auto energy = mod.run_as(water); + auto corr = 2.0 * -75.123456; + REQUIRE_THAT(energy, Catch::Matchers::WithinRel(corr, 0.000001)); +} diff --git a/tests/cxx/unit_tests/ghostfragment/drivers/input_queue.cpp b/tests/cxx/unit_tests/ghostfragment/drivers/input_queue.cpp deleted file mode 100644 index d96d9fff..00000000 --- a/tests/cxx/unit_tests/ghostfragment/drivers/input_queue.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include "hydrocarbon/hydrocarbon.h" -// #include -// #include -// #include - -// using namespace ghostfragment; -// using namespace testing; - -// using my_pt = pt::InputQueue; -// using frags_pt = pt::FragmentedNuclei; -// using mol_pt = pt::FragmentedMolecule; - -// using system_type = chemist::ChemicalSystem; -// using frags_type = chemist::FragmentedNuclei; -// using fragmol_type = chemist::FragmentedMolecule; -// using mol_type = chemist::Molecule; -// using pair_type = std::pair; -// using return_type = std::vector; - -// namespace { - -// auto make_frag_module(const system_type& mol, const frags_type& rv) { -// return pluginplay::make_lambda([=](auto&& mol_in) { -// REQUIRE(mol_in == mol); -// return rv; -// }); -// } - -// auto make_mol_module(const frags_type& mol_1, const frags_type& mol_2, -// const fragmol_type& rv_1, const fragmol_type& rv_2) { -// return pluginplay::make_lambda([=](auto&& mol_in) { -// // Conditional so that lambda function returns correct rv for both -// calls -// // in the InputQueue module -// if(mol_in == mol_1) { -// return rv_1; -// } -// else { -// return rv_2; -// } -// }); -// } - -// } // namespace - -// /* Testing strategy: -// * -// * InputQueue is mainly a driver. Aside from the finding of intersections, -// * the rest of its behavior is determined by submodules. We thus employ -// lambda -// * functions as surrogates for these modules to test InputQueue itself. -// */ - -// TEST_CASE("Input Queue") { -// auto mm = initialize(); -// auto& mod = mm.at("Input Queue"); - -// SECTION("Empty System") { -// system_type system; -// return_type corr; - -// mod.change_submod("Fragmentation", make_frag_module(system, -// frags_type())); mod.change_submod("FragtoMol", -// make_mol_module(frags_type(), frags_type(), fragmol_type(), -// fragmol_type())); REQUIRE_THROWS_AS(mod.run_as(system), -// std::runtime_error); -// } - -// SECTION("Single Atom") { -// chemist::Molecule mol; -// mol.push_back(chemist::Atom("H", 1, 1837.289, 0, 0, 0)); -// system_type system(mol); - -// frags_type frags(mol.nuclei()); -// frags.add_fragment({0}); - -// fragmol_type fragmol(frags); - -// return_type corr; -// corr.push_back(pair_type(system, 1)); - -// mod.change_submod("Fragmentation", make_frag_module(system, frags)); -// mod.change_submod("FragtoMol", make_mol_module(frags, frags, fragmol, -// fragmol)); const auto& rv = mod.run_as(system); REQUIRE(corr -// == rv); -// } - -// SECTION("Methane Single Fragment") { -// auto methane = hydrocarbon(1); -// system_type system(methane); -// frags_type frags(methane.nuclei()); -// frags.add_fragment({0, 1, 2, 3, 4}); - -// fragmol_type fragmol(frags); - -// return_type corr; -// corr.push_back(pair_type(system, 1)); - -// mod.change_submod("Fragmentation", make_frag_module(system, frags)); -// mod.change_submod("FragtoMol", make_mol_module(frags, frags, fragmol, -// fragmol)); const auto& rv = mod.run_as(system); REQUIRE(corr -// == rv); -// } - -// SECTION("Two Disjoint Fragments") { -// chemist::Molecule mol; -// mol.push_back(chemist::Atom("H", 1, 1837.289, 0, 0, 0)); -// mol.push_back(chemist::Atom("H", 1, 1837.289, 1, 1, 1)); -// system_type system(mol); - -// frags_type frags(mol.nuclei()); -// frags.add_fragment({0}); -// frags.add_fragment({1}); - -// fragmol_type fragmol(frags); - -// return_type corr; -// chemist::Molecule mol_1; -// chemist::Molecule mol_2; -// mol_1.push_back(chemist::Atom("H", 1, 1837.289, 0, 0, 0)); -// mol_2.push_back(chemist::Atom("H", 1, 1837.289, 1, 1, 1)); -// corr.push_back(pair_type(system_type(mol_1), 1)); -// corr.push_back(pair_type(system_type(mol_2), 1)); - -// mod.change_submod("Fragmentation", make_frag_module(system, frags)); -// mod.change_submod("FragtoMol", make_mol_module(frags, frags, fragmol, -// fragmol)); const auto& rv = mod.run_as(system); REQUIRE(corr -// == rv); -// } - -// SECTION("Two Nondisjoint Fragments") { -// chemist::Molecule mol; -// mol.push_back(chemist::Atom("H", 1, 1837.289, 0, 0, 0)); -// mol.push_back(chemist::Atom("H", 1, 1837.289, 1, 1, 1)); -// mol.push_back(chemist::Atom("H", 1, 1837.289, 2, 2, 2)); -// system_type system(mol); - -// frags_type frags_1(mol.nuclei()); -// frags_1.add_fragment({0, 1}); -// frags_1.add_fragment({1, 2}); - -// frags_type frags_2(mol.nuclei()); -// frags_2.add_fragment({0, 1}); -// frags_2.add_fragment({1, 2}); -// frags_2.add_fragment({1}); - -// fragmol_type fragmol_1(frags_1); -// fragmol_type fragmol_2(frags_2); - -// return_type corr; -// chemist::Molecule mol_1; -// chemist::Molecule mol_2; -// chemist::Molecule mol_3; -// mol_1.push_back(chemist::Atom("H", 1, 1837.289, 0, 0, 0)); -// mol_1.push_back(chemist::Atom("H", 1, 1837.289, 1, 1, 1)); -// mol_2.push_back(chemist::Atom("H", 1, 1837.289, 1, 1, 1)); -// mol_2.push_back(chemist::Atom("H", 1, 1837.289, 2, 2, 2)); -// mol_3.push_back(chemist::Atom("H", 1, 1837.289, 1, 1, 1)); -// corr.push_back(pair_type(system_type(mol_1), 1)); -// corr.push_back(pair_type(system_type(mol_3), -1)); -// corr.push_back(pair_type(system_type(mol_2), 1)); - -// mod.change_submod("Fragmentation", make_frag_module(system, -// frags_1)); mod.change_submod("FragtoMol", make_mol_module(frags_1, -// frags_2, fragmol_1, fragmol_2)); const auto& rv = -// mod.run_as(system); REQUIRE(corr == rv); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/drivers/neutral.cpp b/tests/cxx/unit_tests/ghostfragment/drivers/neutral.cpp deleted file mode 100644 index 7ef98763..00000000 --- a/tests/cxx/unit_tests/ghostfragment/drivers/neutral.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include -// #include -// #include -// #include - -// using namespace ghostfragment; -// using namespace testing; - -// using my_pt = pt::ChargeMultiplicityAssigner; -// using frag_type = chemist::FragmentedNuclei; -// using cap_type = std::vector; -// using atom_type = chemist::Atom; -// using mol_type = chemist::Molecule; - -// using charge_result_type = std::vector; -// using mult_result_type = std::vector; - -// TEST_CASE("Neutral Singlet") { -// auto mm = initialize(); -// auto& mod = mm.at("Neutral Singlet"); - -// SECTION("Empty Molecule") { -// mol_type mol; -// frag_type frags(mol.nuclei()); -// cap_type caps; - -// charge_result_type charge_corr; -// mult_result_type mult_corr; - -// const auto& [charge_test, mult_test] = mod.run_as(frags, caps, -// mol); - -// REQUIRE(charge_test == charge_corr); -// REQUIRE(mult_test == mult_corr); -// } - -// SECTION("Two fragments") { -// atom_type C1("C", 6ul, 12.0, 0.0, 0.0, 0.0); -// atom_type C2("C", 6ul, 12.0, 1.0, 0.0, 0.0); -// atom_type C3("C", 6ul, 12.0, 2.0, 0.0, 0.0); -// mol_type mol({C1, C2, C3}); -// frag_type frags(mol.nuclei()); -// frags.add_fragment({0, 1}); -// frags.add_fragment({1, 2}); - -// SECTION("No caps") { -// cap_type caps(frags.size(), chemist::CapSet{}); - -// charge_result_type charge_corr(frags.size(), 0); -// mult_result_type mult_corr(frags.size(), 1); - -// const auto& [charge_test, mult_test] = mod.run_as(frags, -// caps, mol); - -// REQUIRE(charge_test == charge_corr); -// REQUIRE(mult_test == mult_corr); -// } - -// SECTION("Two caps") { -// atom_type Cap1("C", 6ul, 12.0, 1.5, 0.0, 0.0); -// atom_type Cap2("C", 6ul, 12.0, 0.5, 0.0, 0.0); - -// cap_type caps; - -// chemist::CapSet cap_set1; -// cap_set1.add_cap(1, 2, Cap1); -// caps.push_back(cap_set1); - -// chemist::CapSet cap_set2; -// cap_set2.add_cap(1, 0, Cap2); -// caps.push_back(cap_set2); - -// charge_result_type charge_corr(frags.size(), 0); -// mult_result_type mult_corr(frags.size(), 1); - -// const auto& [charge_test, mult_test] = mod.run_as(frags, -// caps, mol); - -// REQUIRE(charge_test == charge_corr); -// REQUIRE(mult_test == mult_corr); -// } -// } - -// SECTION("Odd number of elections") { -// atom_type H1("H", 1ul, 2.0, -1.0, 0.0, 0.0); -// atom_type C1("C", 6ul, 12.0, 0.0, 0.0, 0.0); -// atom_type C2("C", 6ul, 12.0, 1.0, 0.0, 0.0); -// atom_type C3("C", 6ul, 12.0, 2.0, 0.0, 0.0); -// atom_type H2("H", 1ul, 2.0, 3.0, 0.0, 0.0); -// mol_type mol({H1, C1, C2, C3, H2}); -// frag_type frags(mol.nuclei()); -// frags.add_fragment({0, 1, 2}); -// frags.add_fragment({2, 3, 4}); - -// SECTION("No caps") { -// cap_type caps; -// for(auto i = 0; i < frags.size(); i++) { -// chemist::CapSet cap_set; -// chemist::Cap c; -// cap_set.push_back(c); -// caps.push_back(cap_set); -// } - -// REQUIRE_THROWS_AS(mod.run_as(frags, caps, mol), -// std::runtime_error); -// } - -// SECTION("Two caps") { -// atom_type Cap1("C", 6ul, 12.0, 1.5, 0.0, 0.0); -// atom_type Cap2("C", 6ul, 12.0, 0.5, 0.0, 0.0); - -// cap_type caps; - -// chemist::CapSet cap_set1; -// cap_set1.add_cap(2, 3, Cap1); -// caps.push_back(cap_set1); - -// chemist::CapSet cap_set2; -// cap_set2.add_cap(2, 1, Cap2); -// caps.push_back(cap_set2); - -// REQUIRE_THROWS_AS(mod.run_as(frags, caps, mol), -// std::runtime_error); -// } -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/drivers/nmer_system.cpp b/tests/cxx/unit_tests/ghostfragment/drivers/nmer_system.cpp deleted file mode 100644 index 47179fbd..00000000 --- a/tests/cxx/unit_tests/ghostfragment/drivers/nmer_system.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" - -// using namespace ghostfragment; -// using namespace testing; - -// using nmer_screener_pt = pt::NMerScreener; -// using mod_pt = pt::NMerSystem; -// using traits_type = pt::NMerSystemTraits; - -// TEST_CASE("NMerSystem Module") { -// auto mm = initialize(); -// auto mod = mm.at("NMerSystem Driver"); - -// auto monomer = fragmented_water_system(1); -// auto nmers = make_nmers(monomer.frags(), 1); - -// auto f2n = pluginplay::make_lambda( -// [=](auto&& frags_in, auto&& n_in) { -// for(const auto& [frag, cap] : frags_in) -// REQUIRE(cap == monomer.caps(frag)); -// REQUIRE(n_in == 1); -// return nmers; -// }); - -// traits_type::result_type corr(monomer, nmers); - -// mod.change_submod("NMer Screener", f2n); - -// const auto& [nmer_system] = mod.run_as(monomer, 1u); -// REQUIRE(nmer_system == corr); - -// REQUIRE_THROWS_AS(mod.run_as(monomer, 2u), std::runtime_error); -// } diff --git a/tests/cxx/unit_tests/ghostfragment/equation/detail_/expression_pimpl.cpp b/tests/cxx/unit_tests/ghostfragment/equation/detail_/expression_pimpl.cpp deleted file mode 100644 index 6a371277..00000000 --- a/tests/cxx/unit_tests/ghostfragment/equation/detail_/expression_pimpl.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// using namespace ghostfragment::equation::detail_; -// using ghostfragment::equation::make_term; - -// TEST_CASE("ExpressionPIMPL") { -// auto water3 = testing::water_nmer_system(3, 2); -// auto nmer = water3.nmer(0); -// auto aos = water3.ao_basis_set(nmer); - -// using term_type = ExpressionPIMPL::term_type; -// auto t = make_term(nmer, aos, 1, 1.23); - -// ExpressionPIMPL defaulted; -// ExpressionPIMPL p; -// p.m_terms.push_back(t); - -// SECTION("Clone") { -// auto defaulted_copy = defaulted.clone(); -// REQUIRE(*defaulted_copy == ExpressionPIMPL()); - -// auto p_copy = p.clone(); -// REQUIRE(*p_copy == p); -// } - -// SECTION("operator==") { -// REQUIRE(defaulted == ExpressionPIMPL()); - -// ExpressionPIMPL p_copy; -// p_copy.m_terms.push_back(t); -// REQUIRE(p == p_copy); - -// // Different terms -// auto t2 = make_term(nmer, aos, 1, 3.14); -// ExpressionPIMPL p2; -// p2.m_terms.push_back(t2); -// REQUIRE_FALSE(p == p2); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/equation/detail_/term_pimpl.cpp b/tests/cxx/unit_tests/ghostfragment/equation/detail_/term_pimpl.cpp deleted file mode 100644 index 25cf6be8..00000000 --- a/tests/cxx/unit_tests/ghostfragment/equation/detail_/term_pimpl.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// using namespace ghostfragment::equation::detail_; - -// TEST_CASE("TermPIMPL") { -// auto water3 = testing::water_nmer_system(3, 2); -// TermPIMPL::molecule_type corr_mol0, corr_mol1; -// const auto super_sys = testing::water(3); -// corr_mol0.push_back(super_sys[0]); -// corr_mol0.push_back(super_sys[1]); -// corr_mol0.push_back(super_sys[2]); -// corr_mol0.push_back(super_sys[3]); -// corr_mol0.push_back(super_sys[4]); -// corr_mol0.push_back(super_sys[5]); -// auto corr_aos0 = testing::sto3g(corr_mol0); - -// corr_mol1.push_back(super_sys[0]); -// corr_mol1.push_back(super_sys[1]); -// corr_mol1.push_back(super_sys[2]); -// corr_mol1.push_back(super_sys[6]); -// corr_mol1.push_back(super_sys[7]); -// corr_mol1.push_back(super_sys[8]); -// auto corr_aos1 = testing::sto3g(corr_mol1); - -// auto nmer0 = water3.nmer(0); -// auto nmer1 = water3.nmer(1); - -// auto aos0 = water3.ao_basis_set(nmer0); -// auto aos1 = water3.ao_basis_set(nmer1); - -// TermPIMPL::coefficient_type c0 = 1.2, c1 = 2.3; -// TermPIMPL::size_type ne0 = 0, ne1 = 2; -// TermPIMPL p(nmer0, aos0, ne0, c0); -// TermPIMPL diff_nmer(nmer1, aos0, ne0, c0); -// TermPIMPL diff_aos(nmer0, aos1, ne0, c0); -// TermPIMPL diff_nes(nmer0, aos0, ne1, c0); -// TermPIMPL diff_cs(nmer0, aos0, ne0, c1); - -// SECTION("Ctor") { -// REQUIRE(p.m_nmer == nmer0); -// REQUIRE(p.m_aos == aos0); -// REQUIRE(p.m_n_electrons == ne0); -// REQUIRE(p.m_coef == c0); - -// REQUIRE(diff_nmer.m_nmer == nmer1); -// REQUIRE(diff_nmer.m_aos == aos0); -// REQUIRE(diff_nmer.m_n_electrons == ne0); -// REQUIRE(diff_nmer.m_coef == c0); - -// REQUIRE(diff_aos.m_nmer == nmer0); -// REQUIRE(diff_aos.m_aos == aos1); -// REQUIRE(diff_aos.m_n_electrons == ne0); -// REQUIRE(diff_aos.m_coef == c0); - -// REQUIRE(diff_nes.m_nmer == nmer0); -// REQUIRE(diff_nes.m_aos == aos0); -// REQUIRE(diff_nes.m_n_electrons == ne1); -// REQUIRE(diff_nes.m_coef == c0); - -// REQUIRE(diff_cs.m_nmer == nmer0); -// REQUIRE(diff_cs.m_aos == aos0); -// REQUIRE(diff_cs.m_n_electrons == ne0); -// REQUIRE(diff_cs.m_coef == c1); -// } - -// SECTION("ao_basis_set()") { -// REQUIRE(p.ao_basis_set() == corr_aos0); -// REQUIRE(diff_nmer.ao_basis_set() == corr_aos0); -// REQUIRE(diff_aos.ao_basis_set() == corr_aos1); -// REQUIRE(diff_nes.ao_basis_set() == corr_aos0); -// REQUIRE(diff_cs.ao_basis_set() == corr_aos0); -// } - -// SECTION("molecule()") { -// REQUIRE(p.molecule() == corr_mol0); -// REQUIRE(diff_nmer.molecule() == corr_mol1); -// REQUIRE(diff_aos.molecule() == corr_mol0); -// REQUIRE(diff_nes.molecule() == corr_mol0); -// REQUIRE(diff_cs.molecule() == corr_mol0); -// } - -// SECTION("clone") { -// auto p_copy = p.clone(); -// REQUIRE(*p_copy == p); - -// auto diff_nmer_copy = diff_nmer.clone(); -// REQUIRE(*diff_nmer_copy == diff_nmer); - -// auto diff_aos_copy = diff_aos.clone(); -// REQUIRE(*diff_aos_copy == diff_aos); - -// auto diff_nes_copy = diff_nes.clone(); -// REQUIRE(*diff_nes_copy == diff_nes); - -// auto diff_cs_copy = diff_cs.clone(); -// REQUIRE(*diff_cs_copy == diff_cs); -// } - -// SECTION("operator==") { -// REQUIRE(p == TermPIMPL(nmer0, aos0, ne0, c0)); -// REQUIRE_FALSE(p == diff_nmer); -// REQUIRE_FALSE(p == diff_aos); -// REQUIRE_FALSE(p == diff_nes); -// REQUIRE_FALSE(p == diff_cs); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/equation/expression.cpp b/tests/cxx/unit_tests/ghostfragment/equation/expression.cpp deleted file mode 100644 index d19722e5..00000000 --- a/tests/cxx/unit_tests/ghostfragment/equation/expression.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// using namespace ghostfragment::equation; - -// TEST_CASE("Expression") { -// auto water3 = testing::water_nmer_system(3, 2); -// auto nmer = water3.nmer(0); -// auto aos = water3.ao_basis_set(nmer); - -// using term_type = Expression::term_type; -// term_type t0 = make_term(nmer, aos, 1, 1.23); -// term_type t1 = make_term(nmer, aos, 1, 3.14); - -// Expression defaulted; -// Expression i0, i1; -// i0.add_term(t0); -// i1.add_term(t1); - -// SECTION("CTor") { -// SECTION("default") { -// REQUIRE(defaulted.empty()); -// REQUIRE(defaulted.size() == 0); -// } - -// SECTION("copy") { -// Expression defaulted_copy(defaulted); -// REQUIRE(defaulted_copy == defaulted); - -// Expression i0_copy(i0); -// REQUIRE(i0_copy == i0); - -// Expression i1_copy(i1); -// REQUIRE(i1_copy == i1); -// } - -// SECTION("move") { -// Expression defaulted_copy(defaulted); -// Expression defaulted_move(std::move(defaulted)); -// REQUIRE(defaulted_copy == defaulted_move); - -// Expression i0_copy(i0); -// Expression i0_move(std::move(i0)); -// REQUIRE(i0_copy == i0_move); - -// Expression i1_copy(i1); -// Expression i1_move(std::move(i1)); -// REQUIRE(i1_copy == i1_move); -// } - -// SECTION("copy assignment") { -// Expression defaulted_copy; -// auto pdefaulted_copy = &(defaulted_copy = defaulted); -// REQUIRE(pdefaulted_copy == &defaulted_copy); -// REQUIRE(defaulted_copy == defaulted); - -// Expression i0_copy; -// auto pi0_copy = &(i0_copy = i0); -// REQUIRE(pi0_copy == &i0_copy); -// REQUIRE(i0_copy == i0); - -// Expression i1_copy; -// auto pi1_copy = &(i1_copy = i1); -// REQUIRE(pi1_copy == &i1_copy); -// REQUIRE(i1_copy == i1); -// } - -// SECTION("move assignment") { -// Expression defaulted_copy(defaulted); -// Expression defaulted_move; -// auto pdefaulted_move = &(defaulted_move = std::move(defaulted)); -// REQUIRE(pdefaulted_move == &defaulted_move); -// REQUIRE(defaulted_copy == defaulted_move); - -// Expression i0_copy(i0); -// Expression i0_move; -// auto pi0_move = &(i0_move = std::move(i0)); -// REQUIRE(pi0_move == &i0_move); -// REQUIRE(i0_copy == i0_move); - -// Expression i1_copy(i1); -// Expression i1_move; -// auto pi1_move = &(i1_move = std::move(i1)); -// REQUIRE(pi1_move == &i1_move); -// REQUIRE(i1_copy == i1_move); -// } -// } - -// SECTION("size") { -// REQUIRE(defaulted.size() == 0); -// REQUIRE(i0.size() == 1); -// REQUIRE(i1.size() == 1); -// } - -// SECTION("at") { -// REQUIRE_THROWS_AS(defaulted.at(0), std::out_of_range); - -// REQUIRE(i0.at(0) == t0); -// REQUIRE_THROWS_AS(i0.at(1), std::out_of_range); - -// REQUIRE(i1.at(0) == t1); -// REQUIRE_THROWS_AS(i1.at(1), std::out_of_range); -// } - -// SECTION("add_term(term)") { -// defaulted.add_term(t0); -// REQUIRE(defaulted == i0); - -// i0.add_term(t1); -// REQUIRE(i0.size() == 2); -// REQUIRE(i0.at(0) == t0); -// REQUIRE(i0.at(1) == t1); -// } - -// SECTION("empty") { -// REQUIRE(defaulted.empty()); -// REQUIRE_FALSE(i0.empty()); -// REQUIRE_FALSE(i1.empty()); -// } - -// SECTION("swap") { -// Expression i0_copy(i0); -// Expression i1_copy(i1); - -// i0.swap(i1); -// REQUIRE(i0 == i1_copy); -// REQUIRE(i1 == i0_copy); -// } - -// SECTION("operator==/operator!=") { -// // defaulted compared to defaulted -// REQUIRE(defaulted == Expression()); -// REQUIRE_FALSE(defaulted != Expression()); - -// // defaulted compared to non-default -// REQUIRE(defaulted != i0); -// REQUIRE_FALSE(defaulted == i0); - -// // non-defaulted to non-defaulted with same state -// Expression i0_2; -// i0_2.add_term(t0); -// REQUIRE(i0 == i0_2); -// REQUIRE_FALSE(i0 != i0_2); - -// // non-defaulted to non-defaulted with different state -// REQUIRE(i0 != i1); -// REQUIRE_FALSE(i0 == i1); - -// // Order matters -// i0.add_term(t1); -// i1.add_term(t0); -// REQUIRE(i0 != i1); -// REQUIRE_FALSE(i0 == i1); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/equation/term.cpp b/tests/cxx/unit_tests/ghostfragment/equation/term.cpp deleted file mode 100644 index 047e055e..00000000 --- a/tests/cxx/unit_tests/ghostfragment/equation/term.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// using namespace ghostfragment::equation; - -// TEST_CASE("Term") { -// auto water3 = testing::water_nmer_system(3, 2); -// const auto super_sys = testing::water(3); -// Term::molecule_type corr_mol; -// corr_mol.push_back(super_sys[0]); -// corr_mol.push_back(super_sys[1]); -// corr_mol.push_back(super_sys[2]); -// corr_mol.push_back(super_sys[3]); -// corr_mol.push_back(super_sys[4]); -// corr_mol.push_back(super_sys[5]); -// auto corr_aos = testing::sto3g(corr_mol); - -// auto nmer0 = water3.nmer(0); -// auto nmer1 = water3.nmer(1); - -// auto aos0 = water3.ao_basis_set(nmer0); -// auto aos1 = water3.ao_basis_set(nmer1); - -// Term::coefficient_type c0 = 1.2, c1 = 2.3; -// Term::size_type ne0 = 1, ne1 = 2; -// Term defaulted; -// Term t = make_term(nmer0, aos0, ne0, c0); - -// SECTION("Ctors") { -// SECTION("Default") { REQUIRE(defaulted.empty()); } - -// SECTION("value") { -// // REQUIRE(t.ao_basis_set() == aos0); -// REQUIRE(t.molecule() == corr_mol); -// REQUIRE(t.n_electrons() == ne0); -// REQUIRE(t.coefficient() == c0); -// } - -// SECTION("copy") { -// Term defaulted_copy(defaulted); -// REQUIRE(defaulted_copy == defaulted); - -// Term t_copy(t); -// REQUIRE(t_copy == t); -// } - -// SECTION("move") { -// Term defaulted_copy(defaulted); -// Term defaulted_move(std::move(defaulted)); -// REQUIRE(defaulted_copy == defaulted_move); - -// Term t_copy(t); -// Term t_move(std::move(t)); -// REQUIRE(t_copy == t_move); -// } - -// SECTION("copy assignment") { -// Term defaulted_copy; -// auto pdefaulted_copy = &(defaulted_copy = defaulted); -// REQUIRE(pdefaulted_copy == &defaulted_copy); -// REQUIRE(defaulted_copy == defaulted); - -// Term t_copy; -// auto pt_copy = &(t_copy = t); -// REQUIRE(pt_copy == &t_copy); -// REQUIRE(t_copy == t); -// } - -// SECTION("move") { -// Term defaulted_copy(defaulted); -// Term defaulted_move; -// auto pdefaulted_move = &(defaulted_move = std::move(defaulted)); -// REQUIRE(pdefaulted_move == &defaulted_move); -// REQUIRE(defaulted_copy == defaulted_move); - -// Term t_copy(t); -// Term t_move; -// auto pt_move = &(t_move = std::move(t)); -// REQUIRE(pt_move == &t_move); -// REQUIRE(t_copy == t_move); -// } -// } - -// SECTION("ao_basis_set") { -// REQUIRE_THROWS_AS(defaulted.ao_basis_set(), std::runtime_error); -// REQUIRE(t.ao_basis_set() == corr_aos); -// } - -// SECTION("molecule") { -// REQUIRE_THROWS_AS(defaulted.molecule(), std::runtime_error); -// REQUIRE(t.molecule() == corr_mol); -// } - -// SECTION("n_electrons") { -// REQUIRE(defaulted.n_electrons() == 0); -// REQUIRE(t.n_electrons() == ne0); -// } - -// SECTION("chemical_system") { -// Term::chemical_system_type corr(t.molecule(), t.n_electrons()); -// REQUIRE(corr == t.chemical_system()); -// } - -// SECTION("coefficient") { -// REQUIRE_THROWS_AS(defaulted.coefficient(), std::runtime_error); -// REQUIRE(t.coefficient() == c0); -// } - -// SECTION("empty") { -// REQUIRE(defaulted.empty()); -// REQUIRE_FALSE(t.empty()); -// } - -// SECTION("swap") { -// Term copy_default(defaulted); -// Term copy_t(t); - -// defaulted.swap(t); -// REQUIRE(t == copy_default); -// REQUIRE(defaulted == copy_t); -// } - -// SECTION("operator==/operator!=") { -// // Default to default -// REQUIRE(defaulted == Term()); -// REQUIRE_FALSE(defaulted != Term()); - -// // Default to non-default -// REQUIRE_FALSE(defaulted == t); -// REQUIRE(defaulted != t); - -// // Has value to Term with same value -// REQUIRE(t == make_term(nmer0, aos0, ne0, c0)); -// REQUIRE_FALSE(t != make_term(nmer0, aos0, ne0, c0)); - -// // Values differ in the n-mer -// auto diff_nmer = make_term(nmer1, aos0, ne0, c0); -// REQUIRE_FALSE(t == diff_nmer); -// REQUIRE(t != diff_nmer); - -// // Values differ in the AOs -// auto diff_aos = make_term(nmer0, aos1, ne0, c0); -// REQUIRE_FALSE(t == diff_aos); -// REQUIRE(t != diff_aos); - -// // Values differ in the number of electrons -// auto diff_nes = make_term(nmer0, aos0, ne1, c0); -// REQUIRE_FALSE(t == diff_nes); -// REQUIRE(t != diff_nes); - -// // Values differ in the coefficient -// auto diff_cs = make_term(nmer0, aos0, ne0, c1); -// REQUIRE_FALSE(t == diff_cs); -// REQUIRE(t != diff_cs); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/expressions/mbe.cpp b/tests/cxx/unit_tests/ghostfragment/expressions/mbe.cpp deleted file mode 100644 index 9e70447a..00000000 --- a/tests/cxx/unit_tests/ghostfragment/expressions/mbe.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// using namespace ghostfragment; -// using namespace ghostfragment::equation; -// using namespace testing; - -// using my_pt = ghostfragment::pt::Expression; - -// TEST_CASE("Many-Body Expansion") { -// auto mm = initialize(); -// auto& mod = mm.at("Many-Body Expansion"); - -// using equation_type = ghostfragment::pt::ExpressionTraits::result_type; - -// SECTION("1-body w/ 1 water") { -// auto waters = water_nmer_system(1, 1); -// const auto& w0 = waters.nmer(0); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 10, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("1-body w/ 2 water") { -// auto waters = water_nmer_system(2, 1); -// const auto& w0 = waters.nmer(0); -// const auto& w1 = waters.nmer(1); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 10, 1.0)); -// corr.add_term(make_term(w1, waters.ao_basis_set(w1), 10, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("2-body w/ 2 water") { -// auto waters = water_nmer_system(2, 2); -// const auto& w0 = waters.nmer(0); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 20, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("1-body w/ 3 water") { -// auto waters = water_nmer_system(3, 1); -// const auto& w0 = waters.nmer(0); -// const auto& w1 = waters.nmer(1); -// const auto& w2 = waters.nmer(2); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 10, 1.0)); -// corr.add_term(make_term(w1, waters.ao_basis_set(w1), 10, 1.0)); -// corr.add_term(make_term(w2, waters.ao_basis_set(w2), 10, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("2-body w/ 3 water") { -// auto waters = water_nmer_system(3, 2); -// const auto& w01 = waters.nmer(0); -// const auto& w02 = waters.nmer(1); -// const auto& w12 = waters.nmer(2); -// auto w0 = w01 ^ w02; -// auto w1 = w01 ^ w12; -// auto w2 = w02 ^ w12; -// auto w0_aos = waters.ao_basis_set(w0.begin(), w0.end()); -// auto w1_aos = waters.ao_basis_set(w1.begin(), w1.end()); -// auto w2_aos = waters.ao_basis_set(w2.begin(), w2.end()); - -// equation_type corr; -// corr.add_term(make_term(w0, w0_aos, 10, -1.0)); -// corr.add_term(make_term(w01, waters.ao_basis_set(w01), 20, 1.0)); -// corr.add_term(make_term(w02, waters.ao_basis_set(w02), 20, 1.0)); -// corr.add_term(make_term(w1, w1_aos, 10, -1.0)); -// corr.add_term(make_term(w12, waters.ao_basis_set(w12), 20, 1.0)); -// corr.add_term(make_term(w2, w2_aos, 10, -1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("3-body w/ 3 water") { -// auto waters = water_nmer_system(3, 3); -// const auto& w0 = waters.nmer(0); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 30, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("1-body w/ 4 water") { -// auto waters = water_nmer_system(4, 1); -// const auto& w0 = waters.nmer(0); -// const auto& w1 = waters.nmer(1); -// const auto& w2 = waters.nmer(2); -// const auto& w3 = waters.nmer(3); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 10, 1.0)); -// corr.add_term(make_term(w1, waters.ao_basis_set(w1), 10, 1.0)); -// corr.add_term(make_term(w2, waters.ao_basis_set(w2), 10, 1.0)); -// corr.add_term(make_term(w3, waters.ao_basis_set(w3), 10, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("2-body w/ 4 water") { -// auto waters = water_nmer_system(4, 2); -// const auto& w01 = waters.nmer(0); -// const auto& w02 = waters.nmer(1); -// const auto& w03 = waters.nmer(2); -// const auto& w12 = waters.nmer(3); -// const auto& w13 = waters.nmer(4); -// const auto& w23 = waters.nmer(5); - -// auto w0 = w01 ^ w02; -// auto w1 = w01 ^ w12; -// auto w2 = w02 ^ w12; -// auto w3 = w03 ^ w13; - -// auto w0_basis = waters.ao_basis_set(w0.begin(), w0.end()); -// auto w1_basis = waters.ao_basis_set(w1.begin(), w1.end()); -// auto w2_basis = waters.ao_basis_set(w2.begin(), w2.end()); -// auto w3_basis = waters.ao_basis_set(w3.begin(), w3.end()); - -// equation_type corr; -// corr.add_term(make_term(w0, w0_basis, 10, -2.0)); -// corr.add_term(make_term(w01, waters.ao_basis_set(w01), 20, 1.0)); -// corr.add_term(make_term(w02, waters.ao_basis_set(w02), 20, 1.0)); -// corr.add_term(make_term(w03, waters.ao_basis_set(w03), 20, 1.0)); -// corr.add_term(make_term(w1, w1_basis, 10, -2.0)); -// corr.add_term(make_term(w12, waters.ao_basis_set(w12), 20, 1.0)); -// corr.add_term(make_term(w13, waters.ao_basis_set(w13), 20, 1.0)); -// corr.add_term(make_term(w2, w2_basis, 10, -2.0)); -// corr.add_term(make_term(w23, waters.ao_basis_set(w23), 20, 1.0)); -// corr.add_term(make_term(w3, w3_basis, 10, -2.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("3-body w/ 4 water") { -// auto waters = water_nmer_system(4, 3); -// const auto& w012 = waters.nmer(0); -// const auto& w013 = waters.nmer(1); -// const auto& w023 = waters.nmer(2); -// const auto& w123 = waters.nmer(3); - -// auto w01 = w012 ^ w013; -// auto w02 = w012 ^ w023; -// auto w03 = w013 ^ w023; -// auto w12 = w012 ^ w123; -// auto w13 = w013 ^ w123; -// auto w23 = w023 ^ w123; - -// auto w01_basis = waters.ao_basis_set(w01.begin(), w01.end()); -// auto w02_basis = waters.ao_basis_set(w02.begin(), w02.end()); -// auto w03_basis = waters.ao_basis_set(w03.begin(), w03.end()); -// auto w12_basis = waters.ao_basis_set(w12.begin(), w12.end()); -// auto w13_basis = waters.ao_basis_set(w13.begin(), w13.end()); -// auto w23_basis = waters.ao_basis_set(w23.begin(), w23.end()); - -// auto w0 = w01 ^ w02; -// auto w1 = w01 ^ w12; -// auto w2 = w02 ^ w12; -// auto w3 = w03 ^ w13; - -// auto w0_basis = waters.ao_basis_set(w0.begin(), w0.end()); -// auto w1_basis = waters.ao_basis_set(w1.begin(), w1.end()); -// auto w2_basis = waters.ao_basis_set(w2.begin(), w2.end()); -// auto w3_basis = waters.ao_basis_set(w3.begin(), w3.end()); - -// equation_type corr; -// corr.add_term(make_term(w0, w0_basis, 10, 1.0)); -// corr.add_term(make_term(w01, w01_basis, 20, -1.0)); -// corr.add_term(make_term(w012, waters.ao_basis_set(w012), 30, 1.0)); -// corr.add_term(make_term(w013, waters.ao_basis_set(w013), 30, 1.0)); -// corr.add_term(make_term(w02, w02_basis, 20, -1.0)); -// corr.add_term(make_term(w023, waters.ao_basis_set(w023), 30, 1.0)); -// corr.add_term(make_term(w03, w03_basis, 20, -1.0)); -// corr.add_term(make_term(w1, w1_basis, 10, 1.0)); -// corr.add_term(make_term(w12, w12_basis, 20, -1.0)); -// corr.add_term(make_term(w123, waters.ao_basis_set(w123), 30, 1.0)); -// corr.add_term(make_term(w13, w13_basis, 20, -1.0)); -// corr.add_term(make_term(w2, w2_basis, 10, 1.0)); -// corr.add_term(make_term(w23, w23_basis, 20, -1.0)); -// corr.add_term(make_term(w3, w3_basis, 10, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } - -// SECTION("4-body w/ 4 water") { -// auto waters = water_nmer_system(4, 4); -// const auto& w0 = waters.nmer(0); - -// equation_type corr; -// corr.add_term(make_term(w0, waters.ao_basis_set(w0), 40, 1.0)); -// const auto& [expression] = mod.run_as(waters); -// REQUIRE(expression == corr); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/fragmented_system.cpp b/tests/cxx/unit_tests/ghostfragment/fragmented_system.cpp deleted file mode 100644 index 89ee31f2..00000000 --- a/tests/cxx/unit_tests/ghostfragment/fragmented_system.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "ghostfragment/fragmented_system.hpp" -// #include "test_ghostfragment.hpp" - -// using namespace ghostfragment; - -// /* Testing Strategy: -// * -// * We make four fragmented systems: -// * - defaulted: A default constructed instance -// * - empty: An instance created with all empty containers -// * - netural: Supersystem containing a single neutral water molecule -// * - charged: Supersystem containing two water molecules, first is netural -// * second is charged -// */ - -// TEST_CASE("FragmentedSystem") { -// auto monomer = testing::fragmented_water(1); -// auto dimer = testing::fragmented_water(2); -// auto mono2ao = testing::water_ao_pairs(1); -// auto dimer2ao = testing::water_ao_pairs(2); - -// using vector_type = FragmentedSystem::atom2nelectron_type; -// using size_type = vector_type::value_type; - -// FragmentedSystem defaulted; -// FragmentedSystem empty = testing::fragmented_water_system(0); -// FragmentedSystem neutral = testing::fragmented_water_system(1); -// auto dimer_pimpl = testing::fragmented_water_system_pimpl(2); -// dimer_pimpl->m_atom2ne[3] = 9; -// FragmentedSystem charged(std::move(dimer_pimpl)); - -// SECTION("Ctors") { -// SECTION("Default") { REQUIRE(defaulted.nfrags() == 0); } - -// SECTION("Value") { -// REQUIRE(empty.nfrags() == 0); -// REQUIRE(neutral.nfrags() == 1); -// REQUIRE(charged.nfrags() == 2); -// } - -// SECTION("Copy") { -// FragmentedSystem copy1(defaulted); -// REQUIRE(copy1 == defaulted); - -// FragmentedSystem copy2(neutral); -// REQUIRE(copy2 == neutral); - -// FragmentedSystem copy3(charged); -// REQUIRE(copy3 == charged); -// } - -// SECTION("Move") { -// FragmentedSystem copy1(defaulted); -// FragmentedSystem moved1(std::move(defaulted)); -// REQUIRE(copy1 == moved1); - -// FragmentedSystem copy2(neutral); -// FragmentedSystem moved2(std::move(neutral)); -// REQUIRE(copy2 == moved2); - -// FragmentedSystem copy3(charged); -// FragmentedSystem moved3(std::move(charged)); -// REQUIRE(copy3 == moved3); -// } - -// SECTION("Copy Assignment") { -// FragmentedSystem copy; -// auto pcopy = &(copy = defaulted); -// REQUIRE(pcopy == ©); -// REQUIRE(copy == defaulted); - -// pcopy = &(copy = neutral); -// REQUIRE(pcopy == ©); -// REQUIRE(copy == neutral); - -// pcopy = &(copy = charged); -// REQUIRE(pcopy == ©); -// REQUIRE(copy == charged); -// } - -// SECTION("Move Assignment") { -// FragmentedSystem copy1(defaulted); -// FragmentedSystem moved; -// auto pmoved = &(moved = std::move(defaulted)); -// REQUIRE(pmoved == &moved); -// REQUIRE(copy1 == moved); - -// FragmentedSystem copy2(neutral); -// pmoved = &(moved = std::move(neutral)); -// REQUIRE(pmoved == &moved); -// REQUIRE(copy2 == moved); - -// FragmentedSystem copy3(charged); -// pmoved = &(moved = std::move(charged)); -// REQUIRE(pmoved == &moved); -// REQUIRE(copy3 == moved); -// } -// } - -// SECTION("nfrags") { -// REQUIRE(defaulted.nfrags() == 0); - -// REQUIRE(empty.nfrags() == 0); - -// REQUIRE(neutral.nfrags() == 1); - -// REQUIRE(charged.nfrags() == 2); -// } - -// SECTION("count") { -// REQUIRE(defaulted.count(monomer[0]) == 0); -// REQUIRE(defaulted.count(dimer[0]) == 0); -// REQUIRE(defaulted.count(dimer[1]) == 0); - -// REQUIRE(empty.count(monomer[0]) == 0); -// REQUIRE(empty.count(dimer[0]) == 0); -// REQUIRE(empty.count(dimer[1]) == 0); - -// REQUIRE(neutral.count(monomer[0]) == 1); -// REQUIRE(neutral.count(dimer[0]) == 0); -// REQUIRE(neutral.count(dimer[1]) == 0); - -// REQUIRE(charged.count(monomer[0]) == 0); -// REQUIRE(charged.count(dimer[0]) == 1); -// REQUIRE(charged.count(dimer[1]) == 1); -// } - -// SECTION("frags") { -// REQUIRE_THROWS_AS(defaulted.frags(), std::runtime_error); -// REQUIRE(empty.frags() == testing::fragmented_water(0)); -// REQUIRE(neutral.frags() == monomer); -// REQUIRE(charged.frags() == dimer); -// } - -// SECTION("fragment") { -// REQUIRE_THROWS_AS(defaulted.fragment(0), std::out_of_range); - -// REQUIRE_THROWS_AS(empty.fragment(0), std::out_of_range); - -// REQUIRE(neutral.fragment(0) == monomer.at(0)); -// REQUIRE_THROWS_AS(neutral.fragment(1), std::out_of_range); - -// REQUIRE(charged.fragment(0) == dimer.at(0)); -// REQUIRE(charged.fragment(1) == dimer.at(1)); -// REQUIRE_THROWS_AS(charged.fragment(2), std::out_of_range); -// } - -// // SECTION("caps") { -// // const auto& w0 = monomer.at(0); -// // REQUIRE_THROWS_AS(defaulted.caps(w0), std::runtime_error); -// // REQUIRE_THROWS_AS(empty.caps(w0), std::out_of_range); - -// // REQUIRE(neutral.caps(w0) == testing::caps_for_water(1)[0]); - -// // auto dimer_caps = testing::caps_for_water(2); -// // REQUIRE(charged.caps(dimer.at(0)) == dimer_caps[0]); -// // REQUIRE(charged.caps(dimer.at(1)) == dimer_caps[0]); -// // REQUIRE_THROWS_AS(charged.caps(w0), std::out_of_range); -// // } - -// SECTION("ao_basis_set") { -// const auto& w0 = monomer.at(0); -// const auto& w1 = dimer.at(1); - -// REQUIRE_THROWS_AS(defaulted.ao_basis_set(w0), std::runtime_error); - -// REQUIRE_THROWS_AS(empty.ao_basis_set(w0), std::out_of_range); - -// auto O0 = monomer.new_subset(); -// auto H0 = monomer.new_subset(); -// auto H1 = monomer.new_subset(); -// O0.insert(0); -// H0.insert(1); -// H1.insert(2); - -// auto w0_basis = mono2ao.at(O0) + mono2ao.at(H0) + mono2ao.at(H1); - -// REQUIRE(neutral.ao_basis_set(w0) == w0_basis); -// REQUIRE_THROWS_AS(neutral.ao_basis_set(w1), std::out_of_range); - -// O0 = dimer.new_subset(); -// H0 = dimer.new_subset(); -// H1 = dimer.new_subset(); -// auto O1 = dimer.new_subset(); -// auto H2 = dimer.new_subset(); -// auto H3 = dimer.new_subset(); -// O0.insert(0); -// H0.insert(1); -// H1.insert(2); -// O1.insert(3); -// H2.insert(4); -// H3.insert(5); -// w0_basis = dimer2ao.at(O0) + dimer2ao.at(H0) + dimer2ao.at(H1); -// auto w1_basis = dimer2ao.at(O1) + dimer2ao.at(H2) + dimer2ao.at(H3); - -// REQUIRE(charged.ao_basis_set(dimer.at(0)) == w0_basis); -// REQUIRE(charged.ao_basis_set(w1) == w1_basis); - -// REQUIRE_THROWS_AS(charged.ao_basis_set(w0), std::out_of_range); -// } - -// SECTION("n_electrons") { -// const auto& w0 = monomer.at(0); -// const auto& w1 = dimer.at(1); - -// REQUIRE_THROWS_AS(defaulted.n_electrons(w0), std::runtime_error); - -// REQUIRE_THROWS_AS(empty.n_electrons(w0), std::out_of_range); - -// REQUIRE(neutral.n_electrons(w0) == 10); -// REQUIRE_THROWS_AS(neutral.n_electrons(w1), std::out_of_range); - -// REQUIRE(charged.n_electrons(dimer.at(0)) == 10); -// REQUIRE(charged.n_electrons(w1) == 11); - -// REQUIRE_THROWS_AS(charged.n_electrons(w0), std::out_of_range); -// } - -// SECTION("Comparisons") { -// FragmentedSystem lhs; - -// REQUIRE(lhs == defaulted); -// REQUIRE_FALSE(lhs != defaulted); - -// REQUIRE(lhs != empty); -// REQUIRE_FALSE(lhs == empty); - -// REQUIRE(lhs != neutral); -// REQUIRE_FALSE(lhs == neutral); - -// REQUIRE(lhs != charged); -// REQUIRE_FALSE(lhs == charged); -// } - -// // SECTION("hash") { -// // auto lhs = pluginplay::hash_objects(FragmentedSystem{}); - -// // REQUIRE(lhs == pluginplay::hash_objects(defaulted)); - -// // REQUIRE(lhs != pluginplay::hash_objects(empty)); - -// // REQUIRE(lhs != pluginplay::hash_objects(neutral)); - -// // REQUIRE(lhs != pluginplay::hash_objects(charged)); -// // } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/fragmenting/ao2atom.cpp b/tests/cxx/unit_tests/ghostfragment/fragmenting/ao2atom.cpp deleted file mode 100644 index 34fda167..00000000 --- a/tests/cxx/unit_tests/ghostfragment/fragmenting/ao2atom.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" - -// using return_type = simde::atom_to_center_return_type; -// using set_type = typename return_type::value_type; - -// TEST_CASE("AO2Atom") { -// auto mm = testing::initialize(); -// auto mod = mm.at("AO Center to Atom Mapper"); - -// for(std::size_t nwaters = 1; nwaters < 4; ++nwaters) { -// SECTION(std::to_string(nwaters) + " waters") { -// auto water = testing::water(nwaters); -// auto bs = testing::sto3g(water); -// const auto& [rv] = mod.run_as(water, bs); - -// // Our testing funtions add the centers in order; so atom i's AOs -// // are the i-th set of AOs -// return_type corr(3 * nwaters); -// for(std::size_t j = 0; j < 3 * nwaters; ++j) corr[j] = -// set_type{j}; REQUIRE(corr == rv); -// } -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/fragmenting/gmbe_weights.cpp b/tests/cxx/unit_tests/ghostfragment/fragmenting/gmbe_weights.cpp new file mode 100644 index 00000000..3a55ee5f --- /dev/null +++ b/tests/cxx/unit_tests/ghostfragment/fragmenting/gmbe_weights.cpp @@ -0,0 +1,204 @@ +/* + * Copyright 2024 GhostFragment + * + * 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_ghostfragment.hpp" +#include + +using namespace ghostfragment; + +using property_type = pt::FragmentWeights; +using traits_type = pt::FragmentWeightsTraits; +using fragmented_sys_type = typename traits_type::fragments_type; +using fragmented_mol_type = + typename fragmented_sys_type::fragmented_molecule_type; +using fragmented_nuclei_type = + typename fragmented_mol_type::fragmented_nuclei_type; +using nuclei_type = typename fragmented_nuclei_type::supersystem_type; +using nucleus_type = typename nuclei_type::value_type; +using weight_container = typename traits_type::weight_container; + +namespace { + +// Wraps going from fragmented nuclei to fragmented system +auto as_system(fragmented_nuclei_type frags) { + fragmented_mol_type fragmented_mol(std::move(frags), 0, 1); + return fragmented_sys_type(std::move(fragmented_mol)); +} + +} // namespace + +/* Testing strategy: + * + * We create a system with four water molecules. Assuming each water is a + * pseudoatom, we then iterate over the powerset of how to form fragments (no + * fragments, one giant fragment, two fragments, three + * fragments, then four fragments). For each level of fragmenting we consider + * the different ways of partitioning the system e.g., no overlap, one pair-wise + * overlap. In practice what matters is not the identify of the overlap (e.g., + * it doesn't matter if two fragments overlap by 1 or 2 waters) but how many + * fragments share the overlap. + */ + +TEST_CASE("GMBE Weights") { + auto mm = testing::initialize(); + auto& mod = mm.at("GMBE Weights"); + + auto nuclei_mol = testing::water(4); + fragmented_nuclei_type frags(nuclei_mol.nuclei()); + + SECTION("No Fragments") { + weight_container corr; + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("One Fragment") { + frags.insert({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}); + weight_container corr(1, 1.0); + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("Two Fragments") { + SECTION("Disjoint") { + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({6, 7, 8, 9, 10, 11}); + weight_container corr(2, 1.0); + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + SECTION("Overlap") { + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({3, 4, 5, 6, 7, 8, 9, 10, 11}); + frags.insert({3, 4, 5}); + + weight_container corr{1.0, 1.0, -1.0}; + auto weights = mod.run_as(as_system(frags)); + } + } + + SECTION("Three Fragments") { + SECTION("Disjoint") { + frags.insert({0, 1, 2}); + frags.insert({3, 4, 5}); + frags.insert({6, 7, 8, 9, 10, 11}); + + weight_container corr{1.0, 1.0, 1.0}; + + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("One pair-wise overlap") { + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({3, 4, 5, 6, 7, 8}); + frags.insert({9, 10, 11}); + frags.insert({3, 4, 5}); + + weight_container corr{1.0, 1.0, 1.0, -1.0}; + + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("Two pair-wise overlaps") { + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({3, 4, 5, 6, 7, 8}); + frags.insert({6, 7, 8, 9, 10, 11}); + frags.insert({3, 4, 5}); + frags.insert({6, 7, 8}); + + weight_container corr{1.0, 1.0, 1.0, -1.0, -1.0}; + + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("Three pair-wise overlaps") { + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({3, 4, 5, 6, 7, 8}); + frags.insert({0, 1, 2, 6, 7, 8, 9, 10, 11}); + frags.insert({0, 1, 2}); + frags.insert({3, 4, 5}); + frags.insert({6, 7, 8}); + + weight_container corr{1.0, 1.0, 1.0, -1.0, -1.0, -1.0}; + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("Three pair-wise overlaps and 1 three-way overlap") { + frags.insert({0, 1, 2, 3, 4, 5, 6, 7, 8}); + frags.insert({0, 1, 2, 3, 4, 5, 9, 10, 11}); + frags.insert({0, 1, 2, 6, 7, 8, 9, 10, 11}); + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({0, 1, 2, 6, 7, 8}); + frags.insert({0, 1, 2, 9, 10, 11}); + frags.insert({0, 1, 2}); + + weight_container corr{1.0, 1.0, 1.0, -1.0, -1.0, -1.0, 1.0}; + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("Three pair-wise overlaps that are the 1 three-way overlap") { + frags.insert({0, 1, 2, 3, 4, 5}); + frags.insert({0, 1, 2, 6, 7, 8}); + frags.insert({0, 1, 2, 9, 10, 11}); + frags.insert({0, 1, 2}); + + weight_container corr{1.0, 1.0, 1.0, -2.0}; + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + } + + SECTION("Four Fragments") { + SECTION("Disjoint") { + frags.insert({0, 1, 2}); + frags.insert({3, 4, 5}); + frags.insert({6, 7, 8}); + frags.insert({9, 10, 11}); + + weight_container corr{1.0, 1.0, 1.0, 1.0}; + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + + SECTION("Non-disjoint") { + frags.insert({0, 1, 2, 3, 4, 5, 6, 7, 8}); + frags.insert({0, 1, 2, 3, 4, 5, 9, 10, 11}); + frags.insert({0, 1, 2, 6, 7, 8, 9, 10, 11}); + frags.insert({3, 4, 5, 6, 7, 8, 9, 10, 11}); + frags.insert({0, 1, 2, 3, 4, 5}); // 1^2 + frags.insert({0, 1, 2, 6, 7, 8}); // 1^3 + frags.insert({0, 1, 2, 9, 10, 11}); // 2^3 + frags.insert({3, 4, 5, 6, 7, 8}); // 1^4 + frags.insert({3, 4, 5, 9, 10, 11}); // 2^4 + frags.insert({6, 7, 8, 9, 10, 11}); // 3^4 + frags.insert({0, 1, 2}); // 1^2^3 + frags.insert({3, 4, 5}); // 1^2^4 + frags.insert({6, 7, 8}); // 1^3^4 + frags.insert({9, 10, 11}); // 2^3^4 + + weight_container corr{1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, + -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0}; + + auto weights = mod.run_as(as_system(frags)); + REQUIRE(weights == corr); + } + } +} diff --git a/tests/cxx/unit_tests/ghostfragment/fragmenting/nuclei_ao.cpp b/tests/cxx/unit_tests/ghostfragment/fragmenting/nuclei_ao.cpp deleted file mode 100644 index 22627a0b..00000000 --- a/tests/cxx/unit_tests/ghostfragment/fragmenting/nuclei_ao.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" - -// using namespace ghostfragment::pt; - -// namespace { -// // Module assuming atoms [3*i, 3 * i + 3) are the atoms in fragment i -// auto frag_mod(const simde::type::molecule& mol) { -// chemist::set_theory::FamilyOfSets rv(mol); -// auto new_set = rv.new_subset(); -// for(std::size_t i = 0, j = 1; i < mol.size(); ++i, ++j) { -// new_set.insert(i); -// if(j == 3) { -// rv.insert(new_set); -// new_set = rv.new_subset(); -// j = 0; // set it to 0 b/c loop will increment it to 1 -// } -// } -// return rv; -// } - -// // Module assuming atom i's AOs are center i -// auto ao2center_mod(const simde::type::molecule& mol, -// const simde::type::ao_basis_set& bs) { -// using return_type = simde::atom_to_center_return_type; -// using subset_type = typename return_type::value_type; - -// return pluginplay::make_lambda( -// [=](auto&& mol_in, auto&& aos_in) { -// REQUIRE(mol_in == mol); -// REQUIRE(aos_in == bs); -// return_type rv(mol.size()); -// for(std::size_t i = 0; i < mol.size(); ++i) { -// rv[i] = subset_type{i}; -// } -// return rv; -// }); -// } -// } // namespace - -// TEST_CASE("NucleiAO") { -// auto mm = testing::initialize(); -// auto mod = mm.at("Nuclei-AO Fragmenter"); - -// using return_type = typename Frag2AOTraits::result_type; - -// for(std::size_t nwaters = 0; nwaters < 4; ++nwaters) { -// SECTION(std::to_string(nwaters) + " waters") { -// auto mol = testing::water(nwaters); -// auto bs = testing::sto3g(mol); -// auto frags = frag_mod(mol); - -// mod.change_submod("Atom to Center", ao2center_mod(mol, bs)); -// auto [rv] = mod.run_as(frags, bs); - -// REQUIRE(rv.size() == nwaters); -// for(const auto& [key, value] : rv) { -// for(const auto& keyi : key) { REQUIRE(value.count(bs[keyi])); -// } -// } -// } -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/nmer_system.cpp b/tests/cxx/unit_tests/ghostfragment/nmer_system.cpp deleted file mode 100644 index 22de169f..00000000 --- a/tests/cxx/unit_tests/ghostfragment/nmer_system.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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_ghostfragment.hpp" -// #include - -// using namespace ghostfragment; -// using namespace testing; - -// TEST_CASE("NMerSystem") { -// auto dimers = make_nmers(fragmented_water(3), 2); -// auto trimers = make_nmers(fragmented_water(4), 3); - -// auto frags = testing::fragmented_water_system(3); - -// NMerSystem defaulted; -// NMerSystem has_value(frags, dimers); - -// SECTION("CTors") { -// SECTION("Default") { REQUIRE(defaulted.size() == 0); } -// SECTION("Value") { -// REQUIRE(has_value.size() == 3); -// REQUIRE(has_value.fragments() == frags); -// } -// SECTION("Copy") { -// NMerSystem default_copy(defaulted); -// REQUIRE(default_copy == defaulted); - -// NMerSystem copy(has_value); -// REQUIRE(copy == has_value); -// } -// SECTION("Move") { -// NMerSystem default_moved(std::move(defaulted)); -// REQUIRE(default_moved == NMerSystem{}); - -// NMerSystem corr(has_value); -// NMerSystem value_moved(std::move(has_value)); -// REQUIRE(corr == value_moved); -// } -// SECTION("Copy Assignment") { -// NMerSystem copy; -// auto pcopy = &(copy = has_value); -// REQUIRE(pcopy == ©); -// REQUIRE(copy == has_value); -// } -// SECTION("Move Assignment") { -// NMerSystem default_moved; -// auto pdefault = &(default_moved = std::move(defaulted)); -// REQUIRE(pdefault == &default_moved); -// REQUIRE(default_moved == NMerSystem{}); - -// NMerSystem corr(has_value); -// NMerSystem value_moved; -// auto pvalue = &(value_moved = std::move(has_value)); -// REQUIRE(pvalue == &value_moved); -// REQUIRE(corr == value_moved); -// } -// } - -// SECTION("size") { -// REQUIRE(defaulted.size() == 0); -// REQUIRE(has_value.size() == 3); -// } - -// SECTION("new_nmer") { -// REQUIRE_THROWS_AS(defaulted.new_nmer(), std::runtime_error); -// REQUIRE(has_value.new_nmer() == dimers.new_subset()); -// } - -// SECTION("nmer") { -// REQUIRE_THROWS_AS(defaulted.nmer(0), std::out_of_range); -// REQUIRE(has_value.nmer(0) == dimers[0]); -// REQUIRE(has_value.nmer(1) == dimers[1]); -// REQUIRE(has_value.nmer(2) == dimers[2]); -// REQUIRE_THROWS_AS(has_value.nmer(3), std::out_of_range); -// } - -// SECTION("count") { -// REQUIRE_FALSE(defaulted.count(dimers[0])); - -// REQUIRE(has_value.count(dimers[0])); -// REQUIRE(has_value.count(dimers[1])); -// REQUIRE(has_value.count(dimers[2])); -// REQUIRE_FALSE(has_value.count(dimers[0] + dimers[1])); -// REQUIRE_FALSE(has_value.count(trimers[0])); -// } - -// SECTION("fragments") { -// REQUIRE_THROWS_AS(defaulted.fragments(), std::runtime_error); -// REQUIRE(has_value.fragments() == frags); -// } - -// // Make AOs for each water -// auto water0_aos = frags.ao_basis_set(frags.fragment(0)); -// auto water1_aos = frags.ao_basis_set(frags.fragment(1)); -// auto water2_aos = frags.ao_basis_set(frags.fragment(2)); - -// SECTION("ao_basis_set(nmer)") { -// using rerror = std::runtime_error; -// REQUIRE_THROWS_AS(defaulted.ao_basis_set(dimers[0]), rerror); - -// auto d0_aos = water0_aos + water1_aos; -// REQUIRE(has_value.ao_basis_set(dimers[0]) == d0_aos); - -// auto d1_aos = water0_aos + water2_aos; -// REQUIRE(has_value.ao_basis_set(dimers[1]) == d1_aos); - -// auto d2_aos = water1_aos + water2_aos; -// REQUIRE(has_value.ao_basis_set(dimers[2]) == d2_aos); - -// using oerror = std::out_of_range; -// REQUIRE_THROWS_AS(has_value.ao_basis_set(trimers[0]), oerror); -// } - -// SECTION("ao_basis_set(frag)") { -// using rerror = std::runtime_error; -// REQUIRE_THROWS_AS(defaulted.ao_basis_set(frags.fragment(0)), rerror); - -// REQUIRE(has_value.ao_basis_set(frags.fragment(0)) == water0_aos); -// REQUIRE(has_value.ao_basis_set(frags.fragment(1)) == water1_aos); -// REQUIRE(has_value.ao_basis_set(frags.fragment(2)) == water2_aos); - -// using oerror = std::out_of_range; -// auto bad_water = fragmented_water(4)[0]; -// REQUIRE_THROWS_AS(has_value.ao_basis_set(bad_water), oerror); -// } - -// SECTION("n_electrons(nmer)") { -// REQUIRE_THROWS_AS(defaulted.n_electrons(dimers[0]), -// std::runtime_error); REQUIRE(has_value.n_electrons(dimers[0]) == 20); -// REQUIRE(has_value.n_electrons(dimers[1]) == 20); -// REQUIRE(has_value.n_electrons(dimers[2]) == 20); -// REQUIRE_THROWS_AS(has_value.n_electrons(trimers[0]), -// std::out_of_range); -// } - -// SECTION("n_electrons(frag)") { -// auto bad_water = fragmented_water(4)[0]; -// REQUIRE_THROWS_AS(defaulted.n_electrons(bad_water), -// std::runtime_error); REQUIRE(has_value.n_electrons(frags.fragment(0)) -// == 10); REQUIRE(has_value.n_electrons(frags.fragment(1)) == 10); -// REQUIRE(has_value.n_electrons(frags.fragment(2)) == 10); -// REQUIRE_THROWS_AS(has_value.n_electrons(bad_water), -// std::out_of_range); -// } - -// SECTION("Comparisons") { -// // default is the same as default -// REQUIRE(defaulted == NMerSystem{}); -// REQUIRE_FALSE(defaulted != NMerSystem{}); - -// // Default != stateful -// REQUIRE_FALSE(has_value == defaulted); -// REQUIRE(has_value != defaulted); - -// // Same n-mers and fragments -// REQUIRE(has_value == NMerSystem(frags, dimers)); -// REQUIRE_FALSE(has_value != NMerSystem(frags, dimers)); - -// // Different fragments -// auto empty_frags = fragmented_water_system(0); -// REQUIRE_FALSE(has_value == NMerSystem(empty_frags, dimers)); -// REQUIRE(has_value != NMerSystem(empty_frags, dimers)); - -// // Different n-mers -// REQUIRE_FALSE(has_value == NMerSystem(frags, trimers)); -// REQUIRE(has_value != NMerSystem(frags, trimers)); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/testing/aos.cpp b/tests/cxx/unit_tests/ghostfragment/testing/aos.cpp deleted file mode 100644 index f38636f7..00000000 --- a/tests/cxx/unit_tests/ghostfragment/testing/aos.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "aos.hpp" -// #include "water.hpp" -// #include - -// using namespace testing; - -// TEST_CASE("atom_to_ao") { -// using pimpl_type = ghostfragment::detail_::FragmentedSystemPIMPL; -// using a2ao_type = pimpl_type::idx2ao_map_type; - -// a2ao_type corr; - -// SECTION("Zero waters") { REQUIRE(corr == atom_to_ao(water(0))); } - -// SECTION("One water") { -// auto mol = water(1); -// ghostfragment::type::fragmented_aos ao_sets(sto3g(mol)); - -// auto ao0 = ao_sets.new_subset(); -// ao0.insert(0); - -// auto ao1 = ao_sets.new_subset(); -// ao1.insert(1); - -// auto ao2 = ao_sets.new_subset(); -// ao2.insert(2); - -// corr.emplace_back(ao0); -// corr.emplace_back(ao1); -// corr.emplace_back(ao2); -// REQUIRE(corr == atom_to_ao(mol)); -// } - -// SECTION("Two waters") { -// auto mol = water(2); -// ghostfragment::type::fragmented_aos ao_sets(sto3g(mol)); - -// auto ao0 = ao_sets.new_subset(); -// ao0.insert(0); - -// auto ao1 = ao_sets.new_subset(); -// ao1.insert(1); - -// auto ao2 = ao_sets.new_subset(); -// ao2.insert(2); - -// auto ao3 = ao_sets.new_subset(); -// ao3.insert(3); - -// auto ao4 = ao_sets.new_subset(); -// ao4.insert(4); - -// auto ao5 = ao_sets.new_subset(); -// ao5.insert(5); - -// corr.emplace_back(ao0); -// corr.emplace_back(ao1); -// corr.emplace_back(ao2); -// corr.emplace_back(ao3); -// corr.emplace_back(ao4); -// corr.emplace_back(ao5); -// REQUIRE(corr == atom_to_ao(mol)); -// } - -// SECTION("Three waters") { -// auto mol = water(3); -// ghostfragment::type::fragmented_aos ao_sets(sto3g(mol)); - -// auto ao0 = ao_sets.new_subset(); -// ao0.insert(0); - -// auto ao1 = ao_sets.new_subset(); -// ao1.insert(1); - -// auto ao2 = ao_sets.new_subset(); -// ao2.insert(2); - -// auto ao3 = ao_sets.new_subset(); -// ao3.insert(3); - -// auto ao4 = ao_sets.new_subset(); -// ao4.insert(4); - -// auto ao5 = ao_sets.new_subset(); -// ao5.insert(5); - -// auto ao6 = ao_sets.new_subset(); -// ao6.insert(6); - -// auto ao7 = ao_sets.new_subset(); -// ao7.insert(7); - -// auto ao8 = ao_sets.new_subset(); -// ao8.insert(8); - -// corr.emplace_back(ao0); -// corr.emplace_back(ao1); -// corr.emplace_back(ao2); -// corr.emplace_back(ao3); -// corr.emplace_back(ao4); -// corr.emplace_back(ao5); -// corr.emplace_back(ao6); -// corr.emplace_back(ao7); -// corr.emplace_back(ao8); -// REQUIRE(corr == atom_to_ao(mol)); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/testing/aos.hpp b/tests/cxx/unit_tests/ghostfragment/testing/aos.hpp deleted file mode 100644 index d2a19309..00000000 --- a/tests/cxx/unit_tests/ghostfragment/testing/aos.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "sto3g.hpp" -// #include - -// namespace testing { - -// // Assigns AOs to nuclei assuming nuclei order is same as AO center order -// inline auto atom_to_ao(const simde::type::molecule& mol) { -// using pimpl_type = ghostfragment::detail_::FragmentedSystemPIMPL; -// using return_type = pimpl_type::idx2ao_map_type; -// return_type atom2aos; -// auto aos = sto3g(mol); -// ghostfragment::type::fragmented_aos ao_sets(aos); -// for(std::size_t atom_i = 0; atom_i < mol.size(); ++atom_i) { -// auto ao_set = ao_sets.new_subset(); -// ao_set.insert(atom_i); -// atom2aos.emplace_back(ao_set); -// } -// return atom2aos; -// } - -// } // namespace testing diff --git a/tests/cxx/unit_tests/ghostfragment/testing/hc_fragment.cpp b/tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon/test_hc_fragment.cpp similarity index 98% rename from tests/cxx/unit_tests/ghostfragment/testing/hc_fragment.cpp rename to tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon/test_hc_fragment.cpp index 0e6bdaa5..b016c6cb 100644 --- a/tests/cxx/unit_tests/ghostfragment/testing/hc_fragment.cpp +++ b/tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon/test_hc_fragment.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "hydrocarbon/hydrocarbon.hpp" +#include "hydrocarbon.hpp" #include #include diff --git a/tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon.cpp b/tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon/test_hydrocarbon.cpp similarity index 99% rename from tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon.cpp rename to tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon/test_hydrocarbon.cpp index e1eb594e..a4aee2a3 100644 --- a/tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon.cpp +++ b/tests/cxx/unit_tests/ghostfragment/testing/hydrocarbon/test_hydrocarbon.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "hydrocarbon/hydrocarbon.hpp" +#include "hydrocarbon.hpp" #include namespace testing { diff --git a/tests/cxx/unit_tests/ghostfragment/testing/sto3g.cpp b/tests/cxx/unit_tests/ghostfragment/testing/sto3g.cpp deleted file mode 100644 index 828aeb0e..00000000 --- a/tests/cxx/unit_tests/ghostfragment/testing/sto3g.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 "sto3g.hpp" -// #include "water.hpp" -// #include - -// using namespace testing; - -// /* Unit tests our function for creating molecular basis sets. We test it -// against -// * hard-coded answers for 0, 1, and 2 waters. The waters are generated by -// * the water() function (which works b/c it's unit tested in water.cpp) so we -// * just need to make sure the function copies the parameters and coordinates -// * into the resulting basis set correctly. It's assumed that if it can do -// that -// * for 0, 1, and 2 waters it can do it for an arbitrary number of waters. -// */ - -// TEST_CASE("STO-3G") { -// using ao_basis_set = ghostfragment::type::ao_basis_set; -// using atomic_basis_set = typename ao_basis_set::value_type; -// using shell_type = typename atomic_basis_set::value_type; -// using vector_t = std::vector; - -// // Taken from hard-coded basis sets in NWX -// // O -// vector_t c0_o{0.15432897, 0.53532814, 0.44463454}; -// vector_t a0_o{130.7093200, 23.8088610, 6.4436083}; -// vector_t c1{-0.09996723, 0.39951283, 0.70011547}; -// vector_t c2{0.15591627, 0.60768372, 0.39195739}; -// vector_t a1{5.0331513, 1.1695961, 0.3803890}; - -// // H -// vector_t c0{0.1543289673, 0.5353281423, 0.4446345422}; -// vector_t a0{3.425250914, 0.6239137298, 0.1688554040}; - -// auto pure = shell_type::pure_type::pure; - -// SECTION("No atoms") { -// ao_basis_set corr; -// REQUIRE(corr == sto3g(water(0))); -// } - -// SECTION("One water") { -// ao_basis_set corr; -// auto mol = water(1); - -// atomic_basis_set O0; -// O0.coord(0) = mol[0].coord(0); -// O0.coord(1) = mol[0].coord(1); -// O0.coord(2) = mol[0].coord(2); -// O0.add_shell(pure, 0, c0_o, a0_o); -// O0.add_shell(pure, 0, c1, a1); -// O0.add_shell(pure, 1, c2, a1); - -// atomic_basis_set H0; -// H0.coord(0) = mol[1].coord(0); -// H0.coord(1) = mol[1].coord(1); -// H0.coord(2) = mol[1].coord(2); -// H0.add_shell(pure, 0, c0, a0); - -// atomic_basis_set H1; -// H1.coord(0) = mol[2].coord(0); -// H1.coord(1) = mol[2].coord(1); -// H1.coord(2) = mol[2].coord(2); -// H1.add_shell(pure, 0, c0, a0); - -// corr.add_center(O0); -// corr.add_center(H0); -// corr.add_center(H1); -// REQUIRE(corr == sto3g(mol)); -// } - -// SECTION("Two waters") { -// ao_basis_set corr; -// auto mol = water(2); - -// atomic_basis_set O0; -// O0.coord(0) = mol[0].coord(0); -// O0.coord(1) = mol[0].coord(1); -// O0.coord(2) = mol[0].coord(2); -// O0.add_shell(pure, 0, c0_o, a0_o); -// O0.add_shell(pure, 0, c1, a1); -// O0.add_shell(pure, 1, c2, a1); - -// atomic_basis_set H0; -// H0.coord(0) = mol[1].coord(0); -// H0.coord(1) = mol[1].coord(1); -// H0.coord(2) = mol[1].coord(2); -// H0.add_shell(pure, 0, c0, a0); - -// atomic_basis_set H1; -// H1.coord(0) = mol[2].coord(0); -// H1.coord(1) = mol[2].coord(1); -// H1.coord(2) = mol[2].coord(2); -// H1.add_shell(pure, 0, c0, a0); - -// atomic_basis_set O1; -// O1.coord(0) = mol[3].coord(0); -// O1.coord(1) = mol[3].coord(1); -// O1.coord(2) = mol[3].coord(2); -// O1.add_shell(pure, 0, c0_o, a0_o); -// O1.add_shell(pure, 0, c1, a1); -// O1.add_shell(pure, 1, c2, a1); - -// atomic_basis_set H2; -// H2.coord(0) = mol[4].coord(0); -// H2.coord(1) = mol[4].coord(1); -// H2.coord(2) = mol[4].coord(2); -// H2.add_shell(pure, 0, c0, a0); - -// atomic_basis_set H3; -// H3.coord(0) = mol[5].coord(0); -// H3.coord(1) = mol[5].coord(1); -// H3.coord(2) = mol[5].coord(2); -// H3.add_shell(pure, 0, c0, a0); - -// corr.add_center(O0); -// corr.add_center(H0); -// corr.add_center(H1); -// corr.add_center(O1); -// corr.add_center(H2); -// corr.add_center(H3); -// REQUIRE(corr == sto3g(mol)); -// } - -// SECTION("Throws if given a bad Z") { -// using molecule_type = ghostfragment::type::nuclei_set; -// using atom_type = typename molecule_type::atom_type; -// using cart_type = typename atom_type::coord_type; -// molecule_type mol; -// mol.push_back(atom_type{"U", 92ul, 238.0, 0.0, 0.0, 0.0}); -// REQUIRE_THROWS_AS(sto3g(mol), std::out_of_range); -// } -// } diff --git a/tests/cxx/unit_tests/ghostfragment/testing/sto3g.hpp b/tests/cxx/unit_tests/ghostfragment/testing/sto3g.hpp deleted file mode 100644 index 1d562db0..00000000 --- a/tests/cxx/unit_tests/ghostfragment/testing/sto3g.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2024 GhostFragment - * - * 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 - -// namespace testing { - -// /// Creates an STO-3G basis set for the provided molecule -// /// (only knows about Z== 1 or 8) -// inline auto sto3g(const ghostfragment::type::nuclei_set& mol) { -// using ao_basis_set = ghostfragment::type::ao_basis_set; -// using atomic_basis_set = typename ao_basis_set::value_type; -// using shell_type = typename atomic_basis_set::value_type; -// using vector_t = std::vector; - -// // Taken from hard-coded basis sets in NWX -// // O -// vector_t c0_o{0.15432897, 0.53532814, 0.44463454}; -// vector_t a0_o{130.7093200, 23.8088610, 6.4436083}; -// vector_t c1{-0.09996723, 0.39951283, 0.70011547}; -// vector_t c2{0.15591627, 0.60768372, 0.39195739}; -// vector_t a1{5.0331513, 1.1695961, 0.3803890}; - -// // H -// vector_t c0{0.1543289673, 0.5353281423, 0.4446345422}; -// vector_t a0{3.425250914, 0.6239137298, 0.1688554040}; - -// auto pure = shell_type::pure_type::pure; - -// ao_basis_set bs; -// for(const auto& atom_i : mol) { -// atomic_basis_set c; -// for(std::size_t i = 0; i < 3; ++i) c.coord(i) = atom_i.coord(i); -// if(atom_i.Z() == 1) { -// c.add_shell(pure, 0, c0, a0); -// } else if(atom_i.Z() == 8) { -// c.add_shell(pure, 0, c0_o, a0_o); -// c.add_shell(pure, 0, c1, a1); -// c.add_shell(pure, 1, c2, a1); -// } else { -// throw std::out_of_range("No data for atomic number"); -// } -// bs.add_center(c); -// } -// return bs; -// } - -// } // namespace testing