| [cc276e] | 1 | /*
 | 
|---|
| [4bc75d] | 2 |  * MPQCData.hpp
 | 
|---|
| [cc276e] | 3 |  *
 | 
|---|
 | 4 |  *  Created on: Feb 08, 2012
 | 
|---|
 | 5 |  *      Author: heber
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
| [4bc75d] | 8 | #ifndef MPQCDATA_HPP_
 | 
|---|
 | 9 | #define MPQCDATA_HPP_
 | 
|---|
| [cc276e] | 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>
 | 
|---|
| [a2a2f7] | 18 | #include <boost/serialization/version.hpp>
 | 
|---|
| [cc276e] | 19 | 
 | 
|---|
| [509014] | 20 | #include <iosfwd>
 | 
|---|
| [cc276e] | 21 | #include <vector>
 | 
|---|
 | 22 | 
 | 
|---|
| [fbf143] | 23 | #include "Fragmentation/Summation/SetValues/SamplingGrid.hpp"
 | 
|---|
| [20bb3b] | 24 | #include "Fragmentation/Summation/SetValues/FragmentForces.hpp"
 | 
|---|
| [28c025] | 25 | 
 | 
|---|
| [cc276e] | 26 | class MPQCCommandJob;
 | 
|---|
 | 27 | class MPQCCommandJobTest;
 | 
|---|
 | 28 | class MPQCDataTest;
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | /** Internal class that holds the data and can be serialized.
 | 
|---|
 | 31 |  *
 | 
|---|
 | 32 |  */
 | 
