| 1 | /* | 
|---|
| 2 | * Particle.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: May 13, 2013 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef PARTICLE_HPP_ | 
|---|
| 9 | #define PARTICLE_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include <iosfwd> | 
|---|
| 17 | #include <string> | 
|---|
| 18 | #include <vector> | 
|---|
| 19 |  | 
|---|
| 20 | #include "types.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | class periodentafel; | 
|---|
| 23 |  | 
|---|
| 24 | class Particle | 
|---|
| 25 | { | 
|---|
| 26 | public: | 
|---|
| 27 | /** Constructor for class Particle. | 
|---|
| 28 | * | 
|---|
| 29 | * Chooses token as combination of element's symbol and a number such that name is | 
|---|
| 30 | * unique with registry. | 
|---|
| 31 | * | 
|---|
| 32 | * \param _periode reference to periodentafel for looking up element nr | 
|---|
| 33 | * \param _number atomic number of particle's element | 
|---|
| 34 | */ | 
|---|
| 35 | Particle(const periodentafel &_periode, const atomicNumber_t &_number); | 
|---|
| 36 |  | 
|---|
| 37 | /** Constructor for class Particle. | 
|---|
| 38 | * | 
|---|
| 39 | * \param _periode reference to periodentafel for looking up element nr | 
|---|
| 40 | * \param _token unique token/name of this particle | 
|---|
| 41 | * \param _number atomic number of particle's element | 
|---|
| 42 | */ | 
|---|
| 43 | Particle(const periodentafel &_periode, const std::string &_token, const atomicNumber_t &_number); | 
|---|
| 44 |  | 
|---|
| 45 | /** Destructor for class Particle. | 
|---|
| 46 | * | 
|---|
| 47 | */ | 
|---|
| 48 | ~Particle() {} | 
|---|
| 49 |  | 
|---|
| 50 | /** Getter for the name of this Particle. | 
|---|
| 51 | * | 
|---|
| 52 | * This function is required such that Particle's can be stored in a registry. | 
|---|
| 53 | * | 
|---|
| 54 | * \return name of particle | 
|---|
| 55 | */ | 
|---|
| 56 | const std::string& getName() const | 
|---|
| 57 | { return name; } | 
|---|
| 58 |  | 
|---|
| 59 | /** Returns the name of the element. | 
|---|
| 60 | * | 
|---|
| 61 | * \return name of the particle's element | 
|---|
| 62 | */ | 
|---|
| 63 | std::string getElement() const; | 
|---|
| 64 |  | 
|---|
| 65 | /** Print parameters to given stream \a ost. | 
|---|
| 66 | * | 
|---|
| 67 | * These are virtual functions to allow for overriding and hence | 
|---|
| 68 | * changing the default behavior. | 
|---|
| 69 | * | 
|---|
| 70 | * @param ost stream to print to | 
|---|
| 71 | */ | 
|---|
| 72 | void stream_to(std::ostream &ost) const; | 
|---|
| 73 |  | 
|---|
| 74 | /** Parse parameters from given stream \a ist. | 
|---|
| 75 | * | 
|---|
| 76 | * These are virtual functions to allow for overriding and hence | 
|---|
| 77 | * changing the default behavior. | 
|---|
| 78 | * | 
|---|
| 79 | * @param ist stream to parse from | 
|---|
| 80 | */ | 
|---|
| 81 | void stream_from(std::istream &ist); | 
|---|
| 82 |  | 
|---|
| 83 | private: | 
|---|
| 84 | //!> grant factory access to default cstor. | 
|---|
| 85 | friend class ParticleFactory; | 
|---|
| 86 |  | 
|---|
| 87 | /** Default constructor for class Particle. | 
|---|
| 88 | * | 
|---|
| 89 | * \warning default constructor is private to prevent Particle without a | 
|---|
| 90 | * unique name. | 
|---|
| 91 | * | 
|---|
| 92 | * \param _periode reference to periodentafel for looking up element nr | 
|---|
| 93 | */ | 
|---|
| 94 | Particle(const periodentafel &_periode); | 
|---|
| 95 |  | 
|---|
| 96 | /** Helper function to find index to a parameter name. | 
|---|
| 97 | * | 
|---|
| 98 | * \param name name of parameter to look up index for | 
|---|
| 99 | * \return index in ParameterNames or -1 if not found | 
|---|
| 100 | */ | 
|---|
| 101 | size_t lookupParameterName(const std::string &name) const; | 
|---|
| 102 |  | 
|---|
| 103 | /** Setter for the particle's element. | 
|---|
| 104 | * | 
|---|
| 105 | * \param element_name name of particle's element, must be known to periodentafel. | 
|---|
| 106 | */ | 
|---|
| 107 | void setElement(const std::string &element_name); | 
|---|
| 108 |  | 
|---|
| 109 | public: | 
|---|
| 110 |  | 
|---|
| 111 | /** Finds the next free token in the registry for the given element. | 
|---|
| 112 | * | 
|---|
| 113 | * \param _periode reference to periodentafel for looking up element nr | 
|---|
| 114 | * \param _number atomic number of particle's element | 
|---|
| 115 | * \return unique token for this element | 
|---|
| 116 | */ | 
|---|
| 117 | static std::string findFreeName( | 
|---|
| 118 | const periodentafel &_periode, | 
|---|
| 119 | const atomicNumber_t &_number); | 
|---|
| 120 |  | 
|---|
| 121 | //!> token/name of this particle | 
|---|
| 122 | const std::string name; | 
|---|
| 123 |  | 
|---|
| 124 | //!> reference to periodentafel to look up elements | 
|---|
| 125 | const periodentafel &periode; | 
|---|
| 126 |  | 
|---|
| 127 | //!> partial charge of this particle | 
|---|
| 128 | double charge; | 
|---|
| 129 | //!> (effective) mass of this particle | 
|---|
| 130 | double mass; | 
|---|
| 131 | //!> (effective) degrees of freedom | 
|---|
| 132 | unsigned int dof; | 
|---|
| 133 | //!> atomic number of the particle's element | 
|---|
| 134 | atomicNumber_t atomic_number; | 
|---|
| 135 |  | 
|---|
| 136 | // the following variables are due to convention in .potentials file | 
|---|
| 137 | double sigma; | 
|---|
| 138 | double epsilon; | 
|---|
| 139 | double sigma_14; | 
|---|
| 140 | double epsilon_14; | 
|---|
| 141 |  | 
|---|
| 142 | enum parameters_t { | 
|---|
| 143 | e_particle_type, | 
|---|
| 144 | e_element_name, | 
|---|
| 145 | e_sigma, | 
|---|
| 146 | e_epsilon, | 
|---|
| 147 | e_sigma_14, | 
|---|
| 148 | e_epsilon_14, | 
|---|
| 149 | e_mass, | 
|---|
| 150 | e_free, | 
|---|
| 151 | e_charge, | 
|---|
| 152 | MAXPARAMETERS | 
|---|
| 153 | }; | 
|---|
| 154 |  | 
|---|
| 155 | static const std::vector<std::string> ParameterNames; | 
|---|
| 156 | }; | 
|---|
| 157 |  | 
|---|
| 158 | /** Output stream operator for class Particle. | 
|---|
| 159 | * | 
|---|
| 160 | * \param ost output stream | 
|---|
| 161 | * \param p Particle instance | 
|---|
| 162 | */ | 
|---|
| 163 | std::ostream& operator<<(std::ostream &ost, const Particle &p); | 
|---|
| 164 |  | 
|---|
| 165 | #endif /* PARTICLE_HPP_ */ | 
|---|