Skip to content

Repository files navigation

PyFock GUI - Interactive DFT Calculations in Your Browser

Streamlit App Python License PyFock

A modern, interactive web interface for PyFock, a pure Python Gaussian-basis DFT code with Numba JIT acceleration, density fitting, PySCF validation, and optional CUDA acceleration through CuPy.

PyFock GUI Banner

Live Demo

Try PyFock GUI instantly without local installation:

Features

Computational Capabilities

Run Kohn-Sham DFT and HF calculations with density fitting, DIIS convergence, selectable CAO/SAO basis representation, native PyFock grids (levels 0–5), selectable SANO or core initial guesses, and optional PySCF energy comparison. For HF, PySCF comparison uses RIHF rather than a DFT calculation.

XC Functionals

The GUI exposes the native PyFock functional list:

  • HF
  • LDA
  • PBE, PBESOL, RPBE, PW91
  • BP86, BLYP
  • B3LYP, PBE0 (global hybrids)
  • R2SCAN, TPSS, M06L, TASK

LibXC is not required for the GUI functional list above.

Visualization

Interactive 3D structure viewing with py3Dmol. After SCF, request HOMO/LUMO plots, any molecular orbital, or electron density cubes. Cube generation is off by default; changing isosurfaces or opacity reuses generated cubes.

Geometry Optimization

The Geometry Optimization page couples PyFock energies and forces to ASE optimizers including BFGS, BFGSLineSearch, LBFGS, LBFGSLineSearch, FIRE, FIRE2, GPMin, MDMin, and ODE12r. It shows the optimized structure and convergence history, and exports both the final structure and the full trajectory as extXYZ with energy and forces retained at every frame. The hosted app limits each run to 10 optimization cycles and 120 basis functions; local runs can increase these limits in the generated reproduction script.

Input/Output

Choose from preconfigured example molecules or paste custom XYZ coordinates. The GUI can download HOMO, LUMO, density cube files, and a generated Python script that reproduces the PyFock calculation.

Key Advantages

PyFock is 100% pure Python, including molecular integral evaluation, with Numba JIT acceleration, density fitting with Cauchy-Schwarz screening, near-quadratic scaling for Coulomb terms, PySCF-level numerical accuracy, and optional GPU support.

Quick Start

Option 1: Use Online

Visit one of the live demo URLs above. No local setup is required.

Option 2: Run Locally

Clone the repository:

git clone https://github.com/manassharma07/PyFock-GUI.git
cd PyFock-GUI

Install dependencies:

pip install pyfock streamlit py3Dmol pyscf ase pandas plotly

# Optional: GPU support, choose the package matching your CUDA version
pip install cupy-cuda12x

Run the app:

streamlit run Home.py

The app will open in your browser at http://localhost:8501.

Usage Guide

Basic Workflow

Select an example molecule or paste custom XYZ coordinates. Choose the basis set, auxiliary basis, XC functional, convergence settings, and CAO or SAO representation. For DFT functionals, choose a native PyFock grid level from 0 (coarsest) to 5 (finest), with level 3 as the default. Choose SANO (default) or core for the initial density guess; both are generated by PyFock. These settings are also available for geometry optimization and included in downloaded scripts. The defaults are 20 SCF iterations and SAO representation. After SCF, request a PySCF comparison for an RIHF or KS-DFT reference energy using the saved molecular setup.

  1. Run SCF with your chosen settings.
  2. Inspect energy decomposition, convergence, HOMO-LUMO gap, orbital energies, and density matrix; view or download the input script and output log.
  3. Request forces, a dipole moment with a 3D direction plot, MO/density cubes, or a PySCF comparison. Results stay in the current Streamlit session, so these actions and display changes do not rerun the original SCF.
  4. Download the updated script, which includes only successfully requested follow-up calculations, using the original SCF settings. A new successful SCF replaces the saved results and clears previous properties and cubes.

Analytical forces reuse a converged, density-fitted pure-DFT result. The current PyFock backend requires additional SCF calculations for numerical HF/hybrid forces, so these are unavailable in the post-SCF force action. Changing any initial DFT setting clears the previous SCF results, input script, output log, and derived properties; run SCF again to obtain results for the new settings. Display-only changes retain saved results. Reloading or closing the session loses the saved calculation.

For a geometry relaxation, open Geometry Optimization in the page navigation, select the PyFock DFT settings and an ASE optimizer, set the maximum-force convergence criterion, and start the run. The page displays the final coordinates and an energy/force convergence plot, and provides optimized-geometry, extXYZ trajectory, and reproduction-script downloads.

Example Calculation

from pyfock import Basis, Mol, DFT

