Version: SMASH-1.7
smash::CustomNucleus Class Reference

#include <customnucleus.h>

Inheriting from Nucleus-Class using modified Nucleon configurations.

Configurations are read in from external lists.

Definition at line 39 of file customnucleus.h.

Inheritance diagram for smash::CustomNucleus:
[legend]
Collaboration diagram for smash::CustomNucleus:
[legend]

Public Member Functions

 CustomNucleus (Configuration &config, int testparticles, bool same_file)
 Constructor that needs configuration parameters from input file and the number of testparticles. More...
 
void fill_from_list (const std::vector< Nucleoncustom > &vec)
 Fills Particlelist from vector containing data for one nucleus. More...
 
ThreeVector distribute_nucleon () override
 Returns position of a nucleon as given in the external file. More...
 
void arrange_nucleons () override
 Sets the positions of the nucleons inside a nucleus. More...
 
std::vector< Nucleoncustomreadfile (std::ifstream &infile, int particle_number) const
 The returned vector contains Data for one nucleus given in the particlelist. More...
 
std::string file_path (const std::string &file_directory, const std::string &file_name)
 Generates the name of the stream file. More...
 
void generate_fermi_momenta () override
 Generates Fermi momenta as it is done in the mother class but in addition prints a warning that the Fermi momenta are generated accoriding to Woods-Saxon distributed nucleons. More...
 
- Public Member Functions inherited from smash::Nucleus
 Nucleus ()=default
 default constructor More...
 
 Nucleus (Configuration &config, int nTest)
 Constructor for Nucleus, that needs the configuration parameters from the inputfile and the number of testparticles. More...
 
 Nucleus (const std::map< PdgCode, int > &particle_list, int nTest)
 Constructor which directly initializes the Nucleus with particles and respective counts. More...
 
virtual ~Nucleus ()=default
 
double mass () const
 
double woods_saxon (double x)
 Woods-Saxon distribution. More...
 
virtual void set_parameters_automatic ()
 Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number. More...
 
virtual void set_parameters_from_config (Configuration &config)
 Sets the parameters of the Woods-Saxon according to manually added values in the configuration file. More...
 
void boost (double beta_scalar)
 Boosts the nuclei into the computational frame, such that the nucleons have the appropriate momentum and the nuclei are lorentz-contracted. More...
 
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. More...
 
void shift (double z_offset, double x_offset, double simulation_time)
 Shifts the nucleus to correct impact parameter and z displacement. More...
 
virtual void rotate ()
 Rotates the nucleus. More...
 
void copy_particles (Particles *particles)
 Copies the particles from this nucleus into the particle list. More...
 
size_t size () const
 Number of numerical (=test-)particles in the nucleus: More...
 
size_t number_of_particles () const
 Number of physical particles in the nucleus: More...
 
size_t number_of_protons () const
 Number of physical protons in the nucleus: More...
 
FourVector center () const
 Calculate geometrical center of the nucleus. More...
 
void align_center ()
 Shifts the nucleus so that its center is at (0,0,0) More...
 
virtual double nucleon_density (double r, double)
 Return the Woods-Saxon probability density for the given position. More...
 
std::vector< ParticleData >::iterator begin ()
 For iterators over the particle list: More...
 
std::vector< ParticleData >::iterator end ()
 For iterators over the particle list: More...
 
std::vector< ParticleData >::const_iterator cbegin () const
 For const iterators over the particle list: More...
 
std::vector< ParticleData >::const_iterator cend () const
 For const iterators over the particle list: More...
 
void set_diffusiveness (double diffuse)
 Sets the diffusiveness of the nucleus. More...
 
double get_diffusiveness () const
 
void set_saturation_density (double density)
 Sets the saturation density of the nucleus. More...
 
double get_saturation_density () const
 
double default_nuclear_radius ()
 Default nuclear radius calculated as: More...
 
void set_nuclear_radius (double rad)
 Sets the nuclear radius. More...
 
double get_nuclear_radius () const
 

Public Attributes

int number_of_nucleons_ = 0
 Number of Nucleons per Nucleus Set initally to zero to be modified in the constructor. More...
 
std::vector< Nucleoncustomcustom_nucleus_
 Vector contianing Data for one nucleus given in the particlelist. More...
 
