Scine::Swoose  1.0.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 <memory>
12 #include <unordered_set>
13 #include <vector>
14 
15 namespace Scine {
16 
17 namespace MolecularMechanics {
18 class MolecularMechanicsCalculator;
19 class BondedTerm;
20 class AngleTerm;
21 class DihedralTerm;
22 class ImproperDihedralTerm;
23 class DispersionTerm;
24 class RepulsionTerm;
25 class ElectrostaticTerm;
26 class HydrogenBondTerm;
27 class LennardJonesTerm;
28 class InteractionTermBase;
29 } // namespace MolecularMechanics
30 
31 namespace Qmmm {
32 
39  public:
41  InteractionTermEliminator(const std::vector<int>& listOfQmAtoms,
42  std::shared_ptr<MolecularMechanics::MolecularMechanicsCalculator> calculator);
43 
51  void eliminateInteractionTerms(bool electrostaticEmbedding, bool eliminateEnvironmentOnlyTerms = false);
52 
56  void reset();
57 
58  private:
59  // @brief Eliminates those bonded interactions which are already covered by the QM calculation in QM/MM.
60  void eliminateBondedTerms(std::vector<MolecularMechanics::BondedTerm>& bondedTerms);
61 
62  // @brief Eliminates those angle interactions which are already covered by the QM calculation in QM/MM.
63  void eliminateAngleTerms(std::vector<MolecularMechanics::AngleTerm>& angleTerms);
64 
65  /*
66  * @brief Eliminates those dihedral interactions which are already covered by the QM calculation in QM/MM.
67  * The additional boolean argument "gaffImproper" is needed if this function is called for the GAFF
68  * method to eliminate improper dihedrals (which are treated as normal dihedrals in GAFF). In such a case,
69  * the allowed number of QM atoms is different.
70  */
71  void eliminateDihedralTerms(std::vector<MolecularMechanics::DihedralTerm>& dihedralTerms, bool gaffImproper = false);
72 
73  // @brief Eliminates those improper dihedral interactions which are already covered by the QM calculation in QM/MM.
74  void eliminateImproperDihedralTerms(std::vector<MolecularMechanics::ImproperDihedralTerm>& improperDihedralTerms);
75 
76  // @brief Eliminates those dispersion interactions which are already covered by the QM calculation in QM/MM.
77  void eliminateDispersionTerms(std::vector<MolecularMechanics::DispersionTerm>& dispersionTerms);
78 
79  // @brief Eliminates those Pauli repulsion interactions which are already covered by the QM calculation in QM/MM.
80  void eliminateRepulsionTerms(std::vector<MolecularMechanics::RepulsionTerm>& repulsionTerms);
81 
82  // @brief Eliminates those Lennard-Jones interactions which are already covered by the QM calculation in QM/MM.
83  void eliminateLennardJonesTerms(std::vector<MolecularMechanics::LennardJonesTerm>& ljTerms);
84 
85  // @brief Eliminates those hydrogen bond interactions which are already covered by the QM calculation in QM/MM.
86  void eliminateHydrogenBondTerms(std::vector<MolecularMechanics::HydrogenBondTerm>& hydrogenBondTerms);
87 
88  /*
89  * @brief Eliminates those electrostatic interactions which are already covered by the QM calculation in QM/MM.
90  * @param electrostaticTerms The electrostatic terms of the MM model.
91  * @param electrostaticEmbedding Whether electrostatic embedding is switched on in the QM/MM calculator.
92  */
93  void eliminateElectrostaticTerms(std::vector<MolecularMechanics::ElectrostaticTerm>& electrostaticTerms,
94  bool electrostaticEmbedding);
95 
96  /*
97  * @brief Eliminates the given interaction term if more than 'allowedInQmRegion' of its atoms are in the QM region.
98  */
99  void eliminateTerm(MolecularMechanics::InteractionTermBase& term, const std::vector<int>& atomsInTerm, int allowedInQmRegion);
100 
101  /*
102  * @brief Returns whether an atom with the given index is in the QM region.
103  */
104  bool isQmAtom(int index);
105 
106  // Enables all representatives of one type of interaction terms.
107  template<typename T>
108  void enableTerms(std::vector<T>& terms);
109 
110  // Eliminates all of the shared interaction terms that are present in all of the possible MM calculators.
111  template<typename CalculatorType>
112  void eliminateSharedInteractionTerms(bool electrostaticEmbedding, CalculatorType& calculator);
113 
114  // Enables all of the shared interaction terms that are present in all of the possible MM calculators.
115  template<typename CalculatorType>
116  void enableSharedInteractionTerms(CalculatorType& calculator);
117 
118  // Hash table containing the indices of the atoms in the QM region.
119  std::unordered_set<int> qmAtoms_;
120 
121  // The MM calculator
122  std::shared_ptr<MolecularMechanics::MolecularMechanicsCalculator> calculator_;
123 
124  // Boolean to keep track of whether we are in a reduced QM/MM energy calculation.
125  bool eliminateEnvironmentOnlyTerms_ = false;
126 };
127 
128 } // namespace Qmmm
129 } // namespace Scine
130 
131 #endif // SWOOSE_QMMM_INTERACTIONTERMELIMINATOR_H
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:38
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:163