Version: SMASH-1.5
nucleus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018
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:
37  Nucleus(Configuration &config, int nTest);
38 
39  Nucleus(const std::map<PdgCode, int> &particle_list, int nTest);
40  virtual ~Nucleus() = default;
41 
46  double mass() const;
47 
57  virtual ThreeVector distribute_nucleon() const;
58 
64  double woods_saxon(double x);
65 
67  void arrange_nucleons();
68 
76  virtual void set_parameters_automatic();
77 
84  virtual void set_parameters_from_config(Configuration &config);
85 
94  virtual void generate_fermi_momenta();
95 
105  void boost(double beta_scalar);
106 
117  void fill_from_list(const std::map<PdgCode, int> &particle_list,
118  int testparticles);
119 
128  void shift(double z_offset, double x_offset, double simulation_time);
129 
134  virtual void rotate() {}
135 
141  void copy_particles(Particles *particles);
142 
144  inline size_t size() const { return particles_.size(); }
145 
152  inline size_t number_of_particles() const {
153  size_t nop = particles_.size() / testparticles_;
154  /* if size() is not a multiple of testparticles_, this will throw an
155  * error. */
156  if (nop * testparticles_ != particles_.size()) {
157  throw TestparticleConfusion(
158  "Number of test particles and test particles"
159  "per particle are incompatible");
160  }
161  return nop;
162  }
163 
169  FourVector center() const;
170 
175  void align_center() {
176  FourVector centerpoint = center();
177  for (auto p = particles_.begin(); p != particles_.end(); ++p) {
178  p->set_4position(p->position() - centerpoint);
179  }
180  }
181 
183  struct TestparticleConfusion : public std::length_error {
184  using std::length_error::length_error;
185  };
186 
187  private:
201  double proton_radius_ = 1.2;
203  size_t testparticles_ = 1;
205  std::vector<ParticleData> particles_;
206 
207  public:
209  inline std::vector<ParticleData>::iterator begin() {
210  return particles_.begin();
211  }
213  inline std::vector<ParticleData>::iterator end() { return particles_.end(); }
215  inline std::vector<ParticleData>::const_iterator cbegin() const {
216  return particles_.cbegin();
217  }
219  inline std::vector<ParticleData>::const_iterator cend() const {
220  return particles_.cend();
221  }
226  inline void set_diffusiveness(double diffuse) { diffusiveness_ = diffuse; }
231  inline double get_diffusiveness() const { return diffusiveness_; }
236  inline void set_saturation_density(double density) {
237  saturation_density_ = density;
238  }
243  inline double get_saturation_density() const { return saturation_density_; }
249  inline double default_nuclear_radius() {
250  return proton_radius_ * std::pow(number_of_particles(), 1. / 3.);
251  }
256  inline void set_nuclear_radius(double rad) { nuclear_radius_ = rad; }
261  inline double get_nuclear_radius() const { return nuclear_radius_; }
266  friend std::ostream &operator<<(std::ostream &, const Nucleus &);
267 };
268 
269 } // namespace smash
270 
271 #endif // SRC_INCLUDE_NUCLEUS_H_
size_t size() const
Number of numerical (=test-)particles in the nucleus:
Definition: nucleus.h:144
void set_diffusiveness(double diffuse)
Sets the diffusiveness of the nucleus.
Definition: nucleus.h:226
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:30
double proton_radius_
Single proton radius in fm.
Definition: nucleus.h:201
void shift(double z_offset, double x_offset, double simulation_time)
Shifts the nucleus to correct impact parameter and z displacement.
Definition: nucleus.cc:447
void set_nuclear_radius(double rad)
Sets the nuclear radius.
Definition: nucleus.h:256
FourVector center() const
Calculate geometrical center of the nucleus.
Definition: nucleus.cc:465
double mass() const
Definition: nucleus.cc:55
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:474
A nucleus is a collection of particles that are initialized, before the beginning of the simulation a...
Definition: nucleus.h:27
virtual void rotate()
Rotates the nucleus.
Definition: nucleus.h:134
double get_nuclear_radius() const
Definition: nucleus.h:261
Interface to the SMASH configuration files.
Nucleus(Configuration &config, int nTest)
Constructor for Nucleus, that needs the configuration parameters from the inputfile and the number of...
Definition: nucleus.cc:32
void boost(double beta_scalar)
Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum ...
Definition: nucleus.cc:403
virtual ThreeVector distribute_nucleon() const
The distribution of return values from this function is according to a spherically symmetric Woods-Sa...
Definition: nucleus.cc:215
double saturation_density_
Saturation density of this nucleus.
Definition: nucleus.h:194
std::vector< ParticleData >::const_iterator cend() const
For const iterators over the particle list:
Definition: nucleus.h:219
void set_saturation_density(double density)
Sets the saturation density of the nucleus.
Definition: nucleus.h:236
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:342
double woods_saxon(double x)
Woods-Saxon distribution.
Definition: nucleus.cc:261
std::vector< ParticleData >::const_iterator cbegin() const
For const iterators over the particle list:
Definition: nucleus.h:215
double get_diffusiveness() const
Definition: nucleus.h:231
double default_nuclear_radius()
Definition: nucleus.h:249
double nuclear_radius_
Nuclear radius of this nucleus.
Definition: nucleus.h:196
virtual ~Nucleus()=default
double diffusiveness_
Diffusiveness of Woods-Saxon distribution of this nucleus in fm (for diffusiveness_ == 0...
Definition: nucleus.h:192
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:433
constexpr int p
Proton.
void arrange_nucleons()
Sets the positions of the nucleons inside a nucleus.
Definition: nucleus.cc:265
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:459
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:205
double get_saturation_density() const
Definition: nucleus.h:243
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:209
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:282
size_t testparticles_
Number of testparticles per physical particle.
Definition: nucleus.h:203
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:175
Definition: action.h:24
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:213
size_t number_of_particles() const
Number of physical particles in the nucleus:
Definition: nucleus.h:152
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:334