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

Added dummy atom data to tcutility.data.atoms #292

Merged
merged 2 commits into from
Aug 18, 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
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/color.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, 128, 0, 128
1, 255, 255, 255
2, 217, 255, 255
3, 204, 128, 255
Expand Down
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/name.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, dummy
1, hydrogen
2, helium
3, lithium
Expand Down
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/radius.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, 0.15
1, 0.31
2, 0.28
3, 1.28
Expand Down
1 change: 1 addition & 0 deletions src/tcutility/data/_atom_data_info/symbol.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0, Xx
1, H
2, He
3, Li
Expand Down
10 changes: 5 additions & 5 deletions src/tcutility/data/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def parse_element(val):
# if it is not an int it should be a string
if val.lower() in _element_order:
# first try to get it in the element name list
return _element_order.index(val.lower()) + 1
return _element_order.index(val.lower())
if val in _symbol_order:
# alternatively try to get it in the symbol list
return _symbol_order.index(val) + 1
return _symbol_order.index(val)
raise KeyError(f'Element "{val}" not parsable.')


Expand Down Expand Up @@ -81,13 +81,13 @@ def atom_number(element):

def symbol(element):
num = parse_element(element)
return _symbol_order[num - 1]
return _symbol_order[num]


def element(element):
num = parse_element(element)
return _element_order[num - 1]
return _element_order[num]


if __name__ == "__main__":
print(symbol(2))
print(symbol(0))
Loading