mol = Mol(coordfile='water.xyz')
basis = Basis(mol, {'all': Basis.load(mol=mol, basis_name='sto-3g')})
auxbasis = Basis(mol, {'all': Basis.load(mol=mol, basis_name='def2-universal-jfit')})

dftObj = DFT(mol, basis, auxbasis, xc='PBE', gridsLevel=3, dmat_guess_method='sano')
dftObj.conv_crit = 1e-6
dftObj.max_itr = 20
dftObj.sao = True

energy, dmat = dftObj.scf()
print(f"Total Energy: {energy:.8f} Ha")

Important Notes

JIT Compilation

PyFock uses Numba JIT compilation. The first calculation in a fresh Python session can be slower while kernels compile; subsequent calculations are usually much faster.

System Limits

The cloud GUI limits calculations to roughly 120 basis functions and geometry optimizations to 10 cycles. Local runs can handle much larger systems and longer optimizations depending on memory, CPU/GPU hardware, and basis size.

Recommended Settings

Use sto-3g with small molecules for quick tests. Use 6-31G, cc-pvDZ, def2-SVP, or def2-TZVP locally for larger or more accurate calculations.

Example Molecules

The GUI includes these preconfigured molecules:

Molecule Atoms Description
Water 3 Quick test system
Acetone 10 Carbonyl-containing molecule
Tetrahydrofuran 13 Cyclic ether
Pyrrole 10 Aromatic heterocycle
Dimethyl ether 9 Ether
Benzene 12 Aromatic ring
Carbon dioxide 3 Linear molecule
Hydrogen peroxide 4 Peroxide linkage
Formic acid 5 Small carboxylic acid
Hydrogen sulfide 3 Sulfur analogue of water
AgCl 2 Silver chloride diatomic
AuCl 2 Gold chloride diatomic
Cd dimer 2 Cadmium dimer

Custom XYZ input is also supported.

Performance Highlights

CPU Performance

PyFock uses Numba, NumPy, NumExpr, SciPy, and Joblib to achieve efficient pure-Python DFT calculations, with near-quadratic scaling for density-fitted Coulomb terms and strong multicore CPU support.

GPU Acceleration

PyFock supports CUDA acceleration through CuPy and Numba. Current project materials report up to 24x speedup on an A100 GPU versus a 4-core CPU, with single-GPU calculations demonstrated for systems with thousands of basis functions.

Technical Details

Supported Methods

  • RHF/RIHF through the HF functional option
  • Kohn-Sham DFT with density fitting
  • DIIS-accelerated SCF
  • CAO and SAO basis representations
  • Optional PySCF energy comparison

Basis Sets

sto-3g, sto-6g, 3-21G, 4-31G, 6-31G, 6-31+G, 6-31++G, cc-pvDZ, def2-SVP, def2-TZVP

The default auxiliary basis in the GUI is def2-universal-jfit.

Technology Stack

Backend powered by PyFock. Frontend built with Streamlit. Molecular visualization uses py3Dmol. Optional energy comparison uses PySCF. Structure parsing uses ASE.

Documentation

PyFock Documentation: https://pyfock-docs.bragitoff.com
PyFock GitHub: https://github.com/manassharma07/PyFock
PyPI Package: https://pypi.org/project/pyfock/

Contributing

Contributions are welcome. Please submit a pull request or open an issue to discuss major changes.

Citation

If you use PyFock or PyFock GUI in your research, please cite:

@article{sharma2026pyfock,
  title        = {PyFock: A Just-In-Time Compiled Gaussian Basis DFT Python Code for CPU and GPU Architectures},
  author       = {Sharma, Manas and Sierka, Marek},
  journal = {The Journal of Physical Chemistry A},
  year = {2026},
  month = {08},
  issn = {1089-5639},
  doi = {10.1021/acs.jpca.6c03727},
  url = {https://doi.org/10.1021/acs.jpca.6c03727},
  eprint = {https://pubs.acs.org/jpcafh/article-pdf/doi/10.1021/acs.jpca.6c03727/67108190/acs.jpca.6c03727.pdf},
}

Author

Manas Sharma Website: manas.bragitoff.com LinkedIn: manassharma07 Contact: Via GitHub issues

Support

If you find this project useful:

  • Star the PyFock repository
  • Star this PyFock GUI repository
  • Share with colleagues and students
  • Report bugs and request features

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

Thanks to the PyFock development team, Streamlit community, PySCF developers, and all contributors and users.


Made with care by PhysWhiz

Pure Python - Numba JIT - GPU Ready

Try Now | Documentation | Issues

About

A streamlit web application for running PyFock interactively on the web or your own PC.

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages