Scine::Swoose  1.0.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
QmmmCalculator.h
Go to the documentation of this file.
1 
8 #ifndef SWOOSE_QMMM_QMMMCALCULATOR_H
9 #define SWOOSE_QMMM_QMMMCALCULATOR_H
10 
12 #include <Utils/CalculatorBasics.h>
14 
15 namespace Scine {
16 
17 namespace MolecularMechanics {
18 class MolecularMechanicsCalculator;
19 } // namespace MolecularMechanics
20 
21 namespace Qmmm {
22 
36 class QmmmCalculator : public Utils::CloneInterface<QmmmCalculator, Core::Calculator> {
37  public:
38  static constexpr const char* model = "QM-SFAM";
42  ~QmmmCalculator() override;
44  QmmmCalculator(const QmmmCalculator& rhs);
48  void setUnderlyingCalculators(std::shared_ptr<Core::Calculator> qmCalculator, std::shared_ptr<Core::Calculator> mmCalculator);
53  void setStructure(const Utils::AtomCollection& structure) override;
58  std::unique_ptr<Utils::AtomCollection> getStructure() const override;
63  void modifyPositions(Utils::PositionCollection newPositions) override;
67  const Utils::PositionCollection& getPositions() const override;
73  void setRequiredProperties(const Utils::PropertyList& requiredProperties) override;
81  Utils::PropertyList possibleProperties() const override;
90  const Utils::Results& calculate(std::string description) override;
95  std::string name() const override;
100  Utils::Settings& settings() override;
105  const Utils::Settings& settings() const override;
110  Utils::Results& results() override;
115  const Utils::Results& results() const override;
121  bool supportsMethodFamily(const std::string& methodFamily) const override;
126  std::shared_ptr<Core::State> getState() const final;
131  void loadState(std::shared_ptr<Core::State> /*state*/) final;
132 
133  private:
134  /*
135  * @brief Implementation of a calculation.
136  */
137  const Utils::Results& calculateImpl(std::string description);
138  /*
139  * @brief Implementation of a calculation where the QM calculation is not performed.
140  */
141  const Utils::Results& ignoreQmCalculateImpl(std::string description);
142  /*
143  * @brief Apply settings.
144  */
145  void applySettings();
146  /*
147  * @brief Apply settings to underlying calculators (QM and MM).
148  */
149  void applySettingsToUnderlyingCalculators();
150  /*
151  * @brief Eliminates those terms from the MM calculator which shall not be calculated at the MM level,
152  * but at the QM level instead.
153  * @param reducedEnergyCalculation Whether the current calculation is part of a
154  * reduced QM/MM energy evaluation. Default: It is not.
155  */
156  void prepareTermsForMmCalculator(bool reducedEnergyCalculation = false);
157  /*
158  * @brief Sets the current log of this calculator to the underlying QM and MM calculators.
159  */
160  void setLogForUnderlyingCalculators();
161  // The required properties.
162  Utils::PropertyList requiredProperties_;
163  // The settings.
164  std::unique_ptr<Utils::Settings> settings_;
165  // The results container.
166  Utils::Results results_;
167  // The structure of the full system
168  Utils::AtomCollection structure_;
169  // The structure of the QM region
170  Utils::AtomCollection qmRegion_;
171  // Vector containing the indices of the MM atoms close to the boundary (part of a cleft bond)
172  std::vector<int> mmBoundaryAtoms_;
173  // Vector containing the indices of the atoms in the QM region
174  std::vector<int> listOfQmAtoms_;
175  // QM calculator
176  std::shared_ptr<Core::Calculator> qmCalculator_;
177  /*
178  * Whether an additional MM calculation is performed to evaluate the QM/MM energy
179  * without any covalent and non-covalent contributions solely within the environment
180  */
181  bool calculateReducedQmMmEnergy_;
182  // MM calculator
183  std::shared_ptr<MolecularMechanics::MolecularMechanicsCalculator> mmCalculator_;
184  // Whether electrostatic embedding shall be used (otherwise just mechanical embedding)
185  bool electrostaticEmbedding_;
186  // Whether to not perform the QM calculation.
187  bool ignoreQm_;
188  // File to which the QM region is written in XYZ format
189  std::string qmRegionFile_;
190  // The scheme for how to redistribute the charges close to the QM-MM boundary
191  std::string chargeRedistributionScheme_;
192  // Name of the ORCA point charges file
193  static constexpr const char* pointChargesFilename_ = "environment_pointcharges.pc";
194  /*
195  * The following boolean keeps track of whether the SCF convergence setting for the QM calculator was already set,
196  * because resetting it with every calculation (e.g., as part of an optimization) will result in a repeated
197  * warning with some calculators (e.g., ORCA). The reason is that some calculators reset this setting internally
198  * After calling setStructure(), this boolean will be reset to false again.
199  *
200  * Important note: This means that if one wants to reset the setting externally, setStructure() has to be recalled
201  * so that the setting is passed on to the QM calculator.
202  */
203  bool scfConvCriterionIsSet_ = false;
204 };
205 
206 } // namespace Qmmm
207 } // namespace Scine
208 
209 #endif // SWOOSE_QMMM_QMMMCALCULATOR_H
bool supportsMethodFamily(const std::string &methodFamily) const override
Whether the calculator supports a method family.
Definition: QmmmCalculator.cpp:26
Calculator implementing the QM/MM method.
Definition: QmmmCalculator.h:36
const Utils::PositionCollection & getPositions() const override
Getter for the coordinates of the underlying Utils::AtomCollection.
Definition: QmmmCalculator.cpp:215
void setStructure(const Utils::AtomCollection &structure) override
Changes the molecular structure to calculate.
Definition: QmmmCalculator.cpp:102
void loadState(std::shared_ptr< Core::State >) final
Implements Core::StateHandableObject::loadState().
Definition: QmmmCalculator.cpp:262
QmmmCalculator()
Constructor.
Definition: QmmmCalculator.cpp:30
Utils::Settings & settings() override
Accessor for the settings.
Definition: QmmmCalculator.cpp:250
Utils::PropertyList possibleProperties() const override
Returns the list of the possible properties to calculate.
Definition: QmmmCalculator.cpp:242
Utils::PropertyList getRequiredProperties() const override
Getter for the properties to calculate.
Definition: QmmmCalculator.cpp:238
~QmmmCalculator() override
Destructor.
Definition: QmmmCalculator.cpp:320
std::unique_ptr< Utils::AtomCollection > getStructure() const override
Gets the molecular structure as a const Utils::AtomCollection&amp;.
Definition: QmmmCalculator.cpp:191
std::string name() const override
Getter for the name of the Calculator.
Definition: QmmmCalculator.cpp:22
void setUnderlyingCalculators(std::shared_ptr< Core::Calculator > qmCalculator, std::shared_ptr< Core::Calculator > mmCalculator)
Sets the underlying QM and MM calculators.
Definition: QmmmCalculator.cpp:52
std::shared_ptr< Core::State > getState() const final
Implements Core::StateHandableObject::getState().
Definition: QmmmCalculator.cpp:266
const Utils::Results & calculate(std::string description) override
The main function running calculations.
Definition: QmmmCalculator.cpp:92
void setRequiredProperties(const Utils::PropertyList &requiredProperties) override
Sets the properties to calculate.
Definition: QmmmCalculator.cpp:219
Utils::Results & results() override
Accessor for the saved instance of Utils::Results.
Definition: QmmmCalculator.cpp:258
void modifyPositions(Utils::PositionCollection newPositions) override
Allows to modify the positions of the underlying Utils::AtomCollection.
Definition: QmmmCalculator.cpp:195