Scine::Swoose  2.1.0
This is the SCINE module Swoose.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
SubsystemGenerator.h
Go to the documentation of this file.
1 
8 #ifndef SWOOSEUTILITIES_SUBSYSTEMGENERATOR_H
9 #define SWOOSEUTILITIES_SUBSYSTEMGENERATOR_H
10 
11 #include <list>
12 #include <memory>
13 #include <random>
14 #include <vector>
15 
16 namespace Scine {
17 
18 namespace Core {
19 struct Log;
20 } // namespace Core
21 
22 namespace Utils {
23 class Atom;
24 class AtomCollection;
25 class BondOrderCollection;
26 } // namespace Utils
27 
28 namespace SwooseUtilities {
29 class FragmentAnalyzer;
30 
32  public:
45  SubsystemGenerator(const Utils::AtomCollection& fullStructure, const Utils::BondOrderCollection& bondOrders,
46  FragmentAnalyzer& fragmentAnalyzer, double bondOrderThreshold, int maximumSubsystemSize,
47  Core::Log& log, int randomSeed = 42, double probabilityToDivideBond = 1.0);
48 
59  Utils::AtomCollection generateSubsystem(int centralAtomIndex, std::vector<int>& atomIndexMapping, double subsystemRadius);
60 
61  private:
62  /*
63  * @brief Tries to update the given subsystem generating a guess for a sensible (in terms of charge and multiplicity)
64  * subsystem structure. All parameters except for the atom index are passed by reference or const reference.
65  *
66  * @param subsystem The current subsystem.
67  * @param centralAtom The atom in the center of the current subsystem (around which the fragment is build).
68  * @param atomIndex The index of the atom at the center of the current subsystem (also subsystem index).
69  * @param atomIndexMapping Vector of indices that correspond to the indices of the atoms
70  * inside the given fragment in the full system. It is given as a reference and updated.
71  * Therefore, it is usually provided to the function as an empty vector.
72  * @param subsystemRadius The initial radius of the sphere defining the subsystem.
73  * @param additionToRadius Variable extra amount that is added to the base subsystem radius and
74  * is updated whenever necessary.
75  * @param unsuccessful Boolean tracking whether the subsystem generation is still unsuccessful.
76  */
77  void tryGeneratingSensibleSubsystem(Utils::AtomCollection& subsystem, const Utils::Atom& centralAtom, int atomIndex,
78  std::vector<int>& atomIndexMapping, const double& subsystemRadius,
79  double& additionToRadius, bool& unsuccessful);
80  /*
81  * Vector of size N (number of atoms in the full system) with the following value for
82  * each atom: the size of the molecular subgraph (individual molecule) it is in.
83  */
84  std::vector<int> subgraphSizes_;
85  // The molecular structure of the whole system.
86  const Utils::AtomCollection& fullStructure_;
87  // Bond orders of the full system.
88  const Utils::BondOrderCollection& bondOrders_;
89  // The connectivity of the system. It is a vector of a list of neighbor atom indices for each atom.
90  std::vector<std::list<int>> listsOfNeighbors_;
91  // Fragment analyzer class reference
92  FragmentAnalyzer& fragmentAnalyzer_;
93  // Threshold of which bond order to still consider as a bond.
94  double bondOrderThreshold_;
95  // Maximum size of a subsystem. If a large subsystem is generated, a warning is printed.
96  int maximumSubsystemSize_;
97  // Random engine for non-deterministic fragment generation.
98  std::shared_ptr<std::mt19937> randomEngine_;
99  // Logger
100  Core::Log& log_;
101  // Probability to cleave a bond that is in principle cleavable.
102  double probabilityToDivideBond_;
103  // Maximum number of fragmentation attempts for one fragment before an exception is thrown
104  static constexpr int maxNumOfAttemptsForOneSubsystem_ = 100;
105 };
106 
107 } // namespace SwooseUtilities
108 } // namespace Scine
109 
110 #endif // SWOOSEUTILITIES_SUBSYSTEMGENERATOR_H
Definition: SubsystemGenerator.h:31
SubsystemGenerator(const Utils::AtomCollection &fullStructure, const Utils::BondOrderCollection &bondOrders, FragmentAnalyzer &fragmentAnalyzer, double bondOrderThreshold, int maximumSubsystemSize, Core::Log &log, int randomSeed=42, double probabilityToDivideBond=1.0)
Constructor.
Definition: SubsystemGenerator.cpp:30
Definition: FragmentAnalyzer.h:22
Utils::AtomCollection generateSubsystem(int centralAtomIndex, std::vector< int > &atomIndexMapping, double subsystemRadius)
Generates a subsystem (fragment) from a given full system.
Definition: SubsystemGenerator.cpp:49