Version: SMASH-2.0
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 
215  void align_center() {
216  FourVector centerpoint = center();
217  for (auto p = particles_.begin(); p != particles_.end(); ++p) {
218  p->set_4position(p->position() - centerpoint);
219  }
220  }
221 
229  virtual double nucleon_density(double r, double) const;
230 
232  struct TestparticleConfusion : public std::length_error {
233  using std::length_error::length_error;
234  };
235 
236  private:
250  double proton_radius_ = 1.2;
252  size_t testparticles_ = 1;
253 
254  protected:
256  std::vector<ParticleData> particles_;
257 
262  void random_euler_angles();
263 
265  double euler_phi_;
267  double euler_theta_;
269  double euler_psi_;
270 
271  public:
273  inline std::vector<ParticleData>::iterator begin() {
274  return particles_.begin();
275  }
277  inline std::vector<ParticleData>::iterator end() { return particles_.end(); }
279  inline std::vector<ParticleData>::const_iterator cbegin() const {
280  return particles_.cbegin();
281  }
283  inline std::vector<ParticleData>::const_iterator cend() const {
284  return particles_.cend();
285  }
290  inline void set_diffusiveness(double diffuse) { diffusiveness_ = diffuse; }
295  inline double get_diffusiveness() const { return diffusiveness_; }
300  inline void set_saturation_density(double density) {
301  saturation_density_ = density;
302  }
307  inline double get_saturation_density() const { return saturation_density_; }
315  inline double default_nuclear_radius() {
316  int A = number_of_particles();
317 
318  if (A <= 16) {
319  // radius: rough guess for all nuclei not listed explicitly with A <= 16
320  return (proton_radius_ * std::cbrt(A));
321  } else {
322  // radius taken from \iref{Rybczynski:2013yba}
323  return (1.12 * std::pow(A, 1.0 / 3.0) - 0.86 * std::pow(A, -1.0 / 3.0));
324  }
325  }
330  inline void set_nuclear_radius(double rad) { nuclear_radius_ = rad; }
335  inline double get_nuclear_radius() const { return nuclear_radius_; }
340  friend std::ostream &operator<<(std::ostream &, const Nucleus &);
341 };
342 
343 } // namespace smash
344 
345 #endif // SRC_INCLUDE_SMASH_NUCLEUS_H_
smash::Nucleus::random_euler_angles
void random_euler_angles()
Randomly generate Euler angles.
Definition: nucleus.cc:497
smash
Definition: action.h:24
smash::Nucleus
A nucleus is a collection of particles that are initialized, before the beginning of the simulation a...
Definition: nucleus.h:27
smash::Nucleus::diffusiveness_
double diffusiveness_
Diffusiveness of Woods-Saxon distribution of this nucleus in fm (for diffusiveness_ == 0,...
Definition: nucleus.h:241
particledata.h
smash::Nucleus::~Nucleus
virtual ~Nucleus()=default
smash::Nucleus::fill_from_list
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
smash::Nucleus::cbegin
std::vector< ParticleData >::const_iterator cbegin() const
For const iterators over the particle list:
Definition: nucleus.h:279
smash::Nucleus::Nucleus
Nucleus()=default
default constructor
smash::Nucleus::generate_fermi_momenta
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:365
smash::Nucleus::number_of_protons
size_t number_of_protons() const
Number of physical protons in the nucleus:
Definition: nucleus.h:183
smash::Nucleus::get_diffusiveness
double get_diffusiveness() const
Definition: nucleus.h:295
smash::Nucleus::default_nuclear_radius
double default_nuclear_radius()
Default nuclear radius calculated as:
Definition: nucleus.h:315
smash::Nucleus::begin
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:273
smash::Nucleus::get_saturation_density
double get_saturation_density() const
Definition: nucleus.h:307
smash::Nucleus::woods_saxon
double woods_saxon(double x)
Woods-Saxon distribution.
Definition: nucleus.cc:259
smash::Nucleus::nuclear_radius_
double nuclear_radius_
Nuclear radius of this nucleus.
Definition: nucleus.h:245
smash::nuclear_density
constexpr double nuclear_density
Ground state density of symmetric nuclear matter [fm^-3].
Definition: constants.h:45
smash::Nucleus::euler_theta_
double euler_theta_
Euler angel theta.
Definition: nucleus.h:267
smash::Nucleus::copy_particles
void copy_particles(Particles *particles)
Copies the particles from this nucleus into the particle list.
Definition: nucleus.cc:482
smash::Nucleus::align_center
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
Definition: nucleus.h:215
smash::Nucleus::arrange_nucleons
virtual void arrange_nucleons()
Sets the positions of the nucleons inside a nucleus.
Definition: nucleus.cc:263
fourvector.h
smash::Nucleus::number_of_particles
size_t number_of_particles() const
Number of physical particles in the nucleus:
Definition: nucleus.h:164
smash::Nucleus::set_parameters_automatic
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number.
Definition: nucleus.cc:280
smash::Nucleus::particles_
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:256
smash::Configuration
Interface to the SMASH configuration files.
Definition: configuration.h:464
forwarddeclarations.h
smash::ThreeVector
Definition: threevector.h:31
smash::Nucleus::testparticles_
size_t testparticles_
Number of testparticles per physical particle.
Definition: nucleus.h:252
smash::Nucleus::euler_psi_
double euler_psi_
Euler angel psi.
Definition: nucleus.h:269
smash::Nucleus::shift
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
smash::Nucleus::operator<<
friend std::ostream & operator<<(std::ostream &, const Nucleus &)
Definition: nucleus.cc:509
smash::Nucleus::set_nuclear_radius
void set_nuclear_radius(double rad)
Sets the nuclear radius.
Definition: nucleus.h:330
smash::Nucleus::distribute_nucleon
virtual ThreeVector distribute_nucleon()
The distribution of return values from this function is according to a spherically symmetric Woods-Sa...
Definition: nucleus.cc:213
threevector.h
smash::Nucleus::end
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:277
smash::Nucleus::center
FourVector center() const
Calculate geometrical center of the nucleus.
Definition: nucleus.cc:488
smash::Nucleus::rotate
virtual void rotate()
Rotates the nucleus.
Definition: nucleus.h:146
smash::Nucleus::set_parameters_from_config
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
smash::Nucleus::proton_radius_
double proton_radius_
Single proton radius in fm.
Definition: nucleus.h:250
smash::Nucleus::mass
double mass() const
Definition: nucleus.cc:53
smash::Nucleus::TestparticleConfusion
Definition: nucleus.h:232
smash::Nucleus::set_diffusiveness
void set_diffusiveness(double diffuse)
Sets the diffusiveness of the nucleus.
Definition: nucleus.h:290
smash::Nucleus::size
size_t size() const
Number of numerical (=test-)particles in the nucleus:
Definition: nucleus.h:156
smash::Particles
Definition: particles.h:33
smash::Nucleus::saturation_density_
double saturation_density_
Saturation density of this nucleus.
Definition: nucleus.h:243
constants.h
smash::Nucleus::euler_phi_
double euler_phi_
Euler angel phi.
Definition: nucleus.h:265
configuration.h
smash::Nucleus::boost
void boost(double beta_scalar)
Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum ...
Definition: nucleus.cc:426
smash::FourVector
Definition: fourvector.h:33
smash::Nucleus::get_nuclear_radius
double get_nuclear_radius() const
Definition: nucleus.h:335
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::Nucleus::nucleon_density
virtual double nucleon_density(double r, double) const
Return the Woods-Saxon probability density for the given position.
Definition: nucleus.cc:504
smash::Nucleus::cend
std::vector< ParticleData >::const_iterator cend() const
For const iterators over the particle list:
Definition: nucleus.h:283
smash::Nucleus::set_saturation_density
void set_saturation_density(double density)
Sets the saturation density of the nucleus.
Definition: nucleus.h:300