Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +0 -31
src/streamlit_app.py
CHANGED
@@ -1,32 +1,3 @@
|
|
1 |
-
Okay, I can help you modify the Streamlit application to include a task for calculating atomization or cohesive energy.
|
2 |
-
|
3 |
-
Here's a breakdown of the changes and the modified code:
|
4 |
-
|
5 |
-
## Summary of Modifications:
|
6 |
-
|
7 |
-
1. **Import `yaml`**: To parse the reference energy data for FairChem models.
|
8 |
-
2. **Define `ELEMENT_REF_ENERGIES_YAML`**: Added the YAML string containing reference energies for isolated atoms for FairChem models. This is parsed into the `ELEMENT_REF_ENERGIES` dictionary.
|
9 |
-
* **Note**: The YAML lists for `oc20_elem_refs`, `odac_elem_refs`, `omat_elem_refs`, and `omc_elem_refs` in your provided snippet are incomplete. I've added a few `0.0` placeholders to make them valid lists, but for accurate calculations, these should contain the correct reference energies for all relevant elements. The `omol_elem_refs` list from your example is more populated and used as such. The code will warn if a reference energy for a specific element is not found in the loaded lists.
|
10 |
-
3. **Update Task Selection**: Added "Atomization/Cohesive Energy" to the `st.sidebar.selectbox` for calculation tasks.
|
11 |
-
4. **Implement Atomization/Cohesive Energy Calculation Logic**:
|
12 |
-
* When the "Atomization/Cohesive Energy" task is selected:
|
13 |
-
* The total energy of the system (`E_system`) is calculated.
|
14 |
-
* The code determines if the system is periodic (for cohesive energy) or not (for atomization energy).
|
15 |
-
* **For FairChem Models**:
|
16 |
-
* It selects the appropriate list of reference energies from `ELEMENT_REF_ENERGIES` based on whether the model is "UMA Small" (using `selected_task_type` like `omol`, `omat`, etc.) or an "ESEN" model (which defaults to `omol_elem_refs`).
|
17 |
-
* It sums the reference energies for each atom in the system. A warning is issued if any element's reference energy is not found in the specified list (treating missing energies as 0).
|
18 |
-
* **For MACE Models**:
|
19 |
-
* It calculates the energy of each unique type of isolated atom by creating a single-atom `ase.Atoms` object (non-periodic) and using the already initialized MACE calculator.
|
20 |
-
* These individual atomic energies are summed, weighted by their counts in the system. A progress bar is shown for this step.
|
21 |
-
* **Final Calculation**:
|
22 |
-
* Atomization Energy: $E_{\text{atomization}} = \sum E_{\text{isolated atoms}} - E_{\text{system}}$
|
23 |
-
* Cohesive Energy: $E_{\text{cohesive}} = (\sum E_{\text{isolated atoms}} - E_{\text{system}}) / N_{\text{atoms}}$
|
24 |
-
* The results, including system energy and total isolated atom energy, are displayed.
|
25 |
-
* Error handling is included for cases like systems with zero atoms or missing reference energy lists for FairChem.
|
26 |
-
|
27 |
-
## Modified Code:
|
28 |
-
|
29 |
-
```python
|
30 |
import streamlit as st
|
31 |
import os
|
32 |
import tempfile
|
@@ -1074,5 +1045,3 @@ with st.expander('ℹ️ About This App & Foundational MLIPs'):
|
|
1074 |
""")
|
1075 |
st.markdown("Universal MLIP Playground App | Created with Streamlit, ASE, MACE, FairChem and ❤️")
|
1076 |
st.markdown("Developed by [Manas Sharma](https://manas.bragitoff.com/) ([Fundamental AI Research (FAIR) team, Meta AI](https://ai.meta.com/research/fair/) and [Ananth Govind Rajan Group, IISc Bangalore](https://www.agrgroup.org/))")
|
1077 |
-
|
1078 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import tempfile
|
|
|
1045 |
""")
|
1046 |
st.markdown("Universal MLIP Playground App | Created with Streamlit, ASE, MACE, FairChem and ❤️")
|
1047 |
st.markdown("Developed by [Manas Sharma](https://manas.bragitoff.com/) ([Fundamental AI Research (FAIR) team, Meta AI](https://ai.meta.com/research/fair/) and [Ananth Govind Rajan Group, IISc Bangalore](https://www.agrgroup.org/))")
|
|
|
|