Giter Site home page Giter Site logo

ajmisquitta / mcmurchie-davidson Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jjgoings/mcmurchie-davidson

0.0 0.0 0.0 1.76 MB

do a simple closed shell Hartree-Fock using McMurchie-Davidson to compute integrals

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

mcmurchie-davidson's Introduction

Build Status codecov Total alerts Language grade: Python

McMurchie-Davidson

This contains some simple routines to compute one and two electron integrals necessary for Hartree Fock calculations using the McMurchie-Davidson algorithm. The Hartree-Fock code can only handle closed shell molecules at the moment. It's not fast (though getting faster with Cython interface), but should be somewhat readable.

I'm slowly porting the integrals over to Cython and reoptimizing. I'm also thinking about reorganizing so as to make it easy to add functionality in the future.

Installation

Installation should be simple. For a local install, just

python setup.py build_ext --inplace install --user

Dependencies

You'll need numpy, scipy, and cython (for the integrals). Some post-SCF functionality requires bitstring, in order to handle the bitstring/integer representations for Slater determinants and to allow for the evaluation of Slater-Condon rules between arbitrary determinants. The install script should yell at you if you don't have the requisite dependencies. You can install them all at once if you have pip:

pip install numpy scipy cython bitstring

Testing

You can test the install with nosetests. In the head directory, just do

nosetests tests

it should take a few seconds, but everything should pass.

Running

Once you've installed, you can try running the input script sample-input.py:

python sample-input.py

which should do an SCF on water with an STO-3G basis and dump out to your terminal:

E(SCF)    =  -74.942079928060 in 10 iterations
  Convergence:
    FPS-SPF  =  3.377372360032819e-13
    RMS(P)   =  2.35e-12
    dE(SCF)  =  -9.95e-10
  Dipole X =  0.00000000
  Dipole Y =  1.53400931
  Dipole Z =  -0.00000000
E(MP2) =  -74.99122956422062

Input file specification

The input is fairly straightforward. Here is a minimal example using water.

from mmd.molecule import *
from mmd.scf import *

water = """
0 1
O    0.000000      -0.075791844    0.000000
H    0.866811829    0.601435779    0.000000
H   -0.866811829    0.601435779    0.000000
"""

# init molecule and build integrals
mol = Molecule(geometry=water,basis='sto-3g')

# do the SCF
mol.RHF()

The first lines import the molecule and scf modules, which we need to specify our molecule and the SCF routines. The molecular geometry follows afterward and is specified by the stuff in triple quotes. The first line is charge and multiplicity, followed by each atom and its Cartesian coordinates (in Angstrom).

water = """
0 1
O    0.000000      -0.075791844    0.000000
H    0.866811829    0.601435779    0.000000
H   -0.866811829    0.601435779    0.000000
"""

Then we generate create the molecule (Molecule object) and build the integrals, and finish by running the SCF.

At any point you can inspect the molecule. For example, you can dump out the (full) integral arrays:

print(mol.S)

which dumps out the overlap matrix:

[[ 1.     0.237  0.     0.     0.     0.038  0.038]
 [ 0.237  1.     0.     0.     0.     0.386  0.386]
 [ 0.     0.     1.     0.     0.     0.268 -0.268]
 [ 0.     0.     0.     1.     0.     0.21   0.21 ]
 [ 0.     0.     0.     0.     1.     0.     0.   ]
 [ 0.038  0.386  0.268  0.21   0.     1.     0.182]
 [ 0.038  0.386 -0.268  0.21   0.     0.182  1.   ]]

There is also some limited post-SCF functionality, hopefully more useful as a template for adding later post-SCF methods.

# do MP2
mp2 = PostSCF(mol)
mp2.MP2()

Examples

In the examples folder you can find some different scripts for setting up more complex jobs. For example, there is a simple script that does Born-Oppenheimer molecular dynamics on minimal basis hydrogen, aptly titled bomd.py. There are some real-time electronic dynamics in real-time.py. It's a good idea to check out the tests folder. In particular, tests/README.md contains an index to the different tests used, which gives some insight into the current functionality.

mcmurchie-davidson's People

Contributors

jjgoings avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.