Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
AtomDef.h
Go to the documentation of this file.
1#ifndef ATOM_DEF_H
2#define ATOM_DEF_H
3
4#include <iostream>
5#include <vector>
6#include <list>
7
8namespace Heed {
9
10/// Definition of atoms.
11/// Only the basic information: name, notation, atomic weight and charge.
12///
13/// The principle of definitions of atoms is dictionary or a database:
14/// the atoms are not repeated,
15/// each atom is presented in the total system no more than one time.
16/// The system knows each atom presented in it.
17/// The atom characteristics can be obtained by literal notation.
18/// The system declines the secondary initialization.
19/// The copying is not declined.
20/// When the user program wants to refer to atom,
21/// it has to use either char* (string) notation, or pointer (or reference)
22/// to one of these objects.
23/// The user pogram can initialize the new atoms.
24/// The standard atoms are initiated in files GasLib.h and GasLib.c.
25///
26/// In principle I am going to initiate all atoms from Mendeleev's table,
27/// but I haven't finished yet. Only its first half is filled at the moment.
28///
29/// The atoms are registered in the static element of class AtomDef
30/// private:
31/// static std::list<AtomDef*> logbook;
32/// The can be obtained by notations by:
33/// public:
34/// static const std::list<AtomDef*>& get_AtomDefLogbook();
35/// static AtomDef* get_AtomDef(const std::string& fnotation);
36/// returns the address of atom with this name if it is registered in system,
37/// or NULL otherwise.
38///
39/// In these files and in the other components of the matter package
40/// the principles are similar. This is the principle of database, the principle
41/// of the strict protection of internal data (variables marked by
42/// suffix 'h') and granting access though the functions which have similar
43/// names without this suffix 'h'.
44///
45/// 1998-2004, I. Smirnov.
46
47class AtomDef {
48 std::string nameh = "none";
49 std::string notationh = "none";
50 /// Atomic number.
51 int Zh = 0;
52 /// Atomic mass in internal units. Transfer to gram/mole if need.
53 double Ah = 0.;
54 static constexpr int max_poss_atom_z = 100;
55
56 public:
57 /// Default constructor
58 AtomDef();
59 /// Constructor
60 AtomDef(const std::string& fnameh, const std::string& fnotationh, int fZh,
61 double fAh);
62 /// Destructor
63 ~AtomDef();
64
65 const std::string& name() const { return nameh; }
66 const std::string& notation() const { return notationh; }
67 int Z() const { return Zh; }
68 double A() const { return Ah; }
69 /// Print all registered atoms.
70 static void printall(std::ostream& file);
71 /// Check that there is no atom with the same name in the container.
72 void verify();
73 /// Initialize the logbook at the first request
74 /// and keep it as internal static variable.
75 static std::list<AtomDef*>& get_logbook();
76 static const std::list<AtomDef*>& get_const_logbook();
77 /// Return the address of atom with this name if it is registered in system,
78 /// or NULL otherwise
79 static AtomDef* get_AtomDef(const std::string& fnotation);
80 /// Return the atomic number corresponding to a given Z.
81 /// If the atom is not registered, the current version
82 /// terminates the program through spexit(). Be careful!
83 static double get_A(int fZ);
84 /// Return the address of atom corresponding to a given Z.
85 /// If the atom is not registered, the current version
86 /// terminates the program through spexit(). Be careful!
87 static AtomDef* get_AtomDef(int fZ);
88
89 void print(std::ostream& file, int l = 0) const;
90 AtomDef* copy() const { return new AtomDef(*this); }
91};
92std::ostream& operator<<(std::ostream& file, const AtomDef& f);
93
94/// Definition of atomic mixtures. Pointers to atoms, weights and
95/// various mean parameters.
96
98 /// Number of different atoms.
99 long qatomh = 0;
100 /// Constituent atoms.
101 std::vector<AtomDef*> atomh;
102 std::vector<double> weight_quanh; // sum is 1
103 std::vector<double> weight_massh; // sum is 1
104
105 /// Weighted mean Z
106 double Z_meanh = 0.;
107 /// Weighted mean A (in internal units). Transfer to gram/mole if needed.
108 double A_meanh = 0.;
109 /// Weighted mean 1 / A (in internal units).
110 double inv_A_meanh = 0.;
111 /// Weighted mean ratio Z / A.
112 double mean_ratio_Z_to_Ah = 0.;
113 double NumberOfElectronsInGramh = 0.;
114
115 public:
116 /// Default constructor
117 AtomMixDef() = default;
118 AtomMixDef(unsigned long fqatom, const std::vector<std::string>& fatom_not,
119 const std::vector<double>& fweight_quan);
120 AtomMixDef(unsigned long fqatom, const std::vector<std::string>& fatom_not,
121 const std::vector<long>& fweight_quan);
122 AtomMixDef(const std::string& fatom_not);
123 AtomMixDef(const std::string& fatom_not1, double fweight_quan1,
124 const std::string& fatom_not2, double fweight_quan2);
125 AtomMixDef(const std::string& fatom_not1, double fweight_quan1,
126 const std::string& fatom_not2, double fweight_quan2,
127 const std::string& fatom_not3, double fweight_quan3);
128 AtomMixDef(const std::string& fatom_not1, double fweight_quan1,
129 const std::string& fatom_not2, double fweight_quan2,
130 const std::string& fatom_not3, double fweight_quan3,
131 const std::string& fatom_not4, double fweight_quan4);
132 void print(std::ostream& file, int l) const;
133 long qatom() const { return qatomh; }
134 const std::vector<AtomDef*>& atom() const { return atomh; }
135 AtomDef* atom(long n) const { return atomh[n]; }
136 const std::vector<double>& weight_quan() const { return weight_quanh; }
137 const std::vector<double>& weight_mass() const { return weight_massh; }
138 double weight_quan(long n) const { return weight_quanh[n]; }
139 double weight_mass(long n) const { return weight_massh[n]; }
140 double Z_mean() const { return Z_meanh; }
141 double A_mean() const { return A_meanh; }
142 double inv_A_mean() const { return inv_A_meanh; }
143 double mean_ratio_Z_to_A() const { return mean_ratio_Z_to_Ah; }
144 double NumberOfElectronsInGram() const {
145 return NumberOfElectronsInGramh;
146 }
147};
148std::ostream& operator<<(std::ostream& file, const AtomMixDef& f);
149}
150
151#endif
~AtomDef()
Destructor.
Definition: AtomDef.cpp:94
double A() const
Definition: AtomDef.h:68
static std::list< AtomDef * > & get_logbook()
Definition: AtomDef.cpp:78
void verify()
Check that there is no atom with the same name in the container.
Definition: AtomDef.cpp:58
AtomDef()
Default constructor.
Definition: AtomDef.cpp:23
int Z() const
Definition: AtomDef.h:67
AtomDef * copy() const
Definition: AtomDef.h:90
const std::string & name() const
Definition: AtomDef.h:65
void print(std::ostream &file, int l=0) const
Definition: AtomDef.cpp:14
static void printall(std::ostream &file)
Print all registered atoms.
Definition: AtomDef.cpp:18
const std::string & notation() const
Definition: AtomDef.h:66
static double get_A(int fZ)
Definition: AtomDef.cpp:36
static AtomDef * get_AtomDef(const std::string &fnotation)
Definition: AtomDef.cpp:87
static const std::list< AtomDef * > & get_const_logbook()
Definition: AtomDef.cpp:83
const std::vector< double > & weight_quan() const
Definition: AtomDef.h:136
AtomMixDef()=default
Default constructor.
void print(std::ostream &file, int l) const
Definition: AtomDef.cpp:415
const std::vector< double > & weight_mass() const
Definition: AtomDef.h:137
long qatom() const
Definition: AtomDef.h:133
double mean_ratio_Z_to_A() const
Definition: AtomDef.h:143
double Z_mean() const
Definition: AtomDef.h:140
double weight_quan(long n) const
Definition: AtomDef.h:138
const std::vector< AtomDef * > & atom() const
Definition: AtomDef.h:134
AtomDef * atom(long n) const
Definition: AtomDef.h:135
double NumberOfElectronsInGram() const
Definition: AtomDef.h:144
double inv_A_mean() const
Definition: AtomDef.h:142
double weight_mass(long n) const
Definition: AtomDef.h:139
double A_mean() const
Definition: AtomDef.h:141
Definition: BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37