size_t index = 0
 Index needed to read out vector in distribute nucleon. More...
 

Private Attributes

std::unique_ptr< std::ifstream > filestream_
 Filestream variable used if projectile and target are read in from different files and they therefore use different streams. More...
 
std::unique_ptr< std::ifstream > * used_filestream_
 Pointer to the used filestream pointer. More...
 

Static Private Attributes

static std::unique_ptr< std::ifstream > filestream_shared_ = nullptr
 Filestream variable used if projectile and target are read in from the same file and they use the same static stream. More...
 

Additional Inherited Members

- Protected Member Functions inherited from smash::Nucleus
void random_euler_angles ()
 Randomly generate Euler angles. More...
 
- Protected Attributes inherited from smash::Nucleus
std::vector< ParticleDataparticles_
 Particles associated with this nucleus. More...
 
double euler_phi_
 Euler angel phi. More...
 
double euler_theta_
 Euler angel theta. More...
 
double euler_psi_
 Euler angel psi. More...
 

Constructor & Destructor Documentation

smash::CustomNucleus::CustomNucleus ( Configuration config,
int  testparticles,
bool  same_file 
)

Constructor that needs configuration parameters from input file and the number of testparticles.

Parameters
[in]configcontains the parameters from the inputfile on the numbers of particles with a certain PDG code and also the path where the external particle list is located
[in]testparticlesrepresents the number of testparticles
[in]same_filespecifies if target and projectile nucleus are read in from the same file, which is important for the ifstream

Definition at line 92 of file customnucleus.cc.

93  {
94  // Read in file directory from config
95  std::string particle_list_file_directory =
96  config.take({"Custom", "File_Directory"});
97  // Read in file name from config
98  std::string particle_list_file_name = config.take({"Custom", "File_Name"});
99 
100  if (particles_.size() != 0) {
101  throw std::runtime_error(
102  "Your Particle List is already filled before reading in from the "
103  "external file."
104  "Something went wrong. Please check your config.");
105  }
106  /*
107  * Counts number of nucleons in one nucleus as it is specialized
108  * by the user in the config file.
109  * It is needed to read in the proper number of nucleons for one
110  * nucleus and to restart at the listreading for the following
111  * nucleus as one does not want to read configurations twice.
112  */
113  std::map<PdgCode, int> particle_list = config.take({"Particles"});
114  for (const auto& particle : particle_list)
115  number_of_nucleons_ += particle.second * testparticles;
116  /*
117  * "if" statement makes sure the streams to the file are initialized
118  * properly.
119  */
120  const std::string path =
121  file_path(particle_list_file_directory, particle_list_file_name);
122  if (same_file && !filestream_shared_) {
123  filestream_shared_ = make_unique<std::ifstream>(path);
125  } else if (!same_file) {
126  filestream_ = make_unique<std::ifstream>(path);
128  } else {
130  }
131 
134  // Inherited from nucleus class (see nucleus.h)
136 }
std::vector< Nucleoncustom > readfile(std::ifstream &infile, int particle_number) const
The returned vector contains Data for one nucleus given in the particlelist.
std::vector< Nucleoncustom > custom_nucleus_
Vector contianing Data for one nucleus given in the particlelist.
Definition: customnucleus.h:95
int number_of_nucleons_
Number of Nucleons per Nucleus Set initally to zero to be modified in the constructor.
Definition: customnucleus.h:93
std::unique_ptr< std::ifstream > filestream_
Filestream variable used if projectile and target are read in from different files and they therefore...
std::string file_path(const std::string &file_directory, const std::string &file_name)
Generates the name of the stream file.
static std::unique_ptr< std::ifstream > filestream_shared_
Filestream variable used if projectile and target are read in from the same file and they use the sam...
void fill_from_list(const std::vector< Nucleoncustom > &vec)
Fills Particlelist from vector containing data for one nucleus.
std::unique_ptr< std::ifstream > * used_filestream_
Pointer to the used filestream pointer.
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:256
virtual void set_parameters_automatic()
Sets the deformation parameters of the Woods-Saxon distribution according to the current mass number...
Definition: nucleus.cc:283

Here is the call graph for this function:

Member Function Documentation

void smash::CustomNucleus::fill_from_list ( const std::vector< Nucleoncustom > &  vec)

Fills Particlelist from vector containing data for one nucleus.

