| 1 | /* | 
|---|
| 2 | * VMGJob.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Jul 12, 2012 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef VMGJOB_HPP_ | 
|---|
| 9 | #define VMGJOB_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 |  | 
|---|
| 12 | // include config.h | 
|---|
| 13 | #ifdef HAVE_CONFIG_H | 
|---|
| 14 | #include <config.h> | 
|---|
| 15 | #endif | 
|---|
| 16 |  | 
|---|
| 17 | #include "boost/serialization/export.hpp" | 
|---|
| 18 | #include "boost/serialization/vector.hpp" | 
|---|
| 19 |  | 
|---|
| 20 | #include "JobMarket/Jobs/FragmentJob.hpp" | 
|---|
| 21 | #include "Fragmentation/Summation/SetValues/SamplingGrid.hpp" | 
|---|
| 22 | #include "Fragmentation/Summation/Containers/VMGData.hpp" | 
|---|
| 23 |  | 
|---|
| 24 | #include <vector> | 
|---|
| 25 |  | 
|---|
| 26 | /** This class encapsulates a VMG Job. | 
|---|
| 27 | * | 
|---|
| 28 | *  VMGJob calculates the long-range contribution that is missed out so far in the | 
|---|
| 29 | *  MPQCJob where the SCF cycle is calculated. To this end | 
|---|
| 30 | * | 
|---|
| 31 | */ | 
|---|
| 32 | class VMGJob : public FragmentJob | 
|---|
| 33 | { | 
|---|
| 34 | public: | 
|---|
| 35 | /** Constructor for class VMGJob. | 
|---|
| 36 | * | 
|---|
| 37 | * @param _JobId id of the job | 
|---|
| 38 | * @param _density_grid sampled electron charge density from short-range solutions | 
|---|
| 39 | * @param _particle_positions position per nuclei | 
|---|
| 40 | * @param _particle_charges charges per nuclei | 
|---|
| 41 | * @param _near_field_cells number of grid-points used to smear our nuclei charge | 
|---|
| 42 | * @param _interpolation_degree degree of interpolation polynomial for getting nuclei | 
|---|
| 43 | *        potential from grid | 
|---|
| 44 | * @param _DoImportParticles whether we import particles (true) or evaluate only | 
|---|
| 45 | * @param _DoPrintDebug whether we do print grid for debug visualization or not | 
|---|
| 46 | * @param _OpenBoundaryConditions whether we have open (true) boundary conditions or periodic (false) | 
|---|
| 47 | * @param _DoSmearCharges whether to smear out electronic charge distributions with bsplines or not | 
|---|
| 48 | */ | 
|---|
| 49 | VMGJob(const JobId_t _JobId, | 
|---|
| 50 | const SamplingGrid &density_grid, | 
|---|
| 51 | const std::vector< std::vector< double > > &_particle_positions, | 
|---|
| 52 | const std::vector< double > &_particle_charges, | 
|---|
| 53 | const size_t _near_field_cells, | 
|---|
| 54 | const size_t _interpolation_degree, | 
|---|
| 55 | const bool _DoImportParticles=true, | 
|---|
| 56 | const bool _DoPrintDebug=false, | 
|---|
| 57 | const bool _OpenBoundaryConditions=false, | 
|---|
| 58 | const bool _DoSmearCharges=false | 
|---|
| 59 | ); | 
|---|
| 60 | virtual ~VMGJob(); | 
|---|
| 61 |  | 
|---|
| 62 | FragmentResult::ptr Work(); | 
|---|
| 63 |  | 
|---|
| 64 | private: | 
|---|
| 65 | void InitVMG(); | 
|---|
| 66 |  | 
|---|
| 67 | void InitVMGArrays(); | 
|---|
| 68 |  | 
|---|
| 69 | private: | 
|---|
| 70 | //!> sampled density required as input | 
|---|
| 71 | const SamplingGrid density_grid; | 
|---|
| 72 | //!> positions of all nuclei | 
|---|
| 73 | const std::vector< std::vector< double > > particle_positions; | 
|---|
| 74 | //!> charges of all nuclei | 
|---|
| 75 | const std::vector< double > particle_charges; | 
|---|
| 76 | //!> near field cells used in smearing out core charge density | 
|---|
| 77 | const size_t near_field_cells; | 
|---|
| 78 | //!> interpolation degree used in sampling the potential of the nuclei | 
|---|
| 79 | const size_t interpolation_degree; | 
|---|
| 80 | //!> whether we import particles (true) or evaluate only | 
|---|
| 81 | const bool DoImportParticles; | 
|---|
| 82 | //!> whether we do print grid for debug visualization or not | 
|---|
| 83 | const bool DoPrintDebug; | 
|---|
| 84 | //!> whether we have open (true) boundary conditions or periodic (false) | 
|---|
| 85 | const bool OpenBoundaryConditions; | 
|---|
| 86 | //!> whether to smear out electronic charge distributions with bsplines or not | 
|---|
| 87 | const bool DoSmearCharges; | 
|---|
| 88 |  | 
|---|
| 89 | private: | 
|---|
| 90 | //!> temporary instance to hold return data | 
|---|
| 91 | VMGData returndata; | 
|---|
| 92 |  | 
|---|
| 93 | /** This structure stores particle values per particle. | 
|---|
| 94 | * | 
|---|
| 95 | * \note This structure contains temporary information needed during solving | 
|---|
| 96 | * with VMG. | 
|---|
| 97 | * \warning It is specifically not serialized! | 
|---|
| 98 | * | 
|---|
| 99 | */ | 
|---|
| 100 | struct particle_arrays { | 
|---|
| 101 | particle_arrays(); | 
|---|
| 102 | ~particle_arrays(); | 
|---|
| 103 |  | 
|---|
| 104 | /** Initializes arrays. | 
|---|
| 105 | * | 
|---|
| 106 | * @param _num_particles size of array per dimension | 
|---|
| 107 | */ | 
|---|
| 108 | void init(const size_t _num_particles); | 
|---|
| 109 |  | 
|---|
| 110 | //!> number of particles | 
|---|
| 111 | size_t num_particles; | 
|---|
| 112 | //!> forces array | 
|---|
| 113 | double *f; | 
|---|
| 114 | //!> position array | 
|---|
| 115 | double *x; | 
|---|
| 116 | //!> potential array | 
|---|
| 117 | double *p; | 
|---|
| 118 | //!> charge array | 
|---|
| 119 | double *q; | 
|---|
| 120 | } particles; | 
|---|
| 121 |  | 
|---|
| 122 | private: | 
|---|
| 123 | /** private default cstor for serialization only | 
|---|
| 124 | */ | 
|---|
| 125 | VMGJob(); | 
|---|
| 126 |  | 
|---|
| 127 | friend class boost::serialization::access; | 
|---|
| 128 | // serialization | 
|---|
| 129 | template <typename Archive> | 
|---|
| 130 | void serialize(Archive& ar, const unsigned int version) | 
|---|
| 131 | { | 
|---|
| 132 | ar & boost::serialization::base_object<FragmentJob>(*this); | 
|---|
| 133 | ar & const_cast< SamplingGrid &>(density_grid); | 
|---|
| 134 | ar & const_cast< std::vector< std::vector< double > > &>(particle_positions); | 
|---|
| 135 | ar & const_cast< std::vector< double > &>(particle_charges); | 
|---|
| 136 | ar & const_cast< size_t &>(near_field_cells); | 
|---|
| 137 | ar & const_cast< size_t &>(interpolation_degree); | 
|---|
| 138 | ar & const_cast< bool &>(DoImportParticles); | 
|---|
| 139 | ar & const_cast< bool &>(DoPrintDebug); | 
|---|
| 140 | ar & const_cast< bool &>(OpenBoundaryConditions); | 
|---|
| 141 | ar & const_cast< bool &>(DoSmearCharges); | 
|---|
| 142 | ar & returndata; | 
|---|
| 143 | } | 
|---|
| 144 | }; | 
|---|
| 145 |  | 
|---|
| 146 | // we need to give this class a unique key for serialization | 
|---|
| 147 | // its is only serialized through its base class FragmentJob | 
|---|
| 148 | BOOST_CLASS_EXPORT_KEY(VMGJob) | 
|---|
| 149 |  | 
|---|
| 150 | #endif /* VMGJOB_HPP_ */ | 
|---|