Version: SMASH-1.6
nucleus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2019
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_NUCLEUS_H_
8 #define SRC_INCLUDE_NUCLEUS_H_
9 
10 #include <map>
11 #include <stdexcept>
12 #include <vector>
13 
14 #include "configuration.h"
15 #include "constants.h"
16 #include "forwarddeclarations.h"
17 #include "fourvector.h"
18 #include "particledata.h"
19 #include "threevector.h"
20 
21 namespace smash {
22 
27 class Nucleus {
28  public:
30  Nucleus() = default;
31 
40  Nucleus(Configuration &config, int nTest);
41 
42  Nucleus(const std::map<PdgCode, int> &particle_list, int nTest);
43  virtual ~Nucleus() = default;
44 
49  double mass() const;
50 
61 
67  double woods_saxon(double x);
68 
70  void arrange_nucleons();
71 
79  virtual void set_parameters_automatic();
80 
87  virtual void set_parameters_from_config(Configuration &config);
88 
97  virtual void generate_fermi_momenta();
98 
108  void boost(double beta_scalar);
109 
120  void fill_from_list(const std::map<PdgCode, int> &particle_list,
121  int testparticles);
122 
131  void shift(double z_offset, double x_offset, double simulation_time);
132 
137  virtual void rotate() {}
138 
144  void copy_particles(Particles *particles);
145 
147  inline size_t size() const { return particles_.size(); }
148 
155  inline size_t number_of_particles() const {
156  size_t nop = particles_.size() / testparticles_;
157  /* if size() is not a multiple of testparticles_, this will throw an
158  * error. */
159  if (nop * testparticles_ != particles_.size()) {
160  throw TestparticleConfusion(
161  "Number of test particles and test particles"
162  "per particle are incompatible");
163  }
164  return nop;
165  }
166 
172  FourVector center() const;
173 
178  void align_center() {
179  FourVector centerpoint = center();
180  for (auto p = particles_.begin(); p != particles_.end(); ++p) {
181  p->set_4position(p->position() - centerpoint);
182  }
183  }
184 
186  struct TestparticleConfusion : public std::length_error {
187  using std::length_error::length_error;
188  };
189 
190  private:
204  double proton_radius_ = 1.2;
206  size_t testparticles_ = 1;
207 
208  protected:
210  std::vector<ParticleData> particles_;
211 
212  public:
214  inline std::vector<ParticleData>::iterator begin() {
215  return particles_.begin();
216  }
218  inline std::vector<ParticleData>::iterator end() { return particles_.end(); }
220  inline std::vector<ParticleData>::const_iterator cbegin() const {
221  return particles_.cbegin();
222  }
224  inline std::vector<ParticleData>::const_iterator cend() const {
225  return particles_.cend();
226  }
231  inline void set_diffusiveness(double diffuse) { diffusiveness_ = diffuse; }
236  inline double get_diffusiveness() const { return diffusiveness_; }
241  inline void set_saturation_density(double density) {
242  saturation_density_ = density;
243  }
248  inline double get_saturation_density() const { return saturation_density_; }
254  inline double default_nuclear_radius() {
255  return proton_radius_ * std::pow(number_of_particles(), 1. / 3.);
256  }
261  inline void set_nuclear_radius(double rad) { nuclear_radius_ = rad; }
266  inline double get_nuclear_radius() const { return nuclear_radius_; }
271  friend std::ostream &operator<<(std::ostream &, const Nucleus &);
272 };
273 
274 } // namespace smash
275 
276 #endif // SRC_INCLUDE_NUCLEUS_H_
void set_diffusiveness(double diffuse)
Sets the diffusiveness of the nucleus.
Definition: nucleus.h:231
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:30
virtual ThreeVector distribute_nucleon()
The distribution of return values from this function is according to a spherically symmetric Woods-Sa...
Definition: nucleus.cc:216
double proton_radius_
Single proton radius in fm.
Definition: nucleus.h:204
void shift(double z_offset, double x_offset, double simulation_time)
Shifts the nucleus to correct impact parameter and z displacement.
Definition: nucleus.cc:448
double get_nuclear_radius() const
Definition: nucleus.h:266
void set_nuclear_radius(double rad)
Sets the nuclear radius.
Definition: nucleus.h:261
Collection of useful constants that are known at compile time.
friend std::ostream & operator<<(std::ostream &, const Nucleus &)
Writes the state of the Nucleus object to the output stream.
Definition: nucleus.cc:475
A nucleus is a collection of particles that are initialized, before the beginning of the simulation a...
Definition: nucleus.h:27
FourVector center() const
Calculate geometrical center of the nucleus.
Definition: nucleus.cc:466
virtual void rotate()
Rotates the nucleus.
Definition: nucleus.h:137
Interface to the SMASH configuration files.
double get_saturation_density() const
Definition: nucleus.h:248
std::vector< ParticleData >::const_iterator cbegin() const
For const iterators over the particle list:
Definition: nucleus.h:220
void boost(double beta_scalar)
Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum ...
Definition: nucleus.cc:404
double saturation_density_
Saturation density of this nucleus.
Definition: nucleus.h:197
void set_saturation_density(double density)
Sets the saturation density of the nucleus.
Definition: nucleus.h:241
size_t size() const
Number of numerical (=test-)particles in the nucleus:
Definition: nucleus.h:147
Nucleus()=default
default constructor
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:343
double get_diffusiveness() const
Definition: nucleus.h:236
double woods_saxon(double x)
Woods-Saxon distribution.
Definition: nucleus.cc:262
std::vector< ParticleData >::const_iterator cend() const
For const iterators over the particle list:
Definition: nucleus.h:224
double mass() const
Definition: nucleus.cc:56
double default_nuclear_radius()
Definition: nucleus.h:254
double nuclear_radius_
Nuclear radius of this nucleus.
Definition: nucleus.h:199
virtual ~Nucleus()=default
double diffusiveness_
Diffusiveness of Woods-Saxon distribution of this nucleus in fm (for diffusiveness_ == 0...
Definition: nucleus.h:195
void fill_from_list(const std::map< PdgCode, int > &particle_list, int testparticles)
Adds particles from a map PDG code => Number_of_particles_with_that_PDG_code to the nucleus...
Definition: nucleus.cc:434
constexpr int p
Proton.
void arrange_nucleons()
Sets the positions of the nucleons inside a nucleus.
Definition: nucleus.cc:266
constexpr double nuclear_density
Ground state density of symmetric nuclear matter [fm^-3].
Definition: constants.h:42
void copy_particles(Particles *particles)
Copies the particles from this nucleus into the particle list.
Definition: nucleus.cc:460
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:210
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:214
size_t number_of_particles() const
Number of physical particles in the nucleus:
Definition: nucleus.h:155
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number...
Definition: nucleus.cc:283
size_t testparticles_
Number of testparticles per physical particle.
Definition: nucleus.h:206
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:32
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
Definition: nucleus.h:178
Definition: action.h:24
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:218
virtual void set_parameters_from_config(Configuration &config)
Sets the parameters of the Woods-Saxon according to manually added values in the configuration file...
Definition: nucleus.cc:335