The data contains everything that is written in struct Nucleoncustom.

Parameters
[in]vecvector containing data from external list for one nucleus

Definition at line 138 of file customnucleus.cc.

138  {
139  particles_.clear();
140  index = 0;
141  // checking if particle is proton or neutron
142  for (const auto& it : vec) {
143  PdgCode pdgcode;
144  if (it.isospin == 1) {
145  pdgcode = pdg::p;
146  } else if (it.isospin == 0) {
147  pdgcode = pdg::n;
148  } else {
149  throw std::runtime_error(
150  "Your particles charges are not 1 = proton or 0 = neutron."
151  "Check whether your list is correct or there is an error.");
152  }
153  // setting parameters for the particles in the particlelist in smash
154  const ParticleType& current_type = ParticleType::find(pdgcode);
155  double current_mass = current_type.mass();
156  particles_.emplace_back(current_type);
157  particles_.back().set_4momentum(current_mass, 0.0, 0.0, 0.0);
158  }
159 }
size_t index
Index needed to read out vector in distribute nucleon.
Definition: customnucleus.h:97
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
constexpr int p
Proton.
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:256
constexpr int n
Neutron.

Here is the call graph for this function:

Here is the caller graph for this function:

ThreeVector smash::CustomNucleus::distribute_nucleon ( )
overridevirtual

Returns position of a nucleon as given in the external file.

Reimplemented from smash::Nucleus.

Definition at line 161 of file customnucleus.cc.

161  {
162  /*
163  * As only arrange_nucleons is called at the beginning of every
164  * event it is important to have readfile and fill from list
165  * called again when a new event starts. The constructor is only
166  * called twice to initialize the first target and projectile.
167  * Therefore this if statement is implemented.
168  */
169  if (index >= custom_nucleus_.size()) {
172  }
173  const auto& pos = custom_nucleus_.at(index);
174  index++;
175  ThreeVector nucleon_position(pos.x, pos.y, pos.z);
176  // rotate nucleon about euler angle
177  nucleon_position.rotate(euler_phi_, euler_theta_, euler_psi_);
178 
179  return nucleon_position;
180 }
double euler_psi_
Euler angel psi.
Definition: nucleus.h:269
std::vector< Nucleoncustom > readfile(std::ifstream &infile, int particle_number) const
The returned vector contains Data for one nucleus given in the particlelist.
std::vector< Nucleoncustom > custom_nucleus_
Vector contianing Data for one nucleus given in the particlelist.
Definition: customnucleus.h:95
double euler_phi_
Euler angel phi.
Definition: nucleus.h:265
size_t index
Index needed to read out vector in distribute nucleon.
Definition: customnucleus.h:97
int number_of_nucleons_
Number of Nucleons per Nucleus Set initally to zero to be modified in the constructor.
Definition: customnucleus.h:93
double euler_theta_
Euler angel theta.
Definition: nucleus.h:267
void fill_from_list(const std::vector< Nucleoncustom > &vec)
Fills Particlelist from vector containing data for one nucleus.
std::unique_ptr< std::ifstream > * used_filestream_
Pointer to the used filestream pointer.

Here is the call graph for this function:

Here is the caller graph for this function:

void smash::CustomNucleus::arrange_nucleons ( )
overridevirtual

Sets the positions of the nucleons inside a nucleus.

Reimplemented from smash::Nucleus.

Definition at line 182 of file customnucleus.cc.

182  {
183  /* Randomly generate Euler angles for rotation everytime a new
184  * custom nucleus is initialiezed. Therefore this is done 2 times per
185  * event.
186  */
188 
189  for (auto i = begin(); i != end(); i++) {
190  // Initialize momentum
191  i->set_4momentum(i->pole_mass(), 0.0, 0.0, 0.0);
192  /* Sampling the Woods-Saxon, get the radial
193  * position and solid angle for the nucleon. */
194  ThreeVector pos = distribute_nucleon();
195  // Set the position of the nucleon.
196  i->set_4position(FourVector(0.0, pos));
197  }
198  // Recenter
199  align_center();
200 }
void random_euler_angles()
Randomly generate Euler angles.
Definition: nucleus.cc:501
std::vector< ParticleData >::iterator begin()
For iterators over the particle list:
Definition: nucleus.h:273
void align_center()
Shifts the nucleus so that its center is at (0,0,0)
Definition: nucleus.h:215
ThreeVector distribute_nucleon() override
Returns position of a nucleon as given in the external file.
std::vector< ParticleData >::iterator end()
For iterators over the particle list:
Definition: nucleus.h:277

