Density Functional Theory

Version 1.1.5 (3.07 MB) by Temo Vekua
Fundamentals and Applications of Density Functional Theory with Interactive Live Scripts and Intuitive Codes
Updated 11 Apr 2024

Density Functional Theory

Fundamentals and Applications of Density Functional Theory with interactive live scripts and intuitive codes. Curriculum Module created in collaboration with Xin Jing, Graduate Research Assistant at Georgia Institute of Technology.

Fundamentals and Applications of Density Functional Theory

View on File Exchange or Open in MATLAB Online

Curriculum Module

Created with R2023a. Compatible with R2020b and later releases.


This curriculum module contains interactive MATLAB® live scripts that teach the fundamental concepts in density functional theory, show how to develop numerical solvers for orbital-free and Kohn-Sham implementations of DFT and highlight the usage of two MATLAB-based DFT toolboxes.


You can use these live scripts to teach an introduction to density functional theory, or learn basics of DFT, an inherently computational topic. The first few live scripts review the fundamentals of single-particle quantum mechanics and highlight usage of symbolic computations. Then Hartree and Hartree-Fock variational methods are introduced and simple numerical codes are provided for calculating the ground state energy of helium atom. Next, we present the Thomas-Fermi model of an atom, introducing the key notion of the energy functional of electron density. Density functional theory and its orbital-free and Kohn-Sham implementations are covered in the later live scrips. Numerical implementations of OFDFT and KS-DFT are provided for systems with spherically symmetric ground state electron densities.

The instructions inside the live scripts will guide you through the exercises. Get started with each live script by running it one section at a time. To stop running the script or a section midway, use the Stop button in the RUN section of the Live Editor tab in the MATLAB Toolstrip.

Contact Us

Hints to solutions for challenging exercises are provided after such exercises. The solutions to two exercises: one for the numerical implementation of Kohn-Sham method including orbitals with nonzero angular momentum and another for solving OFDFT as an eigen problem for effective hamiltonian, are provided as separate live scripts. Contact the MathWorks teaching resources team if you would like to provide feedback, or if you have a question.


This module assumes knowledge of quantum mechanics fundamentals and basic to moderate MATLAB knowledge.

Getting Started

Accessing the Module

On MATLAB Online:

Use the Open in MATLAB Online link to download the module.

On Desktop:

Download all live scripts and 2 .mat files to the same directory. Ensure you have all the required products listed below installed.


MATLAB® and Symbolic Math Toolbox™ are used throughout this module.


  • live script 1: Particle in Box
  • live script 2: Spherically Symmetric Potential
  • live script 3: Gaussian Wave Packet
  • live script 4: Hydrogen Atom
  • live script 5: Hartree Method
  • live script 6: Hartree-Fock Method
  • live script 7: Thomas-Fermi Approximation
  • live script 8: From Many-Body Wave Function Description to Density Functional Theory
  • live script 9: Orbital-Free DFT
  • live script 10: Kohn-Sham DFT
  • live script 11: Applications of DFT
  • live script 12: Solution to Exercise 1 in KS-DFT
  • live script 13: Solution to Exercise 7 in Orbital-Free DFT
  • live script 14: Solution to Exercise 3 in Hydrogen Atom - Quantum Harmonic Oscillator in 1, 2, and 3-Dimensions


The license for this module is available in the

Educator Resources


Looking for more? Find an issue? Have a suggestion? Please contact the MathWorks teaching resources team.

© Copyright 2023 The MathWorks, Inc

Cite As

Temo Vekua (2024). Density Functional Theory (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2023b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Physics in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

See release notes for this release on GitHub:


See release notes for this release on GitHub:


See release notes for this release on GitHub:


See release notes for this release on GitHub:

See release notes for this release on GitHub:


To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.