ManasSharma07 commited on
Commit
d2e8693
·
verified ·
1 Parent(s): 51e1535

more updates to show convergence plot

Browse files
Files changed (1) hide show
  1. src/Home.py +46 -5
src/Home.py CHANGED
@@ -17,6 +17,7 @@ from ase import Atoms
17
  from ase.io import read as ase_read
18
  import pandas as pd
19
 
 
20
  # Set page configuration
21
  st.set_page_config(
22
  page_title='PyFock GUI - Interactive DFT Calculations',
@@ -110,9 +111,10 @@ with st.sidebar.expander("⚡ Performance Highlights"):
110
  - Upto 2x faster than PySCF
111
  - Strong scaling up to 32 cores
112
  - ~O(N²·⁰⁵) scaling with basis functions
 
113
 
114
  **GPU Acceleration:**
115
- - Up to **14× speedup** vs 4-core CPU
116
  - Single A100 GPU handles 4000+ basis functions
117
  - Consumer GPUs (RTX series) supported
118
  """)
@@ -588,7 +590,10 @@ if st.button("🚀 Run DFT Calculation", type="primary"):
588
  progress_bar.progress(50)
589
 
590
  # Display results
591
- st.success(f"✅ PyFock calculation completed in {pyfock_time:.2f} seconds!")
 
 
 
592
 
593
  st.header("3. Results")
594
 
@@ -634,8 +639,44 @@ if st.button("🚀 Run DFT Calculation", type="primary"):
634
  st.metric("HOMO-LUMO Gap", "N/A")
635
 
636
  with col8:
637
- # st.metric("SCF Iterations", f"{len(dftObj.energy_list)}")
638
- st.write('TODO: SCF Iterations')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
639
 
640
  # MO energies
641
  st.subheader("Molecular Orbital Energies")
@@ -948,7 +989,7 @@ print("Cube files generated successfully!")
948
  }
949
  python_script = python_script.format(**parameters)
950
  with st.expander("Input Script to Run the Above PyFock Calculation"):
951
- st.code(python_script)
952
  # Provide script as base64 link (no rerun on click)
953
  st.markdown(make_download_link(python_script, "pyfock_calculation.py", mimetype="text/x-python"), unsafe_allow_html=True)
954
 
 
17
  from ase.io import read as ase_read
18
  import pandas as pd
19
 
20
+
21
  # Set page configuration
22
  st.set_page_config(
23
  page_title='PyFock GUI - Interactive DFT Calculations',
 
111
  - Upto 2x faster than PySCF
112
  - Strong scaling up to 32 cores
113
  - ~O(N²·⁰⁵) scaling with basis functions
114
+ - Suitable for large systems (upto ~10,000 basis functions)
115
 
116
  **GPU Acceleration:**
117
+ - Up to **14× speedup** on A100 GPU vs 4-core CPU
118
  - Single A100 GPU handles 4000+ basis functions
119
  - Consumer GPUs (RTX series) supported
120
  """)
 
590
  progress_bar.progress(50)
591
 
592
  # Display results
593
+ if dftObj.converged:
594
+ st.success(f"✅ PyFock KS-DFT calculation converged in {pyfock_time:.2f} seconds and {dftObj.niter} iterations!")
595
+ else:
596
+ st.warning(f"⚠️ PyFock KS-DFT calculation did not converge in {dftObj.niter} iterations and {pyfock_time:.2f} seconds!")
597
 
598
  st.header("3. Results")
599
 
 
639
  st.metric("HOMO-LUMO Gap", "N/A")
640
 
641
  with col8:
642
+ st.metric("SCF Iterations", f"{dftObj.niter}")
643
+
644
+ with st.expander("SCF Convergence Details"):
645
+ # Create a DataFrame for the energies
646
+ import pandas as pd
647
+ scf_data = pd.DataFrame({
648
+ 'Iteration': range(1, len(dftObj.scf_energies) + 1),
649
+ 'Energy (Ha)': dftObj.scf_energies
650
+ })
651
+
652
+ # Calculate energy change between iterations
653
+ scf_data['ΔE (Ha)'] = scf_data['Energy (Ha)'].diff()
654
+
655
+ # Display the table
656
+ st.dataframe(scf_data, use_container_width=True, hide_index=True)
657
+
658
+ # Plot convergence
659
+ import plotly.graph_objects as go
660
+
661
+ fig = go.Figure()
662
+ fig.add_trace(go.Scatter(
663
+ x=scf_data['Iteration'],
664
+ y=scf_data['Energy (Ha)'],
665
+ mode='lines+markers',
666
+ name='Energy',
667
+ line=dict(color='#1f77b4', width=2),
668
+ marker=dict(size=6)
669
+ ))
670
+
671
+ fig.update_layout(
672
+ title='SCF Energy Convergence',
673
+ xaxis_title='Iteration',
674
+ yaxis_title='Energy (Hartree)',
675
+ hovermode='x unified',
676
+ height=400
677
+ )
678
+
679
+ st.plotly_chart(fig, use_container_width=True)
680
 
681
  # MO energies
682
  st.subheader("Molecular Orbital Energies")
 
989
  }
990
  python_script = python_script.format(**parameters)
991
  with st.expander("Input Script to Run the Above PyFock Calculation"):
992
+ st.code(python_script, language='python')
993
  # Provide script as base64 link (no rerun on click)
994
  st.markdown(make_download_link(python_script, "pyfock_calculation.py", mimetype="text/x-python"), unsafe_allow_html=True)
995