/* ChemicalElement.cpp */ /* Portions copyright (c) 2006 Stanford University and Christopher M. Bruns. * Contributors: Michael Sherman and Paul Mitiguy * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "ChemicalElement.h" using namespace std; const ChemicalElement ChemicalElement::hydrogen (1, "H", "hydrogen", 1.007947); const ChemicalElement ChemicalElement::deuterium (1, "D", "deuterium", 2.01355321270); const ChemicalElement ChemicalElement::helium (2, "He", "helium", 4.003); const ChemicalElement ChemicalElement::lithium (3, "Li", "lithium", 6.941); const ChemicalElement ChemicalElement::beryllium (4, "Be", "beryllium", 9.012); const ChemicalElement ChemicalElement::boron (5, "B", "boron", 10.811); const ChemicalElement ChemicalElement::carbon (6, "C", "carbon", 12.01078); const ChemicalElement ChemicalElement::nitrogen (7, "N", "nitrogen", 14.00672); const ChemicalElement ChemicalElement::oxygen (8, "O", "oxygen", 15.99943); const ChemicalElement ChemicalElement::fluorine (9, "F", "fluorine", 18.998); const ChemicalElement ChemicalElement::neon (10, "Ne", "neon", 20.180); const ChemicalElement ChemicalElement::sodium (11, "Na", "sodium", 22.989769282); const ChemicalElement ChemicalElement::magnesium (12, "Mg", "magnesium", 24.30506); const ChemicalElement ChemicalElement::aluminum (13, "Al", "aluminum", 26.982); const ChemicalElement ChemicalElement::silicon (14, "Si", "silicon", 28.086); const ChemicalElement ChemicalElement::phosphorus (15, "P", "phosphorus", 30.9737622); const ChemicalElement ChemicalElement::sulfur (16, "S", "sulfur", 32.0655); const ChemicalElement ChemicalElement::chlorine (17, "Cl", "chlorine", 35.4532); const ChemicalElement ChemicalElement::argon (18, "Ar", "argon", 39.948); const ChemicalElement ChemicalElement::potassium (19, "K", "potassium", 39.09831); const ChemicalElement ChemicalElement::calcium (20, "Ca", "calcium", 40.0784); const ChemicalElement ChemicalElement::scandium (21, "Sc", "scandium", 44.956); const ChemicalElement ChemicalElement::titanium (22, "Ti", "titanium", 47.88); const ChemicalElement ChemicalElement::vanadium (23, "V", "vanadium", 50.942); const ChemicalElement ChemicalElement::chromium (24, "Cr", "chromium", 51.996); const ChemicalElement ChemicalElement::manganese (25, "Mn", "manganese", 54.9380455); const ChemicalElement ChemicalElement::iron (26, "Fe", "iron", 55.8452); const ChemicalElement ChemicalElement::cobalt (27, "Co", "cobalt", 58.9331955); const ChemicalElement ChemicalElement::nickel (28, "Ni", "nickel", 58.69342); const ChemicalElement ChemicalElement::copper (29, "Cu", "copper", 63.5463); const ChemicalElement ChemicalElement::zinc (30, "Zn", "zinc", 65.4094); const ChemicalElement ChemicalElement::gallium (31, "Ga", "gallium", 69.723); const ChemicalElement ChemicalElement::germanium (32, "Ge", "germanium", 72.61); const ChemicalElement ChemicalElement::arsenic (33, "As", "arsenic", 74.922); const ChemicalElement ChemicalElement::selenium (34, "Se", "selenium", 78.963); const ChemicalElement ChemicalElement::bromine (35, "Br", "bromine", 79.9041); const ChemicalElement ChemicalElement::krypton (36, "Kr", "krypton", 83.80); const ChemicalElement ChemicalElement::rubidium (37, "Rb", "rubidium", 85.468); const ChemicalElement ChemicalElement::strontium (38, "Sr", "strontium", 87.62); const ChemicalElement ChemicalElement::yttrium (39, "Y", "yttrium", 88.906); const ChemicalElement ChemicalElement::zirconium (40, "Zr", "zirconium", 91.224); const ChemicalElement ChemicalElement::niobium (41, "Nb", "niobium", 92.906); const ChemicalElement ChemicalElement::molybdenum (42, "Mo", "molybdenum", 95.94); const ChemicalElement ChemicalElement::technetium (43, "Tc", "technetium", 97.907); const ChemicalElement ChemicalElement::ruthenium (44, "Ru", "ruthenium", 101.07); const ChemicalElement ChemicalElement::rhodium (45, "Rh", "rhodium", 102.906); const ChemicalElement ChemicalElement::palladium (46, "Pd", "palladium", 106.42); const ChemicalElement ChemicalElement::silver (47, "Ag", "silver", 107.868); const ChemicalElement ChemicalElement::cadmium (48, "Cd", "cadmium", 112.411); const ChemicalElement ChemicalElement::indium (49, "In", "indium", 114.82); const ChemicalElement ChemicalElement::tin (50, "Sn", "tin", 118.710); const ChemicalElement ChemicalElement::antimony (51, "Sb", "antimony", 121.757); const ChemicalElement ChemicalElement::tellurium (52, "Te", "tellurium", 127.60); const ChemicalElement ChemicalElement::iodine (53, "I", "iodine", 126.904); const ChemicalElement ChemicalElement::xenon (54, "Xe", "xenon", 131.290); const ChemicalElement ChemicalElement::cesium (55, "Cs", "cesium", 132.905); const ChemicalElement ChemicalElement::barium (56, "Ba", "barium", 137.327); const ChemicalElement ChemicalElement::lanthanum (57, "La", "lanthanum", 138.906); const ChemicalElement ChemicalElement::cerium (58, "Ce", "cerium", 140.115); const ChemicalElement ChemicalElement::praseodymium (59, "Pr", "praseodymium", 140.908); const ChemicalElement ChemicalElement::neodymium (60, "Nd", "neodymium", 144.24); const ChemicalElement ChemicalElement::promethium (61, "Pm", "promethium", 144.913); const ChemicalElement ChemicalElement::samarium (62, "Sm", "samarium", 150.36); const ChemicalElement ChemicalElement::europium (63, "Eu", "europium", 151.965); const ChemicalElement ChemicalElement::gadolinium (64, "Gd", "gadolinium", 157.25); const ChemicalElement ChemicalElement::terbium (65, "Tb", "terbium", 158.925); const ChemicalElement ChemicalElement::dysprosium (66, "Dy", "dysprosium", 162.50); const ChemicalElement ChemicalElement::holmium (67, "Ho", "holmium", 164.930); const ChemicalElement ChemicalElement::erbium (68, "Er", "erbium", 167.26); const ChemicalElement ChemicalElement::thulium (69, "Tm", "thulium", 168.934); const ChemicalElement ChemicalElement::ytterbium (70, "Yb", "ytterbium", 173.04); const ChemicalElement ChemicalElement::lutetium (71, "Lu", "lutetium", 174.967); const ChemicalElement ChemicalElement::hafnium (72, "Hf", "hafnium", 178.49); const ChemicalElement ChemicalElement::tantalum (73, "Ta", "tantalum", 180.948); const ChemicalElement ChemicalElement::tungsten (74, "W", "tungsten", 183.84); const ChemicalElement ChemicalElement::rhenium (75, "Re", "rhenium", 186.207); const ChemicalElement ChemicalElement::osmium (76, "Os", "osmium", 190.2); const ChemicalElement ChemicalElement::iridium (77, "Ir", "iridium", 192.22); const ChemicalElement ChemicalElement::platinum (78, "Pt", "platinum", 195.08); const ChemicalElement ChemicalElement::gold (79, "Au", "gold", 196.967); const ChemicalElement ChemicalElement::mercury (80, "Hg", "mercury", 200.59); const ChemicalElement ChemicalElement::thallium (81, "Tl", "thallium", 204.383); const ChemicalElement ChemicalElement::lead (82, "Pb", "lead", 207.2); const ChemicalElement ChemicalElement::bismuth (83, "Bi", "bismuth", 208.980); const ChemicalElement ChemicalElement::polonium (84, "Po", "polonium", 208.982); const ChemicalElement ChemicalElement::astatine (85, "At", "astatine", 209.978); const ChemicalElement ChemicalElement::radon (86, "Rn", "radon", 222.018); const ChemicalElement ChemicalElement::francium (87, "Fr", "francium", 223.020); const ChemicalElement ChemicalElement::radium (88, "Ra", "radium", 226.025); const ChemicalElement ChemicalElement::actinium (89, "Ac", "actinium", 227.028); const ChemicalElement ChemicalElement::thorium (90, "Th", "thorium", 232.038); const ChemicalElement ChemicalElement::protactinium (91, "Pa", "protactinium", 231.038); const ChemicalElement ChemicalElement::uranium (92, "U", "uranium", 238.028913); const ChemicalElement ChemicalElement::neptunium (93, "Np", "neptunium", 237.048); const ChemicalElement ChemicalElement::plutonium (94, "Pu", "plutonium", 244.064); const ChemicalElement ChemicalElement::americium (95, "Am", "americium", 243.061); const ChemicalElement ChemicalElement::curium (96, "Cm", "curium", 247.070); const ChemicalElement ChemicalElement::berkelium (97, "Bk", "berkelium", 247.070); const ChemicalElement ChemicalElement::californium (98, "Cf", "californium", 251.080); const ChemicalElement ChemicalElement::einsteinium (99, "Es", "einsteinium", 252.083); const ChemicalElement ChemicalElement::fermium (100, "Fm", "fermium", 257.095); const ChemicalElement ChemicalElement::mendelevium (101, "Md", "mendelevium", 258.099); const ChemicalElement ChemicalElement::nobelium (102, "No", "nobelium", 259.101); const ChemicalElement ChemicalElement::lawrencium (103, "Lr", "lawrencium", 260.105); const ChemicalElement ChemicalElement::rutherfordium (104, "Rf", "rutherfordium",261); const ChemicalElement ChemicalElement::dubnium (105, "Db", "dubnium", 262); const ChemicalElement ChemicalElement::seaborgium (106, "Sg", "seaborgium", 263); const ChemicalElement ChemicalElement::bohrium (107, "Bh", "bohrium", 262); const ChemicalElement ChemicalElement::hassium (108, "Hs", "hassium", 265); const ChemicalElement ChemicalElement::meitnerium (109, "Mt", "meitnerium", 266); const ChemicalElement ChemicalElement::darmstadtium (110, "Ds", "darmstadtium", 281); const ChemicalElement ChemicalElement::unununium (111, "Uuu", "unununium", 272); const ChemicalElement ChemicalElement::ununbium (112, "Uub", "ununbium", 285); //-------------------------------------------------------------------------- const ChemicalElement* ChemicalElement::getChemicalElement( const char *symbol ) { static const ChemicalElement* myListOfChemicalElements[] = { &hydrogen, &deuterium, &helium, &lithium, &beryllium, &boron, &carbon, &nitrogen, &oxygen, &fluorine, &neon, &sodium, &magnesium, &aluminum, &silicon, &phosphorus, &sulfur, &chlorine, &argon, &potassium, &calcium, &scandium, &titanium, &vanadium, &chromium, &manganese, &iron, &cobalt, &nickel, &copper, &zinc, &gallium, &germanium, &arsenic, &selenium, &bromine, &krypton, &rubidium, &strontium, &yttrium, &zirconium, &niobium, &molybdenum, &technetium, &ruthenium, &rhodium, &palladium, &silver, &cadmium, &indium, &tin, &antimony, &tellurium, &iodine, &xenon, &cesium, &barium, &lanthanum, &cerium, &praseodymium, &neodymium, &promethium, &samarium, &europium, &gadolinium, &terbium, &dysprosium, &holmium, &erbium, &thulium, &ytterbium, &lutetium, &hafnium, &tantalum, &tungsten, &rhenium, &osmium, &iridium, &platinum, &gold, &mercury, &thallium, &lead, &bismuth, &polonium, &astatine, &radon, &francium, &radium, &actinium, &thorium, &protactinium, &uranium, &neptunium, &plutonium, &americium, &curium, &berkelium, &californium, &einsteinium, &fermium, &mendelevium, &nobelium, &lawrencium, &rutherfordium, &dubnium, &seaborgium, &bohrium, &hassium, &meitnerium, &darmstadtium, &unununium, &ununbium, NULL }; // Look through the list for this symbol const ChemicalElement *currentElement = NULL; for( unsigned int i=0; (currentElement = myListOfChemicalElements[i]) != NULL; i++ ) { const char *currentElementSymbol = currentElement->getSymbol(); bool isSameName = strcmpi( symbol, currentElementSymbol ) == 0; if( isSameName ) break; } // This will return NULL if the symbol was not found return currentElement; }