Пример #1
0
    def make_Hessian(self):

        self.run_disps()
        
        h, N = self.h, self.N
        E0 = self.find_E(0,0,0,0)
        self.H = np.zeros((3*self.N, 3*self.N))

        for i in range(3*N):
            for i in range(3*N):
                self.H[i,i]= (self.find_E(i,0,1,0)+self.find_E(i,0,-1,0)-2*E0)/(h**2)
                for j in range(0,i):
                    self.H[i,j] = (self.find_E(i,j,1,1)+self.find_E(i,j,-1,-1)-self.find_E(i,0,1,0)-self.find_E(j,0,1,0)-self.find_E(j,0,-1,0)-self.find_E(i,0,-1,0)+2*E0)
                    self.H[i,j] /= 2*h**2
                    self.H[j,i] = self.H[i,j]


    def write_Hessian(self):
        """
        write Hessian matrix to hessian.dat file
        """
        self.make_Hessian()
        np.savetxt("hessian.dat",self.H,"%15.7f"," ","\n")

if __name__ == "__main__":

    mol = Molecule(open("/Users/avery/git/summer-program/extra-files/molecule.xyz","r").read() )
    mol.bohr()
    hessian = Hessian(mol,"template.dat")
    hessian.write_Hessian()
Пример #2
0
                En = grab_energy(e, directory + '/c{:d}n/output.dat'.format(x))
                hessian[x][y] = (Ep + En - 2 * E0) / (h**2)
            else:  # Second derivative with respect to two different variables
                Epx = grab_energy(e,
                                  directory + '/c{:d}p/output.dat'.format(x))
                Epy = grab_energy(e,
                                  directory + '/c{:d}p/output.dat'.format(y))
                Enx = grab_energy(e,
                                  directory + '/c{:d}n/output.dat'.format(x))
                Eny = grab_energy(e,
                                  directory + '/c{:d}n/output.dat'.format(y))
                Epp = grab_energy(
                    e, directory + '/c{:d}c{:d}p/output.dat'.format(x, y))
                Enn = grab_energy(
                    e, directory + '/c{:d}c{:d}n/output.dat'.format(x, y))
                hessian[x][y] = (Epp + Enn - Epx - Enx - Epy - Eny +
                                 2 * E0) / (2 * h**2)
                hessian[y][x] = hessian[x][y]
    out = open('hessian.dat', 'w')
    out.write(mwrite(hessian))
    out.close()


water = Molecule('../../extra-files/molecule.xyz')
water.bohr()
generate_inputs(water, '../../extra-files/template.dat')
run_jobs(water)
build_hessian(water)
H = Hessian(water, 'hessian.dat')
H.output()
Пример #3
0
     print("Original Energy: ", e)
     print("New Energy:", np.min(np.array(g[1])))
     print()
     i = np.argmin(np.array(g[1]))
     print("New Configuration will be saved in new_molecule.xyz")
     with open("new_molecule.xyz", "w") as f2:
         print(len(g[0][i]), file=f2)
         print(file=f2)
         for p in g[0][i]:
             print(f"C {p[0]} {p[1]} {p[2]}", file=f2)
 with open("new_molecule.xyz") as f2:
     print(
         "Starting to generate Hessian Matrix... This will take some time. Take a break. Have a KitKat...( Approx 17 mins.. Python is kinda slow.)"
     )
     mol = Molecule(f2, "Angstrom")
     mol.bohr()
     hessian = Hessian(mol, 0.00001)
     hessian.write_Hessian()
     print(
         "Q4 Outputs have been written. as eigen_vectors.dat, eigen_values.dat, hessian.dat"
     )
 with open("new_molecule.xyz", "r") as f2:
     print("Starting Q5..")
     mol = Molecule(f2)
     hessian = open("hessian.dat", "r").read()
     freq = Frequencies(mol, hessian)
     freq.frequency_output("modes.xyz")
     print("Modes have been written to modes.xyz")
     print("A histogram for the frequencies have been saved as hist.png")
     print(
         "Kindly look at Report for the output format of these files and what they contain.."
Пример #4
0
    h = disp_size
    hessian = np.zeros((3*len(molecule), 3*len(molecule)))
    E0 = grab_energy(e, directory + '/ref/output.dat')
    for x in range(len(hessian)):
        for y in range(len(hessian))[x:]:
            if x == y:                                                                        # Second derivative with respect to the same variable
                Ep = grab_energy(e, directory + '/c{:d}p/output.dat'.format(x))
                En = grab_energy(e, directory + '/c{:d}n/output.dat'.format(x))
                hessian[x][y] = (Ep + En - 2*E0)/(h**2) 
            else:                                                                             # Second derivative with respect to two different variables
                Epx = grab_energy(e, directory + '/c{:d}p/output.dat'.format(x))
                Epy = grab_energy(e, directory + '/c{:d}p/output.dat'.format(y))
                Enx = grab_energy(e, directory + '/c{:d}n/output.dat'.format(x))
                Eny = grab_energy(e, directory + '/c{:d}n/output.dat'.format(y))
                Epp = grab_energy(e, directory + '/c{:d}c{:d}p/output.dat'.format(x, y))
                Enn = grab_energy(e, directory + '/c{:d}c{:d}n/output.dat'.format(x, y))
                hessian[x][y] = (Epp + Enn - Epx - Enx - Epy - Eny + 2*E0) / (2*h**2)
                hessian[y][x] = hessian[x][y]
    out = open('hessian.dat', 'w')
    out.write(mwrite(hessian))
    out.close()
    
water = Molecule('../../extra-files/molecule.xyz')
water.bohr()
generate_inputs(water, '../../extra-files/template.dat')
run_jobs(water)
build_hessian(water)
H = Hessian(water, 'hessian.dat')
H.output()

Пример #5
0
#!/usr/bin/python

import sys, numpy as np
sys.path.insert(0, '/Users/avery/git/summer-program/0/aewiens/')
sys.path.insert(0, '/Users/avery/git/summer-program/1/aewiens/')
sys.path.insert(0, '/Users/avery/git/summer-program/2/aewiens/')
sys.path.insert(0, '/Users/avery/git/summer-program/extra-files/')

from molecule import Molecule
from hessian import Hessian
from frequencies import Frequencies

f = open("input.dat", "r").read()
h2o = Molecule(f)
h2o.bohr()

hessian = Hessian(h2o, "template.dat")
hessian.write_Hessian()

hessian = open("hessian.dat", "r").read()
freq = Frequencies(h2o, hessian)
freq.frequency_output("modes.xyz")
Пример #6
0
#!/usr/bin/python

import sys
sys.path.append("/Users/avery/git/summer-program/extra-files/")
sys.path.insert(0,'/Users/avery/git/summer-program/0/aewiens/')
sys.path.insert(0,'/Users/avery/git/summer-program/1/aewiens/')
sys.path.insert(0,'/Users/avery/git/summer-program/2/aewiens/')
from molecule import Molecule
from hessian import Hessian
from frequencies import Frequencies

f  = open("input.dat","r").read()
h2 = Molecule(f)
h2.bohr() 

hessian = Hessian(h2,"template.dat")
#hessian.write_Hessian() 

hessian = open("hessian.dat","r").read()
freq    = Frequencies(h2,hessian)
freq.frequency_output("modes.xyz")