Skip to main content

pydft

Project description

PyDFT

pipeline status

Python based Density Functional Theory code for educational purposes

Purpose

This repository contains a working density functional code using a localized Gaussian-type basis set and Becke grids for the numerical evaluation of density functionals.

Installation

This code depends on a few other packages. To install this code and its dependencies, run the following one-liner from Anaconda prompt

conda install -c ifilot pydft pyqint pylebedev pytessel

Usage

Performing a simple DFT calculation

from pydft import MoleculeBuilder,DFT

#
# Example: Calculate total electronic energy for CO using standard
#          settings.
#

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

Visualizing the Becke fuzzy grid

from pydft import MoleculeBuilder, MolecularGrid
import numpy as np
import matplotlib.pyplot as plt

#
# Example: Construct the Becke fuzzy grid and visualize the maximum
#          value of the atomic weight coefficients for a given set of
#          grid points.
#

# construct molecule
mol = MoleculeBuilder().get_molecule('benzene')
cgfs, atoms = mol.build_basis('sto3g')

# construct molecular grid
molgrid = MolecularGrid(atoms, cgfs)

# produce grid of sampling points to calculate the atomic
# weight coefficients for
N = 100
sz = 8
x = np.linspace(-sz,sz,N)
xv,yv = np.meshgrid(x,x)
points = np.array([[x,y,0] for x,y in zip(xv.flatten(),yv.flatten())])

# calculate the atomic weights
mweights = molgrid.calculate_weights_at_points(points, k=3)

# plot the atomic weights
plt.imshow(np.max(mweights,axis=0).reshape((N,N)),
           extent=(-sz,sz,-sz,sz))
plt.xlabel('x')
plt.xlabel('y')
plt.colorbar()
plt.tight_layout()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydft-0.2.4.0.tar.gz (46.2 kB view hashes)

Uploaded Source

Built Distribution

pydft-0.2.4.0-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page