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