Version: SMASH-3.3
nucleus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2022,2024-2025
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 
52  Nucleus(const std::map<PdgCode, int> &particle_list, int nTest,
53  SpinInteractionType spin_interaction_type = SpinInteractionType::Off);
54 
55  virtual ~Nucleus() = default;
56 
61  double mass() const;
62 
73 
79  double woods_saxon(double x);
80 
82  virtual void arrange_nucleons();
83 
92  virtual void set_parameters_automatic();
93 
102  virtual void generate_fermi_momenta();
103 
113  void boost(double beta_scalar);
114 
125  void fill_from_list(const std::map<PdgCode, int> &particle_list,
126  int testparticles);
127 
136  void shift(double z_offset, double x_offset, double simulation_time);
137 
141  virtual void rotate();
142 
148  void copy_particles(Particles *particles);
149 
151  inline size_t size() const { return particles_.size(); }
152 
159  inline size_t number_of_particles() const {
160  size_t nop = particles_.size() / testparticles_;
161  /* If size() is not a multiple of testparticles_, this will throw an
162  * error. */
163  if (nop * testparticles_ != particles_.size()) {
164  throw TestparticleConfusion(
165  "Number of test particles and test particles"
166  "per particle are incompatible.");
167  }
168  return nop;
169  }
170 
178  inline size_t number_of_protons() const {
179  size_t proton_counter = 0;
180  /* If n_protons is not a multiple of testparticles_, this will throw an
181  * error. */
182  for (auto &particle : particles_) {
183  if (particle.type().pdgcode() == pdg::p) {
184  proton_counter++;
185  }
186  }
187 
188  size_t n_protons = proton_counter / testparticles_;
189 
190  if (n_protons * testparticles_ != proton_counter) {
191  throw TestparticleConfusion(
192  "Number of test protons and test particles"
193  "per proton are incompatible.");
194  }
195 
196  return n_protons;
197  }
198 
204  FourVector center() const;
205 
207  void set_label(BelongsTo label) {
208  for (ParticleData &data : particles_) {
209  data.set_belongs_to(label);
210  }
211  }
212 
217  void align_center() {
218  FourVector centerpoint = center();
219  for (auto p = particles_.begin(); p != particles_.end(); ++p) {
220  p->set_4position(p->position() - centerpoint);
221  }
222  }
223 
231  // This function as well as nucleon_density_unnormalized could in principle
232  // be defined without the second argument
233  virtual double nucleon_density(double r, double, double) const;
241  virtual double nucleon_density_unnormalized(double r, double, double) const;
250  virtual double calculate_saturation_density() const;
255  virtual void set_saturation_density(double density) {
256  saturation_density_ = density;
257  }
258 
260  struct TestparticleConfusion : public std::length_error {
261  using std::length_error::length_error;
262  };
263 
264  private:
276  double proton_radius_ = 1.2;
278  size_t testparticles_ = 1;
279 
282  for (auto &particle : particles_) {
283  particle.set_unpolarized_spin_vector();
284  }
285  }
286 
287  protected:
289  std::vector<ParticleData> particles_;
290 
292  // Needed as public member for inheritance to deformed nuclei
294 
299  void random_euler_angles();
300 
306  double euler_phi_ = 0.0;
308  double euler_theta_ = 0.0;
310  double euler_psi_ = 0.0;
312  bool random_rotation_ = false;
313 
314  public:
316  inline std::vector<ParticleData>::iterator begin() {
317  return particles_.begin();
318  }
320  inline std::vector<ParticleData>::iterator end() { return particles_.end(); }
322  inline std::vector<ParticleData>::const_iterator cbegin() const {
323  return particles_.cbegin();
324  }
326  inline std::vector<ParticleData>::const_iterator cend() const {
327  return particles_.cend();
328  }
333  inline void set_diffusiveness(double diffuse) { diffusiveness_ = diffuse; }
338  inline double get_diffusiveness() const { return diffusiveness_; }
343  inline double get_saturation_density() const { return saturation_density_; }
351  inline double default_nuclear_radius() {
352  int A = number_of_particles();
353 
354  if (A <= 16) {
355  // radius: rough guess for all nuclei not listed explicitly with A <= 16
356  return (proton_radius_ * std::cbrt(A));
357  } else {
358  // radius taken from \iref{Rybczynski:2013yba}
359  return (1.12 * std::pow(A, 1.0 / 3.0) - 0.86 * std::pow(A, -1.0 / 3.0));
360  }
361  }
366  inline void set_nuclear_radius(double rad) { nuclear_radius_ = rad; }
371  inline double get_nuclear_radius() const { return nuclear_radius_; }
377  void set_orientation_from_config(Configuration &orientation_config);
382  friend std::ostream &operator<<(std::ostream &, const Nucleus &);
383 };
384 
390 bool has_projectile_or_target(const Configuration &config);
391 
400 bool is_about_projectile(const Configuration &config);
401 
402 } // namespace smash
403 
404 #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:276
Nucleus()=default
default constructor
double get_diffusiveness() const
Definition: nucleus.h:338
double euler_theta_
Euler angle theta.
Definition: nucleus.h:308
std::vector< ParticleData >::const_iterator cbegin() const
For const iterators over the particle list:
Definition: nucleus.h:322
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:559
void shift(double z_offset, double x_offset, double simulation_time)
Shifts the nucleus to correct impact parameter and z displacement.
Definition: nucleus.cc:520
double get_saturation_density() const
Definition: nucleus.h:343
double woods_saxon(double x)
Woods-Saxon distribution.
Definition: nucleus.cc:285
void random_euler_angles()
Randomly generate Euler angles.
Definition: nucleus.cc:547
virtual ~Nucleus()=default
virtual void arrange_nucleons()
Sets the positions of the nucleons inside a nucleus.
Definition: nucleus.cc:289
virtual double calculate_saturation_density() const
Definition: nucleus.cc:563
double default_nuclear_radius()
Default nuclear radius calculated as:
Definition: nucleus.h:351
double diffusiveness_
Diffusiveness of Woods-Saxon distribution of this nucleus in fm (for diffusiveness_ == 0,...
Definition: nucleus.h:269
double saturation_density_
Saturation density of this nucleus.
Definition: nucleus.h:293
FourVector center() const
Calculate geometrical center of the nucleus.
Definition: nucleus.cc:538
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:415
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number.
Definition: nucleus.cc:306
std::vector< ParticleData >::const_iterator cend() const
For const iterators over the particle list:
Definition: nucleus.h:326
size_t size() const
Number of numerical (=test-)particles in the nucleus:
Definition: nucleus.h:151
size_t testparticles_
Number of testparticles per physical particle.
Definition: nucleus.h:278
double get_nuclear_radius() const
Definition: nucleus.h:371
virtual double nucleon_density(double r, double, double) const
Return the Woods-Saxon probability density for the given position.
Definition: nucleus.cc:554
double euler_phi_
The Euler angle phi of the three Euler angles used to apply rotations to the nucleus.
Definition: nucleus.h:306
double nuclear_radius_
Nuclear radius of this nucleus.
Definition: nucleus.h:271
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:506
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:289
double euler_psi_
Euler angle psi.
Definition: nucleus.h:310
double mass() const
Definition: nucleus.cc:84
void make_nucleus_unpolarized()
Set unpolarized spin vectors for all particles in the nucleus.
Definition: nucleus.h:281
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
Definition: nucleus.h:217
void copy_particles(Particles *particles)
Copies the particles from this nucleus into the particle list.
Definition: nucleus.cc:532
virtual void set_saturation_density(double density)
Sets the saturation density of the nucleus.
Definition: nucleus.h:255
void set_nuclear_radius(double rad)
Sets the nuclear radius.
Definition: nucleus.h:366
void set_label(BelongsTo label)
Sets target / projectile labels on nucleons.
Definition: nucleus.h:207
bool random_rotation_
Whether the nucleus should be rotated randomly.
Definition: nucleus.h:312
void set_diffusiveness(double diffuse)
Sets the diffusiveness of the nucleus.
Definition: nucleus.h:333
virtual void rotate()
Rotates the nucleus using the three euler angles phi, theta and psi.
Definition: nucleus.cc:395
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:316
size_t number_of_protons() const
Number of physical protons in the nucleus:
Definition: nucleus.h:178
void boost(double beta_scalar)
Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum ...
Definition: nucleus.cc:476
virtual ThreeVector distribute_nucleon()
The distribution of return values from this function is according to a spherically symmetric Woods-Sa...
Definition: nucleus.cc:239
size_t number_of_particles() const
Number of physical particles in the nucleus:
Definition: nucleus.h:159
void set_orientation_from_config(Configuration &orientation_config)
Set angles for rotation of the nucleus from config file.
Definition: nucleus.cc:364
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:320
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:59
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.
SpinInteractionType
Possible spin interaction types.
@ Off
No spin interactions.
friend std::ostream & operator<<(std::ostream &, const Nucleus &)
Writes the state of the Nucleus object to the output stream.
Definition: nucleus.cc:579
constexpr int p
Proton.
Definition: action.h:24
constexpr double nuclear_density
Ground state density of symmetric nuclear matter [fm^-3].
Definition: constants.h:52
bool has_projectile_or_target(const Configuration &config)
Find out whether a configuration has a projectile or a target sub-section.
Definition: nucleus.cc:588
bool is_about_projectile(const Configuration &config)
Find out whether a configuration is about projectile or target.
Definition: nucleus.cc:594