Beispiel #1
0
from gpaw.cluster import Cluster
from gpaw.analyse.hirshfeld import HirshfeldDensity, HirshfeldPartitioning
from gpaw.analyse.vdwradii import vdWradii
h = 0.18
box = 4.
xc = 'TS09'
f = paropen('energies_' + xc +'.dat', 'w')
print  >> f, '# h=', h
print  >> f, '# box=', box
print >> f, '# molecule E[1]  E[2]  E[1+2]  E[1]+E[2]-E[1+2]'
for molecule in data:
    print >> f, molecule,
    ss = Cluster(Atoms(data[molecule]['symbols'],
		      data[molecule]['positions']))
    # split the structures
    s1 = ss.find_connected(0)
    s2 = ss.find_connected(-1)
    assert(len(ss) == len(s1) + len(s2))
    if xc == 'TS09' or xc == 'TPSS' or xc == 'M06L':
	c = GPAW(xc='PBE', h=h, nbands=-6, occupations=FermiDirac(width=0.1))
    else:
	c = GPAW(xc=xc, h=h, nbands=-6, occupations=FermiDirac(width=0.1))
    E = []
    for s in [s1, s2, ss]:
	s.set_calculator(c)
	s.minimal_box(box, h=h)
	if xc == 'TS09':
	    s.get_potential_energy()
	    cc = vdWTkatchenko09prl(HirshfeldPartitioning(c),
				    vdWradii(s.get_chemical_symbols(), 'PBE'))
	    s.set_calculator(cc)
Beispiel #2
0
b = [2, 3, 4]
CO.minimal_box(b, h=h)
cc = CO.get_cell()
for c in range(3):
    # print "cc[c,c], cc[c,c] / h % 4 =", cc[c, c], cc[c, c] / h % 4
    for a in CO:
        print(a.symbol, b[c], a.position[c], cc[c, c] - a.position[c])
        assert (a.position[c] > b[c])
    equal(cc[c, c] / h % 4, 0.0, 1e-10)

# connected atoms
assert (len(CO.find_connected(0, 1.1 * R)) == 2)
assert (len(CO.find_connected(0, 0.9 * R)) == 1)

H2O = Cluster(molecule('H2O'))
assert (len(H2O.find_connected(0)) == 3)
assert (len(H2O.find_connected(0, scale=0.9)) == 1)

# I/O
fxyz = 'CO.xyz'
fpdb = 'CO.pdb'

cell = [2., 3., R + 2.]
CO.set_cell(cell, scale_atoms=True)
barrier()
CO.write(fxyz)
barrier()
CO_b = Cluster(filename=fxyz)
assert (len(CO) == len(CO_b))
offdiagonal = CO_b.get_cell().sum() - CO_b.get_cell().diagonal().sum()
assert (offdiagonal == 0.0)
Beispiel #3
0
h = 0.25
box = 3.0

molecule = 'Adenine-thymine_complex_stack'

Energy = {
    'PBE': [],
    'vdW-DF': [],
    'TS09': []}

for molecule in ['Adenine-thymine_complex_stack']:
    ss = Cluster(Atoms(data[molecule]['symbols'],
                       data[molecule]['positions']))

    # split the structures
    s1 = ss.find_connected(0)
    s2 = ss.find_connected(-1)
    assert len(ss) == len(s1) + len(s2)

    c = GPAW(xc='PBE', h=h, nbands=-6,
             occupations=FermiDirac(width=0.1), txt=None)
    cdf = GPAW(xc='vdW-DF', h=h, nbands=-6, occupations=FermiDirac(width=0.1),
               txt=None)

    for s in [s1, s2, ss]:
        s.set_calculator(c)
        s.minimal_box(box, h=h)
        Energy['PBE'].append(s.get_potential_energy())
        cc = vdWTkatchenko09prl(HirshfeldPartitioning(c),
                                vdWradii(s.get_chemical_symbols(), 'PBE'))
        s.set_calculator(cc)
CO.minimal_box(b, h=h)
cc = CO.get_cell() 
for c in range(3):
#    print "cc[c,c], cc[c,c] / h % 4 =", cc[c, c], cc[c, c] / h % 4
    for a in CO:
        print(a.symbol, b[c], a.position[c], cc[c, c] - a.position[c])
        assert(a.position[c] > b[c])
    equal(cc[c, c] / h % 4, 0.0, 1e-10)

# .............................................
# connected atoms
assert(len(CO.find_connected(0, 1.1 * R)) == 2)
assert(len(CO.find_connected(0, 0.9 * R)) == 1)

H2O = Cluster(molecule('H2O'))
assert (len(H2O.find_connected(0)) == 3)
assert (len(H2O.find_connected(0, scale=0.9)) == 1)

# .............................................
# I/O
fxyz='CO.xyz'
fpdb='CO.pdb'

cell = [2.,3.,R+2.]
CO.set_cell(cell, scale_atoms=True)
barrier()
CO.write(fxyz)
barrier()
CO_b = Cluster(filename=fxyz)
assert(len(CO) == len(CO_b))
#for a, b in zip(cell, CO_b.get_cell().diagonal()):