Version: SMASH-1.6
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 40 of file customnucleus.h.

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

Public Member Functions

 CustomNucleus (Configuration &config, int testparticles)
 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...
 
std::vector< Nucleoncustomreadfile (std::ifstream &infile, int particle_number) const
 The returned vector contains Data for one nucleus given in the particlelist. 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)
 
virtual ~Nucleus ()=default
 
double mass () const
 
double woods_saxon (double x)
 Woods-Saxon distribution. More...
 
void arrange_nucleons ()
 Sets the positions of the nucleons inside a nucleus. 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...
 
virtual void generate_fermi_momenta ()
 Generates momenta according to Fermi motion for the nucleons. 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...
 
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...
 
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 ()
 
void set_nuclear_radius (double rad)
 Sets the nuclear radius. More...
 
double get_nuclear_radius () const
 

Public Attributes

std::string particle_list_file_directory_
 Directory where the nucleon configurations are located. More...
 
std::string particle_list_file_name_
 File name of the nucleon configurations. More...
 
int number_of_nucleons_ = 0
 of Nucleons per Nucleus Set initally to zero to be modified in the constructor. More...
 
std::vector< Nucleoncustomcustom_nucleon_
 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...
 

Static Private Member Functions

static std::string streamfile (const std::string &file_directory, const std::string &file_name)
 Generates the name of the stream file. More...
 

Static Private Attributes

static std::unique_ptr< std::ifstream > filestream_ = nullptr
 Variable carrying the output of the streamfile function. More...
 
static bool checkfileopen_ = false
 Bool variable to check if the file was already opened. More...
 

Additional Inherited Members

- Protected Attributes inherited from smash::Nucleus
std::vector< ParticleDataparticles_
 Particles associated with this nucleus. More...
 

Constructor & Destructor Documentation

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

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

Definition at line 90 of file customnucleus.cc.

