Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
InteractionTermEliminator.h
Go to the documentation of this file.
1 
8 #ifndef SWOOSE_QMMM_INTERACTIONTERMELIMINATOR_H
9 #define SWOOSE_QMMM_INTERACTIONTERMELIMINATOR_H
10 
11 #include <Eigen/Sparse>
12 #include <memory>
13 #include <unordered_set>
14 #include <vector>
15 
16 namespace Scine {
17 
18 namespace MolecularMechanics {
19 class MolecularMechanicsCalculator;
20 class BondedTerm;
21 class AngleTerm;
22 class DihedralTerm;
23 class ImproperDihedralTerm;
24 class DispersionTerm;
25 class RepulsionTerm;
26 class HydrogenBondTerm;
27 class InteractionTermBase;
28 class LennardJonesEvaluator;
29 class ElectrostaticEvaluator;
30 } // namespace MolecularMechanics
31 
32 namespace Qmmm {
33 
40  public:
42  InteractionTermEliminator(const std::vector<int>& listOfQmAtoms,
43  std::shared_ptr<MolecularMechanics::MolecularMechanicsCalculator> calculator);
44 
52  void eliminateInteractionTerms(bool electrostaticEmbedding, bool eliminateEnvironmentOnlyTerms = false);
53 
57  void reset();
58 
59  private:
60  // @brief Eliminates those bonded interactions which are already covered by the QM calculation in QM/MM.
61  void eliminateBondedTerms(std::vector<MolecularMechanics::BondedTerm>& bondedTerms);
62 
63  // @brief Eliminates those angle interactions which are already covered by the QM calculation in QM/MM.
64  void eliminateAngleTerms(std::vector<MolecularMechanics::AngleTerm>& angleTerms);
65 
66  /*
67  * @brief Eliminates those dihedral interactions which are already covered by the QM calculation in QM/MM.
68  * The additional boolean argument "gaffImproper" is needed if this function is called for the GAFF
69  * method to eliminate improper dihedrals (which are treated as normal dihedrals in GAFF). In such a case,
70  * the allowed number of QM atoms is different.
71  */
72  void eliminateDihedralTerms(std::vector<MolecularMechanics::DihedralTerm>& dihedralTerms, bool gaffImproper = false);
73 
74  // @brief Eliminates those improper dihedral interactions which are already covered by the QM calculation in QM/MM.
75  void eliminateImproperDihedralTerms(std::vector<MolecularMechanics::ImproperDihedralTerm>& improperDihedralTerms);
76 
77  // @brief Eliminates those dispersion interactions which are already covered by the QM calculation in QM/MM.
78  void eliminateDispersionTerms(std::vector<MolecularMechanics::DispersionTerm>& dispersionTerms);
79 
80  // @brief Eliminates those Pauli repulsion interactions which are already covered by the QM calculation in QM/MM.
81  void eliminateRepulsionTerms(std::vector<MolecularMechanics::RepulsionTerm>& repulsionTerms);
82 
83  // @brief Eliminates those Lennard-Jones interactions which are already covered by the QM calculation in QM/MM.
84  void eliminateLennardJonesTerms(MolecularMechanics::LennardJonesEvaluator& lennardJonesEvaluator);
85 
86  // @brief Eliminates those hydrogen bond interactions which are already covered by the QM calculation in QM/MM.
87  void eliminateHydrogenBondTerms(std::vector<MolecularMechanics::HydrogenBondTerm>& hydrogenBondTerms);
88 
89  /*
90  * @brief Eliminates those electrostatic interactions which are already covered by the QM calculation in QM/MM.
91  * @param electrostaticTerms The electrostatic terms of the MM model.
92  * @param electrostaticEmbedding Whether electrostatic embedding is switched on in the QM/MM calculator.
93  */
94  void eliminateElectrostaticTerms(MolecularMechanics::ElectrostaticEvaluator& electrostaticEvaluator,
95  bool electrostaticEmbedding);
96 
97  /*
98  * @brief Eliminates the given interaction term if more than 'allowedInQmRegion' of its atoms are in the QM region.
99  */
100  void eliminateTerm(MolecularMechanics::InteractionTermBase& term, const std::vector<int>& atomsInTerm, int allowedInQmRegion);
101 
102  bool termToEliminate(const std::vector<int>& atomsInTerm, int allowedInQmRegion);
103  /*
104  * @brief Returns whether an atom with the given index is in the QM region.
105  */
106  bool isQmAtom(int index);
107 
108  // Enables all representatives of one type of interaction terms.
109  template<typename T>
110  void enableTerms(std::vector<T>& terms);
111 
112  // Eliminates all the shared interaction terms that are present in all the possible MM calculators.
113  template<typename CalculatorType>
114  void eliminateSharedInteractionTerms(bool electrostaticEmbedding, CalculatorType& calculator);
115 
116  // Enables all of the shared interaction terms that are present in all the possible MM calculators.
117  template<typename CalculatorType>
118  void enableSharedInteractionTerms(CalculatorType& calculator);
119 
120  // Hash table containing the indices of the atoms in the QM region.
121  std::unordered_set<int> qmAtoms_;
122 
123  // The MM calculator
124  std::shared_ptr<MolecularMechanics::MolecularMechanicsCalculator> calculator_;
125 
126  // Boolean to keep track of whether we are in a reduced QM/MM energy calculation.
127  bool eliminateEnvironmentOnlyTerms_ = false;
128  // The exclusion set before eliminating QM-QM internal terms.
129  Eigen::SparseMatrix<bool> originalLJExclusions_;
130  Eigen::SparseMatrix<bool> originalElectrostaticExclusions_;
131 };
132 
133 } // namespace Qmmm
134 } // namespace Scine
135 
136 #endif // SWOOSE_QMMM_INTERACTIONTERMELIMINATOR_H
LennardJonesEvaluator LennardJonesEvaluator.h.
Definition: LennardJonesEvaluator.h:34
InteractionTermEliminator(const std::vector< int > &listOfQmAtoms, std::shared_ptr< MolecularMechanics::MolecularMechanicsCalculator > calculator)
Constructor.
Definition: InteractionTermEliminator.cpp:15
This class handles the elimination of MM interaction terms, which are already covered by the QM calcu...
Definition: InteractionTermEliminator.h:39
Base class for all interaction terms.
Definition: InteractionTermBase.h:18
void eliminateInteractionTerms(bool electrostaticEmbedding, bool eliminateEnvironmentOnlyTerms=false)
Eliminates the interactions terms in an MM calculator for QM/MM, which are already covered by the QM ...
Definition: InteractionTermEliminator.cpp:20
void reset()
Enables all of the interactions terms (reverting elimination and therefore resetting the state of the...
Definition: InteractionTermEliminator.cpp:186
Class evaluating the total energy and derivatives from the electrostatic interactions.
Definition: ElectrostaticEvaluator.h:34