예제 #1
0
    alpha2 = (pol1 - pol2) / 2

# Test 3

if test3:
    pcd = 1000.0  # distance of the two point charges
    maxcharge = 100.0  # maximum charge on the point charge

    e = []
    e1s = []
    d = []
    charges = np.linspace(-maxcharge, maxcharge, nfs)
    fields = []
    for charge in charges:
        ex = PointCharges(positions=[[a0 / 2, a0 / 2, -pcd / 2 + a0 / 2],
                                     [a0 / 2, a0 / 2, pcd / 2 + a0 / 2]],
                          charges=[charge, -charge])
        c.set(external=ex)
        etot = a.get_potential_energy()
        e += [etot]
        ev0 = c.get_eigenvalues(0)
        ev1 = c.get_eigenvalues(1)
        e1s += [min(ev0[0], ev1[0])]
        dip = c.get_dipole_moment()
        d += [dip[2]]
        field = ex.get_taylor(position=a[0].get_position())[1][1]
        if rank == 0 and debug:
            print field * to_eVA, 2 * charge / ((pcd / 2)**2) * Hartree * Bohr
        fields += [field * to_eVA]

    pol1, dummy = np.polyfit(fields, d, 1)
nelectrons = 2 * H2[0].number

txt = None
#txt = '-'

# load point charges
fname = 'pc.xyz'
if world.rank == 0:
    f = open('i' + fname, 'w')
    print("""1

X 0 0 100 -0.5""", file=f)
    f.close()
world.barrier()

ex = PointCharges()
ex.read('i' + fname)
ex.write('o' + fname)

convergence = {
    'eigenstates': 1.e-4 * 40 * 1.5**3,
    'density': 1.e-2,
    'energy': 0.1
}

# without potential
if True:
    if txt:
        print('\n################## no potential')
    c00 = GPAW(h=0.3, nbands=-1, convergence=convergence, txt=txt)
    c00.calculate(H2)
예제 #3
0
import numpy as np
from ase import *

from gpaw.cluster import Cluster
from gpaw.point_charges import PointCharges

# I/O, translate

# old Cmdft style
fCmdft = 'PC_info'
f = open(fCmdft, 'w')
print >> f, """0.4
-3.0  0 0 -4
1.5   0 0 4.
"""
f.close()

pc = PointCharges(fCmdft)
assert (len(pc) == 2)
assert (pc.charge() == -1.5)

fxyz = 'pc.xyz'
pc.write(fxyz)

shift = np.array([0.2, 0.6, 2.8])
pc.translate(shift)

pc2 = PointCharges(fxyz)
for p1, p2 in zip(pc, pc2):
    assert (np.sum(p1.position - shift - p2.position) < 1e-6)