15 if (l > 0) file << (*this);
19 Ifile <<
"AtomDef::printall:\n";
29 : nameh(fnameh), notationh(fnotationh), Zh(fZh), Ah(fAh) {
37 mfunnamep(
"double AtomDef::get_A(int fZ)");
39 if (atom->Z() == fZ)
return atom->A();
42 mcerr <<
"Atom is not found, Z=" << fZ <<
'\n';
48 mfunnamep(
"AtomDef* AtomDef::get_AtomDef(int fZ)");
50 if (atom->Z() == fZ)
return atom;
53 mcerr <<
"Atom is not found, Z=" << fZ <<
'\n';
60 if (nameh ==
"none" && notationh ==
"none")
return;
62 if (atom->nameh != nameh && atom->notationh != notationh)
continue;
64 mcerr <<
"cannot initialize two atoms with the same name or notation\n";
65 mcerr <<
"name=" << nameh <<
" notation=" << notationh <<
'\n';
71 Ifile <<
"AtomDef: name=" << std::setw(10) << f.
name()
72 <<
" notation=" << std::setw(3) << f.
notation();
73 Ifile <<
" Z()=" << std::setw(3) << f.
Z()
74 <<
" A()/(gram/mole)=" << f.
A() / (gram / mole) <<
'\n';
79 static std::list<AtomDef*> logbook;
89 if (atom->notation() == fnotation)
return atom;
97 const std::vector<std::string>& fatom_not,
98 const std::vector<double>& fweight_quan)
100 atomh(fqatom, nullptr),
101 weight_quanh(fqatom, 0.0),
102 weight_massh(fqatom, 0.0) {
103 mfunnamep(
"AtomMixDef::AtomMixDef(...)");
108 for (
long n = 0; n < qatomh; ++n) {
112 mcerr <<
"cannot find atom with notation " << fatom_not[n]
113 <<
"\nIn particular, check the sequence of initialization\n";
119 for (
long n = 0; n < qatomh; n++) {
120 weight_quanh[n] = fweight_quan[n];
122 s += weight_quanh[n];
126 for (
long n = 0; n < qatomh; n++) {
127 weight_quanh[n] /= s;
130 for (
long n = 0; n < qatomh; n++) {
131 weight_massh[n] = weight_quanh[n] * atomh[n]->A();
134 for (
long n = 0; n < qatomh; n++) {
135 s += weight_massh[n];
139 for (
long n = 0; n < qatomh; n++) {
140 weight_massh[n] /= s;
143 for (
long n = 0; n < qatomh; n++) {
144 Z_meanh += atomh[n]->Z() * weight_quanh[n];
145 A_meanh += atomh[n]->A() * weight_quanh[n];
146 inv_A_meanh += (1.0 / atomh[n]->A()) * weight_quanh[n];
148 mean_ratio_Z_to_Ah = Z_meanh / A_meanh;
149 NumberOfElectronsInGramh = mean_ratio_Z_to_Ah * (gram / mole) * Avogadro;
153 const std::vector<std::string>& fatom_not,
154 const std::vector<long>& fweight_quan)
156 atomh(fqatom, nullptr),
157 weight_quanh(fqatom, 0.0),
158 weight_massh(fqatom, 0.0) {
159 mfunnamep(
"AtomMixDef::AtomMixDef(...)");
164 for (
long n = 0; n < qatomh; ++n) {
168 mcerr <<
"cannot find atom with notation " << fatom_not[n]
169 <<
"\nIn particular, check the sequence of initialization\n";
175 for (
long n = 0; n < qatomh; n++) {
176 weight_quanh[n] = fweight_quan[n];
178 s += weight_quanh[n];
182 for (
long n = 0; n < qatomh; n++) {
183 weight_quanh[n] /= s;
186 for (
long n = 0; n < qatomh; n++) {
187 weight_massh[n] = weight_quanh[n] * atomh[n]->A();
190 for (
long n = 0; n < qatomh; n++) {
191 s += weight_massh[n];
195 for (
long n = 0; n < qatomh; n++) {
196 weight_massh[n] /= s;
199 for (
long n = 0; n < qatomh; n++) {
200 Z_meanh += atomh[n]->Z() * weight_quanh[n];
201 A_meanh += atomh[n]->A() * weight_quanh[n];
202 inv_A_meanh += (1.0 / atomh[n]->A()) * weight_quanh[n];
204 mean_ratio_Z_to_Ah = Z_meanh / A_meanh;
205 NumberOfElectronsInGramh = mean_ratio_Z_to_Ah * (gram / mole) * Avogadro;
213 weight_massh(1, 1.) {
214 mfunnamep(
"AtomMixDef::AtomMixDef(...)");
218 mcerr <<
"cannot find atom with notation " << fatom_not
219 <<
"\nIn particular, check the sequence of initialization\n";
224 weight_quanh[0] = 1.0;
225 weight_massh[0] = 1.0;
227 Z_meanh += atomh[0]->Z();
228 A_meanh += atomh[0]->A();
229 inv_A_meanh += (1.0 / atomh[0]->A());
230 mean_ratio_Z_to_Ah = Z_meanh / A_meanh;
231 NumberOfElectronsInGramh = mean_ratio_Z_to_Ah * (gram / mole) * Avogadro;
236 const std::string& fatom_not2,
double fweight_quan2)
241 mfunnamep(
"AtomMixDef::AtomMixDef(...)");
242 std::vector<std::string> fatom_not(2);
243 fatom_not[0] = fatom_not1;
244 fatom_not[1] = fatom_not2;
246 for (
long n = 0; n < qatomh; ++n) {
250 mcerr <<
"cannot find atom with notation " << fatom_not[n]
251 <<
"\nIn particular, check the sequence of initialization\n";
256 weight_quanh[0] = fweight_quan1;
257 weight_quanh[1] = fweight_quan2;
259 for (
long n = 0; n < qatomh; n++) {
261 s += weight_quanh[n];
265 for (
long n = 0; n < qatomh; n++) {
266 weight_quanh[n] /= s;
269 for (
long n = 0; n < qatomh; n++) {
270 weight_massh[n] = weight_quanh[n] * atomh[n]->A();
273 for (
long n = 0; n < qatomh; n++) {
274 s += weight_massh[n];
278 for (
long n = 0; n < qatomh; n++) {
279 weight_massh[n] /= s;
282 for (
long n = 0; n < qatomh; n++) {
283 Z_meanh += atomh[n]->Z() * weight_quanh[n];
284 A_meanh += atomh[n]->A() * weight_quanh[n];
285 inv_A_meanh += (1.0 / atomh[n]->A()) * weight_quanh[n];
287 mean_ratio_Z_to_Ah = Z_meanh / A_meanh;
288 NumberOfElectronsInGramh = mean_ratio_Z_to_Ah * (gram / mole) * Avogadro;
293 const std::string& fatom_not2,
double fweight_quan2,
294 const std::string& fatom_not3,
double fweight_quan3)
300 mfunnamep(
"AtomMixDef::AtomMixDef(...)");
301 std::vector<std::string> fatom_not(3);
302 fatom_not[0] = fatom_not1;
303 fatom_not[1] = fatom_not2;
304 fatom_not[2] = fatom_not3;
306 for (
long n = 0; n < qatomh; ++n) {
310 mcerr <<
"cannot find atom with notation " << fatom_not[n]
311 <<
"\nIn particular, check the sequence of initialization\n";
316 weight_quanh[0] = fweight_quan1;
317 weight_quanh[1] = fweight_quan2;
318 weight_quanh[2] = fweight_quan3;
320 for (
long n = 0; n < qatomh; n++) {
322 s += weight_quanh[n];
326 for (
long n = 0; n < qatomh; n++) {
327 weight_quanh[n] /= s;
330 for (
long n = 0; n < qatomh; n++) {
331 weight_massh[n] = weight_quanh[n] * atomh[n]->A();
334 for (
long n = 0; n < qatomh; n++) {
335 s += weight_massh[n];
339 for (
long n = 0; n < qatomh; n++) {
340 weight_massh[n] /= s;
343 for (
long n = 0; n < qatomh; n++) {
344 Z_meanh += atomh[n]->Z() * weight_quanh[n];
345 A_meanh += atomh[n]->A() * weight_quanh[n];
346 inv_A_meanh += (1.0 / atomh[n]->A()) * weight_quanh[n];
348 mean_ratio_Z_to_Ah = Z_meanh / A_meanh;
349 NumberOfElectronsInGramh = mean_ratio_Z_to_Ah * (gram / mole) * Avogadro;
354 const std::string& fatom_not2,
double fweight_quan2,
355 const std::string& fatom_not3,
double fweight_quan3,
356 const std::string& fatom_not4,
double fweight_quan4)
360 weight_massh(4, 0.) {
361 mfunnamep(
"AtomMixDef::AtomMixDef(...)");
362 std::vector<std::string> fatom_not(4);
363 fatom_not[0] = fatom_not1;
364 fatom_not[1] = fatom_not2;
365 fatom_not[2] = fatom_not3;
366 fatom_not[3] = fatom_not4;
368 for (
long k = 0; k < qatomh; k++) {
372 mcerr <<
"cannot find atom with notation " << fatom_not[k]
373 <<
"\nIn particular, check the sequence of initialization\n";
378 weight_quanh[0] = fweight_quan1;
379 weight_quanh[1] = fweight_quan2;
380 weight_quanh[2] = fweight_quan3;
381 weight_quanh[3] = fweight_quan4;
383 for (
long n = 0; n < qatomh; n++) {
385 s += weight_quanh[n];
389 for (
long n = 0; n < qatomh; n++) {
390 weight_quanh[n] /= s;
393 for (
long n = 0; n < qatomh; n++) {
394 weight_massh[n] = weight_quanh[n] * atomh[n]->A();
397 for (
long n = 0; n < qatomh; n++) {
398 s += weight_massh[n];
402 for (
long n = 0; n < qatomh; n++) {
403 weight_massh[n] /= s;
406 for (
long n = 0; n < qatomh; n++) {
407 Z_meanh += atomh[n]->Z() * weight_quanh[n];
408 A_meanh += atomh[n]->A() * weight_quanh[n];
409 inv_A_meanh += (1.0 / atomh[n]->A()) * weight_quanh[n];
411 mean_ratio_Z_to_Ah = Z_meanh / A_meanh;
412 NumberOfElectronsInGramh = mean_ratio_Z_to_Ah * (gram / mole) * Avogadro;
416 if (l > 0) file << (*this);
420 mfunname(
"std::ostream& operator << (std::ostream&, const AtomMixDef&)");
421 Ifile <<
"AtomMixDef\n";
423 constexpr double gpm = gram / mole;
425 <<
" A_mean()/(gram/mole)=" << f.
A_mean() / gpm <<
'\n';
427 Ifile <<
"mean_ratio_Z_to_A()*(gram/mole)="
434 for (
long n = 0; n < f.
qatom(); n++) {
435 Ifile <<
"n=" << n <<
" atom(n)->notation=" << f.
atom(n)->notation()
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
#define check_econd11(a, signb, stream)
#define mfunnamep(string)
#define check_econd12(a, sign, b, stream)
static std::list< AtomDef * > & get_logbook()
void verify()
Check that there is no atom with the same name in the container.
AtomDef()
Default constructor.
const std::string & name() const
void print(std::ostream &file, int l=0) const
static void printall(std::ostream &file)
Print all registered atoms.
const std::string & notation() const
static double get_A(int fZ)
static AtomDef * get_AtomDef(const std::string &fnotation)
static const std::list< AtomDef * > & get_const_logbook()
const std::vector< double > & weight_quan() const
AtomMixDef()=default
Default constructor.
void print(std::ostream &file, int l) const
const std::vector< double > & weight_mass() const
double mean_ratio_Z_to_A() const
const std::vector< AtomDef * > & atom() const
double NumberOfElectronsInGram() const
double inv_A_mean() const
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
#define Iprintn(file, name)