A complete containerized environment for quantum chemistry calculations using PySCF, demonstrating reproducible computational workflows across platforms.
By the end of this module, students will:
- Explain why containers matter for computational reproducibility in quantum chemistry
- Build and run a Docker image that executes PySCF jobs deterministically
- Compare HF, MP2, and DFT methods on accuracy vs. cost trade-offs
- Configure SCF/geometry convergence and basis set options appropriately
- Deploy containerized calculations to GitHub Container Registry (GHCR)
Required Setup:
- Docker Desktop/Engine with
docker composev2 - GitHub Personal Access Token with
write:packagesscope - Basic command line familiarity
Quick Verification:
docker --version
docker compose version
docker run hello-worldgit clone <repository-url>
cd Week_2
docker compose build pyscf# B3LYP geometry optimization of water
docker compose run --rm pyscf scripts/optimize_water.py
# Check results
cat results/water_opt.xyz# Hartree-Fock calculation
docker compose run --rm pyscf scripts/water_hf.py
# DFT calculation
docker compose run --rm pyscf scripts/water_dft.py
# MP2 calculation
docker compose run --rm pyscf scripts/water_mp2.py
# COβ single-point energy
docker compose run --rm pyscf scripts/co2_test.pyweek2/
βββ π³ Dockerfile # Python 3.10 + PySCF environment
βββ π§ docker-compose.yml # Cross-platform bind mounts
βββ π scripts/ # Calculation scripts
β βββ optimize_water.py # B3LYP geometry optimization
β βββ co2_test.py # COβ single-point energy
β βββ water_B3LYP_631Gd.py # B3LYP/6-31G(d) calculation
β βββ water_dft.py # DFT demonstration
β βββ water_hf.py # Hartree-Fock calculation
β βββ water_mp2.py # MP2 correlation energy
βββ π results/ # Output files (.xyz, .txt, .json)
βββ π jobs/ # Batch job artifacts
βββ π docs/ # Platform-specific setup guides
β βββ local_MacOS.md # Apple Silicon setup
β βββ local_Windows.md # Windows 10/11 setup
β βββ local_original.md # Original macOS guide
βββ π resources/
βββ outline.md # Detailed course outline
| Method | Scaling | Accuracy | Use Case |
|---|---|---|---|
| HF | O(Nβ΄) | Baseline | Orbital analysis, teaching |
| DFT | O(NΒ³-Nβ΄) | Good | Geometries, relative energies |
| MP2 | O(Nβ΅) | Better | Small molecules, correlation |
- Quick screening:
def2-SVPbasis,grids.level=3 - Production:
def2-TZVPbasis,conv_tol=1e-9 - High accuracy:
def2-QZVP+ CBS extrapolation
FROM python:3.10-slim
# Pinned versions: numpy==1.26.4, scipy==1.13.1, pyscf==2.4.0
# No embedded scripts - pure bind mount approach
WORKDIR /workspace
ENTRYPOINT ["/usr/local/bin/python"]volumes:
- ./scripts:/workspace/scripts:rw # Live script editing
- ./results:/workspace/results:rw # Persistent outputs
- ./jobs:/workspace/jobs:rw # Batch artifacts# See detailed guide
open docs/local_MacOS.md# See detailed guide
start docs/local_Windows.md# Docker Engine installation
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.shObjective: Containerize COβ single-point calculation and push to GitHub Container Registry
-
Build & Test Locally
docker compose run --rm pyscf scripts/co2_test.py cat results/co2_b3lyp.txt
-
Authenticate to GHCR
echo $CR_PAT | docker login ghcr.io -u <USERNAME> --password-stdin
-
Tag & Push
docker tag week2/pyscf:1.0 ghcr.io/<USERNAME>/pyscf-co2:week2 docker push ghcr.io/<USERNAME>/pyscf-co2:week2
- β Git repository with complete codebase
- β
RUNBOOK.mdwith build/run instructions - β
RESULTS.mdwith energy values and metadata - β GHCR image link with digest hash
# Move to accessible location if bind mounts fail
cp -r /path/to/project /Users/$USER/docker-projects/
cd /Users/$USER/docker-projects/Week_2- macOS/Linux: Python 3.10-3.11 supported
- Windows: Python 3.10 required (pre-built wheels limitation)
# Increase Docker memory allocation
# Docker Desktop β Settings β Resources β Memory: 8GB+- PySCF Documentation: https://pyscf.org/user.html
- Basis Set Exchange: https://www.basissetexchange.org/
- Docker Best Practices: https://docs.docker.com/develop/best-practices/
- Fork the repository
- Create a feature branch (
git checkout -b feature/calculation-type) - Commit changes (
git commit -am 'Add new calculation method') - Push to branch (
git push origin feature/calculation-type) - Create Pull Request
This educational content is available under MIT License. See LICENSE file for details.
π Course: Computational Chemistry
π
Module: Week 2 - Container Workflows
π¨βπ« Instructor: Viwat Vchirawongkwin
π« Institution: Chulalongkorn University