Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
MockQmCalculator.h
Go to the documentation of this file.
1 
8 #ifndef SWOOSE_MOCK_QMCALCULATOR_H
9 #define SWOOSE_MOCK_QMCALCULATOR_H
10 
15 #include <Utils/Settings.h>
18 
19 namespace Scine {
20 namespace Swoose {
21 
22 namespace SettingsNames {
23 static constexpr const char* mockIntSettingKey = "mock_int_setting";
24 static constexpr const char* mockStringSettingKey = "mock_string_setting";
25 } // namespace SettingsNames
26 
29  public:
30  MockQmCalculatorSettings() : Utils::Settings("MockQmCalculatorSettings") {
31  Utils::UniversalSettings::IntDescriptor mockIntSetting("Mock integer setting.");
32  mockIntSetting.setDefaultValue(42);
33  _fields.push_back(SettingsNames::mockIntSettingKey, std::move(mockIntSetting));
34 
35  Utils::UniversalSettings::StringDescriptor mockStringSetting("Mock string setting.");
36  mockStringSetting.setDefaultValue("test");
37  _fields.push_back(SettingsNames::mockStringSettingKey, std::move(mockStringSetting));
38 
39  Utils::UniversalSettings::IntDescriptor spinMultiplicity("Spin multiplicity.");
40  spinMultiplicity.setDefaultValue(1);
41  _fields.push_back(Utils::SettingsNames::spinMultiplicity, std::move(spinMultiplicity));
42 
43  Utils::UniversalSettings::IntDescriptor molecularCharge("Molecular charge.");
44  molecularCharge.setDefaultValue(0);
45  _fields.push_back(Utils::SettingsNames::molecularCharge, std::move(molecularCharge));
46 
47  Utils::UniversalSettings::StringDescriptor method("The applied method.");
48  method.setDefaultValue("MOCK-QM");
49  _fields.push_back(Utils::SettingsNames::method, std::move(method));
50 
51  resetToDefaults();
52  }
53 };
54 
56 class MockQmCalculator final : public Utils::CloneInterface<MockQmCalculator, Core::Calculator, Core::Calculator> {
57  public:
58  static constexpr const char* model = "MOCK-QM";
62  ~MockQmCalculator() final = default;
69  void setStructure(const Utils::AtomCollection& structure) override;
74  std::unique_ptr<Utils::AtomCollection> getStructure() const override;
79  void modifyPositions(Utils::PositionCollection newPositions) override;
83  const Utils::PositionCollection& getPositions() const override;
89  void setRequiredProperties(const Utils::PropertyList& requiredProperties) override;
99  Utils::PropertyList possibleProperties() const override;
108  const Utils::Results& calculate(std::string description) override;
113  std::string name() const override;
118  Utils::Settings& settings() override;
123  const Utils::Settings& settings() const override;
128  std::shared_ptr<Core::State> getState() const final;
133  void loadState(std::shared_ptr<Core::State> state) final;
138  Utils::Results& results() override;
143  const Utils::Results& results() const override;
147  std::string getFileNameBase() const;
151  std::string getCalculationDirectory() const;
157  bool supportsMethodFamily(const std::string& methodFamily) const override;
162  bool allowsPythonGILRelease() const override {
163  return true;
164  };
165 
166  private:
167  /*
168  * @brief Apply settings.
169  */
170  void applySettings();
171  // The settings.
172  std::unique_ptr<Utils::Settings> settings_;
173  // The results.
174  Utils::Results results_;
175  // The required properties.
176  Utils::PropertyList requiredProperties_;
177  // The molecular structure.
178  Utils::AtomCollection structure_;
179  // An integer setting.
180  int intSetting_;
181  // A string setting.
182  std::string stringSetting_;
183 };
184 
185 } // namespace Swoose
186 } // namespace Scine
187 
188 #endif // SWOOSE_MOCK_QMCALCULATOR_H
Utils::PropertyList possibleProperties() const override
Returns the list of the possible properties to calculate analytically. By some method analytical hess...
Definition: MockQmCalculator.cpp:69
const Utils::PositionCollection & getPositions() const override
Getter for the coordinates of the underlying AtomCollection.
Definition: MockQmCalculator.cpp:57
Mock class for a QM calculator to use in QM/MM tests.
Definition: MockQmCalculator.h:56
bool allowsPythonGILRelease() const override
Whether the calculator has no underlying Python code and can therefore release the global interpreter...
Definition: MockQmCalculator.h:162
std::unique_ptr< Utils::AtomCollection > getStructure() const override
Gets the molecular structure as a std::unique_ptr&lt;AtomCollection&gt;.
Definition: MockQmCalculator.cpp:49
Utils::Results & results() override
Accessor for the saved instance of Results.
Definition: MockQmCalculator.cpp:123
bool supportsMethodFamily(const std::string &methodFamily) const override
Whether the calculator supports a method family.
Definition: MockQmCalculator.cpp:17
Utils::Settings & settings() override
Accessor for the settings.
Definition: MockQmCalculator.cpp:107
const Utils::Results & calculate(std::string description) override
The main function running calculations (dummy).
Definition: MockQmCalculator.cpp:73
std::shared_ptr< Core::State > getState() const final
Implements Core::StateHandableObject::getState().
Definition: MockQmCalculator.cpp:111
~MockQmCalculator() final=default
Default Destructor.
MockQmCalculator()
Default Constructor.
Definition: MockQmCalculator.cpp:21
std::string getCalculationDirectory() const
Getter for the calculation directory.
Mocks the settings for the mock QM calculator.
Definition: MockQmCalculator.h:28
void setRequiredProperties(const Utils::PropertyList &requiredProperties) override
Sets the properties to calculate.
Definition: MockQmCalculator.cpp:61
std::string name() const override
Getter for the name of the Calculator.
Definition: MockQmCalculator.cpp:13
std::string getFileNameBase() const
Getter for the file name base string.
void loadState(std::shared_ptr< Core::State > state) final
Implements Core::StateHandableObject::loadState().
Definition: MockQmCalculator.cpp:115
void setStructure(const Utils::AtomCollection &structure) override
Changes the molecular structure to calculate.
Definition: MockQmCalculator.cpp:44
void modifyPositions(Utils::PositionCollection newPositions) override
Allows to modify the positions of the underlying AtomCollection.
Definition: MockQmCalculator.cpp:53
Utils::PropertyList getRequiredProperties() const override
Getter for the properties to calculate.
Definition: MockQmCalculator.cpp:65