Skip to content

Isotopes #43

@mattwthompson

Description

@mattwthompson

Thank you for writing this nice little package. It's satisfying to be able to solve a small problem without needing to pull in a big library.

One usage question I have is how to deal with isotopes of elements, i.e. Deuterium in heavy water. I can make a custom element as I please, but this doesn't propogate out to the lookup functions.

$ cat repro.py
import ele

deuterium = ele.element.Element(name="deuterium", symbol="D", mass="2.0", atomic_number="1")
ele.element_from_symbol("D")
$ python repro.py
Traceback (most recent call last):
  File "repro.py", line 4, in <module>
    ele.element_from_symbol("D")
  File "/Users/mwt/miniconda3/envs/openff-system/lib/python3.8/site-packages/ele/element.py", line 74, in element_from_symbol
    raise ElementError(f"No element with symbol {symbol}")
ele.exceptions.ElementError: No element with symbol D

Attempting to force it in (i.e. ele.element.elements.append(deuterium)) doesn't work, and it's probably not a good idea to modify module variables directly in the absence of an API to do so. What would be the suggested usage here, or is this intended to be out of the scope of this project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions