| 1 | /*
 | 
|---|
| 2 |  * MPQCData.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: Feb 08, 2012
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #ifndef MPQCDATA_HPP_
 | 
|---|
| 9 | #define MPQCDATA_HPP_
 | 
|---|
| 10 | 
 | 
|---|
| 11 | // include config.h
 | 
|---|
| 12 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 13 | #include <config.h>
 | 
|---|
| 14 | #endif
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include <boost/serialization/access.hpp>
 | 
|---|
| 17 | #include <boost/serialization/vector.hpp>
 | 
|---|
| 18 | #include <boost/serialization/version.hpp>
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include <iosfwd>
 | 
|---|
| 21 | #include <vector>
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #include "Fragmentation/Summation/SetValues/SamplingGrid.hpp"
 | 
|---|
| 24 | 
 | 
|---|
| 25 | class MPQCCommandJob;
 | 
|---|
| 26 | class MPQCCommandJobTest;
 | 
|---|
| 27 | class MPQCDataTest;
 | 
|---|
| 28 | 
 | 
|---|
| 29 | /** Internal class that holds the data and can be serialized.
 | 
|---|
| 30 |  *
 | 
|---|
| 31 |  */
 | 
|---|
| 32 | class MPQCData {
 | 
|---|
| 33 |   //!> allow MPQCCommandJob access to member variables directly
 | 
|---|
| 34 |   friend class MPQCCommandJob;
 | 
|---|
| 35 |   //!> grant MPQCCommandJob's unit test access
 | 
|---|
| 36 |   friend class MPQCCommandJobTest;
 | 
|---|
| 37 |   //!> grant unit test access
 | 
|---|
| 38 |   friend class MPQCDataTest;
 | 
|---|
| 39 |   //!> grant access to output stream operator
 | 
|---|
| 40 |   friend std::ostream & operator<<(std::ostream &ost, const MPQCData &data);
 | 
|---|
| 41 | public:
 | 
|---|
| 42 |   /** Constructor for class MPQCData with full sampling information.
 | 
|---|
| 43 |    *
 | 
|---|
| 44 |    * \param _props properties of the grid
 | 
|---|
| 45 |    */
 | 
|---|
| 46 |   MPQCData(const SamplingGridProperties &_props);
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   /** Default Constructor for class MPQCData.
 | 
|---|
| 49 |    *
 | 
|---|
| 50 |    */
 | 
|---|
| 51 |   MPQCData();
 | 
|---|
| 52 | 
 | 
|---|
| 53 |   bool operator==(const MPQCData &other) const;
 | 
|---|
| 54 | 
 | 
|---|
| 55 |   bool operator!=(const MPQCData &other) const {
 | 
|---|
| 56 |     return !(*this == other);
 | 
|---|
| 57 |   }
 | 
|---|
| 58 | 
 | 
|---|
| 59 |   /// Energie structure
 | 
|---|
| 60 |   struct energy_t {
 | 
|---|
| 61 |     /** Constructor for struct energy_t, sets all to zero.
 | 
|---|
| 62 |      *
 | 
|---|
| 63 |      */
 | 
|---|
| 64 |     energy_t();
 | 
|---|
| 65 | 
 | 
|---|
| 66 |     double total;
 | 
|---|
| 67 |     double nuclear_repulsion;
 | 
|---|
| 68 |     double electron_coulomb;
 | 
|---|
| 69 |     double electron_exchange;
 | 
|---|
| 70 |     double correlation;
 | 
|---|
| 71 |     double overlap;
 | 
|---|
| 72 |     double kinetic;
 | 
|---|
| 73 |     double hcore;
 | 
|---|
| 74 | 
 | 
|---|
| 75 |     std::vector<double> eigenvalues;
 | 
|---|
| 76 |   } energies;
 | 
|---|
| 77 | 
 | 
|---|
| 78 |   /// Forces
 | 
|---|
| 79 |   typedef std::vector<double> vector_type;
 | 
|---|
| 80 |   std::vector< vector_type  > forces;
 | 
|---|
| 81 | 
 | 
|---|
| 82 |   //!> whether to actually sample the density
 | 
|---|
| 83 |   enum DoLongrange_t {
 | 
|---|
| 84 |     DontSampleDensity=0,
 | 
|---|
| 85 |     DoSampleDensity=1
 | 
|---|
| 86 |   };
 | 
|---|
| 87 |   DoLongrange_t DoLongrange;
 | 
|---|
| 88 | 
 | 
|---|
| 89 |   //!> whether to sample just the valence or the total electron and nuclei density
 | 
|---|
| 90 |   enum DoValenceOnly_t {
 | 
|---|
| 91 |     DontSampleValenceOnly=0,
 | 
|---|
| 92 |     DoSampleValenceOnly=1
 | 
|---|
| 93 |   };
 | 
|---|
| 94 |   DoValenceOnly_t DoValenceOnly;
 | 
|---|
| 95 | 
 | 
|---|
| 96 |   /// Density
 | 
|---|
| 97 |   SamplingGrid sampled_grid;
 | 
|---|
| 98 | 
 | 
|---|
| 99 |   // nuclei positions and charges
 | 
|---|
| 100 |   std::vector< std::vector<double> > positions;
 | 
|---|
| 101 |   std::vector<double> charges;
 | 
|---|
| 102 | 
 | 
|---|
| 103 |   /// Timing structure
 | 
|---|
| 104 |   struct times_t {
 | 
|---|
| 105 |     /** Constructor for struct times_t, sets all to zero.
 | 
|---|
| 106 |      *
 | 
|---|
| 107 |      */
 | 
|---|
| 108 |     times_t();
 | 
|---|
| 109 | 
 | 
|---|
| 110 |     double total_walltime;
 | 
|---|
| 111 |     double total_cputime;
 | 
|---|
| 112 |     double total_flops;
 | 
|---|
| 113 |     double gather_walltime;
 | 
|---|
| 114 |     double gather_cputime;
 | 
|---|
| 115 |     double gather_flops;
 | 
|---|
| 116 |   } times;
 | 
|---|
| 117 | 
 | 
|---|
| 118 | private:
 | 
|---|
| 119 |   friend class boost::serialization::access;
 | 
|---|
| 120 |   // serialization
 | 
|---|
| 121 |   template <typename Archive>
 | 
|---|
| 122 |   void serialize(Archive& ar, const unsigned int version)
 | 
|---|
| 123 |   {
 | 
|---|
| 124 |     ar & energies.total;
 | 
|---|
| 125 |     ar & energies.nuclear_repulsion;
 | 
|---|
| 126 |     ar & energies.electron_coulomb;
 | 
|---|
| 127 |     ar & energies.electron_exchange;
 | 
|---|
| 128 |     ar & energies.correlation;
 | 
|---|
| 129 |     ar & energies.overlap;
 | 
|---|
| 130 |     ar & energies.kinetic;
 | 
|---|
| 131 |     ar & energies.hcore;
 | 
|---|
| 132 |     ar & energies.eigenvalues;
 | 
|---|
| 133 |     ar & forces;
 | 
|---|
| 134 |     ar & sampled_grid;
 | 
|---|
| 135 |     ar & DoLongrange;
 | 
|---|
| 136 |     if (version > 0)
 | 
|---|
| 137 |       ar & DoValenceOnly;
 | 
|---|
| 138 |     ar & positions;
 | 
|---|
| 139 |     ar & charges;
 | 
|---|
| 140 |     ar & times.total_walltime;
 | 
|---|
| 141 |     ar & times.total_cputime;
 | 
|---|
| 142 |     ar & times.total_flops;
 | 
|---|
| 143 |     ar & times.gather_walltime;
 | 
|---|
| 144 |     ar & times.gather_cputime;
 | 
|---|
| 145 |     ar & times.gather_flops;
 | 
|---|
| 146 |   }
 | 
|---|
| 147 | };
 | 
|---|
| 148 | 
 | 
|---|
| 149 | BOOST_CLASS_VERSION(MPQCData, 1)
 | 
|---|
| 150 | 
 | 
|---|
| 151 | std::ostream & operator<<(std::ostream &ost, const MPQCData &data);
 | 
|---|
| 152 | 
 | 
|---|
| 153 | #endif /* MPQCDATA_HPP_ */
 | 
|---|