| 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 "Jobs/Grid/SamplingGrid.hpp" | 
|---|
| 22 | #include "Jobs/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 | */ | 
|---|
| 43 | VMGJob(const JobId_t _JobId, | 
|---|
| 44 | const SamplingGrid &density_grid, | 
|---|
| 45 | const std::vector< std::vector< double > > &_particle_positions, | 
|---|
| 46 | const std::vector< double > &_particle_charges, | 
|---|
| 47 | const size_t _near_field_cells); | 
|---|
| 48 | virtual ~VMGJob(); | 
|---|
| 49 |  | 
|---|
| 50 | FragmentResult::ptr Work(); | 
|---|
| 51 |  | 
|---|
| 52 | private: | 
|---|
| 53 | void InitVMG(); | 
|---|
| 54 |  | 
|---|
| 55 | void InitVMGArrays(); | 
|---|
| 56 |  | 
|---|
| 57 | private: | 
|---|
| 58 | //!> sampled density required as input | 
|---|
| 59 | const SamplingGrid density_grid; | 
|---|
| 60 | //!> positions of all nuclei | 
|---|
| 61 | const std::vector< std::vector< double > > particle_positions; | 
|---|
| 62 | //!> charges of all nuclei | 
|---|
| 63 | const std::vector< double > particle_charges; | 
|---|
| 64 | //!> near field cells used in smearing out core charge density | 
|---|
| 65 | const size_t near_field_cells; | 
|---|
| 66 |  | 
|---|
| 67 | private: | 
|---|
| 68 | //!> temporary instance to hold return data | 
|---|
| 69 | VMGData returndata; | 
|---|
| 70 |  | 
|---|
| 71 | //!> number of particles | 
|---|
| 72 | size_t num_particles; | 
|---|
| 73 | //!> forces array | 
|---|
| 74 | double *f; | 
|---|
| 75 | //!> position array | 
|---|
| 76 | double *x; | 
|---|
| 77 | //!> potential array | 
|---|
| 78 | double *p; | 
|---|
| 79 | //!> charge array | 
|---|
| 80 | double *q; | 
|---|
| 81 |  | 
|---|
| 82 | private: | 
|---|
| 83 | /** private default cstor for serialization only | 
|---|
| 84 | */ | 
|---|
| 85 | VMGJob(); | 
|---|
| 86 |  | 
|---|
| 87 | friend class boost::serialization::access; | 
|---|
| 88 | // serialization | 
|---|
| 89 | template <typename Archive> | 
|---|
| 90 | void serialize(Archive& ar, const unsigned int version) | 
|---|
| 91 | { | 
|---|
| 92 | ar & boost::serialization::base_object<FragmentJob>(*this); | 
|---|
| 93 | ar & const_cast< SamplingGrid &>(density_grid); | 
|---|
| 94 | ar & const_cast< std::vector< std::vector< double > > &>(particle_positions); | 
|---|
| 95 | ar & const_cast< std::vector< double > &>(particle_charges); | 
|---|
| 96 | ar & const_cast< size_t &>(near_field_cells); | 
|---|
| 97 | ar & returndata; | 
|---|
| 98 | } | 
|---|
| 99 | }; | 
|---|
| 100 |  | 
|---|
| 101 | // we need to give this class a unique key for serialization | 
|---|
| 102 | // its is only serialized through its base class FragmentJob | 
|---|
| 103 | BOOST_CLASS_EXPORT_KEY(VMGJob) | 
|---|
| 104 |  | 
|---|
| 105 | #endif /* VMGJOB_HPP_ */ | 
|---|