File size: 8,171 Bytes
447a6c8
5b6877c
 
447a6c8
 
 
 
 
 
 
5b6877c
447a6c8
 
5b6877c
447a6c8
e8f5144
5b6877c
e8f5144
5b6877c
 
 
 
e8f5144
5b6877c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
title: PyFock GUI
emoji: 
colorFrom: red
colorTo: red
sdk: docker
app_port: 8501
tags:
- streamlit
pinned: true
short_description: A web-based GUI application for running PyFock interactively 
license: mit
thumbnail: >-
  https://cdn-uploads.huggingface.co/production/uploads/639e2fd4f87da5e2eb198210/PwAxx1kYEqaiV1Dd0XbAG.png
---

# PyFock GUI - Interactive DFT Calculations in Your Browser

[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://pyfock.streamlit.app)
[![Python](https://img.shields.io/badge/Python-3.8%2B-blue.svg)](https://www.python.org/)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
[![PyFock](https://img.shields.io/badge/PyFock-Latest-orange.svg)](https://github.com/manassharma07/PyFock)

A modern, interactive web interface for [PyFock](https://github.com/manassharma07/PyFock) - a pure Python DFT code with Numba JIT acceleration and performance matching C++ implementations.

![PyFock GUI Banner](https://raw.githubusercontent.com/manassharma07/PyFock/main/logo_crysx_pyfock.png)

## Live Demo

Try PyFock GUI instantly without any installation:

- Primary: [https://pyfock.streamlit.app](https://pyfock.streamlit.app)
- Alternative: [https://pyfock-gui.bragitoff.com](https://pyfock-gui.bragitoff.com)
- HuggingFace: [https://manassharma07-pyfock-gui.hf.space/](https://manassharma07-pyfock-gui.hf.space/)

## Features

### Computational Capabilities
Pure Python DFT calculations with performance matching C++ codes. Supports multiple XC functionals (LDA, PBE, BLYP, BP86) and flexible basis sets (STO-3G, 6-31G, cc-pVDZ, def2-SVP, def2-TZVP). Includes density fitting for efficiency and optional PySCF comparison for validation.

### Visualization
Interactive 3D structure viewer with customizable styles. Real-time HOMO/LUMO visualization with adjustable isosurfaces. Electron density maps and exploration of any molecular orbital.

### Input/Output
15+ example molecules included (water, benzene, acetone, pyrrole, THF). Custom XYZ input supported. Downloadable cube files for HOMO, LUMO, and density. Python script generation for reproducible calculations with detailed convergence logs.

### Key Advantages
100% Pure Python including molecular integrals. Numba JIT acceleration for near-C++ performance. GPU support via CuPy. Near-quadratic scaling (~O(N²·⁰⁵)). High accuracy matching PySCF (<10⁻⁷ Ha). Cross-platform compatibility. Easy pip installation.

## Quick Start

### Option 1: Use Online (Recommended)
Simply visit any of the live demo URLs above - no installation required.

### Option 2: Run Locally

Clone the repository:
```bash
git clone https://github.com/manassharma07/pyfock-gui.git
cd pyfock-gui
```

Install dependencies:
```bash
# Install LibXC (required by PyFock)
# For Python < 3.10:
sudo apt-get install libxc-dev     # Ubuntu/Debian
pip install pylibxc2

# For Python >= 3.10 (recommended):
conda install -c conda-forge pylibxc -y

# Install PyFock and dependencies
pip install pyfock streamlit py3Dmol pyscf ase pandas

# Optional: GPU support
pip install cupy-cuda12x   # adjust for your CUDA version
```

Run the app:
```bash
streamlit run app.py
```

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

## Usage Guide

### Basic Workflow

Select a molecule from 15+ examples or paste your own XYZ coordinates. Configure calculation parameters: basis set, XC functional, convergence criteria, and optionally enable PySCF comparison. Adjust visualization settings including cube file resolution, isovalue, and opacity. Run the calculation and monitor progress through status updates. Explore results including energy components, HOMO-LUMO gap, orbital energies, and interactive 3D visualizations. Download cube files and generated Python scripts.

### Example Calculation

```python
# The GUI generates ready-to-run Python scripts
# Example for water molecule with PBE/sto-3g

from pyfock import Basis, Mol, DFT, Utils

# Initialize molecule
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')})

# Run DFT
dftObj = DFT(mol, basis, auxbasis, xc=[101, 130])  # PBE
energy, dmat = dftObj.scf()

# Generate cube files
Utils.write_orbital_cube(mol, basis, dftObj.mo_coefficients[:, homo_idx], 'HOMO.cube')
```

## Important Notes

### JIT Compilation
PyFock uses Numba JIT compilation for acceleration. The **first calculation will be slower** as functions are compiled. **Subsequent runs will be significantly faster** - this is expected behavior and a key advantage of JIT compilation.

### System Limits
Cloud version is limited to ~120 basis functions due to computational constraints. Local version can handle much larger systems (~10,000 basis functions). For large molecules, use smaller basis sets (sto-3g) or run locally.

### Recommended Settings
Quick tests: sto-3g basis with small molecules (water, benzene). Production runs: 6-31G or def2-SVP basis. High accuracy: cc-pVDZ or def2-TZVP basis (use locally for large systems).

## Example Molecules

The GUI includes 15+ pre-configured molecules:

| Molecule | Atoms | Description |
|----------|-------|-------------|
| Water | 3 | Quick test system |
| Benzene | 12 | Aromatic ring |
| Acetone | 10 | Carbonyl group |
| Pyrrole | 10 | Heterocycle |
| THF | 13 | Cyclic ether |
| CO₂ | 3 | Linear molecule |
| H₂O₂ | 4 | Peroxide linkage |

## Performance Highlights

### CPU Performance
Up to 2× faster than PySCF with strong scaling up to 32 cores. Near-quadratic scaling (~O(N²·⁰⁵)) with basis functions.

### GPU Acceleration
Up to 14× speedup vs 4-core CPU. Single A100 GPU handles 4000+ basis functions. Consumer GPUs (RTX series) supported.

## Technical Details

### Supported Methods
Kohn-Sham density functional theory with density fitting (resolution of identity approximation) and DIIS-accelerated SCF convergence.

### XC Functionals
LDA: SVWN5 (Slater + VWN5 correlation)  
GGA: PBE, BLYP, BP86

### Basis Sets
STO-3G, STO-6G, 3-21G, 4-31G, 6-31G, 6-31+G, 6-31++G, cc-pVDZ, def2-SVP, def2-TZVP

## Technology Stack

Backend powered by [PyFock](https://github.com/manassharma07/PyFock) for pure Python DFT calculations. Frontend built with [Streamlit](https://streamlit.io/). Visualization using [py3Dmol](https://3dmol.csb.pitt.edu/). Optional comparison with [PySCF](https://pyscf.org/). Structure handling via [ASE](https://wiki.fysik.dtu.dk/ase/).

## Documentation

PyFock Documentation: [https://pyfock-docs.bragitoff.com](https://pyfock-docs.bragitoff.com)  
PyFock GitHub: [https://github.com/manassharma07/PyFock](https://github.com/manassharma07/PyFock)  
PyPI Package: [https://pypi.org/project/pyfock/](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:

```bibtex
@software{pyfock2024,
  author = {Sharma, Manas},
  title = {PyFock: Pure Python DFT with Numba Acceleration},
  year = {2024},
  url = {https://github.com/manassharma07/PyFock}
}
```

Paper coming soon on arXiv.

## Author

**Manas Sharma**  
Website: [bragitoff.com](https://bragitoff.com)  
LinkedIn: [manassharma07](https://www.linkedin.com/in/manassharma07)  
Contact: Via GitHub issues

## Support

If you find this project useful:
- Star the [PyFock](https://github.com/manassharma07/PyFock) repository
- Star this [PyFock GUI](https://github.com/manassharma07/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](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](https://pyfock.streamlit.app) | [Documentation](https://pyfock-docs.bragitoff.com) | [Issues](https://github.com/manassharma07/pyfock-gui/issues)