Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_chemicalElement.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include <ctype.h>
11
12#include <PoPI.hpp>
13
14namespace PoPI {
15
16#define PoPI_Z_Chars "Z"
17
18static std::string emptyString( "" );
19static std::map<int, std::string> ZtoChemicalElementSymbols{
20 {1, "H"}, {2, "He"}, {3, "Li"}, {4, "Be"}, {5, "B"}, {6, "C"}, {7, "N"}, {8, "O"}, {9, "F"}, {10, "Ne"},
21 {11, "Na"}, {12, "Mg"}, {13, "Al"}, {14, "Si"}, {15, "P"}, {16, "S"}, {17, "Cl"}, {18, "Ar"}, {19, "K"}, {20, "Ca"},
22 {21, "Sc"}, {22, "Ti"}, {23, "V"}, {24, "Cr"}, {25, "Mn"}, {26, "Fe"}, {27, "Co"}, {28, "Ni"}, {29, "Cu"}, {30, "Zn"},
23 {31, "Ga"}, {32, "Ge"}, {33, "As"}, {34, "Se"}, {35, "Br"}, {36, "Kr"}, {37, "Rb"}, {38, "Sr"}, {39, "Y"}, {40, "Zr"},
24 {41, "Nb"}, {42, "Mo"}, {43, "Tc"}, {44, "Ru"}, {45, "Rh"}, {46, "Pd"}, {47, "Ag"}, {48, "Cd"}, {49, "In"}, {50, "Sn"},
25 {51, "Sb"}, {52, "Te"}, {53, "I"}, {54, "Xe"}, {55, "Cs"}, {56, "Ba"}, {57, "La"}, {58, "Ce"}, {59, "Pr"}, {60, "Nd"},
26 {61, "Pm"}, {62, "Sm"}, {63, "Eu"}, {64, "Gd"}, {65, "Tb"}, {66, "Dy"}, {67, "Ho"}, {68, "Er"}, {69, "Tm"}, {70, "Yb"},
27 {71, "Lu"}, {72, "Hf"}, {73, "Ta"}, {74, "W"}, {75, "Re"}, {76, "Os"}, {77, "Ir"}, {78, "Pt"}, {79, "Au"}, {80, "Hg"},
28 {81, "Tl"}, {82, "Pb"}, {83, "Bi"}, {84, "Po"}, {85, "At"}, {86, "Rn"}, {87, "Fr"}, {88, "Ra"}, {89, "Ac"}, {90, "Th"},
29 {91, "Pa"}, {92, "U"}, {93, "Np"}, {94, "Pu"}, {95, "Am"}, {96, "Cm"}, {97, "Bk"}, {98, "Cf"}, {99, "Es"}, {100, "Fm"},
30 {101, "Md"}, {102, "No"}, {103, "Lr"}, {104, "Rf"}, {105, "Db"}, {106, "Sg"}, {107, "Bh"}, {108, "Hs"}, {109, "Mt"}, {110, "Ds"},
31 {111, "Rg"}, {112, "Cn"}, {113, "Nh"}, {114, "Fl"}, {115, "Mc"}, {116, "Lv"}, {117, "Ts"}, {118, "Og"} };
32
33static std::map<std::string, int> chemicalElementSymbolToZs;
34std::map<std::string, std::string> supportedNucleusAliases{ {"d", "h2"}, {"t", "h3"}, {"h", "he3"}, {"a", "he4"} };
35static std::string protonFakeAlias( "h1" );
36
37/*! \class ChemicalElement
38 * This class represents a **PoPs** chemicalElement instance.
39 */
40
41/* *********************************************************************************************************//**
42 * Constructor that parses an **HAPI** instance to create a **GNDS** chemicalElement node.
43 *
44 * @param a_node [in] The **HAPI::Node** to be parsed.
45 * @param a_DB [in] The **PoPI::Database:: instance to add the constructed **ChemicalElement** to.
46 * @param a_parent [in] The parent suite that will contain *this*.
47 ***********************************************************************************************************/
48
49ChemicalElement::ChemicalElement( HAPI::Node const &a_node, Database *a_DB, LUPI_maybeUnused Database *a_parent ) :
50 SymbolBase( a_node, Particle_class::chemicalElement ),
51 m_Z( a_node.attribute( PoPI_Z_Chars ).as_int( ) ),
52 m_name( a_node.attribute( PoPI_nameChars ).value( ) ),
53 m_isotopes( PoPI_isotopesChars ) {
54
55 addToSymbols( a_DB );
56 m_isotopes.appendFromParentNode( a_node.child( PoPI_isotopesChars ), a_DB, this );
57}
58
59/* *********************************************************************************************************//**
60 ***********************************************************************************************************/
61
65
66/* *********************************************************************************************************//**
67 ***********************************************************************************************************/
68
70
71 for( std::size_t i1 = 0; i1 < m_isotopes.size( ); ++i1 ) {
72 Isotope const &isotope = m_isotopes[i1];
73
74 isotope.calculateNuclideGammaBranchStateInfos( a_pops, a_nuclideGammaBranchStateInfos );
75 }
76}
77
78/* *********************************************************************************************************//**
79 * Adds the contents of *this* to *a_XMLList* where each item in *a_XMLList* is one line (without linefeeds) to output as an XML representation of *this*.
80 *
81 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
82 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
83 ***********************************************************************************************************/
84
85void ChemicalElement::toXMLList( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
86
87 std::string::size_type size = m_isotopes.size( );
88 std::string ZStr = LUPI::Misc::argumentsToString( "%d", m_Z );
89
90 if( size == 0 ) return;
91
92 std::string header = a_indent1 + "<chemicalElement symbol=\"" + symbol( ) + "\" Z=\"" + ZStr + "\" name=\"" + m_name + "\">";
93 a_XMLList.push_back( std::move( header ) );
94
95 std::string indent2 = a_indent1 + " ";
96 std::string isotopeSuite = indent2 + "<" + PoPI_isotopesChars + ">";
97 a_XMLList.push_back( std::move( isotopeSuite ) );
98
99 std::string indent3 = indent2 + " ";
100 for( std::string::size_type i1 = 0; i1 < size; ++i1 ) m_isotopes[i1].toXMLList( a_XMLList, indent3 );
101
102 appendXMLEnd( a_XMLList, PoPI_isotopesChars );
104}
105
106/* *********************************************************************************************************//**
107 * Returns the maximum supported Z (atomic number) supported by function chemicalElementInfoFromZ.
108 *
109 * @return int.
110 ***********************************************************************************************************/
111
113
114 return( static_cast<int>( ZtoChemicalElementSymbols.size( ) ) );
115}
116
117/* *********************************************************************************************************//**
118 * Returns the chemical element's symbol (*a_wantSymbol* = **true**) or name (*a_wantSymbol* = **false**) for
119 * the requrest atomic number *a_Z*. *a_wantSymbol* is **true**, the returned symbol is for the nuclide when
120 * *a_asNucleus* is **false** and for the nucleus otherwise.
121 *
122 * @param a_Z [in] The Z (atomic number of the chemical element.
123 * @param a_wantSymbol [in] If **true** returns the chemical element's symbol otherwise its name.
124 * @param a_asNucleus [in] If **true** returns the symbol for the nucleus, otherwise for the nuclide. As no affect if a_wantSymbol is **false**.
125 *
126 * @return The symbol for the nuclide or the nucleus, or the name as a std::string.
127 ***********************************************************************************************************/
128
129std::string chemicalElementInfoFromZ( int a_Z, bool a_wantSymbol, bool a_asNucleus ) {
130
131 std::string info;
132
133 switch( a_Z ) {
134 case 1:
135 if( a_wantSymbol ) {
136 info = "H"; }
137 else {
138 info = "Hydrogen";
139 }
140 break;
141 case 2:
142 if( a_wantSymbol ) {
143 info = "He"; }
144 else {
145 info = "Helium";
146 }
147 break;
148 case 3:
149 if( a_wantSymbol ) {
150 info = "Li"; }
151 else {
152 info = "Lithium";
153 }
154 break;
155 case 4:
156 if( a_wantSymbol ) {
157 info = "Be"; }
158 else {
159 info = "Beryllium";
160 }
161 break;
162 case 5:
163 if( a_wantSymbol ) {
164 info = "B"; }
165 else {
166 info = "Boron";
167 }
168 break;
169 case 6:
170 if( a_wantSymbol ) {
171 info = "C"; }
172 else {
173 info = "Carbon";
174 }
175 break;
176 case 7:
177 if( a_wantSymbol ) {
178 info = "N"; }
179 else {
180 info = "Nitrogen";
181 }
182 break;
183 case 8:
184 if( a_wantSymbol ) {
185 info = "O"; }
186 else {
187 info = "Oxygen";
188 }
189 break;
190 case 9:
191 if( a_wantSymbol ) {
192 info = "F"; }
193 else {
194 info = "Fluorine";
195 }
196 break;
197 case 10:
198 if( a_wantSymbol ) {
199 info = "Ne"; }
200 else {
201 info = "Neon";
202 }
203 break;
204 case 11:
205 if( a_wantSymbol ) {
206 info = "Na"; }
207 else {
208 info = "Sodium";
209 }
210 break;
211 case 12:
212 if( a_wantSymbol ) {
213 info = "Mg"; }
214 else {
215 info = "Magnesium";
216 }
217 break;
218 case 13:
219 if( a_wantSymbol ) {
220 info = "Al"; }
221 else {
222 info = "Aluminium";
223 }
224 break;
225 case 14:
226 if( a_wantSymbol ) {
227 info = "Si"; }
228 else {
229 info = "Silicon";
230 }
231 break;
232 case 15:
233 if( a_wantSymbol ) {
234 info = "P"; }
235 else {
236 info = "Phosphorus";
237 }
238 break;
239 case 16:
240 if( a_wantSymbol ) {
241 info = "S"; }
242 else {
243 info = "Sulphur";
244 }
245 break;
246 case 17:
247 if( a_wantSymbol ) {
248 info = "Cl"; }
249 else {
250 info = "Chlorine";
251 }
252 break;
253 case 18:
254 if( a_wantSymbol ) {
255 info = "Ar"; }
256 else {
257 info = "Argon";
258 }
259 break;
260 case 19:
261 if( a_wantSymbol ) {
262 info = "K"; }
263 else {
264 info = "Potassium";
265 }
266 break;
267 case 20:
268 if( a_wantSymbol ) {
269 info = "Ca"; }
270 else {
271 info = "Calcium";
272 }
273 break;
274 case 21:
275 if( a_wantSymbol ) {
276 info = "Sc"; }
277 else {
278 info = "Scandium";
279 }
280 break;
281 case 22:
282 if( a_wantSymbol ) {
283 info = "Ti"; }
284 else {
285 info = "Titanium";
286 }
287 break;
288 case 23:
289 if( a_wantSymbol ) {
290 info = "V"; }
291 else {
292 info = "Vanadium";
293 }
294 break;
295 case 24:
296 if( a_wantSymbol ) {
297 info = "Cr"; }
298 else {
299 info = "Chromium";
300 }
301 break;
302 case 25:
303 if( a_wantSymbol ) {
304 info = "Mn"; }
305 else {
306 info = "Manganese";
307 }
308 break;
309 case 26:
310 if( a_wantSymbol ) {
311 info = "Fe"; }
312 else {
313 info = "Iron";
314 }
315 break;
316 case 27:
317 if( a_wantSymbol ) {
318 info = "Co"; }
319 else {
320 info = "Cobalt";
321 }
322 break;
323 case 28:
324 if( a_wantSymbol ) {
325 info = "Ni"; }
326 else {
327 info = "Nickel";
328 }
329 break;
330 case 29:
331 if( a_wantSymbol ) {
332 info = "Cu"; }
333 else {
334 info = "Copper";
335 }
336 break;
337 case 30:
338 if( a_wantSymbol ) {
339 info = "Zn"; }
340 else {
341 info = "Zinc";
342 }
343 break;
344 case 31:
345
346 if( a_wantSymbol ) {
347 info = "Ga"; }
348 else {
349 info = "Gallium";
350 }
351 break;
352 case 32:
353 if( a_wantSymbol ) {
354 info = "Ge"; }
355 else {
356 info = "Germanium";
357 }
358 break;
359 case 33:
360 if( a_wantSymbol ) {
361 info = "As"; }
362 else {
363 info = "Arsenic";
364 }
365 break;
366 case 34:
367 if( a_wantSymbol ) {
368 info = "Se"; }
369 else {
370 info = "Selenium";
371 }
372 break;
373 case 35:
374 if( a_wantSymbol ) {
375 info = "Br"; }
376 else {
377 info = "Bromine";
378 }
379 break;
380 case 36:
381 if( a_wantSymbol ) {
382 info = "Kr"; }
383 else {
384 info = "Krypton";
385 }
386 break;
387 case 37:
388 if( a_wantSymbol ) {
389 info = "Rb"; }
390 else {
391 info = "Rubidium";
392 }
393 break;
394 case 38:
395 if( a_wantSymbol ) {
396 info = "Sr"; }
397 else {
398 info = "Strontium";
399 }
400 break;
401 case 39:
402 if( a_wantSymbol ) {
403 info = "Y"; }
404 else {
405 info = "Yttrium";
406 }
407 break;
408 case 40:
409 if( a_wantSymbol ) {
410 info = "Zr"; }
411 else {
412 info = "Zirconium";
413 }
414 break;
415 case 41:
416 if( a_wantSymbol ) {
417 info = "Nb"; }
418 else {
419 info = "Niobium";
420 }
421 break;
422 case 42:
423 if( a_wantSymbol ) {
424 info = "Mo"; }
425 else {
426 info = "Molybdenum";
427 }
428 break;
429 case 43:
430 if( a_wantSymbol ) {
431 info = "Tc"; }
432 else {
433 info = "Technetium";
434 }
435 break;
436 case 44:
437 if( a_wantSymbol ) {
438 info = "Ru"; }
439 else {
440 info = "Ruthenium";
441 }
442 break;
443 case 45:
444 if( a_wantSymbol ) {
445 info = "Rh"; }
446 else {
447 info = "Rhodium";
448 }
449 break;
450 case 46:
451 if( a_wantSymbol ) {
452 info = "Pd"; }
453 else {
454 info = "Palladium";
455 }
456 break;
457 case 47:
458 if( a_wantSymbol ) {
459 info = "Ag"; }
460 else {
461 info = "Silver";
462 }
463 break;
464 case 48:
465 if( a_wantSymbol ) {
466 info = "Cd"; }
467 else {
468 info = "Cadmium";
469 }
470 break;
471 case 49:
472 if( a_wantSymbol ) {
473 info = "In"; }
474 else {
475 info = "Indium";
476 }
477 break;
478 case 50:
479 if( a_wantSymbol ) {
480 info = "Sn"; }
481 else {
482 info = "Tin";
483 }
484 break;
485 case 51:
486 if( a_wantSymbol ) {
487 info = "Sb"; }
488 else {
489 info = "Antimony";
490 }
491 break;
492 case 52:
493 if( a_wantSymbol ) {
494 info = "Te"; }
495 else {
496 info = "Tellurium";
497 }
498 break;
499 case 53:
500 if( a_wantSymbol ) {
501 info = "I"; }
502 else {
503 info = "Iodine";
504 }
505 break;
506 case 54:
507 if( a_wantSymbol ) {
508 info = "Xe"; }
509 else {
510 info = "Xenon";
511 }
512 break;
513 case 55:
514 if( a_wantSymbol ) {
515 info = "Cs"; }
516 else {
517 info = "Cesium";
518 }
519 break;
520 case 56:
521 if( a_wantSymbol ) {
522 info = "Ba"; }
523 else {
524 info = "Barium";
525 }
526 break;
527 case 57:
528 if( a_wantSymbol ) {
529 info = "La"; }
530 else {
531 info = "Lanthanum";
532 }
533 break;
534 case 58:
535 if( a_wantSymbol ) {
536 info = "Ce"; }
537 else {
538 info = "Cerium";
539 }
540 break;
541 case 59:
542 if( a_wantSymbol ) {
543 info = "Pr"; }
544 else {
545 info = "Praseodymium";
546 }
547 break;
548 case 60:
549 if( a_wantSymbol ) {
550 info = "Nd"; }
551 else {
552 info = "Neodymium";
553 }
554 break;
555 case 61:
556 if( a_wantSymbol ) {
557 info = "Pm"; }
558 else {
559 info = "Promethium";
560 }
561 break;
562 case 62:
563 if( a_wantSymbol ) {
564 info = "Sm"; }
565 else {
566 info = "Samarium";
567 }
568 break;
569 case 63:
570 if( a_wantSymbol ) {
571 info = "Eu"; }
572 else {
573 info = "Europium";
574 }
575 break;
576 case 64:
577 if( a_wantSymbol ) {
578 info = "Gd"; }
579 else {
580 info = "Gadolinium";
581 }
582 break;
583 case 65:
584 if( a_wantSymbol ) {
585 info = "Tb"; }
586 else {
587 info = "Terbium";
588 }
589 break;
590 case 66:
591 if( a_wantSymbol ) {
592 info = "Dy"; }
593 else {
594 info = "Dysprosium";
595 }
596 break;
597 case 67:
598 if( a_wantSymbol ) {
599 info = "Ho"; }
600 else {
601 info = "Holmium";
602 }
603 break;
604 case 68:
605 if( a_wantSymbol ) {
606 info = "Er"; }
607 else {
608 info = "Erbium";
609 }
610 break;
611 case 69:
612 if( a_wantSymbol ) {
613 info = "Tm"; }
614 else {
615 info = "Thulium";
616 }
617 break;
618 case 70:
619 if( a_wantSymbol ) {
620 info = "Yb"; }
621 else {
622 info = "Ytterbium";
623 }
624 break;
625 case 71:
626 if( a_wantSymbol ) {
627 info = "Lu"; }
628 else {
629 info = "Lutetium";
630 }
631 break;
632 case 72:
633 if( a_wantSymbol ) {
634 info = "Hf"; }
635 else {
636 info = "Hafnium";
637 }
638 break;
639 case 73:
640 if( a_wantSymbol ) {
641 info = "Ta"; }
642 else {
643 info = "Tantalum";
644 }
645 break;
646 case 74:
647 if( a_wantSymbol ) {
648 info = "W"; }
649 else {
650 info = "Tungsten";
651 }
652 break;
653 case 75:
654 if( a_wantSymbol ) {
655 info = "Re"; }
656 else {
657 info = "Rhenium";
658 }
659 break;
660 case 76:
661 if( a_wantSymbol ) {
662 info = "Os"; }
663 else {
664 info = "Osmium";
665 }
666 break;
667 case 77:
668 if( a_wantSymbol ) {
669 info = "Ir"; }
670 else {
671 info = "Iridium";
672 }
673 break;
674 case 78:
675 if( a_wantSymbol ) {
676 info = "Pt"; }
677 else {
678 info = "Platinum";
679 }
680 break;
681 case 79:
682 if( a_wantSymbol ) {
683 info = "Au"; }
684 else {
685 info = "Gold";
686 }
687 break;
688 case 80:
689 if( a_wantSymbol ) {
690 info = "Hg"; }
691 else {
692 info = "Mercury";
693 }
694 break;
695 case 81:
696 if( a_wantSymbol ) {
697 info = "Tl"; }
698 else {
699 info = "Thallium";
700 }
701 break;
702 case 82:
703 if( a_wantSymbol ) {
704 info = "Pb"; }
705 else {
706 info = "Lead";
707 }
708 break;
709 case 83:
710 if( a_wantSymbol ) {
711 info = "Bi"; }
712 else {
713 info = "Bismuth";
714 }
715 break;
716 case 84:
717 if( a_wantSymbol ) {
718 info = "Po"; }
719 else {
720 info = "Polonium";
721 }
722 break;
723 case 85:
724 if( a_wantSymbol ) {
725 info = "At"; }
726 else {
727 info = "Astatine";
728 }
729 break;
730 case 86:
731 if( a_wantSymbol ) {
732 info = "Rn"; }
733 else {
734 info = "Radon";
735 }
736 break;
737 case 87:
738 if( a_wantSymbol ) {
739 info = "Fr"; }
740 else {
741 info = "Francium";
742 }
743 break;
744 case 88:
745 if( a_wantSymbol ) {
746 info = "Ra"; }
747 else {
748 info = "Radium";
749 }
750 break;
751 case 89:
752 if( a_wantSymbol ) {
753 info = "Ac"; }
754 else {
755 info = "Actinium";
756 }
757 break;
758 case 90:
759 if( a_wantSymbol ) {
760 info = "Th"; }
761 else {
762 info = "Thorium";
763 }
764 break;
765 case 91:
766 if( a_wantSymbol ) {
767 info = "Pa"; }
768 else {
769 info = "Protactinium";
770 }
771 break;
772 case 92:
773 if( a_wantSymbol ) {
774 info = "U"; }
775 else {
776 info = "Uranium";
777 }
778 break;
779 case 93:
780 if( a_wantSymbol ) {
781 info = "Np"; }
782 else {
783 info = "Neptunium";
784 }
785 break;
786 case 94:
787 if( a_wantSymbol ) {
788 info = "Pu"; }
789 else {
790 info = "Plutonium";
791 }
792 break;
793 case 95:
794 if( a_wantSymbol ) {
795 info = "Am"; }
796 else {
797 info = "Americium";
798 }
799 break;
800 case 96:
801 if( a_wantSymbol ) {
802 info = "Cm"; }
803 else {
804 info = "Curium";
805 }
806 break;
807 case 97:
808 if( a_wantSymbol ) {
809 info = "Bk"; }
810 else {
811 info = "Berkelium";
812 }
813 break;
814 case 98:
815 if( a_wantSymbol ) {
816 info = "Cf"; }
817 else {
818 info = "Californium";
819 }
820 break;
821 case 99:
822 if( a_wantSymbol ) {
823 info = "Es"; }
824 else {
825 info = "Einsteinium";
826 }
827 break;
828 case 100:
829 if( a_wantSymbol ) {
830 info = "Fm"; }
831 else {
832 info = "Fermium";
833 }
834 break;
835 case 101:
836 if( a_wantSymbol ) {
837 info = "Md"; }
838 else {
839 info = "Mendelevium";
840 }
841 break;
842 case 102:
843 if( a_wantSymbol ) {
844 info = "No"; }
845 else {
846 info = "Nobelium";
847 }
848 break;
849 case 103:
850 if( a_wantSymbol ) {
851 info = "Lr"; }
852 else {
853 info = "Lawrencium";
854 }
855 break;
856 case 104:
857 if( a_wantSymbol ) {
858 info = "Rf"; }
859 else {
860 info = "Rutherfordium";
861 }
862 break;
863 case 105:
864 if( a_wantSymbol ) {
865 info = "Db"; }
866 else {
867 info = "Dubnium";
868 }
869 break;
870 case 106:
871 if( a_wantSymbol ) {
872 info = "Sg"; }
873 else {
874 info = "Seaborgium";
875 }
876 break;
877 case 107:
878 if( a_wantSymbol ) {
879 info = "Bh"; }
880 else {
881 info = "Bohrium";
882 }
883 break;
884 case 108:
885 if( a_wantSymbol ) {
886 info = "Hs"; }
887 else {
888 info = "Hassium";
889 }
890 break;
891 case 109:
892 if( a_wantSymbol ) {
893 info = "Mt"; }
894 else {
895 info = "Meitnerium";
896 }
897 break;
898 case 110:
899 if( a_wantSymbol ) {
900 info = "Ds"; }
901 else {
902 info = "Darmstadtium";
903 }
904 break;
905 case 111:
906 if( a_wantSymbol ) {
907 info = "Rg"; }
908 else {
909 info = "Roentgenium";
910 }
911 break;
912 case 112:
913 if( a_wantSymbol ) {
914 info = "Cn"; }
915 else {
916 info = "Copernicium";
917 }
918 break;
919 case 113:
920 if( a_wantSymbol ) {
921 info = "Nh"; }
922 else {
923 info = "Nihonium";
924 }
925 break;
926 case 114:
927 if( a_wantSymbol ) {
928 info = "Fl"; }
929 else {
930 info = "Flerovium";
931 }
932 break;
933 case 115:
934 if( a_wantSymbol ) {
935 info = "Mc"; }
936 else {
937 info = "Moscovium";
938 }
939 break;
940 case 116:
941 if( a_wantSymbol ) {
942 info = "Lv"; }
943 else {
944 info = "Livermorium";
945 }
946 break;
947 case 117:
948 if( a_wantSymbol ) {
949 info = "Ts"; }
950 else {
951 info = "Tennessine";
952 }
953 break;
954 case 118:
955 if( a_wantSymbol ) {
956 info = "Og"; }
957 else {
958 info = "Oganesson";
959 }
960 break;
961 default:
962 break;
963 }
964
965 if( a_wantSymbol && a_asNucleus ) {
966 char c1[3];
967 c1[0] = static_cast<char>( tolower( info.c_str( )[0] ) );
968 c1[1] = 0;
969 c1[2] = 0;
970 if( info.size( ) > 1 ) c1[1] = info.c_str( )[1];
971
972 info = c1;
973 }
974
975 return( info );
976}
977
978/* *********************************************************************************************************//**
979 * Returns the chemical element symbol for the requested atomic number *a_Z*.
980 *
981 * @param a_Z [in] The atomic number (Z) of the requested chemical element.
982 *
983 * @return The symbol for the nuclide or an empty string if *a_Z* is an invalid atomic number.
984 ***********************************************************************************************************/
985
986std::string const &chemicalElementSymbolFromZ( int a_Z ) {
987
988 if( ZtoChemicalElementSymbols.find( a_Z ) == ZtoChemicalElementSymbols.end( ) ) return( emptyString );
989
990 return( ZtoChemicalElementSymbols[a_Z ] );
991}
992
993/* *********************************************************************************************************//**
994 * Returns the atomic number (Z) for the requested chemical element's symbol.
995 *
996 * @param a_symbol [in] The atomic symbol.
997 *
998 * @return The atomic number or 0 if *a_symbol* is an invalid symbol.
999 ***********************************************************************************************************/
1000
1001int Z_FromChemicalElementSymbol( std::string const &a_symbol ) {
1002
1003 if( chemicalElementSymbolToZs.size( ) == 0 ) {
1004 for( auto iter = ZtoChemicalElementSymbols.begin( ); iter != ZtoChemicalElementSymbols.end( ); ++iter ) {
1005 chemicalElementSymbolToZs[iter->second] = iter->first;
1006 }
1007 }
1008
1009 if( chemicalElementSymbolToZs.find( a_symbol ) == chemicalElementSymbolToZs.end( ) ) return( 0 );
1010
1011 return( chemicalElementSymbolToZs[a_symbol] );
1012}
1013
1014
1015/* *********************************************************************************************************//**
1016 * This class breaks down a PoPs id for a nuclide or nuclear into its components (e.g., Z, A, index).
1017 * The *a_id* can also be a nuclear meta-stable or one of the light paritlce aliases (i.e., "d", "t", "h" or "a").
1018 * If *a_id* is a light particle alias, its nucleus equavalent is used. Also, "p" is treated as "h1", and "n"
1019 * returns Z = 0 and A = 1. Currently, no other PoPs id's are supported.
1020 *
1021 * @param a_id [in] The PoPs id of the particle.
1022 ***********************************************************************************************************/
1023
1024ParseIdInfo::ParseIdInfo( std::string const &a_id ) :
1025 m_isSupported( false ),
1026 m_id( a_id ),
1027 m_isNuclear( false ),
1028 m_isNucleus( false ),
1029 m_isChemicalElement( false ),
1030 m_isAnti( false ),
1031 m_isMetaStable( false ),
1032 m_symbol( "" ),
1033 m_Z( 0 ),
1034 m_A( 0 ),
1035 m_index( 0 ),
1036 m_qualifier( "" ) {
1037
1038 std::string a_anti;
1039
1040 std::string baseId = baseAntiQualifierFromID( a_id, a_anti, &m_qualifier );
1041 m_isAnti = IDs::anti == a_anti;
1042
1043 if( supportedNucleusAliases.find( baseId ) != supportedNucleusAliases.end( ) ) {
1044 baseId = supportedNucleusAliases[baseId]; }
1045 else if( baseId == IDs::proton ) {
1046 baseId = protonFakeAlias;
1047 }
1048
1049 if( baseId == "n" ) {
1050 m_A = 1;
1051 m_isSupported = true;
1052 return;
1053 }
1054
1055 std::vector<std::string> parts;
1056 if( baseId.find( "_m" ) != std::string::npos ) {
1057 m_isMetaStable = true;
1058 parts = LUPI::Misc::splitString( baseId, "_m" ); }
1059 else {
1060 parts = LUPI::Misc::splitString( baseId, "_e" );
1061 }
1062
1063// Now look for something of the form "SA(_[em]N)" in parts[0] where S is symbol, A is atomic number and "_[em]N" is options nulcear level or
1064// meta-stable specifier. If no match is found, assume a_id does not define a nuclear id.
1065 std::string isotope = parts[0];
1066 std::size_t digitIndex = isotope.find_first_of( "01233456789" );
1067
1068 std::string symbol( isotope.substr( 0, digitIndex ) ); // This should be S.
1069 std::string symbolCap;
1070 if( symbol.size( ) > 0 ) {
1071 char firstChar[2];
1072 firstChar[0] = static_cast<char>( std::toupper( symbol[0] ) );
1073 firstChar[1] = 0;
1074 std::string firstStringChar( firstChar );
1075 symbolCap = firstStringChar + symbol.substr( 1 );
1076 }
1077
1078 if( digitIndex != std::string::npos ) {
1079 std::string AStr( isotope.substr( digitIndex ) ); // This should be A.
1080 if( symbol.size( ) > 0 ) {
1081 m_Z = Z_FromChemicalElementSymbol( symbolCap );
1082 if( m_Z > 0 ) { // We have a valid chemical element symbol.
1083 if( ( AStr.size( ) > 0 ) && ( LUPI::Misc::stringToInt( AStr, m_A ) ) ) {
1084 if( m_A < 0 ) {
1085 m_A = 0; }
1086 else {
1087 bool isValidNuclearId = parts.size( ) == 1;
1088
1089 if( parts.size( ) > 1 ) {
1090 isValidNuclearId = ( parts.size( ) == 2 ) && LUPI::Misc::stringToInt( parts[1], m_index );
1091 }
1092
1093 if( isValidNuclearId ) { // Should be a valid nuclear id.
1094 m_symbol = symbolCap;
1095 m_isNuclear = true;
1096 m_isNucleus = symbolCap != symbol;
1097 }
1098 }
1099 }
1100 m_isSupported = true;
1101 }
1102 } }
1103 else if( symbol.size( ) > 0 ) {
1104 m_Z = Z_FromChemicalElementSymbol( symbolCap );
1105 if( m_Z > 0 ) {
1106 m_symbol = std::move( symbolCap );
1107 m_isChemicalElement = true;
1108 m_isSupported = true;
1109 }
1110 }
1111}
1112
1113/* *********************************************************************************************************//**
1114 * This method prints the contents of *this*. This is mainly for debugging.
1115 *
1116 * @param a_terse [in] If **true**, all members are printed on one line with no description. Otherwise, each member is printed on a separate line with a description.
1117 * @param a_indent [in] The amount of indentation on each line before anything is printed.
1118 ***********************************************************************************************************/
1119
1120void ParseIdInfo::print( bool a_terse, std::string const &a_indent ) const {
1121
1122 if( a_terse ) {
1123 std::cout << a_indent << m_id
1124 << boolToString( m_isSupported, " " ).c_str( )
1125 << boolToString( m_isNuclear, " " ).c_str( )
1126 << boolToString( m_isNucleus, " " ).c_str( )
1127 << boolToString( m_isChemicalElement, " " ).c_str( )
1128 << boolToString( m_isAnti, " " ).c_str( )
1129 << boolToString( m_isMetaStable, " " ).c_str( )
1130 << LUPI::Misc::argumentsToString( " %s", m_symbol.c_str( ) )
1131 << LUPI::Misc::argumentsToString( " %d", m_Z )
1132 << LUPI::Misc::argumentsToString( " %d", m_A )
1133 << LUPI::Misc::argumentsToString( " %d", m_index )
1134 << LUPI::Misc::argumentsToString( " %s", m_qualifier.c_str( ) )
1135 << std::endl; }
1136 else {
1137 std::cout << a_indent << "id = " << m_id << std::endl;
1138 std::cout << a_indent << LUPI::Misc::argumentsToString( " isSupported = %s", boolToString( m_isSupported, "" ).c_str( ) ) << std::endl;
1139 std::cout << a_indent << LUPI::Misc::argumentsToString( " isNuclear = %s", boolToString( m_isNuclear, "" ).c_str( ) ) << std::endl;
1140 std::cout << a_indent << LUPI::Misc::argumentsToString( " isNucleus = %s", boolToString( m_isNucleus, "" ).c_str( ) ) << std::endl;
1141 std::cout << a_indent << LUPI::Misc::argumentsToString( " isChemicalElement = %s", boolToString( m_isChemicalElement, "" ).c_str( ) ) << std::endl;
1142 std::cout << a_indent << LUPI::Misc::argumentsToString( " isAnti = %s", boolToString( m_isAnti, "" ).c_str( ) ) << std::endl;
1143 std::cout << a_indent << LUPI::Misc::argumentsToString( " isMetaStable = %s", boolToString( m_isMetaStable, "" ).c_str( ) ) << std::endl;
1144 std::cout << a_indent << LUPI::Misc::argumentsToString( " symbol = <%s>", m_symbol.c_str( ) ) << std::endl;
1145 std::cout << a_indent << LUPI::Misc::argumentsToString( " Z = %d", m_Z ) << std::endl;
1146 std::cout << a_indent << LUPI::Misc::argumentsToString( " A = %d", m_A ) << std::endl;
1147 std::cout << a_indent << LUPI::Misc::argumentsToString( " index = %d", m_index ) << std::endl;
1148 std::cout << a_indent << LUPI::Misc::argumentsToString( " qualifier = <%s>", m_qualifier.c_str( ) ) << std::endl;
1149 }
1150}
1151
1152/* *********************************************************************************************************//**
1153 * This method returns a string representation of *a_value*.
1154 *
1155 * @param a_value [in] If **true**, all members are printed on one line with no description. Otherwise, each member is printed on a separate line w
1156 * @param a_prefix [in] The amount of indentation on each line before anything is printed.
1157 *
1158 * @return The string representation of *a_value*.
1159 ***********************************************************************************************************/
1160
1161std::string ParseIdInfo::boolToString( bool a_value, std::string const &a_prefix ) const {
1162
1163 std::string boolString( a_prefix );
1164
1165 if( a_value ) {
1166 boolString += "true"; }
1167 else {
1168 boolString += "false";
1169 }
1170
1171 return( boolString );
1172}
1173
1174}
#define LUPI_maybeUnused
#define PoPI_isotopesChars
Definition PoPI.hpp:43
#define PoPI_nameChars
Definition PoPI.hpp:93
#define PoPI_chemicalElementChars
Definition PoPI.hpp:42
#define PoPI_Z_Chars
Node child(const char *name) const
Definition HAPI_Node.cc:72
void calculateNuclideGammaBranchStateInfos(PoPI::Database const &a_pops, NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos) const
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
ChemicalElement(HAPI::Node const &a_node, Database *a_DB, Database *a_parent)
void print(bool a_terse, std::string const &a_indent="") const
std::string const & symbol()
Definition PoPI.hpp:289
ParseIdInfo(std::string const &a_id)
std::string const & symbol() const
Definition PoPI.hpp:712
std::vector< std::string > splitString(std::string const &a_string, char a_delimiter, bool a_strip=false)
Definition LUPI_misc.cc:103
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305
bool stringToInt(std::string const &a_string, int &a_value)
Definition LUPI_misc.cc:260
Definition PoPI.hpp:28
int maximumChemicalElementZ()
std::map< std::string, std::string > supportedNucleusAliases
std::string const & chemicalElementSymbolFromZ(int a_Z)
std::string chemicalElementInfoFromZ(int a_Z, bool a_wantSymbol, bool a_asNucleus=false)
void appendXMLEnd(std::vector< std::string > &a_XMLList, std::string const &a_label)
Definition PoPI_misc.cc:53
std::string baseAntiQualifierFromID(std::string const &a_id, std::string &a_anti, std::string *a_qualifier=nullptr)
Definition PoPI_misc.cc:458
Particle_class
Definition PoPI.hpp:58
int Z_FromChemicalElementSymbol(std::string const &a_symbol)
static std::string const anti
Definition PoPI.hpp:173
static std::string const proton
Definition PoPI.hpp:165