{"id":44664281,"url":"https://github.com/ifilot/pypwdft","last_synced_at":"2026-02-15T00:15:00.070Z","repository":{"id":257805558,"uuid":"865523703","full_name":"ifilot/pypwdft","owner":"ifilot","description":"Python-based plane wave density functional theory code for educational purposes","archived":false,"fork":false,"pushed_at":"2025-03-17T07:47:09.000Z","size":11675,"stargazers_count":30,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T18:01:47.578Z","etag":null,"topics":["density-functional-theory","dft","electronic-structure","planewave-basis"],"latest_commit_sha":null,"homepage":"https://ifilot.github.io/pypwdft/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ifilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-30T17:10:27.000Z","updated_at":"2025-07-09T06:29:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2de111e-ec60-4fb7-a4c7-264ed9c98cac","html_url":"https://github.com/ifilot/pypwdft","commit_stats":null,"previous_names":["ifilot/pypwdft"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ifilot/pypwdft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifilot%2Fpypwdft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifilot%2Fpypwdft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifilot%2Fpypwdft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifilot%2Fpypwdft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ifilot","download_url":"https://codeload.github.com/ifilot/pypwdft/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ifilot%2Fpypwdft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29461560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T22:42:09.113Z","status":"ssl_error","status_checked_at":"2026-02-14T22:42:05.053Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["density-functional-theory","dft","electronic-structure","planewave-basis"],"created_at":"2026-02-15T00:14:56.355Z","updated_at":"2026-02-15T00:15:00.062Z","avatar_url":"https://github.com/ifilot.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyPWDFT\n[![build](https://github.com/ifilot/pypwdft/actions/workflows/build_pypi.yml/badge.svg)](https://github.com/ifilot/pypwdft/actions/workflows/build_pypi.yml)\n[![build](https://github.com/ifilot/pypwdft/actions/workflows/build_conda.yml/badge.svg)](https://github.com/ifilot/pypwdft/actions/workflows/build_conda.yml)\n[![Anaconda-Server Badge](https://anaconda.org/ifilot/pypwdft/badges/version.svg)](https://anaconda.org/ifilot/pypwdft)\n[![PyPI](https://img.shields.io/pypi/v/pypwdft?color=green)](https://pypi.org/project/pypwdft/)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n## Purpose\nPlane wave DFT electronic solver for educational purposes.\n\n\u003e [!IMPORTANT]  \n\u003e It has come to my attention that my code shares the same name as the one presented in the recent publication\n\u003e by [Yang et al](https://pubs.acs.org/doi/10.1021/acs.jctc.4c01605). Unbeknownst to the authors of the paper and me,\n\u003e we independently opted for the same name. I would like to clarify that my code was developed\n\u003e entirely independently and has **no affiliation** with this publication. Moreover, my code predates the submission\n\u003e of the paper by approximately one month and the publication itself by about six months.\n\n## Properties\n\n* Plane wave basis set\n* **No** pseudopotential implementation\n* Slater exchange functional\n* Vosko-Wilk-Nusair correlation functional (VWN5)\n* Dualism: the same basis set is used to describe both the molecular orbitals\n  as well as the electron density.\n* Option to specify FFT module (NumPy, SciPy or pyFFTW)\n\n## Dependencies\n\n`PyPWDFT` depends on the following modules:\n\n* [NumPy](https://numpy.org/)\n* [Scipy](https://scipy.org/)\n* [pyFFTW](https://pyfftw.readthedocs.io/)\n\n## Example calculation\n\nThe script below shows an example calculation for the methane molecule placed in\na cubic unit cell with edge sizes of 10 Bohr. First, a `PeriodicSystem` object\nis created that contains the dimensions of the cubic unit cell and the number of\nsampling points per Cartesian direction. The atoms are placed inside the unit\ncell. They are entered in Cartesian coordinates and are expected to lie within\nthe unit cell. Note that `PyPWDFT` uses [atomic units ](https://en.wikipedia.org/wiki/Atomic_units)\nthroughout the code. This means that all distances are in Bohr units and\nall energies are in Hartrees.\n\nNext, a `PyPWDFT` calculator object is constructed. The `PeriodicSystem` object\nis supplied as input. During initialization of the `PyPWDFT` calculator object,\nthe user can also chose the preferred type of FFT algorithm. `PyPWDFT` can use\nNumPy FFT, Scipy FFT or PyPWDFT. Benchmark studies show that the latter is the\nmost efficient algorithm, which is therefore also the default choice if nothing\nis specified by the user.\n\nTo start the self-consistent field procedure, the `SCF()` method of the\ncalculator object is executed. This method takes as input the criterion for\nelectronic convergence (`tolerance`) and whether verbose output is requested.\nUsing verbose output, the total electronic energy and computation time per\nelectronic step in the SCF procedure is printed.\n\n```python\n# import the required libraries for the test\nfrom pypwdft import PyPWDFT, PeriodicSystem, MoleculeBuilder\nimport numpy as np\n\ndef main():\n    # create cubic periodic system with lattice size of 10 Bohr\n    npts = 16   # number of grid points\n    sz = 10\n    # construct CH4 molecule system via SystemBuilder\n    s = SystemBuilder().from_name('CH4', sz=sz, npts=npts)\n        \n    # construct calculator object\n    calculator = PyPWDFT(s)\n    \n    # perform self-consistent field procedure and store results in res object\n    res = calculator.scf(tol=1e-1, verbose=True)\n\nif __name__ == '__main__':\n    main()\n```\n\nThis calculation gives the output as shown below. Note that this calculation\nuses a fairly small number of plane waves (only 4096) and a loose tolerance.\nThis has the benefit that the computation time is rather short, yet the final\nelectronic energy is quite far off from the expected value for a LDA/DFT\ncalculation of methane. Nevertheless, qualitatively decent molecular orbital\nshapes are found.\n\n```\n001 | Etot =  10.70148118 Ht | eps = 1.0701e+01 | dt = 0.0505 s\n002 | Etot =  -8.01768059 Ht | eps = 1.8719e+01 | dt = 0.0381 s\n003 | Etot = -19.73474499 Ht | eps = 1.1717e+01 | dt = 0.0488 s\n004 | Etot = -25.38933285 Ht | eps = 5.6546e+00 | dt = 0.0586 s\n005 | Etot = -28.06387148 Ht | eps = 2.6745e+00 | dt = 0.0632 s\n006 | Etot = -29.47265035 Ht | eps = 1.4088e+00 | dt = 0.0693 s\n007 | Etot = -30.27492437 Ht | eps = 8.0227e-01 | dt = 0.0706 s\n008 | Etot = -30.75674641 Ht | eps = 4.8182e-01 | dt = 0.0756 s\n009 | Etot = -31.05689472 Ht | eps = 3.0015e-01 | dt = 0.0743 s\n010 | Etot = -31.24824460 Ht | eps = 1.9135e-01 | dt = 0.0773 s\n011 | Etot = -31.37191520 Ht | eps = 1.2367e-01 | dt = 0.0789 s\n012 | Etot = -31.45248517 Ht | eps = 8.0570e-02 | dt = 0.0751 s\n```\n\n## Example results\n\nOccupied molecular orbitals of CH4 (10x10x10 A cell, 16 grid points, 1e-1 tolerance)\n![Occupied molecular orbitals of CH4](img/orbs_ch4.png)\n\nValence molecular orbitals of CO (10x10x10 A cell, 32 grid points, 1e-4 tolerance)\n![Valence molecular orbitals of CO](img/orbs_co.png)\n\n## Computational details\n\nIn contrast to localized orbital DFT, the basis functions in plane wave DFT are\nnot 'spawned' by the atoms but by the unit cell. The number of plane waves is\ndetermined by the number of sampling points. `PyPWDFT` uses cubic unit cells and\na fixed number of grid points per Cartesian direction. To get a proper\ndescription (expansion) of the electron density and of the atomic orbitals, the\nplane wave basis set needs to be relatively large. In comparison to localized\norbital DFT, many more basis functions are needed and plane wave basis set host\nthousands (if not more) of basis functions. For this reason, the Hamiltonian\nmatrix in the electronic structure problem is not solved in full, but only the\npart corresponding to its lowest eigenvalues (the occupied molecular orbitals)\nis solved. In `PyPWDFT`, the Implicitly Restarted Arnoldi Method as implemented\nin the [eigs function of Scipy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.eigs.html)\nis used for this purpose.\n\nConventional plane wave DFT calculations use a so-called frozen core\napproximation wherein the core electrons are not explicitly calculated but are\nrepresented by a pseudopotential. As the core electrons do not participate in\nchemical bonding, their wave function varies little by the chemical environment\nof the nuclei and one could therefore keep them fixed. `PyPWDFT` does not use\nsuch pseudopotentials and explicitly calculates the core electrons.\nUnfortunately, the core electrons require a large amount of plane waves for an\naccurate description. As such, if one requires an accurate calculation using\n`PyPWDFT`, a very large basis set is required which will result in lengthy\ncalculations.\n\n## Scaling properties\n\nBecause `PyPWDFT` is a Python-based program, it will be (significantly) slower\nthan commercial PW-DFT packages which use compiled languages such as C++ and/or\nFORTRAN. To assess the efficiency and scaling properties of `PyPWDFT`, consider\nthe methane molecule inside a 10x10x10 Bohr unit cell as a probe system.\nIn the graph below, the total energy and computation time as function of the\nnumber of grid points per Cartesian direction is shown.\n\n![Scaling of computation as function of number of grid points](img/scaling_ch4.png)\n\n## Other interesting codes\n\n* The [SimpleDFT](https://gitlab.com/wangenau/simpledft) code of Wanja Schulze\n  is another Python-based plane wave DFT code. In contrast to `PyPWDFT`,\n  `SimpleDFT` uses a steepest descent method. Furthermore, `PyPWDFT` is built\n  upon the rather elegant alternative \n  [algebraic formulation of Thomas Arias](https://arxiv.org/abs/cond-mat/9909130).\n* [PyDFT](https://github.com/ifilot/pydft) is a localized orbital DFT code\n  written in Python.\n* [PyQInt](https://github.com/ifilot/pyqint) is a Hartree-Fock based electronic\n  structure code, also written in Python.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifilot%2Fpypwdft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fifilot%2Fpypwdft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifilot%2Fpypwdft/lists"}