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

Scripts for NIST IP determination #11

Merged
merged 2 commits into from
Feb 28, 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
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ dev-dependencies = [
"pytest>=7.4.4",
"hypothesis>=6.97.1",
"pytest-cov>=4.1.0",
"requests>=2.31.0",
"iniabu>=1.1.2",
]

[tool.rye.scripts]
Expand All @@ -55,3 +57,9 @@ packages = ["src/rimsschemedrawer"]
testpaths = "tests"
addopts = "--cov -v"
filterwarnings = 'ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning' # 3rd party

[tool.box]
builder = "rye"
app_entry = "rimsschemedrawer.app:run_gui"
app_name = "rimsschemedrawer[gui]"
optional_deps = "gui"
20 changes: 11 additions & 9 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
-e file:.
attrs==23.2.0
# via hypothesis
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
contourpy==1.2.0
# via matplotlib
coverage==7.4.1
Expand All @@ -19,6 +23,9 @@ cycler==0.12.1
fonttools==4.47.2
# via matplotlib
hypothesis==6.97.1
idna==3.6
# via requests
iniabu==1.1.2
iniconfig==2.0.0
# via pytest
kiwisolver==1.4.5
Expand All @@ -27,33 +34,28 @@ matplotlib==3.8.2
# via rimsschemedrawer
numpy==1.26.3
# via contourpy
# via iniabu
# via matplotlib
# via rimsschemedrawer
packaging==23.2
# via matplotlib
# via pytest
# via qtpy
pillow==10.2.0
# via matplotlib
pluggy==1.3.0
# via pytest
pyparsing==3.1.1
# via matplotlib
pyqt6==6.6.1
# via rimsschemedrawer
pyqt6-qt6==6.6.1
# via pyqt6
pyqt6-sip==13.6.0
# via pyqt6
pytest==7.4.4
# via pytest-cov
pytest-cov==4.1.0
python-dateutil==2.8.2
# via matplotlib
qtpy==2.4.1
# via rimsschemedrawer
requests==2.31.0
ruff==0.1.14
six==1.16.0
# via python-dateutil
sortedcontainers==2.4.0
# via hypothesis
urllib3==2.2.1
# via requests
9 changes: 0 additions & 9 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,11 @@ numpy==1.26.3
# via rimsschemedrawer
packaging==23.2
# via matplotlib
# via qtpy
pillow==10.2.0
# via matplotlib
pyparsing==3.1.1
# via matplotlib
pyqt6==6.6.1
# via rimsschemedrawer
pyqt6-qt6==6.6.1
# via pyqt6
pyqt6-sip==13.6.0
# via pyqt6
python-dateutil==2.8.2
# via matplotlib
qtpy==2.4.1
# via rimsschemedrawer
six==1.16.0
# via python-dateutil
85 changes: 85 additions & 0 deletions scripts/ip_nist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"H": 109678.77174307,
"He": 198310.66637,
"Li": 43487.1142,
"Be": 75192.64,
"B": 66928.04,
"C": 90820.348,
"N": 117225.7,
"O": 109837.02,
"F": 140524.5,
"Ne": 173929.75,
"Na": 41449.451,
"Mg": 61671.05,
"Al": 48278.48,
"Si": 65747.76,
"P": 84580.83,
"S": 83559.1,
"Cl": 104591.01,
"Ar": 127109.842,
"K": 35009.814,
"Ca": 49305.924,
"Sc": 52922.0,
"Ti": 55072.5,
"V": 54411.67,
"Cr": 54575.6,
"Mn": 59959.56,
"Fe": 63737.704,
"Co": 63564.6,
"Ni": 61619.77,
"Cu": 62317.46,
"Zn": 75769.31,
"Ga": 48387.634,
"Ge": 63713.24,
"As": 78950.0,
"Se": 78658.15,
"Br": 95284.8,
"Kr": 112914.433,
"Rb": 33690.81,
"Sr": 45932.2036,
"Y": 50145.6,
"Zr": 53507.832,
"Nb": 54513.8,
"Mo": 57204.3,
"Ru": 59366.4,
"Rh": 60160.1,
"Pd": 67241.14,
"Ag": 61106.45,
"Cd": 72540.05,
"In": 46670.107,
"Sn": 59232.69,
"Sb": 69431.34,
"Te": 72669.006,
"I": 84294.9,
"Xe": 97833.787,
"Cs": 31406.4677325,
"Ba": 42034.91,
"La": 44981.0,
"Ce": 44672.0,
"Pr": 44120.0,
"Nd": 44562.0,
"Sm": 45519.69,
"Eu": 45734.74,
"Gd": 49601.45,
"Tb": 47295.0,
"Dy": 47901.76,
"Ho": 48567.0,
"Er": 49262.0,
"Tm": 49880.57,
"Yb": 50443.2,
"Lu": 43762.6,
"Hf": 55047.9,
"Ta": 60891.4,
"W": 63427.7,
"Re": 63181.6,
"Os": 68058.9,
"Ir": 72323.9,
"Pt": 72257.8,
"Au": 74409.11,
"Hg": 84184.15,
"Tl": 49266.66,
"Pb": 59819.558,
"Bi": 58761.65,
"Th": 50867.0,
"U": 49958.4
}
59 changes: 59 additions & 0 deletions scripts/ip_nist_reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import json

from iniabu import ini
import requests


def get_url(ele: str) -> str:
"""Get URL for csv file from NIST.

:param ele: String of element, e.g., Mg

:return: URL to get csv file from NIST.
"""
url = (
f"https://physics.nist.gov/cgi-bin/ASD/energy1.pl?de=0&spectrum={ele}+"
f"I&units=0&format=2&output=0&page_size=15&multiplet_ordered=0&conf_out"
f"=on&term_out=on&level_out=on&unc_out=1&j_out=on&lande_out=on&perc_out"
f"=on&biblio=on&temp=&submit=Retrieve+Data"
)
return url


def get_ip(ele: str) -> float:
"""Get ionization potential from NIST.

:param ele: String of element, e.g., Mg

:return: Ionization potential in eV.
"""
data = requests.get(get_url(ele)).text
data = data.split("\n")

# find limit line in data
for it, line in enumerate(data):
if "Limit" in line:
idx = it
break

line = data[idx].replace('"', "").replace("=", "").split(",")
# print(line)
ip = line[4]
if ip == "[" or ip == "":
ip = line[5] # we got a best guess value in []
return float(ip)


elements = ini.ele_dict.keys() # list of all elements
ele_ips = {}

# print(elements)

# print(get_ip("Tb"))

for ele in elements:
print(f"{ele} is up")
ele_ips[ele] = get_ip(ele)

with open("ip_nist.json", "w") as fout:
json.dump(ele_ips, fout, indent=4)
Loading