All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.chem.Element Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.chem;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;

import com.hfg.exception.ProgrammingException;
import com.hfg.exception.UserInputException;
import com.hfg.units.length.Angstroms;
import com.hfg.units.length.Length;
import com.hfg.util.Case;
import com.hfg.util.CompareUtil;
import com.hfg.util.StringUtil;
import com.hfg.util.io.CSV;
import com.hfg.util.io.StreamUtil;

//------------------------------------------------------------------------------
/**
 Atomic element. Elemental mass reference:
 
Coursey JS, Schwab DJ, and Dragoset RA. 2005. Atomic Weights and Isotopic Compositions (version 2.4.1).
   [Online] Available: http://physics.nist.gov/PhysRefData/Compositions/ [2006, August 18].
   National Institute of Standards and Technology, Gaithersburg, MD.
   (Note that the value in parenthesis is the
   standard uncertainty.)
 
Organic mass values used are from:
   Zhang Z, Pan H, Chen X. 2009. Mass spectrometry for structural characterization
   of therapeutic antibodies. Mass Spectrom Rev 28:147-176.
 
@author J. Alex Taylor, hairyfatguy.com */ //------------------------------------------------------------------------------ // com.hfg XML/HTML Coding Library // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com // [email protected] //------------------------------------------------------------------------------ public class Element implements Comparable, Matter { //########################################################################## // PRIVATE FIELDS //########################################################################## private final String mName; private final String mSymbol; private Set mAliases; private final int mAtomicNum; private Double mOrganicAverageMass; private int[] mDefaultValences; private Length mVanderWaalsRadius; private Length mCovalentRadius; /** Enumeration of the supported NIST versions of atomic weight information. */ public enum AtomicWeightsVersion { v2_4_1("v2.4.1"), v4_1("v4.1"); private final String mDisplayName; //----------------------------------------------------------------------- private AtomicWeightsVersion(String inDisplayName) { mDisplayName = inDisplayName; } //----------------------------------------------------------------------- public String getDisplayName() { return mDisplayName; } } private static final Map ATOMIC_WEIGHT_VERSIONS_RSRC_MAP = new HashMap<>(5); private static final Map> sMonoisotopicMasses = new HashMap<>(5); private static final Map> sAverageMasses = new HashMap<>(5); private static AtomicWeightsVersion sDefaultAtomicWeightsVersion = AtomicWeightsVersion.v2_4_1; // This declaration has to come before the public constants below. private static Set sValues = new HashSet<>(120); //########################################################################## // PUBLIC FIELDS //########################################################################## public static final Element HYDROGEN = new Element("Hydrogen", "H", 1); public static final Element HELIUM = new Element("Helium", "He", 2); public static final Element LITHIUM = new Element("Lithium", "Li", 3); public static final Element BERYLLIUM = new Element("Beryllium", "Be", 4); public static final Element BORON = new Element("Boron", "B", 5); public static final Element CARBON = new Element("Carbon", "C", 6); public static final Element NITROGEN = new Element("Nitrogen", "N", 7); public static final Element OXYGEN = new Element("Oxygen", "O", 8); public static final Element FLUORINE = new Element("Fluorine", "F", 9); public static final Element NEON = new Element("Neon", "Ne", 10); public static final Element SODIUM = new Element("Sodium", "Na", 11); public static final Element MAGNESIUM = new Element("Magnesium", "Mg", 12); public static final Element ALUMINIUM = new Element("Aluminium", "Al", 13); public static final Element SILICON = new Element("Silicon", "Si", 14); public static final Element PHOSPHOROUS = new Element("Phosphorous", "P", 15); public static final Element SULFUR = new Element("Sulfur", "S", 16); public static final Element CHLORINE = new Element("Chlorine", "Cl", 17); public static final Element ARGON = new Element("Argon", "Ar", 18); public static final Element POTASSIUM = new Element("Potassium", "K", 19); public static final Element CALCIUM = new Element("Calcium", "Ca", 20); public static final Element SCANDIUM = new Element("Scandium", "Sc", 21); public static final Element TITANIUM = new Element("Titanium", "Ti", 22); public static final Element VANADIUM = new Element("Vanadium", "V", 23); public static final Element CHROMIUM = new Element("Chromium", "Cr", 24); public static final Element MANGANESE = new Element("Manganese", "Mn", 25); public static final Element IRON = new Element("Iron", "Fe", 26); public static final Element COBALT = new Element("Cobalt", "Co", 27); public static final Element NICKEL = new Element("Nickel", "Ni", 28); public static final Element COPPER = new Element("Copper", "Cu", 29); public static final Element ZINC = new Element("Zinc", "Zn", 30); public static final Element GALLIUM = new Element("Gallium", "Ga", 31); public static final Element GERMANIUM = new Element("Germanium", "Ge", 32); public static final Element ARSENIC = new Element("Arsenic", "As", 33); public static final Element SELENIUM = new Element("Selenium", "Se", 34); public static final Element BROMINE = new Element("Bromine", "Br", 35); public static final Element KRYPTON = new Element("Krypton", "Kr", 36); public static final Element RUBIDIUM = new Element("Rubidium", "Rb", 37); public static final Element STRONTIUM = new Element("Strontium", "Sr", 38); public static final Element YTTRIUM = new Element("Yttrium", "Y", 39); public static final Element ZIRCONIUM = new Element("Zirconium", "Zr", 40); public static final Element NIOBIUM = new Element("Niobium", "Nb", 41); public static final Element MOLYBDENUM = new Element("Molybdenum", "Mo", 42); public static final Element TECHNETIUM = new Element("Technetium", "Tc", 43); public static final Element RUTHENIUM = new Element("Ruthenium", "Ru", 44); public static final Element RHODIUM = new Element("Rhodium", "Rh", 45); public static final Element PALLADIUM = new Element("Palladium", "Pd", 46); public static final Element SILVER = new Element("Silver", "Ag", 47); public static final Element CADMIUM = new Element("Cadmium", "Cd", 48); public static final Element INDIUM = new Element("Indium", "In", 49); public static final Element TIN = new Element("Tin", "Sn", 50); public static final Element ANTIMONY = new Element("Antimony", "Sb", 51); public static final Element TELLURIUM = new Element("Tellurium", "Te", 52); public static final Element IODINE = new Element("Iodine", "I", 53); public static final Element XENON = new Element("Xenon", "Xe", 54); public static final Element CESIUM = new Element("Cesium", "Cs", 55); public static final Element BARIUM = new Element("Barium", "Ba", 56); public static final Element LANTHANUM = new Element("Lanthanum", "La", 57); public static final Element CERIUM = new Element("Cerium", "Ce", 58); public static final Element PRASEODYMIUM = new Element("Praseodymium", "Pr", 59); public static final Element NEODYMIUM = new Element("Neodymium", "Nd", 60); public static final Element PROMETHIUM = new Element("Promethium", "Pm", 61); public static final Element SAMARIUM = new Element("Samarium", "Sm", 62); public static final Element EUROPIUM = new Element("Europium", "Eu", 63); public static final Element GADOLINIUM = new Element("Gadolinium", "Gd", 64); public static final Element TERBIUM = new Element("Terbium", "Tb", 65); public static final Element DYSPROSIUM = new Element("Dysprosium", "Dy", 66); public static final Element HOLMIUM = new Element("Holmium", "Ho", 67); public static final Element ERBIUM = new Element("Erbium", "Er", 68); public static final Element THULIUM = new Element("Thulium", "Tm", 69); public static final Element YTTERBIUM = new Element("Ytterbium", "Yb", 70); public static final Element LUTETIUM = new Element("Lutetium", "Lu", 71); public static final Element HAFNIUM = new Element("Hafnium", "Hf", 72); public static final Element TANTALUM = new Element("Tantalum", "Ta", 73); public static final Element TUNGSTEN = new Element("Tungsten", "W", 74); public static final Element RHENIUM = new Element("Rhenium", "Re", 75); public static final Element OSMIUM = new Element("Osmium", "Os", 76); public static final Element IRIDIUM = new Element("Iridium", "Ir", 77); public static final Element PLATINUM = new Element("Platinum", "Pt", 78); public static final Element GOLD = new Element("Gold", "Au", 79); public static final Element MERCURY = new Element("Mercury", "Hg", 80); public static final Element THALLIUM = new Element("Thallium", "Tl", 81); public static final Element LEAD = new Element("Lead", "Pb", 82); public static final Element BISMUTH = new Element("Bismuth", "Bi", 83); public static final Element POLONIUM = new Element("Polonium", "Po", 84); public static final Element ASTATINE = new Element("Astatine", "At", 85); public static final Element RADON = new Element("Radon", "Rn", 86); public static final Element FRANCIUM = new Element("Francium", "Fr", 87); public static final Element RADIUM = new Element("Radium", "Ra", 88); public static final Element ACTINIUM = new Element("Actinium", "Ac", 89); public static final Element THORIUM = new Element("Thorium", "Th", 90); public static final Element PROACTINIUM = new Element("Proactinium", "Pa", 91); public static final Element URANIUM = new Element("Uranium", "U", 92); public static final Element NEPTUNIUM = new Element("Neptunium", "Np", 93); public static final Element PLUTONIUM = new Element("Plutonium", "Pu", 94); public static final Element AMERICIUM = new Element("Americium", "Am", 95); public static final Element CURIUM = new Element("Curium", "Cm", 96); public static final Element BERKELIUM = new Element("Berkelium", "Bk", 97); public static final Element CALIFORNIUM = new Element("Californium", "Cf", 98); public static final Element EINSTEINIUM = new Element("Einsteinium", "Es", 99); public static final Element FERMIUM = new Element("Fermium", "Fm", 100); public static final Element MENDELEVIUM = new Element("Mendelevium", "Md", 101); public static final Element NOBELIUM = new Element("Nobelium", "No", 102); public static final Element LAWRENCIUM = new Element("Lawrencium", "Lr", 103); public static final Element RUTHERFORDIUM = new Element("Rutherfordium", "Rf", 104); public static final Element DUBNIUM = new Element("Dubnium", "Db", 105); public static final Element SEABORGIUM = new Element("Seaborgium", "Sg", 106); public static final Element BOHRIUM = new Element("Bohrium", "Bh", 107); public static final Element HASSIUM = new Element("Hassium", "Hs", 108); public static final Element MEITNERIUM = new Element("Meitnerium", "Mt", 109); public static final Element DARMSTADTIUM = new Element("Darmstadtium", "Ds", 110); public static final Element ROENTGENIUM = new Element("Roentgenium", "Rg", 111); public static final Element COPERNICIUM = new Element("Copernicium", "Cn", 112).addAlias("Ununbium").addAlias("Uub"); public static final Element NIHONIUM = new Element("Nihonium", "Nh", 113).addAlias("Ununtrium").addAlias("Uut"); public static final Element FLEROVIUM = new Element("Flerovium", "Fl", 114).addAlias("Ununquadium").addAlias("Uuq"); public static final Element MOSCOVIUM = new Element("Moscovium", "Mc", 115).addAlias("Ununpentium").addAlias("Uup"); public static final Element LIVERMORIUM = new Element("Livermorium", "Lv", 116).addAlias("Ununhexium").addAlias("Uuh"); public static final Element TENNESSINE = new Element("Tennessine", "Ts", 117).addAlias("Ununseptium").addAlias("Uus"); public static final Element OGANESSON = new Element("Oganesson", "Og", 118).addAlias("Ununoctium").addAlias("Uuo"); static { ATOMIC_WEIGHT_VERSIONS_RSRC_MAP.put(AtomicWeightsVersion.v2_4_1, "rsrc/atomic_weights_v2.4.1.csv"); ATOMIC_WEIGHT_VERSIONS_RSRC_MAP.put(AtomicWeightsVersion.v4_1, "rsrc/atomic_weights_v4.1.csv"); for (AtomicWeightsVersion version : AtomicWeightsVersion.values()) { loadAtomicWeightsData(version); } // Organic average masses // From: Zhang Z, Pan H, Chen X. 2009. Mass spectrometry for structural characterization // of therapeutic antibodies. Mass Spectrom Rev 28:147-176. HYDROGEN.mOrganicAverageMass = 1.007968; CARBON.mOrganicAverageMass = 12.01079; NITROGEN.mOrganicAverageMass = 14.00669; OXYGEN.mOrganicAverageMass = 15.99937; SULFUR.mOrganicAverageMass = 32.0639; // From Table 1 in // Alvarez, Santiago. 2013. // “A Cartography of the van Der Waals Territories.” // Dalton Transactions 42 (24): 8617–36. // https://doi.org/10.1039/c3dt50599e. HYDROGEN.setVanderWaalsRadius(new Angstroms(1.20)); HELIUM.setVanderWaalsRadius(new Angstroms(1.43)); LITHIUM.setVanderWaalsRadius(new Angstroms(2.12)); BERYLLIUM.setVanderWaalsRadius(new Angstroms(1.98)); BORON.setVanderWaalsRadius(new Angstroms(1.91)); CARBON.setVanderWaalsRadius(new Angstroms(1.77)); NITROGEN.setVanderWaalsRadius(new Angstroms(1.66)); OXYGEN.setVanderWaalsRadius(new Angstroms(1.50)); FLUORINE.setVanderWaalsRadius(new Angstroms(1.46)); NEON.setVanderWaalsRadius(new Angstroms(1.58)); SODIUM.setVanderWaalsRadius(new Angstroms(2.50)); MAGNESIUM.setVanderWaalsRadius(new Angstroms(2.51)); ALUMINIUM.setVanderWaalsRadius(new Angstroms(2.25)); SILICON.setVanderWaalsRadius(new Angstroms(2.19)); PHOSPHOROUS.setVanderWaalsRadius(new Angstroms(1.90)); SULFUR.setVanderWaalsRadius(new Angstroms(1.89)); CHLORINE.setVanderWaalsRadius(new Angstroms(1.82)); ARGON.setVanderWaalsRadius(new Angstroms(1.83)); POTASSIUM.setVanderWaalsRadius(new Angstroms(2.73)); CALCIUM.setVanderWaalsRadius(new Angstroms(2.62)); SCANDIUM.setVanderWaalsRadius(new Angstroms(2.58)); TITANIUM.setVanderWaalsRadius(new Angstroms(2.46)); VANADIUM.setVanderWaalsRadius(new Angstroms(2.42)); CHROMIUM.setVanderWaalsRadius(new Angstroms(2.45)); MANGANESE.setVanderWaalsRadius(new Angstroms(2.45)); IRON.setVanderWaalsRadius(new Angstroms(2.44)); COBALT.setVanderWaalsRadius(new Angstroms(2.40)); NICKEL.setVanderWaalsRadius(new Angstroms(2.40)); COPPER.setVanderWaalsRadius(new Angstroms(2.38)); ZINC.setVanderWaalsRadius(new Angstroms(2.39)); GALLIUM.setVanderWaalsRadius(new Angstroms(2.32)); GERMANIUM.setVanderWaalsRadius(new Angstroms(2.29)); ARSENIC.setVanderWaalsRadius(new Angstroms(1.88)); SELENIUM.setVanderWaalsRadius(new Angstroms(1.82)); BROMINE.setVanderWaalsRadius(new Angstroms(1.86)); KRYPTON.setVanderWaalsRadius(new Angstroms(2.25)); RUBIDIUM.setVanderWaalsRadius(new Angstroms(3.21)); STRONTIUM.setVanderWaalsRadius(new Angstroms(2.84)); YTTRIUM.setVanderWaalsRadius(new Angstroms(2.75)); ZIRCONIUM.setVanderWaalsRadius(new Angstroms(2.52)); NIOBIUM.setVanderWaalsRadius(new Angstroms(2.56)); MOLYBDENUM.setVanderWaalsRadius(new Angstroms(2.45)); TECHNETIUM.setVanderWaalsRadius(new Angstroms(2.44)); RUTHENIUM.setVanderWaalsRadius(new Angstroms(2.46)); RHODIUM.setVanderWaalsRadius(new Angstroms(2.44)); PALLADIUM.setVanderWaalsRadius(new Angstroms(2.15)); SILVER.setVanderWaalsRadius(new Angstroms(2.53)); CADMIUM.setVanderWaalsRadius(new Angstroms(2.49)); INDIUM.setVanderWaalsRadius(new Angstroms(2.43)); TIN.setVanderWaalsRadius(new Angstroms(2.42)); ANTIMONY.setVanderWaalsRadius(new Angstroms(2.47)); TELLURIUM.setVanderWaalsRadius(new Angstroms(1.99)); IODINE.setVanderWaalsRadius(new Angstroms(2.04)); XENON.setVanderWaalsRadius(new Angstroms(2.06)); CESIUM.setVanderWaalsRadius(new Angstroms(3.48)); BARIUM.setVanderWaalsRadius(new Angstroms(3.03)); LANTHANUM.setVanderWaalsRadius(new Angstroms(2.98)); CERIUM.setVanderWaalsRadius(new Angstroms(2.88)); PRASEODYMIUM.setVanderWaalsRadius(new Angstroms(2.92)); NEODYMIUM.setVanderWaalsRadius(new Angstroms(2.95)); // PROMETHIUM.setVanderWaalsRadius(new Angstroms()); SAMARIUM.setVanderWaalsRadius(new Angstroms(2.90)); EUROPIUM.setVanderWaalsRadius(new Angstroms(2.87)); GADOLINIUM.setVanderWaalsRadius(new Angstroms(2.83)); TERBIUM.setVanderWaalsRadius(new Angstroms(2.79)); DYSPROSIUM.setVanderWaalsRadius(new Angstroms(2.87)); HOLMIUM.setVanderWaalsRadius(new Angstroms(2.81)); ERBIUM.setVanderWaalsRadius(new Angstroms(2.83)); THULIUM .setVanderWaalsRadius(new Angstroms(2.79)); YTTERBIUM.setVanderWaalsRadius(new Angstroms(2.80)); LUTETIUM.setVanderWaalsRadius(new Angstroms(2.74)); HAFNIUM.setVanderWaalsRadius(new Angstroms(2.63)); TANTALUM.setVanderWaalsRadius(new Angstroms(2.53)); TUNGSTEN.setVanderWaalsRadius(new Angstroms(2.57)); RHENIUM.setVanderWaalsRadius(new Angstroms(2.49)); OSMIUM.setVanderWaalsRadius(new Angstroms(2.48)); IRIDIUM.setVanderWaalsRadius(new Angstroms(2.41)); PLATINUM.setVanderWaalsRadius(new Angstroms(2.29)); GOLD.setVanderWaalsRadius(new Angstroms(2.32)); MERCURY.setVanderWaalsRadius(new Angstroms(2.45)); THALLIUM.setVanderWaalsRadius(new Angstroms(2.47)); LEAD.setVanderWaalsRadius(new Angstroms(2.60)); BISMUTH.setVanderWaalsRadius(new Angstroms(2.54)); // POLONIUM.setVanderWaalsRadius(new Angstroms()); // ASTATINE.setVanderWaalsRadius(new Angstroms()); // RADON.setVanderWaalsRadius(new Angstroms()); // FRANCIUM.setVanderWaalsRadius(new Angstroms()); // RADIUM.setVanderWaalsRadius(new Angstroms()); ACTINIUM.setVanderWaalsRadius(new Angstroms(2.8)); THORIUM.setVanderWaalsRadius(new Angstroms(2.93)); PROACTINIUM.setVanderWaalsRadius(new Angstroms(2.88)); URANIUM.setVanderWaalsRadius(new Angstroms(2.71)); NEPTUNIUM.setVanderWaalsRadius(new Angstroms(2.82)); PLUTONIUM.setVanderWaalsRadius(new Angstroms(2.81)); AMERICIUM.setVanderWaalsRadius(new Angstroms(2.83)); CURIUM.setVanderWaalsRadius(new Angstroms(3.05)); BERKELIUM.setVanderWaalsRadius(new Angstroms(3.4)); CALIFORNIUM.setVanderWaalsRadius(new Angstroms(3.05)); EINSTEINIUM.setVanderWaalsRadius(new Angstroms(2.7)); // From Table 2 in // Cordero, Beatriz, Verónica Gómez, Ana E. Platero-Prats, // Marc Revés, Jorge Echeverría, Eduard Cremades, // Flavia Barragán, and Santiago Alvarez. 2008. // “Covalent Radii Revisited.” // Journal of the Chemical Society. Dalton Transactions, no. 21: 2832–38. // https://doi.org/10.1039/b801115j. HYDROGEN. setCovalentRadius(new Angstroms(0.31)); HELIUM. setCovalentRadius(new Angstroms(0.28)); LITHIUM. setCovalentRadius(new Angstroms(1.28)); BERYLLIUM. setCovalentRadius(new Angstroms(0.96)); BORON. setCovalentRadius(new Angstroms(0.84)); CARBON. setCovalentRadius(new Angstroms(0.76)); NITROGEN. setCovalentRadius(new Angstroms(0.71)); OXYGEN. setCovalentRadius(new Angstroms(0.66)); FLUORINE. setCovalentRadius(new Angstroms(0.57)); NEON. setCovalentRadius(new Angstroms(0.58)); SODIUM. setCovalentRadius(new Angstroms(1.66)); MAGNESIUM. setCovalentRadius(new Angstroms(1.41)); ALUMINIUM. setCovalentRadius(new Angstroms(1.21)); SILICON. setCovalentRadius(new Angstroms(1.11)); PHOSPHOROUS. setCovalentRadius(new Angstroms(1.07)); SULFUR. setCovalentRadius(new Angstroms(1.05)); CHLORINE. setCovalentRadius(new Angstroms(1.02)); ARGON. setCovalentRadius(new Angstroms(1.06)); POTASSIUM. setCovalentRadius(new Angstroms(2.03)); CALCIUM. setCovalentRadius(new Angstroms(1.76)); SCANDIUM. setCovalentRadius(new Angstroms(1.70)); TITANIUM. setCovalentRadius(new Angstroms(1.60)); VANADIUM. setCovalentRadius(new Angstroms(1.53)); CHROMIUM. setCovalentRadius(new Angstroms(1.39)); MANGANESE. setCovalentRadius(new Angstroms(1.39)); IRON. setCovalentRadius(new Angstroms(1.32)); COBALT. setCovalentRadius(new Angstroms(1.26)); NICKEL. setCovalentRadius(new Angstroms(1.24)); COPPER. setCovalentRadius(new Angstroms(1.32)); ZINC. setCovalentRadius(new Angstroms(1.22)); GALLIUM. setCovalentRadius(new Angstroms(1.22)); GERMANIUM. setCovalentRadius(new Angstroms(1.20)); ARSENIC. setCovalentRadius(new Angstroms(1.19)); SELENIUM. setCovalentRadius(new Angstroms(1.20)); BROMINE. setCovalentRadius(new Angstroms(1.20)); KRYPTON. setCovalentRadius(new Angstroms(1.16)); RUBIDIUM. setCovalentRadius(new Angstroms(2.20)); STRONTIUM. setCovalentRadius(new Angstroms(1.95)); YTTRIUM. setCovalentRadius(new Angstroms(1.90)); ZIRCONIUM. setCovalentRadius(new Angstroms(1.75)); NIOBIUM. setCovalentRadius(new Angstroms(1.64)); MOLYBDENUM. setCovalentRadius(new Angstroms(1.54)); TECHNETIUM. setCovalentRadius(new Angstroms(1.47)); RUTHENIUM. setCovalentRadius(new Angstroms(1.46)); RHODIUM. setCovalentRadius(new Angstroms(1.42)); PALLADIUM. setCovalentRadius(new Angstroms(1.39)); SILVER. setCovalentRadius(new Angstroms(1.45)); CADMIUM. setCovalentRadius(new Angstroms(1.44)); INDIUM. setCovalentRadius(new Angstroms(1.42)); TIN. setCovalentRadius(new Angstroms(1.39)); ANTIMONY. setCovalentRadius(new Angstroms(1.39)); TELLURIUM. setCovalentRadius(new Angstroms(1.38)); IODINE. setCovalentRadius(new Angstroms(1.39)); XENON. setCovalentRadius(new Angstroms(1.40)); CESIUM. setCovalentRadius(new Angstroms(2.44)); BARIUM. setCovalentRadius(new Angstroms(2.15)); LANTHANUM. setCovalentRadius(new Angstroms(2.07)); CERIUM. setCovalentRadius(new Angstroms(2.04)); PRASEODYMIUM. setCovalentRadius(new Angstroms(2.03)); NEODYMIUM. setCovalentRadius(new Angstroms(2.01)); PROMETHIUM. setCovalentRadius(new Angstroms(1.99)); SAMARIUM. setCovalentRadius(new Angstroms(1.98)); EUROPIUM. setCovalentRadius(new Angstroms(1.98)); GADOLINIUM. setCovalentRadius(new Angstroms(1.96)); TERBIUM. setCovalentRadius(new Angstroms(1.94)); DYSPROSIUM. setCovalentRadius(new Angstroms(1.92)); HOLMIUM. setCovalentRadius(new Angstroms(1.92)); ERBIUM. setCovalentRadius(new Angstroms(1.89)); THULIUM . setCovalentRadius(new Angstroms(1.90)); YTTERBIUM. setCovalentRadius(new Angstroms(1.87)); LUTETIUM. setCovalentRadius(new Angstroms(1.87)); HAFNIUM. setCovalentRadius(new Angstroms(1.75)); TANTALUM. setCovalentRadius(new Angstroms(1.70)); TUNGSTEN. setCovalentRadius(new Angstroms(1.62)); RHENIUM. setCovalentRadius(new Angstroms(1.51)); OSMIUM. setCovalentRadius(new Angstroms(1.44)); IRIDIUM. setCovalentRadius(new Angstroms(1.41)); PLATINUM. setCovalentRadius(new Angstroms(1.36)); GOLD. setCovalentRadius(new Angstroms(1.36)); MERCURY. setCovalentRadius(new Angstroms(1.32)); THALLIUM. setCovalentRadius(new Angstroms(1.45)); LEAD. setCovalentRadius(new Angstroms(1.46)); BISMUTH. setCovalentRadius(new Angstroms(1.48)); POLONIUM. setCovalentRadius(new Angstroms(1.40)); ASTATINE. setCovalentRadius(new Angstroms(1.50)); RADON. setCovalentRadius(new Angstroms(1.50)); FRANCIUM. setCovalentRadius(new Angstroms(2.60)); RADIUM. setCovalentRadius(new Angstroms(2.21)); ACTINIUM. setCovalentRadius(new Angstroms(2.15)); THORIUM. setCovalentRadius(new Angstroms(2.06)); PROACTINIUM. setCovalentRadius(new Angstroms(2.00)); URANIUM. setCovalentRadius(new Angstroms(1.96)); NEPTUNIUM. setCovalentRadius(new Angstroms(1.90)); PLUTONIUM. setCovalentRadius(new Angstroms(1.87)); AMERICIUM. setCovalentRadius(new Angstroms(1.80)); CURIUM. setCovalentRadius(new Angstroms(1.69)); HYDROGEN.setDefaultValences(new int[] { 1 }); BORON.setDefaultValences(new int[] { 3 }); CARBON.setDefaultValences(new int[] { 4 }); NITROGEN.setDefaultValences(new int[] { 3 }); OXYGEN.setDefaultValences(new int[] { 2 }); FLUORINE.setDefaultValences(new int[] { 1 }); SILICON.setDefaultValences(new int[] { 4 }); PHOSPHOROUS.setDefaultValences(new int[] { 3, 5 }); SULFUR.setDefaultValences(new int[] { 2, 4, 6 }); CHLORINE.setDefaultValences(new int[] { 1, 3, 5, 7 }); ARSENIC.setDefaultValences(new int[] { 3, 5 }); SELENIUM.setDefaultValences(new int[] { 2, 4, 6 }); BROMINE.setDefaultValences(new int[] { 1, 3, 5, 7 }); TELLURIUM.setDefaultValences(new int[] { 2, 4, 6 }); IODINE.setDefaultValences(new int[] { 1, 3, 5, 7 }); ASTATINE.setDefaultValences(new int[] { 1, 3, 5, 7 }); } //########################################################################## // CONSTRUCTORS //########################################################################## //-------------------------------------------------------------------------- protected Element(String inName, String inSymbol, int inAtomicNum) { mName = inName; mSymbol = inSymbol; mAtomicNum = inAtomicNum; if (getClass().equals(Element.class)) // We don't want to include isotopes { sValues.add(this); } } //########################################################################## // PUBLIC METHODS //########################################################################## //-------------------------------------------------------------------------- public static AtomicWeightsVersion getDefaultAtomicWeightsVersion() { return sDefaultAtomicWeightsVersion; } //-------------------------------------------------------------------------- public static void setDefaultAtomicWeightsVersion(AtomicWeightsVersion inValue) { if (null == inValue) { throw new UserInputException("The atomic weight version to use cannot be set to null!"); } sDefaultAtomicWeightsVersion = inValue; } //-------------------------------------------------------------------------- public static Element valueOf(String inString) { return valueOf(inString, Case.SENSITIVE); } //-------------------------------------------------------------------------- public static Element valueOf(String inString, Case inCaseSensitive) { Element value = null; if (StringUtil.isSet(inString)) { for (Element element : sValues) { if(inCaseSensitive != null && inCaseSensitive.equals(Case.INSENSITIVE)) { // Compare in a case-insensitive way if (element.getName().equalsIgnoreCase(inString) || element.getSymbol().equalsIgnoreCase(inString)) { value = element; break; } else if (element.getAliases() != null) { for (String alias : element.getAliases()) { if (alias.equalsIgnoreCase(inString)) { value = element; break; } } if (value != null) { break; } } } else if (element.getName().equals(inString) || element.getSymbol().equals(inString) || (element.getAliases() != null && element.getAliases().contains(inString))) { // Compare in a case-sensitive way value = element; break; } } } return value; } //-------------------------------------------------------------------------- public static Element valueOf(Integer inAtomicNum) { Element value = null; if (inAtomicNum != null) { for (Element element : sValues) { if (element.getAtomicNum() == inAtomicNum) { value = element; break; } } } return value; } //-------------------------------------------------------------------------- public static Element[] values() { return sValues.toArray(new Element[sValues.size()]); } //-------------------------------------------------------------------------- public String getName() { return mName; } //-------------------------------------------------------------------------- public String getSymbol() { return mSymbol; } //-------------------------------------------------------------------------- public int getAtomicNum() { return mAtomicNum; } //-------------------------------------------------------------------------- public Element addAlias(String inValue) { if (null == mAliases) { mAliases = new HashSet<>(2); } mAliases.add(inValue); return this; } //-------------------------------------------------------------------------- public Set getAliases() { return mAliases; } //-------------------------------------------------------------------------- @Override public String toString() { return getSymbol(); } //-------------------------------------------------------------------------- public int compareTo(Element inObj2) { int result = CompareUtil.compare(getAtomicNum(), inObj2.getAtomicNum()); return result; } // Matter interface methods: //-------------------------------------------------------------------------- public Map getElementalComposition() { Map elemComp = new HashMap<>(1); elemComp.put(this, 1.0f); return elemComp; } //-------------------------------------------------------------------------- /** Returns a chemical formula String. For Elements this returns the symbol. @return the chemical formula string */ public String getChemicalFormula() { return getSymbol(); } //-------------------------------------------------------------------------- public Double getMonoisotopicMass() { return getMonoisotopicMass(sDefaultAtomicWeightsVersion); } //-------------------------------------------------------------------------- public Double getMonoisotopicMass(AtomicWeightsVersion inAtomicWeightsVersion) { return sMonoisotopicMasses.get(inAtomicWeightsVersion).get(this); } //-------------------------------------------------------------------------- public Double getAverageMass() { return getAverageMass(sDefaultAtomicWeightsVersion); } //-------------------------------------------------------------------------- public Double getAverageMass(AtomicWeightsVersion inAtomicWeightsVersion) { return sAverageMasses.get(inAtomicWeightsVersion).get(this); } //-------------------------------------------------------------------------- /** Returns the average mass as estimated from organic sources. [Zhang Z, Pan H, Chen X. 2009. Mass spectrometry for structural characterization of therapeutic antibodies. Mass Spectrom Rev 28:147-176.] */ public Double getOrganicAverageMass() { return mOrganicAverageMass; } //--------------------------------------------------------------------------- private void setVanderWaalsRadius(Length inValue) { mVanderWaalsRadius = inValue; } //--------------------------------------------------------------------------- /** Returns the Van der Waals radius. [From Table 1 in Alvarez, Santiago. 2013. “A Cartography of the van Der Waals Territories.” Dalton Transactions 42 (24): 8617–36. https://doi.org/10.1039/c3dt50599e. @return the Van der Waals radius */ public Length getVanderWaalsRadius() { return mVanderWaalsRadius; } //--------------------------------------------------------------------------- private void setCovalentRadius(Length inValue) { mCovalentRadius = inValue; } //--------------------------------------------------------------------------- /** Returns the covalent radius. [From Table 2 in Cordero, Beatriz, Verónica Gómez, Ana E. Platero-Prats, Marc Revés, Jorge Echeverría, Eduard Cremades, Flavia Barragán, and Santiago Alvarez. 2008. “Covalent Radii Revisited.” Journal of the Chemical Society. Dalton Transactions, no. 21: 2832–38. https://doi.org/10.1039/b801115j. @return the Van der Waals radius */ public Length getCovalentRadius() { return mCovalentRadius; } //--------------------------------------------------------------------------- private static void loadAtomicWeightsData(AtomicWeightsVersion inVersion) { sMonoisotopicMasses.put(inVersion, new HashMap<>(120)); sAverageMasses.put(inVersion, new HashMap<>(120)); String rsrc = ATOMIC_WEIGHT_VERSIONS_RSRC_MAP.get(inVersion); InputStream stream = Isotope.class.getResourceAsStream(rsrc); if (null == stream) { throw new ProgrammingException("The rsrc " + rsrc + " couldn't be found!?"); } BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(stream)); String line; int lineNum = 0; Element currentElement = null; while ((line = reader.readLine()) != null) { lineNum++; if (! StringUtil.isSet(line) // Skip blank lines || line.startsWith("#")) // Skip comment lines { continue; } String[] fields = CSV.parseLine(line); if (StringUtil.isSet(fields[1])) { currentElement = Element.valueOf(Integer.parseInt(fields[1].trim())); } if (fields.length >= 3 && StringUtil.isSet(fields[2])) { sMonoisotopicMasses.get(inVersion).put(currentElement, Double.parseDouble(fields[2])); } Double avgMass = null; if (fields.length >= 4 && StringUtil.isSet(fields[3])) { avgMass = Double.parseDouble(fields[3]); } sAverageMasses.get(inVersion).put(currentElement, avgMass); } } catch (IOException e) { throw new RuntimeException("Problem initializing atomic weight data!", e); } finally { StreamUtil.close(reader); } } //--------------------------------------------------------------------------- private void setDefaultValences(int[] inValues) { mDefaultValences = inValues; } //--------------------------------------------------------------------------- /** Returns the default values for the number of valence electrons for the element. Used when calculating implicit hydrogens for a compound. */ public int[] getDefaultValences() { return mDefaultValences; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy