Chemical Data Processing Library C++ API - Version 1.4.0
MHMOPiChargeCalculator.hpp
Go to the documentation of this file.
1 /*
2  * MHMOPiChargeCalculator.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_MOLPROP_MHMOPICHARGECALCULATOR_HPP
30 #define CDPL_MOLPROP_MHMOPICHARGECALCULATOR_HPP
31 
32 #include <vector>
33 #include <cstddef>
34 #include <cstdint>
35 #include <memory>
36 
39 #include "CDPL/Math/Matrix.hpp"
40 #include "CDPL/Math/Vector.hpp"
41 #include "CDPL/Util/BitSet.hpp"
42 
43 
44 namespace CDPL
45 {
46 
47  namespace Chem
48  {
49 
50  class MolecularGraph;
51  class Bond;
52  } // namespace Chem
53 
54  namespace MolProp
55  {
56 
57  class PEOESigmaChargeCalculator;
58 
71  {
72 
73  public:
77  typedef std::shared_ptr<MHMOPiChargeCalculator> SharedPointer;
78 
83 
92 
100 
102 
107 
109 
114  void localizedPiBonds(bool localized);
115 
120  bool localizedPiBonds() const;
121 
126  void calculate(const Chem::MolecularGraph& molgraph);
127 
133  void calculate(const Chem::ElectronSystemList& pi_sys_list, const Chem::MolecularGraph& molgraph);
134 
141  double getElectronDensity(std::size_t atom_idx) const;
142 
149  double getCharge(std::size_t atom_idx) const;
150 
157  double getBondOrder(std::size_t bond_idx) const;
158 
163  double getEnergy() const;
164 
165  private:
166  void initAtomPiSysCounts(const Chem::ElectronSystemList& pi_sys_list, const Chem::MolecularGraph& molgraph);
167  void initAtomFreeElecCounts(const Chem::ElectronSystemList& pi_sys_list, const Chem::MolecularGraph& molgraph);
168 
169  void calcForPiSys(const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph);
170 
171  void initAtomPiElecCounts(const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph);
172 
173  std::size_t getNumBonds(const Chem::Atom& atom, const Chem::ElectronSystem& pi_sys,
174  const Chem::MolecularGraph& molgraph) const;
175 
176  void getInvolvedBonds(const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph);
177  void initHueckelMatrix(const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph);
178 
179  void calcSigmaCharges(const Chem::MolecularGraph& molgraph);
180  double getAlpha(const Chem::Atom& atom, const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph) const;
181  double getAlphaCorrection(const Chem::Atom& atom, const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph) const;
182  double getBeta(const Chem::Bond& bond, const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph) const;
183 
184  std::uint64_t getAtomID(const Chem::Atom& atom, const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph) const;
185  std::uint64_t getBondID(const Chem::Bond& bond, const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph) const;
186 
187  bool diagHueckelMatrix();
188  void distElectrons(const Chem::ElectronSystem& pi_sys);
189  void updateEnergy();
190  void updateAtomElecDensitiesAndCharges(const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph);
191  void updateBondElecDensities(const Chem::ElectronSystem& pi_sys, const Chem::MolecularGraph& molgraph);
192 
193  double calcElecDensity(std::size_t i, std::size_t j) const;
194 
195  struct MODescr
196  {
197 
198  double energy;
199  double coeffVecIndex;
200  double elecCount;
201  };
202 
203  typedef Math::Matrix<double> Matrix;
204  typedef Math::Vector<double> Vector;
205  typedef std::vector<const Chem::Bond*> BondList;
206  typedef std::vector<std::size_t> CountsArray;
207  typedef std::vector<double> DoubleArray;
208  typedef std::vector<MODescr> MODescrArray;
209  typedef std::vector<MODescr*> MODescrPtrArray;
210  typedef std::unique_ptr<PEOESigmaChargeCalculator> PEOECalculatorPtr;
211 
212  Matrix hueckelMatrix;
213  Matrix hmEigenVectors;
214  Vector hmEigenValues;
215  BondList piSysBonds;
216  CountsArray atomPiSysCounts;
217  CountsArray atomFreeElecCounts;
218  CountsArray atomPiElecCounts;
219  Util::BitSet specialAtomTypes;
220  MODescrArray moDescriptors;
221  MODescrPtrArray moDescriptorPtrs;
222  bool locPiBonds;
223  DoubleArray atomElecDensities;
224  DoubleArray bondElecDensities;
225  DoubleArray atomPiCharges;
226  double energy;
227  PEOECalculatorPtr peoeCalculatorPtr;
228  };
229  } // namespace MolProp
230 } // namespace CDPL
231 
232 #endif // CDPL_MOLPROP_MHMOPICHARGECALCULATOR_HPP
Declaration of type CDPL::Util::BitSet.
Definition of class CDPL::Chem::ElectronSystemList.
Definition of matrix data types.
Definition of the preprocessor macro CDPL_MOLPROP_API.
#define CDPL_MOLPROP_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of vector data types.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Abstract base class representing a chemical bond between two Chem::Atom instances.
Definition: Bond.hpp:54
Data structure for the storage of Chem::ElectronSystem objects.
Definition: ElectronSystemList.hpp:49
Describes an electron system of a molecule in terms of involved atoms and their electron contribution...
Definition: ElectronSystem.hpp:55
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Calculator that uses a Modified Hückel Molecular Orbital (MHMO) treatment to compute π-electron densi...
Definition: MHMOPiChargeCalculator.hpp:71
double getElectronDensity(std::size_t atom_idx) const
Returns the calculated π-electron density of the atom at index atom_idx.
void calculate(const Chem::MolecularGraph &molgraph)
Performs the MHMO calculation for molgraph, perceiving the π-electron systems on the fly.
double getBondOrder(std::size_t bond_idx) const
Returns the calculated π-bond order of the bond at index bond_idx.
void localizedPiBonds(bool localized)
Specifies whether the calculation shall use localized pi-bonds.
double getCharge(std::size_t atom_idx) const
Returns the calculated π-charge of the atom at index atom_idx.
MHMOPiChargeCalculator(const MHMOPiChargeCalculator &)=delete
void calculate(const Chem::ElectronSystemList &pi_sys_list, const Chem::MolecularGraph &molgraph)
Performs the MHMO calculation for the given π-electron systems of molgraph.
MHMOPiChargeCalculator(const Chem::ElectronSystemList &pi_sys_list, const Chem::MolecularGraph &molgraph)
Constructs the MHMOPiChargeCalculator instance and performs the MHMO calculation for the given π-elec...
MHMOPiChargeCalculator(const Chem::MolecularGraph &molgraph)
Constructs the MHMOPiChargeCalculator instance and performs the MHMO calculation for molgraph.
std::shared_ptr< MHMOPiChargeCalculator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MHMOPiChargeCalculator instances.
Definition: MHMOPiChargeCalculator.hpp:77
MHMOPiChargeCalculator()
Constructs the MHMOPiChargeCalculator instance.
MHMOPiChargeCalculator & operator=(const MHMOPiChargeCalculator &)=delete
bool localizedPiBonds() const
Tells whether the calculation uses localized π-bonds.
double getEnergy() const
Returns the total π-electron energy of the molecular graph from the last calculation.
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.