|---|
 | 33 | class MPQCData {
 | 
|---|
 | 34 |   //!> allow MPQCCommandJob access to member variables directly
 | 
|---|
 | 35 |   friend class MPQCCommandJob;
 | 
|---|
 | 36 |   //!> grant MPQCCommandJob's unit test access
 | 
|---|
 | 37 |   friend class MPQCCommandJobTest;
 | 
|---|
 | 38 |   //!> grant unit test access
 | 
|---|
 | 39 |   friend class MPQCDataTest;
 | 
|---|
| [509014] | 40 |   //!> grant access to output stream operator
 | 
|---|
 | 41 |   friend std::ostream & operator<<(std::ostream &ost, const MPQCData &data);
 | 
|---|
| [cc276e] | 42 | public:
 | 
|---|
| [28c025] | 43 |   /** Constructor for class MPQCData with full sampling information.
 | 
|---|
 | 44 |    *
 | 
|---|
 | 45 |    * \param _props properties of the grid
 | 
|---|
 | 46 |    */
 | 
|---|
 | 47 |   MPQCData(const SamplingGridProperties &_props);
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 |   /** Default Constructor for class MPQCData.
 | 
|---|
 | 50 |    *
 | 
|---|
 | 51 |    */
 | 
|---|
 | 52 |   MPQCData();
 | 
|---|
 | 53 | 
 | 
|---|
| [cc276e] | 54 |   bool operator==(const MPQCData &other) const;
 | 
|---|
 | 55 | 
 | 
|---|
 | 56 |   bool operator!=(const MPQCData &other) const {
 | 
|---|
 | 57 |     return !(*this == other);
 | 
|---|
 | 58 |   }
 | 
|---|
 | 59 | 
 | 
|---|
| [2ebfd7] | 60 |   /** Assignment operator with a downsampled grid.
 | 
|---|
 | 61 |    *
 | 
|---|
 | 62 |    * All values are taken over (with self-assignment check), but the grid
 | 
|---|
 | 63 |    * is sampled down to the desired \a _level (left untouched if larger
 | 
|---|
 | 64 |    * than grid level contained in \a other).
 | 
|---|
 | 65 |    *
 | 
|---|
 | 66 |    * \param instance instance to assign, containing desired grid and level
 | 
|---|
 | 67 |    * \param other instance to get values and grid from
 | 
|---|
 | 68 |    */
 | 
|---|
 | 69 |   static void assignWithDownsampledGrid(
 | 
|---|
 | 70 |       MPQCData &instance,
 | 
|---|
 | 71 |       const MPQCData &other);
 | 
|---|
 | 72 | 
 | 
|---|
| [a9558f] | 73 |   /// Energie structure
 | 
|---|
 | 74 |   struct energy_t {
 | 
|---|
 | 75 |     /** Constructor for struct energy_t, sets all to zero.
 | 
|---|
 | 76 |      *
 | 
|---|
 | 77 |      */
 | 
|---|
 | 78 |     energy_t();
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 |     double total;
 | 
|---|
 | 81 |     double nuclear_repulsion;
 | 
|---|
| [adccae] | 82 |     double electron_coulomb;
 | 
|---|
 | 83 |     double electron_exchange;
 | 
|---|
| [a9558f] | 84 |     double correlation;
 | 
|---|
 | 85 |     double overlap;
 | 
|---|
 | 86 |     double kinetic;
 | 
|---|
 | 87 |     double hcore;
 | 
|---|
| [188639] | 88 | 
 | 
|---|
 | 89 |     std::vector<double> eigenvalues;
 | 
|---|
| [a9558f] | 90 |   } energies;
 | 
|---|
| [cc276e] | 91 | 
 | 
|---|
| [a9558f] | 92 |   /// Forces
 | 
|---|
| [20bb3b] | 93 |   FragmentForces forces;
 | 
|---|
| [cc276e] | 94 | 
 | 
|---|
| [503acc1] | 95 |   //!> whether to actually sample the density
 | 
|---|
 | 96 |   enum DoLongrange_t {
 | 
|---|
 | 97 |     DontSampleDensity=0,
 | 
|---|
 | 98 |     DoSampleDensity=1
 | 
|---|
 | 99 |   };
 | 
|---|
 | 100 |   DoLongrange_t DoLongrange;
 | 
|---|
 | 101 | 
 | 
|---|
| [6ff62c] | 102 |   //!> whether to sample just the valence or the total electron and nuclei density
 | 
|---|
 | 103 |   enum DoValenceOnly_t {
 | 
|---|
 | 104 |     DontSampleValenceOnly=0,
 | 
|---|
 | 105 |     DoSampleValenceOnly=1
 | 
|---|
 | 106 |   };
 | 
|---|
 | 107 |   DoValenceOnly_t DoValenceOnly;
 | 
|---|
 | 108 | 
 | 
|---|
| [815f60] | 109 |   /// Density
 | 
|---|
| [28c025] | 110 |   SamplingGrid sampled_grid;
 | 
|---|
| [815f60] | 111 | 
 | 
|---|
| [cd77fc] | 112 |   // nuclei positions and charges
 | 
|---|
 | 113 |   std::vector< std::vector<double> > positions;
 | 
|---|
 | 114 |   std::vector<double> charges;
 | 
|---|
 | 115 | 
 | 
|---|
| [a9558f] | 116 |   /// Timing structure
 | 
|---|
 | 117 |   struct times_t {
 | 
|---|
 | 118 |     /** Constructor for struct times_t, sets all to zero.
 | 
|---|
 | 119 |      *
 | 
|---|
 | 120 |      */
 | 
|---|
 | 121 |     times_t();
 | 
|---|
 | 122 | 
 | 
|---|
| [4aee30] | 123 |     double total_walltime;
 | 
|---|
 | 124 |     double total_cputime;
 | 
|---|
 | 125 |     double total_flops;
 | 
|---|
 | 126 |     double gather_walltime;
 | 
|---|
 | 127 |     double gather_cputime;
 | 
|---|
 | 128 |     double gather_flops;
 | 
|---|
| [a9558f] | 129 |   } times;
 | 
|---|
 | 130 | 
 | 
|---|
| [9ff818] | 131 |   //!> reached (relative) accuracy
 | 
|---|
 | 132 |   double accuracy;
 | 
|---|
 | 133 |   //!> desired accuracy
 | 
|---|
 | 134 |   double desired_accuracy;
 | 
|---|
 | 135 | 
 | 
|---|
| [cc276e] | 136 | private:
 | 
|---|
 | 137 |   friend class boost::serialization::access;
 | 
|---|
 | 138 |   // serialization
 | 
|---|
 | 139 |   template <typename Archive>
 | 
|---|
 | 140 |   void serialize(Archive& ar, const unsigned int version)
 | 
|---|
 | 141 |   {
 | 
|---|
| [a9558f] | 142 |     ar & energies.total;
 | 
|---|
 | 143 |     ar & energies.nuclear_repulsion;
 | 
|---|
| [adccae] | 144 |     ar & energies.electron_coulomb;
 | 
|---|
 | 145 |     ar & energies.electron_exchange;
 | 
|---|
| [a9558f] | 146 |     ar & energies.correlation;
 | 
|---|
 | 147 |     ar & energies.overlap;
 | 
|---|
 | 148 |     ar & energies.kinetic;
 | 
|---|
 | 149 |     ar & energies.hcore;
 | 
|---|
| [188639] | 150 |     ar & energies.eigenvalues;
 | 
|---|
| [20bb3b] | 151 |     if (version < 2) {
 | 
|---|
 | 152 |       FragmentForces::forces_t justforces(forces);
 | 
|---|
 | 153 |       ar & justforces;
 | 
|---|
 | 154 |       dynamic_cast<FragmentForces::forces_t &>(forces) = justforces;
 | 
|---|
 | 155 |     } else
 | 
|---|
 | 156 |       ar & forces;
 | 
|---|
| [28c025] | 157 |     ar & sampled_grid;
 | 
|---|
| [503acc1] | 158 |     ar & DoLongrange;
 | 
|---|
| [6ff62c] | 159 |     if (version > 0)
 | 
|---|
 | 160 |       ar & DoValenceOnly;
 | 
|---|
| [cd77fc] | 161 |     ar & positions;
 | 
|---|
 | 162 |     ar & charges;
 | 
|---|
| [4aee30] | 163 |     ar & times.total_walltime;
 | 
|---|
 | 164 |     ar & times.total_cputime;
 | 
|---|
 | 165 |     ar & times.total_flops;
 | 
|---|
 | 166 |     ar & times.gather_walltime;
 | 
|---|
 | 167 |     ar & times.gather_cputime;
 | 
|---|
 | 168 |     ar & times.gather_flops;
 | 
|---|
| [9ff818] | 169 |     if (version > 2) {
 | 
|---|
 | 170 |       ar & accuracy;
 | 
|---|
 | 171 |       ar & desired_accuracy;
 | 
|---|
 | 172 |     }
 | 
|---|
| [cc276e] | 173 |   }
 | 
|---|
 | 174 | };
 | 
|---|
 | 175 | 
 | 
|---|
| [9ff818] | 176 | BOOST_CLASS_VERSION(MPQCData, 3)
 | 
|---|
| [6ff62c] | 177 | 
 | 
|---|
| [509014] | 178 | std::ostream & operator<<(std::ostream &ost, const MPQCData &data);
 | 
|---|
 | 179 | 
 | 
|---|
| [4bc75d] | 180 | #endif /* MPQCDATA_HPP_ */
 | 
|---|