Version: SMASH-2.1
nucleus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_NUCLEUS_H_
8 #define SRC_INCLUDE_SMASH_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 
51  Nucleus(const std::map<PdgCode, int> &particle_list, int nTest);
52  virtual ~Nucleus() = default;
53 
58  double mass() const;
59 
70 
76  double woods_saxon(double x);
77 
79  virtual void arrange_nucleons();
80 
88  virtual void set_parameters_automatic();
89 
96  virtual void set_parameters_from_config(Configuration &config);
97 
106  virtual void generate_fermi_momenta();
107 
117  void boost(double beta_scalar);
118 
129  void fill_from_list(const std::map<PdgCode, int> &particle_list,
130  int testparticles);
131 
140  void shift(double z_offset, double x_offset, double simulation_time);
141 
146  virtual void rotate() {}
147 
153  void copy_particles(Particles *particles);
154 
156  inline size_t size() const { return particles_.size(); }
157 
164  inline size_t number_of_particles() const {
165  size_t nop = particles_.size() / testparticles_;
166  /* If size() is not a multiple of testparticles_, this will throw an
167  * error. */
168  if (nop * testparticles_ != particles_.size()) {
169  throw TestparticleConfusion(
170  "Number of test particles and test particles"
171  "per particle are incompatible.");
172  }
173  return nop;
174  }
175 
183  inline size_t number_of_protons() const {
184  size_t proton_counter = 0;
185  /* If n_protons is not a multiple of testparticles_, this will throw an
186  * error. */
187  for (auto &particle : particles_) {
188  if (particle.type().pdgcode() == pdg::p) {
189  proton_counter++;
190  }
191  }
192 
193  size_t n_protons = proton_counter / testparticles_;
194 
195  if (n_protons * testparticles_ != proton_counter) {
196  throw TestparticleConfusion(
197  "Number of test protons and test particles"
198  "per proton are incompatible.");
199  }
200 
201  return n_protons;
202  }
203 
209  FourVector center() const;
210 
212  void set_label(BelongsTo label) {
213  for (ParticleData &data : particles_) {
214  data.set_belongs_to(label);
215  }
216  }
217 
222  void align_center() {
223  FourVector centerpoint = center();
224  for (auto p = particles_.begin(); p != particles_.end(); ++p) {
225  p->set_4position(p->position() - centerpoint);
226  }
227  }
228 
236  virtual double nucleon_density(double r, double) const;
237 
239  struct TestparticleConfusion : public std::length_error {
240  using std::length_error::length_error;
241  };
242 
243  private:
257  double proton_radius_ = 1.2;
259  size_t testparticles_ = 1;
260 
261  protected:
263  std::vector<ParticleData> particles_;
264 
269  void random_euler_angles();
270 
272  double euler_phi_;
274  double euler_theta_;
276  double euler_psi_;
277 
278  public:
280  inline std::vector<ParticleData>::iterator begin() {
281  return particles_.begin();
282  }
284  inline std::vector<ParticleData>::iterator end() { return particles_.end(); }
286  inline std::vector<ParticleData>::const_iterator cbegin() const {
287  return particles_.cbegin();
288  }
290  inline std::vector<ParticleData>::const_iterator cend() const {
291  return particles_.cend();
292  }
297  inline void set_diffusiveness(double diffuse) { diffusiveness_ = diffuse; }
302  inline double get_diffusiveness() const { return diffusiveness_; }
307  inline void set_saturation_density(double density) {
308  saturation_density_ = density;
309  }
314  inline double get_saturation_density() const { return saturation_density_; }
322  inline double default_nuclear_radius() {
323  int A = number_of_particles();
324 
325  if (A <= 16) {
326  // radius: rough guess for all nuclei not listed explicitly with A <= 16
327  return (proton_radius_ * std::cbrt(A));
328  } else {
329  // radius taken from \iref{Rybczynski:2013yba}
330  return (1.12 * std::pow(A, 1.0 / 3.0) - 0.86 * std::pow(A, -1.0 / 3.0));
331  }
332  }
337  inline void set_nuclear_radius(double rad) { nuclear_radius_ = rad; }
342  inline double get_nuclear_radius() const { return nuclear_radius_; }
347  friend std::ostream &operator<<(std::ostream &, const Nucleus &);
348 };
349 
350 } // namespace smash
351 
352 #endif // SRC_INCLUDE_SMASH_NUCLEUS_H_
Interface to the SMASH configuration files.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
A nucleus is a collection of particles that are initialized, before the beginning of the simulation a...
Definition: nucleus.h:27
virtual double nucleon_density(double r, double) const
Return the Woods-Saxon probability density for the given position.
Definition: nucleus.cc:504
double proton_radius_
Single proton radius in fm.
Definition: nucleus.h:257
Nucleus()=default
default constructor
double get_diffusiveness() const
Definition: nucleus.h:302
double euler_theta_
Euler angel theta.
Definition: nucleus.h:274
std::vector< ParticleData >::const_iterator cbegin() const
For const iterators over the particle list:
Definition: nucleus.h:286
void shift(double z_offset, double x_offset, double simulation_time)
Shifts the nucleus to correct impact parameter and z displacement.
Definition: nucleus.cc:470
double get_saturation_density() const
Definition: nucleus.h:314
double woods_saxon(double x)
Woods-Saxon distribution.
Definition: nucleus.cc:259
void random_euler_angles()
Randomly generate Euler angles.
Definition: nucleus.cc:497
void set_saturation_density(double density)
Sets the saturation density of the nucleus.
Definition: nucleus.h:307
virtual ~Nucleus()=default
virtual void arrange_nucleons()
Sets the positions of the nucleons inside a nucleus.
Definition: nucleus.cc:263
virtual void rotate()
Rotates the nucleus.
Definition: nucleus.h:146
double default_nuclear_radius()
Default nuclear radius calculated as:
Definition: nucleus.h:322
double diffusiveness_
Diffusiveness of Woods-Saxon distribution of this nucleus in fm (for diffusiveness_ == 0,...
Definition: nucleus.h:248
double saturation_density_
Saturation density of this nucleus.
Definition: nucleus.h:250
FourVector center() const
Calculate geometrical center of the nucleus.
Definition: nucleus.cc:488
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:365
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number.
Definition: nucleus.cc:280
std::vector< ParticleData >::const_iterator cend() const
For const iterators over the particle list:
Definition: nucleus.h:290
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:357
size_t size() const
Number of numerical (=test-)particles in the nucleus:
Definition: nucleus.h:156
size_t testparticles_
Number of testparticles per physical particle.
Definition: nucleus.h:259
double get_nuclear_radius() const
Definition: nucleus.h:342
double euler_phi_
Euler angel phi.
Definition: nucleus.h:272
double nuclear_radius_
Nuclear radius of this nucleus.
Definition: nucleus.h:252
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:456
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:263
double euler_psi_
Euler angel psi.
Definition: nucleus.h:276
double mass() const
Definition: nucleus.cc:53
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
Definition: nucleus.h:222
void copy_particles(Particles *particles)
Copies the particles from this nucleus into the particle list.
Definition: nucleus.cc:482
void set_nuclear_radius(double rad)
Sets the nuclear radius.
Definition: nucleus.h:337
void set_label(BelongsTo label)
Sets target / projectile labels on nucleons.
Definition: nucleus.h:212
void set_diffusiveness(double diffuse)
Sets the diffusiveness of the nucleus.
Definition: nucleus.h:297
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:280
size_t number_of_protons() const
Number of physical protons in the nucleus:
Definition: nucleus.h:183
void boost(double beta_scalar)
Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum ...
Definition: nucleus.cc:426
virtual ThreeVector distribute_nucleon()
The distribution of return values from this function is according to a spherically symmetric Woods-Sa...
Definition: nucleus.cc:213
size_t number_of_particles() const
Number of physical particles in the nucleus:
Definition: nucleus.h:164
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:284
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:58
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
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:509
constexpr int p
Proton.
Definition: action.h:24
constexpr double nuclear_density
Ground state density of symmetric nuclear matter [fm^-3].
Definition: constants.h:48