90  {
91  // Read in file directory from config
92  std::string fd = config.take({"Custom", "File_Directory"});
94  // Read in file name from config
95  std::string fn = config.take({"Custom", "File_Name"});
97 
98  if (particles_.size() != 0) {
99  throw std::runtime_error(
100  "Your Particle List is already filled before reading in from the "
101  "external file."
102  "Something went wrong. Please check your config.");
103  }
104 
105  /*
106  * Counts number of nucleons in one nucleus as it is specialized
107  * by the user in the config file.
108  * It is needed to read in the proper number of nucleons for one
109  * nucleus and to restart at the listreading for the following
110  * nucleus as one does not want to read configurations twice. */
111  std::map<PdgCode, int> particle_list = config.take({"Particles"});
112  for (const auto& particle : particle_list)
113  number_of_nucleons_ += particle.second * testparticles;
114  if (!checkfileopen_) {
115  filestream_ = make_unique<std::ifstream>(
117  // tracked that file was opened once
118  checkfileopen_ = true;
119  }
121 
123  // Inherited from nucleus class (see nucleus.h)
125 }
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_nucleon_
Vector contianing Data for one nucleus given in the particlelist.
Definition: customnucleus.h:89
static bool checkfileopen_
Bool variable to check if the file was already opened.
int number_of_nucleons_
of Nucleons per Nucleus Set initally to zero to be modified in the constructor.
Definition: customnucleus.h:87
static std::string streamfile(const std::string &file_directory, const std::string &file_name)
Generates the name of the stream file.
static std::unique_ptr< std::ifstream > filestream_
Variable carrying the output of the streamfile function.
void fill_from_list(const std::vector< Nucleoncustom > &vec)
Fills Particlelist from vector containing data for one nucleus.
std::vector< ParticleData > particles_
Particles associated with this nucleus.
Definition: nucleus.h:210
std::string particle_list_file_directory_
Directory where the nucleon configurations are located.
Definition: customnucleus.h:75
std::string particle_list_file_name_
File name of the nucleon configurations.
Definition: customnucleus.h:80
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 127 of file customnucleus.cc.

127  {
128  particles_.clear();
129  index = 0;
130  // checking if particle is proton or neutron
131  for (const auto& it : vec) {
132  PdgCode pdgcode;
133  if (it.isospin == 1) {
134  pdgcode = pdg::p;
135  } else if (it.isospin == 0) {
136  pdgcode = pdg::n;
137  } else {
138  throw std::runtime_error(
139  "Your particles charges are not 1 = proton or 0 = neutron."
140  "Check whether your list is correct or there is an error.");
141  }
142  // setting parameters for the particles in the particlelist in smash
143  const ParticleType& current_type = ParticleType::find(pdgcode);
144  double current_mass = current_type.mass();
145  particles_.emplace_back(current_type);
146  particles_.back().set_4momentum(current_mass, 0.0, 0.0, 0.0);
147  }
148 }
size_t index
Index needed to read out vector in distribute nucleon.
Definition: customnucleus.h:91
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:210
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 150 of file customnucleus.cc.

150  {
151  if (index >= custom_nucleon_.size()) {
153 
155  }
156  const auto& pos = custom_nucleon_.at(index);
157  index++;
158  return ThreeVector(pos.x, pos.y, pos.z);
159 }
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_nucleon_
Vector contianing Data for one nucleus given in the particlelist.
Definition: customnucleus.h:89
size_t index
Index needed to read out vector in distribute nucleon.
Definition: customnucleus.h:91
int number_of_nucleons_
of Nucleons per Nucleus Set initally to zero to be modified in the constructor.
Definition: customnucleus.h:87
static std::unique_ptr< std::ifstream > filestream_
Variable carrying the output of the streamfile function.
void fill_from_list(const std::vector< Nucleoncustom > &vec)
Fills Particlelist from vector containing data for one nucleus.

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 170 of file customnucleus.cc.

171  {
172  int A = particle_number;
173  std::string line;
174  std::vector<Nucleoncustom> nucleon;
175  int i = 0;
176  while (std::getline(infile, line)) {
177  Nucleoncustom nuc;
178  std::istringstream iss(line);
179  if (!(iss >> nuc.x >> nuc.y >> nuc.z >> nuc.spinprojection >>
180  nuc.isospin)) {
181  throw std::runtime_error(
182  "SMASH could not read in a line from your initial nuclei input file."
183  "Check if your file has follwing format: x y z spinprojection "
184  "isospin");
185  break;
186  }
187  nucleon.push_back(nuc);
188  // ensuring that only A particles are read in for one nucleus
189  if (++i == A) {
190  break;
191  }
192  }
193  return nucleon;
194 }

Here is the caller graph for this function:

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

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 161 of file customnucleus.cc.

162  {
163  if (file_directory.back() == '/') {
164  return file_directory + file_name;
165  } else {
166  return file_directory + '/' + file_name;
167  }
168 }

Here is the caller graph for this function:

Member Data Documentation

std::string smash::CustomNucleus::particle_list_file_directory_

Directory where the nucleon configurations are located.

Name is read in from manual input in the config.yaml

Definition at line 75 of file customnucleus.h.

std::string smash::CustomNucleus::particle_list_file_name_

File name of the nucleon configurations.

Name is read in from manual input in the config.yaml

Definition at line 80 of file customnucleus.h.

int smash::CustomNucleus::number_of_nucleons_ = 0

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 87 of file customnucleus.h.

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

Vector contianing Data for one nucleus given in the particlelist.

Definition at line 89 of file customnucleus.h.

size_t smash::CustomNucleus::index = 0

Index needed to read out vector in distribute nucleon.

Definition at line 91 of file customnucleus.h.

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

Variable carrying the output of the streamfile function.

Definition at line 108 of file customnucleus.h.

bool smash::CustomNucleus::checkfileopen_ = false
staticprivate

Bool variable to check if the file was already opened.

It ensures to read in every nucleus configuration given only once. If the bool is true the constructor uses the stream that was given the last time the constructor was called.

Definition at line 114 of file customnucleus.h.


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