molshape/ChemFormula

Addition of Named Isotopes

Opened this issue · 1 comments

Would you consider adding element symbols of named isotopes, specifically Deuterium (D) and Tritium (T) to the atomic weight table?

Thank you for your suggestion regarding the addition of element symbols for named isotopes. Currently, the atomic weight data in ChemFormula is based on average atomic weights, reflecting the natural isotopic distribution of non-radioactive elements (of unknown origin). As such, the package does not differentiate between isotopes like protium (1H), deuterium (D, 2H), or tritium (T, 3H). From a calculation perspective, the package cannot distinguish whether H represents 1H (protium) or the natural isotopic distribution of hydrogen. This naturally applies to all elements - not just hydrogen.

However, you can extend the file /src/elements.py in your local installation by modifying the atomic_weight() function to include entries for deuterium and tritium as a quick workaround. I would also recommend defining a custom symbol for protium (e.g., Hp, since P, Pr, and Pm are already defined) to differentiate between the specific isotopes and natural hydrogen. This would look something like this:

def atomic_weight(element):
    atomic_weight_table = {
        "H":    1.008,   # average atomic weight for hydrogen in accordance with Pure Appl. Chem., 2016, 88, 265-291
        "D":    2.014,   # atomic weight for deuterium
        "T":    3.016,   # atomic weight for tritium
        "Hp":   1.00784, # atomic weight for protium, with a custom atomic symbol (not IUPAC compliant)
        # ... rest of the elements
    }
    # return the atomic weight of the element symbol passed to the function, False if the element symbol does not exist
    return float(atomic_weight_table[element]) if element in atomic_weight_table else False

This will allow you to specify deuterium and tritium in your formulas and calculations.

For a future release, I am planning to add support for user-defined abbreviations in chemical formulas, such as Ph for C6H5. In this context, I will also consider how to better support isotopes, as this deserves a more general approach. Thanks again for your feedback!