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

Update the list of supported elements #223

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gemd/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.1.9"
__version__ = "2.1.10"
24 changes: 15 additions & 9 deletions gemd/entity/value/empirical_formula.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
"""An empirical chemical formula."""
import re

from gemd.entity.value.composition_value import CompositionValue
from gemd.entity.bounds import CompositionBounds

__all__ = ["EmpiricalFormula"]


_all_elements = {
'Tb', 'Be', 'Sb', 'Re', 'Sr', 'Ac', 'Ho', 'Ir', 'Cr', 'Os', 'S', 'Pt', 'Si', 'C', 'V', 'Bi',
'U', 'Pr', 'B', 'O', 'Zn', 'Xe', 'N', 'Ni', 'No', 'Ti', 'Pa', 'Am', 'Cu', 'I', 'Al', 'Ba',
'Pu', 'Ca', 'Bk', 'Ge', 'In', 'H', 'Es', 'Se', 'Cs', 'Te', 'Rn', 'Hf', 'Cm', 'Kr', 'Y',
'Cf', 'Li', 'F', 'Hg', 'Sm', 'Nd', 'Br', 'Er', 'K', 'Zr', 'Pd', 'Au', 'Eu', 'Md', 'Ga', 'As',
'Mn', 'Ag', 'Nb', 'Gd', 'Ru', 'Po', 'W', 'Na', 'Cl', 'Mo', 'Rh', 'Pm', 'Rb', 'Np', 'Lr',
'Ce', 'Ra', 'Tm', 'Dy', 'Fr', 'Sc', 'Lu', 'Fe', 'Fm', 'Cd', 'Ar', 'Mg', 'P', 'Th', 'Co',
'Tc', 'Pb', 'Ta', 'Tl', 'At', 'He', 'Yb', 'La', 'Sn', 'Ne'
}
_periodic_table = """
H D T He
Li Be B C N O F Ne
Na Mg Al Si P S Cl Ar
K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr
Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe
Cs Ba Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn
Fr Ra Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og

La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu
Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr
"""
_all_elements = re.split(r"\s+", _periodic_table.strip())


class EmpiricalFormula(CompositionValue, typ="empirical_formula"):
Expand Down
2 changes: 1 addition & 1 deletion tests/entity/value/test_empirical_formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_all_elements():
"""Check that list of all elements exists and has some select examples."""
for el in ["H", "He", "C", "Si", "Mg", "Al", "Co", "Ce"]:
assert el in EmpiricalFormula.all_elements(), "Couldn't find {} in all_elements".format(el)
assert len(EmpiricalFormula.all_elements()) == 103, "Expected 103 elements"
assert len(EmpiricalFormula.all_elements()) == 120, "Expected 120 elements"


def test_json():
Expand Down