ManasSharma07 commited on
Commit
f16065f
·
verified ·
1 Parent(s): f79665b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +72 -9
src/streamlit_app.py CHANGED
@@ -615,7 +615,7 @@ st.set_page_config(
615
 
616
  # Title and description
617
  st.markdown('## MLIP Playground', unsafe_allow_html=True)
618
- st.write('#### Run, test and compare 22 state-of-the-art universal machine learning interatomic potentials (MLIPs) for atomistic simulations of molecules and materials')
619
  st.markdown('Upload molecular structure files or select from predefined examples, then compute energies and forces using foundation models such as those from MACE or FairChem (Meta).', unsafe_allow_html=True)
620
 
621
  # Create a directory for sample structures if it doesn't exist
@@ -1604,6 +1604,69 @@ if atoms is not None:
1604
  mime="chemical/x-xyz"
1605
  )
1606
  show_optimized_structure_download_button()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1607
  os.unlink(tmp_filepath_opt)
1608
 
1609
  @st.fragment
@@ -2030,18 +2093,18 @@ with st.expander('ℹ️ About This App & Foundational MLIPs'):
2030
  st.write("""
2031
  **Test, compare, and benchmark universal machine learning interatomic potentials (MLIPs).**
2032
  This application allows you to perform atomistic simulations using pre-trained foundational MLIPs
2033
- from the MACE and FairChem (by Meta AI) libraries.
2034
 
2035
  **Features:**
2036
- - Upload structure files (XYZ, CIF, POSCAR, etc.) or use built-in examples.
2037
- - Select from various MACE and FairChem models.
2038
- - Calculate energies, forces, and perform geometry/cell optimizations.
2039
- - **New**: Calculate atomization energy (for molecules) or cohesive energy (for periodic systems).
2040
- - Visualize atomic structures in 3D and download results.
2041
 
2042
  **Quick Start:**
2043
  1. **Input**: Choose an input method in the sidebar (e.g., "Select Example").
2044
- 2. **Model**: Pick a model type (MACE/FairChem) and specific model. For FairChem UMA, select the appropriate task type (e.g., `omol` for molecules, `omat` for materials).
 
2045
  3. **Task**: Select a calculation task (e.g., "Energy Calculation", "Atomization/Cohesive Energy", "Geometry Optimization").
2046
  4. **Run**: Click "Run Calculation" and view the results.
2047
 
@@ -2134,4 +2197,4 @@ with st.expander('🔧 Tech Stack & System Information'):
2134
 
2135
  st.markdown("---")
2136
  st.markdown("Universal MLIP Playground App | Created with Streamlit, ASE, MACE, FairChem, SevenNet, ORB and ❤️")
2137
- st.markdown("Developed by [Manas Sharma](https://manas.bragitoff.com/) in the groups of [Prof. Ananth Govind Rajan Group](https://www.agrgroup.org/) and [Prof. Sudeep Punnathanam](https://chemeng.iisc.ac.in/sudeep/) at [IISc Bangalore](https://iisc.ac.in/)")
 
615
 
616
  # Title and description
617
  st.markdown('## MLIP Playground', unsafe_allow_html=True)
618
+ st.write('#### Run, test and compare 38 state-of-the-art universal machine learning interatomic potentials (MLIPs) for atomistic simulations of molecules and materials')
619
  st.markdown('Upload molecular structure files or select from predefined examples, then compute energies and forces using foundation models such as those from MACE or FairChem (Meta).', unsafe_allow_html=True)
620
 
621
  # Create a directory for sample structures if it doesn't exist
 
1604
  mime="chemical/x-xyz"
1605
  )
1606
  show_optimized_structure_download_button()
1607
+ # --- Energy vs. Optimization Cycles Plot ---
1608
+ @st.fragment
1609
+ def show_energy_plot(traj_filename):
1610
+ from ase.io import read
1611
+ import pandas as pd
1612
+ import plotly.express as px
1613
+ import os
1614
+
1615
+ if os.path.exists(traj_filename):
1616
+ try:
1617
+ trajectory = read(traj_filename, index=":")
1618
+
1619
+ # Extract energy and step number
1620
+ energies = [atoms.get_potential_energy() for atoms in trajectory]
1621
+ steps = list(range(len(energies)))
1622
+
1623
+ # Create a DataFrame for Plotly
1624
+ data = {
1625
+ "Optimization Cycle": steps,
1626
+ "Energy (eV)": energies
1627
+ }
1628
+ df = pd.DataFrame(data)
1629
+
1630
+ st.markdown("### Energy Profile During Optimization")
1631
+
1632
+ # Create the Plotly figure
1633
+ fig = px.line(
1634
+ df,
1635
+ x="Optimization Cycle",
1636
+ y="Energy (eV)",
1637
+ markers=True, # Show points for each step
1638
+ title="Energy Convergence vs. Optimization Cycle",
1639
+ )
1640
+
1641
+ # Enhance aesthetics
1642
+ fig.update_layout(
1643
+ xaxis_title="Optimization Cycle",
1644
+ yaxis_title="Energy (eV)",
1645
+ hovermode="x unified",
1646
+ template="plotly_white", # Clean, professional look
1647
+ font=dict(size=12),
1648
+ title_x=0.5, # Center the title
1649
+ )
1650
+
1651
+ # Highlight the converged energy (optional: useful if the plot is zoomed out)
1652
+ fig.add_hline(
1653
+ y=energies[-1],
1654
+ line_dash="dot",
1655
+ line_color="red",
1656
+ annotation_text=f"Final Energy: {energies[-1]:.4f} eV",
1657
+ annotation_position="bottom right"
1658
+ )
1659
+
1660
+ # Render the plot in Streamlit
1661
+ st.plotly_chart(fig, use_container_width=True)
1662
+
1663
+ except Exception as e:
1664
+ st.error(f"Error generating energy plot: {e}")
1665
+ else:
1666
+ st.warning("Cannot generate energy plot: Trajectory file not found.")
1667
+
1668
+ show_energy_plot(traj_filename)
1669
+ # --- End of Energy Plot Code ---
1670
  os.unlink(tmp_filepath_opt)
1671
 
1672
  @st.fragment
 
2093
  st.write("""
2094
  **Test, compare, and benchmark universal machine learning interatomic potentials (MLIPs).**
2095
  This application allows you to perform atomistic simulations using pre-trained foundational MLIPs
2096
+ from the MACE, MatterSim (Microsoft), SevenNet, Orb (Orbital Materials) and FairChem (Meta AI) developers and researchers.
2097
 
2098
  **Features:**
2099
+ - Upload/Paste structure files (XYZ, CIF, POSCAR, etc.), import from Materials Project/PubChem or use built-in examples.
2100
+ - Select from various MACE, ORB, SevenNet, MatterSim and FairChem models.
2101
+ - Calculate energies, forces, cohesive/atomization energy, vibrational modes and perform geometry/cell optimizations.
2102
+ - Visualize atomic structures in 3D and download results, optimized structures and optimization trajectories.
 
2103
 
2104
  **Quick Start:**
2105
  1. **Input**: Choose an input method in the sidebar (e.g., "Select Example").
2106
+ 2. **Model**: Pick a model type (MACE/FairChem/MatterSim/ORB/SevenNet) and specific model. For FairChem UMA, select the appropriate task type (e.g., `omol` for molecules, `omat` for materials).
2107
+ For models trained on OMOL25 dataset (whenever the model name contains `omol`) then the user also needs to provide a charge and spin multiplicity (`2S+1`) value. By default the charge is set to zero and spin multiplicity to 1 (S=0).
2108
  3. **Task**: Select a calculation task (e.g., "Energy Calculation", "Atomization/Cohesive Energy", "Geometry Optimization").
2109
  4. **Run**: Click "Run Calculation" and view the results.
2110
 
 
2197
 
2198
  st.markdown("---")
2199
  st.markdown("Universal MLIP Playground App | Created with Streamlit, ASE, MACE, FairChem, SevenNet, ORB and ❤️")
2200
+ st.markdown("Developed by [Dr. Manas Sharma](https://manas.bragitoff.com/) in the groups of [Prof. Ananth Govind Rajan Group](https://www.agrgroup.org/) and [Prof. Sudeep Punnathanam](https://chemeng.iisc.ac.in/sudeep/) at [IISc Bangalore](https://iisc.ac.in/)")