Version: SMASH-3.1
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 
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_
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