Version: SMASH-3.1
nucleus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2022
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 
89  virtual void set_parameters_automatic();
90 
97  virtual void set_parameters_from_config(Configuration &config);
98 
107  virtual void generate_fermi_momenta();
108 
118  void boost(double beta_scalar);
119 
130  void fill_from_list(const std::map<PdgCode, int> &particle_list,
131  int testparticles);
132 
141  void shift(double z_offset, double x_offset, double simulation_time);
142 
147  virtual void rotate() {}
148 
154  void copy_particles(Particles *particles);
155 
157  inline size_t size() const { return particles_.size(); }
158 
165  inline size_t number_of_particles() const {
166  size_t nop = particles_.size() / testparticles_;
167  /* If size() is not a multiple of testparticles_, this will throw an
168  * error. */
169  if (nop * testparticles_ != particles_.size()) {
170  throw TestparticleConfusion(
171  "Number of test particles and test particles"
172  "per particle are incompatible.");
173  }
174  return nop;
175  }
176 
184  inline size_t number_of_protons() const {
185  size_t proton_counter = 0;
186  /* If n_protons is not a multiple of testparticles_, this will throw an
187  * error. */
188  for (auto &particle : particles_) {
189  if (particle.type().pdgcode() == pdg::p) {
190  proton_counter++;
191  }
192  }
193 
194  size_t n_protons = proton_counter / testparticles_;
195 
196  if (n_protons * testparticles_ != proton_counter) {
197  throw TestparticleConfusion(
198  "Number of test protons and test particles"
199  "per proton are incompatible.");
200  }
201 
202  return n_protons;
203  }
204 
210  FourVector center() const;
211 
213  void set_label(BelongsTo label) {
214  for (ParticleData &data : particles_) {
215  data.set_belongs_to(label);
216  }
217  }
218 
223  void align_center() {
224  FourVector centerpoint = center();
225  for (auto p = particles_.begin(); p != particles_.end(); ++p) {
226  p->set_4position(p->position() - centerpoint);
227  }
228  }
229 
237  // This function as well as nucleon_density_unnormalized could in principle
238  // be defined without the second argument
239  virtual double nucleon_density(double r, double, double) const;
247  virtual double nucleon_density_unnormalized(double r, double, double) const;
256  virtual double calculate_saturation_density() const;
261  virtual void set_saturation_density(double density) {
262  saturation_density_ = density;
263  }
264 
266  struct TestparticleConfusion : public std::length_error {
267  using std::length_error::length_error;
268  };
269 
270  private:
282  double proton_radius_ = 1.2;
284  size_t testparticles_ = 1;
285 
286  protected:
288  std::vector<ParticleData> particles_;
289 
291  // Needed as public member for inheritance to deformed nuclei
293 
298  void random_euler_angles();
299 
301  double euler_phi_;
303  double euler_theta_;
305  double euler_psi_;
306 
307  public:
309  inline std::vector<ParticleData>::iterator begin() {
310  return particles_.begin();
311  }
313  inline std::vector<ParticleData>::iterator end() { return particles_.end(); }
315  inline std::vector<ParticleData>::const_iterator cbegin() const {
316  return particles_.cbegin();
317  }
319  inline std::vector<ParticleData>::const_iterator cend() const {
320  return particles_.cend();
321  }
326  inline void set_diffusiveness(double diffuse) { diffusiveness_ = diffuse; }
331  inline double get_diffusiveness() const { return diffusiveness_; }
336  inline double get_saturation_density() const { return saturation_density_; }
344  inline double default_nuclear_radius() {
345  int A = number_of_particles();
346 
347  if (A <= 16) {
348  // radius: rough guess for all nuclei not listed explicitly with A <= 16
349  return (proton_radius_ * std::cbrt(A));
350  } else {
351  // radius taken from \iref{Rybczynski:2013yba}
352  return (1.12 * std::pow(A, 1.0 / 3.0) - 0.86 * std::pow(A, -1.0 / 3.0));
353  }
354  }
359  inline void set_nuclear_radius(double rad) { nuclear_radius_ = rad; }
364  inline double get_nuclear_radius() const { return nuclear_radius_; }
369  friend std::ostream &operator<<(std::ostream &, const Nucleus &);
370 };
371 
372 } // namespace smash
373 
374 #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
double proton_radius_
Single proton radius in fm.
Definition: nucleus.h:282
Nucleus()=default
default constructor
double get_diffusiveness() const
Definition: nucleus.h:331
double euler_theta_
Euler angel theta.
Definition: nucleus.h:303
std::vector< ParticleData >::const_iterator cbegin() const
For const iterators over the particle list:
Definition: nucleus.h:315
virtual double nucleon_density_unnormalized(double r, double, double) const
Return the unnormalized Woods-Saxon distribution for the given position without deformation.
Definition: nucleus.cc:492
void shift(double z_offset, double x_offset, double simulation_time)
Shifts the nucleus to correct impact parameter and z displacement.
Definition: nucleus.cc:453
double get_saturation_density() const
Definition: nucleus.h:336
double woods_saxon(double x)
Woods-Saxon distribution.
Definition: nucleus.cc:261
void random_euler_angles()
Randomly generate Euler angles.
Definition: nucleus.cc:480
virtual ~Nucleus()=default
virtual void arrange_nucleons()
Sets the positions of the nucleons inside a nucleus.
Definition: nucleus.cc:265
virtual double calculate_saturation_density() const
Definition: nucleus.cc:496
virtual void rotate()
Rotates the nucleus.
Definition: nucleus.h:147
double default_nuclear_radius()
Default nuclear radius calculated as:
Definition: nucleus.h:344
double diffusiveness_
Diffusiveness of Woods-Saxon distribution of this nucleus in fm (for diffusiveness_ == 0,...
Definition: nucleus.h:275
double saturation_density_
Saturation density of this nucleus.
Definition: nucleus.h:292
FourVector center() const
Calculate geometrical center of the nucleus.
Definition: nucleus.cc:471
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:348
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number.
Definition: nucleus.cc:282
std::vector< ParticleData >::const_iterator cend() const
For const iterators over the particle list:
Definition: nucleus.h:319
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:340
size_t size() const
Number of numerical (=test-)particles in the nucleus:
Definition: nucleus.h:157
size_t testparticles_
Number of testparticles per physical particle.
Definition: nucleus.h:284
double get_nuclear_radius() const
Definition: nucleus.h:364
virtual double nucleon_density(double r, double, double) const
Return the Woods-Saxon probability density for the given position.
Definition: nucleus.cc:487
double euler_phi_
Euler angel phi.
Definition: nucleus.h:301
double nuclear_radius_
Nuclear radius of this nucleus.
Definition: nucleus.h:277
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:439
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:288
double euler_psi_
Euler angel psi.
Definition: nucleus.h:305
double mass() const
Definition: nucleus.cc:55
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
Definition: nucleus.h:223
void copy_particles(Particles *particles)
Copies the particles from this nucleus into the particle list.
Definition: nucleus.cc:465
virtual void set_saturation_density(double density)
Sets the saturation density of the nucleus.
Definition: nucleus.h:261
void set_nuclear_radius(double rad)
Sets the nuclear radius.
Definition: nucleus.h:359
void set_label(BelongsTo label)
Sets target / projectile labels on nucleons.
Definition: nucleus.h:213
void set_diffusiveness(double diffuse)
Sets the diffusiveness of the nucleus.
Definition: nucleus.h:326
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:309
size_t number_of_protons() const
Number of physical protons in the nucleus:
Definition: nucleus.h:184
void boost(double beta_scalar)
Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum ...
Definition: nucleus.cc:409
virtual ThreeVector distribute_nucleon()
The distribution of return values from this function is according to a spherically symmetric Woods-Sa...
Definition: nucleus.cc:215
size_t number_of_particles() const
Number of physical particles in the nucleus:
Definition: nucleus.h:165
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:313
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:512
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