| [ff09f3] | 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 | /** Print parameters to given stream \a ost.
|
|---|
| 60 | *
|
|---|
| 61 | * These are virtual functions to allow for overriding and hence
|
|---|
| 62 | * changing the default behavior.
|
|---|
| 63 | *
|
|---|
| 64 | * @param ost stream to print to
|
|---|
| 65 | */
|
|---|
| 66 | void stream_to(std::ostream &ost) const;
|
|---|
| 67 |
|
|---|
| 68 | /** Parse parameters from given stream \a ist.
|
|---|
| 69 | *
|
|---|
| 70 | * These are virtual functions to allow for overriding and hence
|
|---|
| 71 | * changing the default behavior.
|
|---|
| 72 | *
|
|---|
| 73 | * @param ist stream to parse from
|
|---|
| 74 | */
|
|---|
| 75 | void stream_from(std::istream &ist);
|
|---|
| 76 |
|
|---|
| 77 | private:
|
|---|
| 78 | /** Default constructor for class Particle.
|
|---|
| 79 | *
|
|---|
| 80 | * \warning default constructor is private to prevent Particle without a
|
|---|
| 81 | * unique name.
|
|---|
| 82 | *
|
|---|
| 83 | */
|
|---|
| 84 | Particle();
|
|---|
| 85 |
|
|---|
| 86 | /** Helper function to find index to a parameter name.
|
|---|
| 87 | *
|
|---|
| 88 | * \param name name of parameter to look up index for
|
|---|
| 89 | * \return index in ParameterNames or -1 if not found
|
|---|
| 90 | */
|
|---|
| 91 | size_t lookupParameterName(const std::string &name) const;
|
|---|
| 92 |
|
|---|
| 93 | /** Returns the name of the element.
|
|---|
| 94 | *
|
|---|
| 95 | * \return name of the particle's element
|
|---|
| 96 | */
|
|---|
| 97 | std::string getElement() const;
|
|---|
| 98 |
|
|---|
| 99 | /** Setter for the particle's element.
|
|---|
| 100 | *
|
|---|
| 101 | * \param element_name name of particle's element, must be known to periodentafel.
|
|---|
| 102 | */
|
|---|
| 103 | void setElement(const std::string &element_name);
|
|---|
| 104 |
|
|---|
| 105 | /** Finds the next free token in the registry for the given element.
|
|---|
| 106 | *
|
|---|
| 107 | * \param _periode reference to periodentafel for looking up element nr
|
|---|
| 108 | * \param _number atomic number of particle's element
|
|---|
| 109 | * \return unique token for this element
|
|---|
| 110 | */
|
|---|
| 111 | std::string findFreeName(
|
|---|
| 112 | const periodentafel &_periode,
|
|---|
| 113 | const atomicNumber_t &_number) const;
|
|---|
| 114 |
|
|---|
| 115 | private:
|
|---|
| 116 | //!> token/name of this particle
|
|---|
| 117 | const std::string name;
|
|---|
| 118 |
|
|---|
| 119 | //!> reference to periodentafel to look up elements
|
|---|
| 120 | const periodentafel &periode;
|
|---|
| 121 |
|
|---|
| 122 | //!> partial charge of this particle
|
|---|
| 123 | double charge;
|
|---|
| 124 | //!> (effective) mass of this particle
|
|---|
| 125 | double mass;
|
|---|
| 126 | //!> (effective) degrees of freedom
|
|---|
| 127 | unsigned int dof;
|
|---|
| 128 | //!> atomic number of the particle's element
|
|---|
| 129 | atomicNumber_t atomic_number;
|
|---|
| 130 |
|
|---|
| 131 | // the following variables are due to convention in .potentials file
|
|---|
| 132 | double sigma;
|
|---|
| 133 | double epsilon;
|
|---|
| 134 | double sigma_14;
|
|---|
| 135 | double epsilon_14;
|
|---|
| 136 |
|
|---|
| 137 | enum parameters_t {
|
|---|
| 138 | e_particle_type,
|
|---|
| 139 | e_element_name,
|
|---|
| 140 | e_sigma,
|
|---|
| 141 | e_epsilon,
|
|---|
| 142 | e_sigma_14,
|
|---|
| 143 | e_epsilon_14,
|
|---|
| 144 | e_mass,
|
|---|
| 145 | e_free,
|
|---|
| 146 | e_charge,
|
|---|
| 147 | MAXPARAMETERS
|
|---|
| 148 | };
|
|---|
| 149 |
|
|---|
| 150 | static const std::vector<std::string> ParameterNames;
|
|---|
| 151 | };
|
|---|
| 152 |
|
|---|
| 153 | /** Output stream operator for class Particle.
|
|---|
| 154 | *
|
|---|
| 155 | * \param ost output stream
|
|---|
| 156 | * \param p Particle instance
|
|---|
| 157 | */
|
|---|
| 158 | std::ostream& operator<<(std::ostream &ost, const Particle &p);
|
|---|
| 159 |
|
|---|
| 160 | #endif /* PARTICLE_HPP_ */
|
|---|