Here is the call graph for this function:

std::vector< Nucleoncustom > smash::CustomNucleus::readfile ( std::ifstream &  infile,
int  particle_number 
) const

The returned vector contains Data for one nucleus given in the particlelist.

Parameters
[in]infileis needed to read in from the external file
[in]particle_numberensures that only as many lines are read in as the nucleus contains nucleons.

Definition at line 220 of file customnucleus.cc.

221  {
222  int A = particle_number;
223  std::string line;
224  std::vector<Nucleoncustom> custom_nucleus;
225  // read in only A particles for one nucleus
226  for (int i = 0; i < A; ++i) {
227  std::getline(infile, line);
228  // make sure the stream goes back to the beginning when it hits end of file
229  if (infile.eof()) {
230  infile.clear();
231  infile.seekg(0, infile.beg);
232  std::getline(infile, line);
233  }
234  Nucleoncustom nucleon;
235  std::istringstream iss(line);
236  if (!(iss >> nucleon.x >> nucleon.y >> nucleon.z >>
237  nucleon.spinprojection >> nucleon.isospin)) {
238  throw std::runtime_error(
239  "SMASH could not read in a line from your initial nuclei input file."
240  "Check if your file has the following format: x y z spinprojection "
241  "isospin");
242  break;
243  }
244  custom_nucleus.push_back(nucleon);
245  }
246  return custom_nucleus;
247 }

Here is the caller graph for this function:

std::string smash::CustomNucleus::file_path ( const std::string &  file_directory,
const std::string &  file_name 
)

Generates the name of the stream file.

Parameters
[in]file_directoryis the path to the external file
[in]file_nameis the name of the external file

Definition at line 211 of file customnucleus.cc.

212  {
213  if (file_directory.back() == '/') {
214  return file_directory + file_name;
215  } else {
216  return file_directory + '/' + file_name;
217  }
218 }

Here is the caller graph for this function:

void smash::CustomNucleus::generate_fermi_momenta ( )
overridevirtual

Generates Fermi momenta as it is done in the mother class but in addition prints a warning that the Fermi momenta are generated accoriding to Woods-Saxon distributed nucleons.

Reimplemented from smash::Nucleus.

Definition at line 202 of file customnucleus.cc.

202  {
204  const auto& log = logger<LogArea::Collider>();
205  log.warn() << "Fermi motion activated with a custom nucleus.\n";
206  log.warn() << "Be aware that generating the Fermi momenta\n"
207  << "assumes nucleons distributed according to a\n"
208  << "Woods-Saxon distribution.";
209 }
virtual void generate_fermi_momenta()
Generates momenta according to Fermi motion for the nucleons.
Definition: nucleus.cc:368

Here is the call graph for this function:

Member Data Documentation

int smash::CustomNucleus::number_of_nucleons_ = 0

Number of Nucleons per Nucleus Set initally to zero to be modified in the constructor.

Is obtained by adding the proton and neutron numbers specified in the config.yaml

Definition at line 93 of file customnucleus.h.

std::vector<Nucleoncustom> smash::CustomNucleus::custom_nucleus_

Vector contianing Data for one nucleus given in the particlelist.

Definition at line 95 of file customnucleus.h.

size_t smash::CustomNucleus::index = 0

Index needed to read out vector in distribute nucleon.

Definition at line 97 of file customnucleus.h.

std::unique_ptr< std::ifstream > smash::CustomNucleus::filestream_shared_ = nullptr
staticprivate

Filestream variable used if projectile and target are read in from the same file and they use the same static stream.

Definition at line 110 of file customnucleus.h.

std::unique_ptr<std::ifstream> smash::CustomNucleus::filestream_
private

Filestream variable used if projectile and target are read in from different files and they therefore use different streams.

Definition at line 115 of file customnucleus.h.

std::unique_ptr<std::ifstream>* smash::CustomNucleus::used_filestream_
private

Pointer to the used filestream pointer.

Definition at line 117 of file customnucleus.h.


The documentation for this class was generated from the following files: