[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 |
|
---|
[6829d2] | 112 | // nuclei positions, atomic numbers and charges
|
---|
[cd77fc] | 113 | std::vector< std::vector<double> > positions;
|
---|
[6829d2] | 114 | std::vector< unsigned int > atomicnumbers;
|
---|
[cd77fc] | 115 | std::vector<double> charges;
|
---|
| 116 |
|
---|
[a9558f] | 117 | /// Timing structure
|
---|
| 118 | struct times_t {
|
---|
| 119 | /** Constructor for struct times_t, sets all to zero.
|
---|
| 120 | *
|
---|
| 121 | */
|
---|
| 122 | times_t();
|
---|
| 123 |
|
---|
[4aee30] | 124 | double total_walltime;
|
---|
| 125 | double total_cputime;
|
---|
| 126 | double total_flops;
|
---|
| 127 | double gather_walltime;
|
---|
| 128 | double gather_cputime;
|
---|
| 129 | double gather_flops;
|
---|
[a9558f] | 130 | } times;
|
---|
| 131 |
|
---|
[9ff818] | 132 | //!> reached (relative) accuracy
|
---|
| 133 | double accuracy;
|
---|
| 134 | //!> desired accuracy
|
---|
| 135 | double desired_accuracy;
|
---|
| 136 |
|
---|
[cc276e] | 137 | private:
|
---|
| 138 | friend class boost::serialization::access;
|
---|
| 139 | // serialization
|
---|
| 140 | template <typename Archive>
|
---|
| 141 | void serialize(Archive& ar, const unsigned int version)
|
---|
| 142 | {
|
---|
[a9558f] | 143 | ar & energies.total;
|
---|
| 144 | ar & energies.nuclear_repulsion;
|
---|
[adccae] | 145 | ar & energies.electron_coulomb;
|
---|
| 146 | ar & energies.electron_exchange;
|
---|
[a9558f] | 147 | ar & energies.correlation;
|
---|
| 148 | ar & energies.overlap;
|
---|
| 149 | ar & energies.kinetic;
|
---|
| 150 | ar & energies.hcore;
|
---|
[188639] | 151 | ar & energies.eigenvalues;
|
---|
[20bb3b] | 152 | if (version < 2) {
|
---|
| 153 | FragmentForces::forces_t justforces(forces);
|
---|
| 154 | ar & justforces;
|
---|
| 155 | dynamic_cast<FragmentForces::forces_t &>(forces) = justforces;
|
---|
| 156 | } else
|
---|
| 157 | ar & forces;
|
---|
[28c025] | 158 | ar & sampled_grid;
|
---|
[503acc1] | 159 | ar & DoLongrange;
|
---|
[6ff62c] | 160 | if (version > 0)
|
---|
| 161 | ar & DoValenceOnly;
|
---|
[cd77fc] | 162 | ar & positions;
|
---|
| 163 | ar & charges;
|
---|
[6829d2] | 164 | if (version > 3)
|
---|
| 165 | ar & atomicnumbers;
|
---|
[4aee30] | 166 | ar & times.total_walltime;
|
---|
| 167 | ar & times.total_cputime;
|
---|
| 168 | ar & times.total_flops;
|
---|
| 169 | ar & times.gather_walltime;
|
---|
| 170 | ar & times.gather_cputime;
|
---|
| 171 | ar & times.gather_flops;
|
---|
[9ff818] | 172 | if (version > 2) {
|
---|
| 173 | ar & accuracy;
|
---|
| 174 | ar & desired_accuracy;
|
---|
| 175 | }
|
---|
[cc276e] | 176 | }
|
---|
| 177 | };
|
---|
| 178 |
|
---|
[6829d2] | 179 | BOOST_CLASS_VERSION(MPQCData, 4)
|
---|
[6ff62c] | 180 |
|
---|
[509014] | 181 | std::ostream & operator<<(std::ostream &ost, const MPQCData &data);
|
---|
| 182 |
|
---|
[4bc75d] | 183 | #endif /* MPQCDATA_HPP_ */
|
---|