Spaces:
Running
Running
add hydrogen combution rank
Browse files- serve/app.py +0 -15
- serve/ranks/__init__.py +0 -0
- serve/ranks/combustion.py +101 -6
- serve/tasks/combustion.py +0 -38
serve/app.py
CHANGED
@@ -4,21 +4,6 @@ import streamlit as st
|
|
4 |
|
5 |
from mlip_arena.tasks import REGISTRY as TASKS
|
6 |
|
7 |
-
# if "logged_in" not in st.session_state:
|
8 |
-
# st.session_state.logged_in = False
|
9 |
-
|
10 |
-
# def login():
|
11 |
-
# if st.button("Log in"):
|
12 |
-
# st.session_state.logged_in = True
|
13 |
-
# st.rerun()
|
14 |
-
|
15 |
-
# def logout():
|
16 |
-
# if st.button("Log out"):
|
17 |
-
# st.session_state.logged_in = False
|
18 |
-
# st.rerun()
|
19 |
-
|
20 |
-
# login_page = st.Page(login, title="Log in", icon=":material/login:")
|
21 |
-
# logout_page = st.Page(logout, title="Log out", icon=":material/logout:")
|
22 |
|
23 |
leaderboard = st.Page(
|
24 |
"leaderboard.py", title="Leaderboard", icon=":material/trophy:", default=True
|
|
|
4 |
|
5 |
from mlip_arena.tasks import REGISTRY as TASKS
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
leaderboard = st.Page(
|
9 |
"leaderboard.py", title="Leaderboard", icon=":material/trophy:", default=True
|
serve/ranks/__init__.py
DELETED
File without changes
|
serve/ranks/combustion.py
CHANGED
@@ -28,7 +28,7 @@ df = get_data(valid_models)
|
|
28 |
|
29 |
@st.cache_data
|
30 |
def get_com_drifts(df):
|
31 |
-
df_exploded = df.explode(["timestep", "com_drifts"]).reset_index(drop=True)
|
32 |
|
33 |
# Convert the 'com_drifts' column (which are arrays) into separate columns for x, y, and z components
|
34 |
df_exploded[["com_drift_x", "com_drift_y", "com_drift_z"]] = pd.DataFrame(
|
@@ -42,14 +42,109 @@ def get_com_drifts(df):
|
|
42 |
df_flat["com_drift_x"] ** 2 + df_flat["com_drift_y"] ** 2 + df_flat["com_drift_z"] ** 2
|
43 |
)
|
44 |
|
|
|
|
|
45 |
return df_flat
|
46 |
|
47 |
df_exploded = get_com_drifts(df)
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
table = pd.DataFrame()
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
@st.cache_data
|
30 |
def get_com_drifts(df):
|
31 |
+
df_exploded = df.explode(["timestep", "energies", "com_drifts"]).reset_index(drop=True)
|
32 |
|
33 |
# Convert the 'com_drifts' column (which are arrays) into separate columns for x, y, and z components
|
34 |
df_exploded[["com_drift_x", "com_drift_y", "com_drift_z"]] = pd.DataFrame(
|
|
|
42 |
df_flat["com_drift_x"] ** 2 + df_flat["com_drift_y"] ** 2 + df_flat["com_drift_z"] ** 2
|
43 |
)
|
44 |
|
45 |
+
df_flat = df_flat.drop(columns=["com_drift_x", "com_drift_y", "com_drift_z"])
|
46 |
+
|
47 |
return df_flat
|
48 |
|
49 |
df_exploded = get_com_drifts(df)
|
50 |
|
51 |
+
for method, row in df_exploded.groupby("method"):
|
52 |
+
# # row = df[df["method"] == method].iloc[0]
|
53 |
+
energies = np.array(row["energies"])
|
54 |
+
df_exploded.loc[df_exploded["method"] == method,"reaction_enthlapy_diff"] = (energies[-1] - energies[0]) / 128 * 23.
|
55 |
+
df_exploded.loc[df_exploded["method"] == method, "final_com_drift"] = np.array(row["total_com_drift"])[-1]
|
56 |
+
|
57 |
+
exp_ref = -68.3078 # kcal/mol
|
58 |
+
|
59 |
+
|
60 |
+
df_exploded.drop(columns=["temperatures", "pressures", "total_steps", "energies", "kinetic_energies", "timestep", "nproducts", "total_com_drift", "target_steps", "reaction", "formula", "natoms", "seconds_per_step", "seconds_per_step_per_atom", "final_step", "total_time_seconds"], axis=1, inplace=True)
|
61 |
+
|
62 |
+
df_exploded.drop_duplicates(inplace=True, subset=["method"])
|
63 |
+
|
64 |
+
print(df_exploded.columns)
|
65 |
+
|
66 |
+
df_exploded.set_index("method", inplace=True)
|
67 |
+
|
68 |
+
df_exploded.rename(columns={
|
69 |
+
"method": "Model"
|
70 |
+
}, inplace=True)
|
71 |
+
|
72 |
+
|
73 |
table = pd.DataFrame()
|
74 |
|
75 |
+
for index, row in df_exploded.iterrows():
|
76 |
+
|
77 |
+
new_row = {
|
78 |
+
"Model": index,
|
79 |
+
"Reaction enthalpy error [kcal/mol]": row["reaction_enthlapy_diff"],
|
80 |
+
"Final COM drift [Å]": row["final_com_drift"],
|
81 |
+
"Steps per second": row["steps_per_second"],
|
82 |
+
"Yield [%]": row["yield"] * 100,
|
83 |
+
}
|
84 |
+
|
85 |
+
table = pd.concat([table, pd.DataFrame([new_row])], ignore_index=True)
|
86 |
+
|
87 |
+
table.set_index("Model", inplace=True)
|
88 |
+
|
89 |
+
table.sort_values("Reaction enthalpy error [kcal/mol]", ascending=True, inplace=True)
|
90 |
+
table["Rank"] = np.argsort(np.abs(table["Reaction enthalpy error [kcal/mol]"].to_numpy()))
|
91 |
+
|
92 |
+
table.sort_values("Final COM drift [Å]", ascending=True, inplace=True)
|
93 |
+
table["Rank"] += np.argsort(table["Final COM drift [Å]"].to_numpy())
|
94 |
+
|
95 |
+
table.sort_values("Steps per second", ascending=False, inplace=True)
|
96 |
+
table["Rank"] += np.argsort(-table["Steps per second"].to_numpy())
|
97 |
+
|
98 |
+
table.sort_values("Yield [%]", ascending=False, inplace=True)
|
99 |
+
table["Rank"] += np.argsort(-table["Yield [%]"].to_numpy())
|
100 |
+
|
101 |
+
table["Rank"] += 1
|
102 |
+
|
103 |
+
table.sort_values(["Rank"], ascending=True, inplace=True)
|
104 |
+
|
105 |
+
table["Rank aggr."] = table["Rank"]
|
106 |
+
table["Rank"] = table["Rank aggr."].rank(method='min').astype(int)
|
107 |
+
|
108 |
+
|
109 |
+
table = table.reindex(
|
110 |
+
columns=[
|
111 |
+
"Rank",
|
112 |
+
"Rank aggr.",
|
113 |
+
"Reaction enthalpy error [kcal/mol]",
|
114 |
+
"Final COM drift [Å]",
|
115 |
+
"Steps per second",
|
116 |
+
"Yield [%]",
|
117 |
+
]
|
118 |
+
)
|
119 |
+
|
120 |
+
s = (
|
121 |
+
table.style.background_gradient(
|
122 |
+
cmap="Oranges",
|
123 |
+
subset=["Reaction enthalpy error [kcal/mol]"],
|
124 |
+
)
|
125 |
+
.background_gradient(
|
126 |
+
cmap="Oranges",
|
127 |
+
subset=["Final COM drift [Å]"],
|
128 |
+
gmap=np.log10(table["Final COM drift [Å]"].to_numpy() + 1e-10),
|
129 |
+
)
|
130 |
+
.background_gradient(
|
131 |
+
cmap="Oranges_r",
|
132 |
+
subset=["Steps per second", "Yield [%]"]
|
133 |
+
)
|
134 |
+
.background_gradient(
|
135 |
+
cmap="Blues",
|
136 |
+
subset=["Rank", "Rank aggr."],
|
137 |
+
)
|
138 |
+
.format(
|
139 |
+
"{:.3e}",
|
140 |
+
subset=["Final COM drift [Å]"],
|
141 |
+
)
|
142 |
+
)
|
143 |
+
|
144 |
+
|
145 |
+
def render():
|
146 |
+
|
147 |
+
st.dataframe(
|
148 |
+
s,
|
149 |
+
use_container_width=True,
|
150 |
+
)
|
serve/tasks/combustion.py
CHANGED
@@ -250,36 +250,6 @@ fig.update_layout(
|
|
250 |
|
251 |
st.plotly_chart(fig)
|
252 |
|
253 |
-
# Total Energy
|
254 |
-
|
255 |
-
# fig = go.Figure()
|
256 |
-
|
257 |
-
# for method in df["method"].unique():
|
258 |
-
# row = df[df["method"] == method].iloc[0]
|
259 |
-
# fig.add_trace(
|
260 |
-
# go.Scatter(
|
261 |
-
# x=row["timestep"],
|
262 |
-
# y=np.array(row["energies"]) - row["energies"][0] + np.array(row["kinetic_energies"]),
|
263 |
-
# mode="lines",
|
264 |
-
# name=method,
|
265 |
-
# line=dict(
|
266 |
-
# color=method_color_mapping[method],
|
267 |
-
# # width=1
|
268 |
-
# ),
|
269 |
-
# marker=dict(color=method_color_mapping[method], size=3),
|
270 |
-
# showlegend=True,
|
271 |
-
# ),
|
272 |
-
# )
|
273 |
-
|
274 |
-
# fig.update_layout(
|
275 |
-
# # title="Hydrogen Combustion (2H2 + O2 -> 2H2O, 64 units)",
|
276 |
-
# xaxis_title="Timestep",
|
277 |
-
# yaxis_title="Total Energy 𝚫 (eV)",
|
278 |
-
# # template="plotly_dark",
|
279 |
-
# )
|
280 |
-
|
281 |
-
# st.plotly_chart(fig)
|
282 |
-
|
283 |
# Reaction energy
|
284 |
|
285 |
fig = go.Figure()
|
@@ -334,16 +304,8 @@ fig.add_annotation(
|
|
334 |
)
|
335 |
|
336 |
fig.update_layout(
|
337 |
-
# title="Reaction energy 𝚫H (kcal/mol)",
|
338 |
xaxis_title="Method <br> <span style='font-size: 10px;'>[1] Lide, D. R. (Ed.). (2004). CRC handbook of chemistry and physics (Vol. 85). CRC press.</span>",
|
339 |
yaxis_title="Reaction energy 𝚫H (kcal/mol)",
|
340 |
-
# annotations = [
|
341 |
-
# dict(
|
342 |
-
# x=0.5, xref="paper", xanchor="center",
|
343 |
-
# y=-0.5, yref="paper", yanchor="bottom",
|
344 |
-
# text="Caption",
|
345 |
-
# )
|
346 |
-
# ]
|
347 |
)
|
348 |
|
349 |
st.plotly_chart(fig)
|
|
|
250 |
|
251 |
st.plotly_chart(fig)
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
# Reaction energy
|
254 |
|
255 |
fig = go.Figure()
|
|
|
304 |
)
|
305 |
|
306 |
fig.update_layout(
|
|
|
307 |
xaxis_title="Method <br> <span style='font-size: 10px;'>[1] Lide, D. R. (Ed.). (2004). CRC handbook of chemistry and physics (Vol. 85). CRC press.</span>",
|
308 |
yaxis_title="Reaction energy 𝚫H (kcal/mol)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
)
|
310 |
|
311 |
st.plotly_chart(fig)
|