Skip to main content

PyDFT

build codecov PyPI License: GPL v3

Purpose

PyDFT is a pure-Python package for performing localized-orbital Density Functional Theory (DFT) calculations using Gaussian Type Orbitals. It implements restricted Kohn-Sham DFT for closed-shell molecules and currently supports the LDA and PBE exchange-correlation functionals.

The goal of PyDFT is not to be the fastest DFT code, but to be the most transparent one. It is designed first and foremost as an educational tool that reveals how a DFT calculation is actually assembled, from numerical grids and electron densities to potentials, matrix elements, and the self-consistent field procedure. Every intermediate quantity is exposed to the user and can be inspected, plotted, or modified, and considerable effort was put into documenting the code. PyDFT is not intended for professional calculations and does not offer the speed or breadth of features of mature open-source or commercial packages; what it offers instead is a clear, modifiable view into a working DFT code.

The figure below gives a high-level overview of a complete PyDFT calculation: from molecular input and dependencies, through construction of the Becke grid and one-electron matrices, to the Kohn-Sham SCF iteration and the wide range of quantities exposed for inspection.

Overview of the PyDFT workflow

Features

The sections below highlight a few of the capabilities that make PyDFT useful as a teaching and exploration tool.

Numerical integration using Becke grids

Electron-electron interaction terms (both classical as well as exchange-correlation) are performed by means of extensive numerical integration schemes performed over so-called Becke grids. Utilizing these grids, molecular integrals are decomposed into series of weighted atomic integrals.

Becke grids

Molecular orbital visualization

PyDFT can be readily used alongside matplotlib to make figures of molecular orbitals or density fields.

Molecular orbitals of CO

Extensive output

Internal matrices, e.g. overlap or Hamiltonian matrix, are exposed to the user and can be readily visualized using specific matrix visualization routines.

Matrices

Tunable numerical settings

Numerical choices that are usually hidden behind defaults in production codes, such as the radial and angular resolution of the grid, the spherical-harmonic expansion used for the Hartree potential, the exchange-correlation functional, and the SCF convergence criteria, are all exposed directly. This makes it straightforward to study how each setting affects accuracy, stability, and computational cost.

Installation

PyDFT supports Python 3.10 and newer.

To install PyDFT and its core runtime dependencies, run

pip install pydft

The plotting and example scripts use optional visualization dependencies:

pip install "pydft[plot]"

To install the dependencies used by the example scripts, including isosurface support, run

pip install "pydft[examples]"

Usage

Check the current version

import pydft
print(pydft.__version__)

Performing a simple calculation

from pydft import MoleculeBuilder, DFT

CO = MoleculeBuilder().get_molecule("CO")
dft = DFT(CO, basis='sto3g')
res = dft.scf(1e-4)
print("Total electronic energy: %f Ht" % res['energy'])

Community guidelines

License

Unless otherwise stated, all code in this repository is provided under the GNU General Public License version 3.

Metadata

Release files for pydft 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydft 1.1.0
File Size Uploaded Provenance Actions
pydft-1.1.0.tar.gz 60.6 kB With provenance Details for pydft-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydft 1.1.0
File Interpreter ABI Platform Actions
pydft-1.1.0-py3-none-any.whl Python 3 none any Details for pydft-1.1.0-py3-none-any.whl

Total release size: 111.3 kB

Release files / pydft-1.1.0.tar.gz

Download URL pydft-1.1.0.tar.gz
Size 60.6 kB
Tags Source
SHA-256 checksum
How to use checksums
65a506d0ce4a577f263bd246bf0485c7bc1095d528db11ea5ed693695ad577b9
BLAKE2b-256 checksum
How to use checksums
950190db5da3811f68cd0b88afcc45fdeb49b42b5d36b12f7c74ea62ebdbdf53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / pydft-1.1.0-py3-none-any.whl

Download URL pydft-1.1.0-py3-none-any.whl
Size 50.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03883810b5e8411219524b6849de43ae4cdf4c9cb1bb3cb1bc0b55e317d93ff4
BLAKE2b-256 checksum
How to use checksums
915622ca2471e2c26bd900562f3d61bd1f4ed2d685c860030ac86ac8226e7956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for pydft 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydft-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page