Version: SMASH-2.0
customnucleus.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_CUSTOMNUCLEUS_H_
8 #define SRC_INCLUDE_SMASH_CUSTOMNUCLEUS_H_
9 
10 #include <fstream>
11 #include <map>
12 #include <memory>
13 #include <string>
14 #include <vector>
15 
16 #include "nucleus.h"
17 #include "pdgcode.h"
18 #include "threevector.h"
19 namespace smash {
20 
24 struct Nucleoncustom {
26  double x;
28  double y;
30  double z;
34  bool isospin;
35 };
36 
41 class CustomNucleus : public Nucleus {
42  public:
54  CustomNucleus(Configuration& config, int testparticles, bool same_file);
61  void fill_from_list(const std::vector<Nucleoncustom>& vec);
65  void arrange_nucleons() override;
72  std::vector<Nucleoncustom> readfile(std::ifstream& infile) const;
78  std::string file_path(const std::string& file_directory,
79  const std::string& file_name);
85  void generate_fermi_momenta() override;
86 
87  private:
92  /*
93  * The unique_ptr is only required to work around a bug in GCC 4.8, because it
94  * seems to be trying to use the non-existing copy-constructor of
95  * `std::ifstream`. Newer compilers don't require this unneccessary
96  * indirection.
97  */
98  static std::unique_ptr<std::ifstream> filestream_shared_;
103  std::unique_ptr<std::ifstream> filestream_;
105  std::unique_ptr<std::ifstream>* used_filestream_;
118  std::vector<Nucleoncustom> custom_nucleus_;
120  size_t index_ = 0;
121 };
122 
123 } // namespace smash
124 
125 #endif // SRC_INCLUDE_SMASH_CUSTOMNUCLEUS_H_
smash::CustomNucleus::distribute_nucleon
ThreeVector distribute_nucleon() override
Returns position of a nucleon as given in the external file.
Definition: customnucleus.cc:169
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::CustomNucleus::arrange_nucleons
void arrange_nucleons() override
Sets the positions of the nucleons inside a nucleus.
Definition: customnucleus.cc:190
smash::Nucleoncustom::z
double z
z-coordinate
Definition: customnucleus.h:30
smash::Nucleoncustom::x
double x
x-coordinate
Definition: customnucleus.h:26
smash::CustomNucleus::CustomNucleus
CustomNucleus(Configuration &config, int testparticles, bool same_file)
Constructor that needs configuration parameters from input file and the number of testparticles.
Definition: customnucleus.cc:89
smash::Nucleoncustom::y
double y
y-coordinate
Definition: customnucleus.h:28
smash::CustomNucleus
Inheriting from Nucleus-Class using modified Nucleon configurations.
Definition: customnucleus.h:41
smash::Nucleoncustom::isospin
bool isospin
to differentiate between protons isospin=1 and neutrons isospin=0
Definition: customnucleus.h:34
smash::CustomNucleus::generate_fermi_momenta
void generate_fermi_momenta() override
Generates Fermi momenta as it is done in the mother class but in addition prints a warning that the F...
Definition: customnucleus.cc:210
smash::Configuration
Interface to the SMASH configuration files.
Definition: configuration.h:464
smash::CustomNucleus::filestream_
std::unique_ptr< std::ifstream > filestream_
Filestream variable used if projectile and target are read in from different files and they therefore...
Definition: customnucleus.h:103
smash::ThreeVector
Definition: threevector.h:31
smash::CustomNucleus::custom_nucleus_
std::vector< Nucleoncustom > custom_nucleus_
Vector contianing Data for one nucleus given in the particlelist.
Definition: customnucleus.h:118
threevector.h
smash::CustomNucleus::number_of_nucleons_
int number_of_nucleons_
Number of nucleons per nucleus Set initally to zero to be modified in the constructor.
Definition: customnucleus.h:112
smash::CustomNucleus::number_of_neutrons_
int number_of_neutrons_
Number of neutrons per nucleus.
Definition: customnucleus.h:116
smash::CustomNucleus::used_filestream_
std::unique_ptr< std::ifstream > * used_filestream_
Pointer to the used filestream pointer.
Definition: customnucleus.h:105
nucleus.h
smash::CustomNucleus::file_path
std::string file_path(const std::string &file_directory, const std::string &file_name)
Generates the name of the stream file.
Definition: customnucleus.cc:218
smash::CustomNucleus::number_of_protons_
int number_of_protons_
Number of protons per nucleus.
Definition: customnucleus.h:114
pdgcode.h
smash::Nucleoncustom
Contains data for one nucleon that is read in from the list.
Definition: customnucleus.h:24
smash::CustomNucleus::filestream_shared_
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...
Definition: customnucleus.h:98
smash::Nucleoncustom::spinprojection
bool spinprojection
spinprojection of the nucleon
Definition: customnucleus.h:32
smash::CustomNucleus::index_
size_t index_
Index needed to read out vector in distribute nucleon.
Definition: customnucleus.h:120
smash::CustomNucleus::fill_from_list
void fill_from_list(const std::vector< Nucleoncustom > &vec)
Fills Particlelist from vector containing data for one nucleus.
Definition: customnucleus.cc:146
smash::CustomNucleus::readfile
std::vector< Nucleoncustom > readfile(std::ifstream &infile) const
The returned vector contains Data for one nucleus given in the particlelist.
Definition: customnucleus.cc:227