Version: SMASH-3.4
customnucleus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-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 
21 /**
22  * Contains data for one nucleon that is read in from the list
23  */
24 struct Nucleoncustom {
25  /// x-coordinate
26  double x;
27  /// y-coordinate
28  double y;
29  /// z-coordinate
30  double z;
31  /// spinprojection of the nucleon
33  /// to differentiate between protons isospin=1 and neutrons isospin=0
34  bool isospin;
35 };
36 
37 /**
38  * Inheriting from Nucleus-Class using modified Nucleon configurations.
39  * Configurations are read in from external lists.
40  */
41 class CustomNucleus : public Nucleus {
42  public:
43  /**
44  * Constructor that needs configuration parameters from input file
45  * and the number of testparticles
46  *
47  * \param[in] config contains the parameters from the inputfile on the
48  * numbers of particles with a certain PDG code and also the path where
49  * the external particle list is located
50  * \param[in] testparticles represents the number of testparticles
51  * \param[in] same_file specifies if target and projectile nucleus are
52  * read in from the same file, which is important for the ifstream
53  */
54  CustomNucleus(Configuration& config, int testparticles, bool same_file);
55  /**
56  * Fills Particlelist from vector containing data for one nucleus.
57  * The data contains everything that is written in struct Nucleoncustom.
58  *
59  * \param[in] vec vector containing data from external list for one nucleus
60  */
61  void fill_from_list(const std::vector<Nucleoncustom>& vec);
62  /// Returns position of a nucleon as given in the external file
64  /// Sets the positions of the nucleons inside a nucleus.
65  void arrange_nucleons() override;
66  /**
67  * The returned vector contains Data for one nucleus given in the
68  * particlelist.
69  *
70  * \param[in] infile is needed to read in from the external file
71  */
72  std::vector<Nucleoncustom> readfile(std::ifstream& infile) const;
73  /**
74  * Generates the name of the stream file.
75  * \param[in] file_directory is the path to the external file
76  * \param[in] file_name is the name of the external file
77  */
78  std::string file_path(const std::string& file_directory,
79  const std::string& file_name);
80  /**
81  * Generates Fermi momenta as it is done in the mother class but in addition
82  * prints a warning that the Fermi momenta are generated accoriding to
83  * Woods-Saxon distributed nucleons.
84  */
85  void generate_fermi_momenta() override;
86 
87  private:
88  /**
89  * Filestream variable used if projectile and target are read in from the
90  * same file and they use the same static stream.
91  */
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_;
99  /**
100  * Filestream variable used if projectile and target are read in from
101  * different files and they therefore use different streams.
102  */
103  std::unique_ptr<std::ifstream> filestream_;
104  /// Pointer to the used filestream pointer
105  std::unique_ptr<std::ifstream>* used_filestream_;
106  /**
107  * Number of nucleons per nucleus
108  * Set initally to zero to be modified in the constructor.
109  * Is obtained by adding the proton and neutron numbers
110  * specified in the config.yaml
111  */
113  /// Number of protons per nucleus
115  /// Number of neutrons per nucleus
117  /// Vector contianing Data for one nucleus given in the particlelist
118  std::vector<Nucleoncustom> custom_nucleus_;
119  /// Index needed to read out vector in distribute nucleon
120  size_t index_ = 0;
121 };
122 
123 } // namespace smash
124 
125 #endif // SRC_INCLUDE_SMASH_CUSTOMNUCLEUS_H_
Interface to the SMASH configuration files.
Inheriting from Nucleus-Class using modified Nucleon configurations.
Definition: customnucleus.h:41
size_t index_
Index needed to read out vector in distribute nucleon.
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...
Definition: customnucleus.h:98
int number_of_protons_
Number of protons per nucleus.
ThreeVector distribute_nucleon() override
Returns position of a nucleon as given in the external file.
void arrange_nucleons() override
Sets the positions of the nucleons inside a nucleus.
CustomNucleus(Configuration &config, int testparticles, bool same_file)
Constructor that needs configuration parameters from input file and the number of testparticles.
std::vector< Nucleoncustom > custom_nucleus_
Vector contianing Data for one nucleus given in the particlelist.
int number_of_neutrons_
Number of neutrons per nucleus.
int number_of_nucleons_
Number of nucleons per nucleus Set initally to zero to be modified in the constructor.
std::unique_ptr< std::ifstream > filestream_
Filestream variable used if projectile and target are read in from different files and they therefore...
std::vector< Nucleoncustom > readfile(std::ifstream &infile) const
The returned vector contains Data for one nucleus given in the particlelist.
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...
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.
A nucleus is a collection of particles that are initialized, before the beginning of the simulation a...
Definition: nucleus.h:27
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
Definition: action.h:24
Contains data for one nucleon that is read in from the list.
Definition: customnucleus.h:24
double z
z-coordinate
Definition: customnucleus.h:30
double x
x-coordinate
Definition: customnucleus.h:26
bool isospin
to differentiate between protons isospin=1 and neutrons isospin=0
Definition: customnucleus.h:34
bool spinprojection
spinprojection of the nucleon
Definition: customnucleus.h:32
double y
y-coordinate
Definition: customnucleus.h:28