Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
OptimizationSetup.h
Go to the documentation of this file.
1 
8 #ifndef MMPARAMETRIZATION_OPTIMIZATIONSETUP_H
9 #define MMPARAMETRIZATION_OPTIMIZATIONSETUP_H
10 
12 #include <Eigen/Core>
13 #include <memory>
14 #include <vector>
15 
16 namespace Scine {
17 
18 namespace Utils {
19 class Settings;
20 } // namespace Utils
21 
22 namespace MMParametrization {
23 struct ParametrizationData;
24 
30  public:
34  OptimizationSetup(ParametrizationData& data, std::shared_ptr<Utils::Settings> settings, Core::Log& log);
50  static double getInitialBondForceConstant();
54  static double getInitialAngleForceConstant();
59 
60  private:
61  /*
62  * @brief Converts a vector of atom indices to a vector of the positions of these atoms in
63  * a reasonable optimized fragment. The second argument is the number of indices from that
64  * given vector (starting from front) which should be used as initial candidate indices to build
65  * the vector of candidate fragments from which to take the reference data. For example, if the indices of
66  * an angle are {atom1, atom2, atom3} and numberOfInitialCandidateFragments is 2, atom1 and atom2 build
67  * the initial candidate fragments vector which is then updated by the FragmentDataDistributor class
68  * to include their neighbors.
69  */
70  std::vector<Eigen::RowVector3d> atomIndicesToPositions(std::vector<int> indices, int numberOfInitialCandidateFragments);
71  /*
72  * @brief Extracts all equilibrium values in the MM parameters from the reference structure.
73  */
74  void setEquilibriumValues();
75  /*
76  * @brief Adds atomic charges to the MM parameters.
77  */
78  void setAtomicCharges();
79  /*
80  * @brief Adds non-covalent parameters to the MM parameters.
81  */
82  void setNonCovalentParameters();
83  /*
84  * @brief Adds C6 parameters to the MM parameters.
85  */
86  void setC6Parameters();
87  /*
88  * @brief Adds periodicity and phase shift for dihedral angles to MM parameters.
89  */
90  void setConstantDihedralParameters();
91  /*
92  * @brief Creates the initial guess for the force constants and barrier heights.
93  */
94  void setInitialGuessForForceConstants();
95  /*
96  * @brief This function evaluates the mean value for a given parameter given a map containing the parameter types
97  * and their values as well as a current parameter type to consider.
98  */
99  template<typename M, typename T>
100  double getMeanValueForEquilibriumValue(const M& map, const T& parameterType) const;
101  // This function calculates the phase shift of a dihedral angle.
102  double getPhaseShift(int atom1, int atom2, int periodicity);
103  // This function calculates the periodicity of a dihedral angle.
104  int getPeriodicity(int atom1, int atom2) const;
105  // Greatest common denominator function.
106  int gcd(int n1, int n2) const;
107  // Constant value that is used for the force constants of improper dihedrals.
108  static constexpr double improperDihedralForceConstantForPlanarGroups_ = 50.0; // TODO: What is a good value?
109  // The data used within all MM parametrization classes
110  ParametrizationData& data_;
111  // The settings
112  std::shared_ptr<Utils::Settings> settings_;
113  // The logger.
114  Core::Log& log_;
115  // Pointer to an instance of the fragment data distributor class needed to find fragment candidates to get data from.
116  std::unique_ptr<FragmentDataDistributor> fragmentDataDistributor_;
117  // Initial force constant values
118  static constexpr double initialBondForceConstant_ = 700.0; // Unit: kcal/(mol*A^2)
119  static constexpr double initialAngleForceConstant_ = 120.0; // Unit: kcal/(mol*rad^2)
120  static constexpr double initialDihedralHalfBarrierHeight_ = 0.5; // Unit kcal/mol
121  // TODO: Does it make sense to start with 0.0?
122  static constexpr double initialImproperDihedralForceConstantForNonPlanarGroups_ = 0.0; // Unit: kcal/(mol*rad^2)
123  /*
124  * When a parameter is created, it does not get assigned an initial value
125  * for the force constant/half barrier height right away, but only in
126  * a later function. Therefore, this constant is introduced to keep
127  * track whether a correct initial value has been set already for
128  * a given parameter. This is important, because if a parameter already
129  * exists, we do not want to overwrite its value.
130  */
131  static constexpr double parameterValueInUninitializedState_ = -1.0;
132 };
133 
134 } // namespace MMParametrization
135 } // namespace Scine
136 
137 #endif // MMPARAMETRIZATION_OPTIMIZATIONSETUP_H
static double getInitialAngleForceConstant()
Getter for the initial value that is used for the force constants of angles.
Definition: OptimizationSetup.cpp:405
OptimizationSetup(ParametrizationData &data, std::shared_ptr< Utils::Settings > settings, Core::Log &log)
Constructor.
Definition: OptimizationSetup.cpp:27
void generateInitialParameters()
This function generates the initial MM parameters.
Definition: OptimizationSetup.cpp:32
static double getImproperDihedralForceConstantForPlanarGroups()
Getter for the constant value that is used for the force constants of improper dihedrals.
Definition: OptimizationSetup.cpp:393
static double getInitialDihedralHalfBarrierHeight()
Getter for the initial value that is used for the force constants of dihedral angles.
Definition: OptimizationSetup.cpp:401
static double getInitialBondForceConstant()
Getter for the initial value that is used for the force constants of bonds.
Definition: OptimizationSetup.cpp:409
static double getInitialImproperDihedralForceConstantForNonPlanarGroups()
Getter for the initial value that is used for the force constants of improper dihedrals of non-planar...
Definition: OptimizationSetup.cpp:397
This struct holds all objects used inside the MM parametrization algorithm.
Definition: ParametrizationData.h:29
This class sets up the initial MM parameters. The force constants will be optimized after that...
Definition: OptimizationSetup.h:29