Skip to content

avcopan/electronic-structure-with-python-obsolete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A small collection of python modules for programming electronic structure theories in simple spin-orbital form. Primarily designed to be used with psi4, building on the functionality of psi4numpy. The tensor contraction modules (index and block), permutation module (permutation), and DIIS module (diis) can be used independently. The goal is to allow one to write code that looks as much as possible like the equations to be implemented.

Requires tensorshuffle module.

Spin-orbital codes are not intended for production-level efficiency, but you will see a substantial speed-up if your versions of numpy and scipy make use of an optimized BLAS library (e.g. openblas) since the contractions are wrapped around numpy.tensordot. You can check your BLAS/LAPACK linkage by running python -c 'import numpy; numpy.__config__.show()' in a terminal.

Probably most useful is the index module, which allows one to associate index characters with specific contraction ranges.

from meinsum.index import Index

indx = Index(dim, 'pqrs')
indx.add_index_range(   0, nocc, 'ijkl')
indx.add_index_range(nocc,  dim, 'abcd')

Using this Index object, one can solve for the coupled-cluster doubles (CCD) energy as

t = indx.einsum('ijab', (Ep,"ijab"), (g,"ijab"))

for i in range(maxiter):

  t = Ep * indx.meinsums('ijab',
             [ 1.  , I         , (g,"abij")                        ],
             [ 1./2, I         , (g,"abcd"), (t,"ijcd")            ],
             [ 1./2, I         , (g,"klij"), (t,"klab")            ],
             [ 1.  , P("ij|ab"), (g,"kbcj"), (t,"ikac")            ],
             [ 1./4, I         , (g,"klcd"), (t,"ijcd"), (t,"klab")],
             [ 1.  , P("ij")   , (g,"klcd"), (t,"ikac"), (t,"jlbd")],
             [-1./2, P("ij")   , (g,"klcd"), (t,"ikdc"), (t,"ljab")],
             [-1./2, P("ab")   , (g,"klcd"), (t,"lkac"), (t,"ijdb")])

E = 1./4 * indx.einsum('', (g,"ijab"), (t,"ijab"))

where the P operators are provided by the permutation module. The corresponding equations are

CCD Equations (see Shavitt and Bartlett Many-Body Methods for details). The permutation module supports arbitrary permutations of the form P(i/jk|a/bc...) as defined by Shavitt and Bartlett. This module is especially useful for methods like CCSD(T).

Example codes and input files are provided. These can be run as psi4 input.dat with a recent version of psi4, once this directory has been added to your PYTHONPATH (e.g. export PYTHONPATH=/path/to/meinsum/).

This is primarily intended for my own personal use, but comments and suggestions are welcome.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages