forked from ZhaoYilin/polar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
51 lines (40 loc) · 1.52 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import sympy as sp
from horton import (context, IOData, get_gobasis,
CholeskyLinalgFactory, guess_core_hamiltonian,
compute_nucnuc, RTwoIndexTerm, RDirectTerm,
RExchangeTerm, REffHam, AufbauOccModel)
from polar.data_generate import model_finitefield_ham
# Hartree-Fock calculation
# ------------------------
# Load the coordinates from file.
# Use the XYZ file from HORTON's test data directory.
fn_xyz = context.get_fn('test/water.xyz')
mol = IOData.from_file(fn_xyz)
# Create a Gaussian basis set
obasis = get_gobasis(mol.coordinates, mol.numbers, 'sto-3g')
lf = CholeskyLinalgFactory(obasis.nbasis)
# Create a linalg factory
# Compute Gaussian integrals
olp = obasis.compute_overlap(lf)
kin = obasis.compute_kinetic(lf)
na = obasis.compute_nuclear_attraction(mol.coordinates, mol.pseudo_numbers, lf)
er = obasis.compute_electron_repulsion(lf)
# Create alpha orbitals
orb = lf.create_expansion()
# Initial guess
guess_core_hamiltonian(olp, kin, na, orb)
# Construct the restricted HF effective Hamiltonian
external = {'nn': compute_nucnuc(mol.coordinates, mol.pseudo_numbers)}
terms = [
RTwoIndexTerm(kin, 'kin'),
RDirectTerm(er, 'hartree'),
RExchangeTerm(er, 'x_hf'),
RTwoIndexTerm(na, 'ne'),
]
ham = REffHam(terms, external)
# Decide how to occupy the orbitals (5 alpha electrons)
occ_model = AufbauOccModel(5)
print(model_finitefield_ham(ham, lf, obasis, olp, orb, occ_model, mol, [2], 2))