Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Named Isotopes #14

Open
lcnittl opened this issue Aug 19, 2024 · 1 comment
Open

Addition of Named Isotopes #14

lcnittl opened this issue Aug 19, 2024 · 1 comment

Comments

@lcnittl
Copy link

lcnittl commented Aug 19, 2024

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

@molshape
Copy link
Owner

molshape commented Sep 7, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants