Source code for xgc_analysis.periodic_table

# Basic periodic table: element name -> atomic mass (mean atomic mass from IUPAC)
periodic_table_data = {
    "e":   5.446e-4,
    "H":   1.008,
    "D":   2.014,
    "T":   3.0016,
    "He":  4.0026,
    "Li":  6.94,
    "Be":  9.0122,
    "B":  10.81,
    "C":  12.011,
    "N":  14.007,
    "O":  15.999,
    "F":  18.998,
    "Ne": 20.180,
    "Na": 22.990,
    "Mg": 24.305,
    "Al": 26.982,
    "Si": 28.085,
    "P":  30.974,
    "S":  32.06,
    "Cl": 35.45,
    "Ar": 39.948,
    "K":  39.098,
    "Ca": 40.078,
    "Ti": 47.867,
    "Cr": 51.996,
    "Mn": 54.938,
    "Fe": 55.845,
    "Ni": 58.693,
    "Cu": 63.546,
    "Zn": 65.38,
    "Mo": 95.95,
    "Xe": 131.293,
    "W":  183.84,
    "Au": 196.97,
    "Hg": 200.59,
    "Pb": 207.2,
    "U":  238.03,
}

[docs] def get_element_name_by_mass(mass_au, tolerance=0.5): """ Returns the name of the element with atomic mass closest to the given mass_au. Parameters: - mass_au : float Mass in atomic mass units. - tolerance : float Maximum allowed deviation to consider a match. Returns: - str: Element symbol or 'Unknown' if no match is found. """ closest_element = None min_diff = float("inf") for element, atomic_mass in periodic_table_data.items(): diff = abs(atomic_mass - mass_au) if diff < min_diff and diff <= tolerance: min_diff = diff closest_element = element return closest_element if closest_element else "Unknown"