Вы находитесь на странице: 1из 2

#!

/usr/bin/python
import numpy
from scipy.special import erfc
from math import pi
from math import exp
from math import sqrt
#--------------------------------------------------------------------------------# Define some handy functions to tell us the extent of overlap between functions
#--------------------------------------------------------------------------------def exp_gau_overlap(e1,g1):
normalization = (2*g1/pi)**0.75 * (e1**3/pi)**0.5
overlap1 = exp(e1**2/(4*g1))*(pi**1.5)*(e1**2+2*g1)*erfc(0.5*e1/sqrt(g1))/(2*g1**2.5)
overlap2 = -pi*e1/g1**2
s = normalization * (overlap1 + overlap2)
return s
def gau_gau_overlap(g1,g2):
s = (2*g1)**0.75 * (2*g2)**0.75 * (g1+g2)**(-1.5)
return s
#--------------------------------------------------------------------------------# Set values for some variables that will define our final basis set - number
# of basis functions, parameters that control range of Gaussian orbital sizes
#--------------------------------------------------------------------------------alpha = *** choose value ***
beta = *** choose value ***
n_gauss_func = *** choose value ***
slater_exponent = *** choose value ***
e1 = slater_exponent
#--------------------------------------------------------------------------------# Generate even-tempered set of orbital exponents for Gaussian functions
#
zeta = alpha*beta^n n = 1,2,...,n_gauss_funcs
#--------------------------------------------------------------------------------gaussian_exponents = []
for n in range(1,n_gauss_func+1):
*** append the appropriate Gaussian orbital exponent (alpha*beta**n)
to the gaussian_exponents list ***
#--------------------------------------------------------------------------------# Find out how much Gaussian basis functions have in common with one another
# constructing S matrix as we go
#--------------------------------------------------------------------------------S_matrix = []
for i in range(0,n_gauss_func):
S_vec = []
*** load up the ith Gaussian orbital exponent from the
gaussian_exponents list, with name g1 ***
for j in range(0,n_gauss_func):
*** load up the jth Gaussian orbital exponent from the
gaussian_exponents list, with name g2 ***
*** calculate the overlap between orbitals i and j with
exponents g1 and g2, using the gau_gau_overlap function
defined above, saving result as s ***
S_vec.append(s)
S_matrix.append(S_vec)
#--------------------------------------------------------------------------------# Find out how much basis functions have in common with the Slater-type orbital
# Note the trick that each element of the T vector must be appended as a one-element list
#--------------------------------------------------------------------------------T_vec = []
for i in range(0,n_gauss_func):
*** load up the ith Gaussian orbital exponent from the
gaussian_exponents list, with name g1 ***
*** calculate overlap between the target exponential with exponent e1 and
the ith Gaussian orbital with exponent g1, using the exp_gau_overlap
function defined above, saving result as t ***
T_vec.append([t])

#--------------------------------------------------------------------------------# Find coefficients that minimize the square of the difference between
# a linear combination of Gaussian functions and the Slater-type orbital
# First convert the S matrix and T vector to numpy matrices A & B
# Then calculate the coefficient (C) vector, also in numpy matrix format
# Convention: S,T,U = matrices in python's list of lists format
#
A,B,C = equivalent matrices in numpy format
# To convert the C vector from numpy matrix format to a nice list of coefficients,
# use the following:
#
U_vec = numpy.array(C_vec).flatten().tolist()
#--------------------------------------------------------------------------------*** convert S_matrix and T_vec to numpy matrices using numpy.matrix ***
*** solve for the coefficients using numpy.linalg.solve ***
*** convert coefficients from numpy matrix format back to python list format ***
print 'Optimized contraction coefficients:'
print U_vec
#--------------------------------------------------------------------------------# Calculate R^2 (Square of difference between Slater-type orbital and sum of Gaussians)
#--------------------------------------------------------------------------------R2 = 1.0
for i in range(0,n_gauss_func):
g1 = gaussian_exponents[i]
c1 = U_vec[i]
t = exp_gau_overlap(e1,g1)
R2 += -2*c1*t
for j in range(0,n_gauss_func):
g2 = gaussian_exponents[j]
c2 = U_vec[j]
s = gau_gau_overlap(g1,g2)
R2 += c1*c2*s
print 'Residual error:'
print R2

Вам также может понравиться