Ejemplo n.º 1
0
def run(lastres=[]):
    results = []

    # Hirshfeld ----------------------------------------

    if 1:

        hd = HirshfeldDensity(calc)

        # check for the number of electrons
        expected = [
            [None, 10],
            [[0, 1, 2], 10],
            [[1, 2], 2],
            [[0], 8],
        ]
        #expected = [[[0, 2], 9], ]
        #expected = [[None, 10], ]
        for gridrefinement in [1, 2, 4]:
            #Test for all gridrefinements for get_all_electron_density
            parprint('grid refinement', gridrefinement)
            for result in expected:
                indicees, result = result
                full, gd = hd.get_density(indicees, gridrefinement)
                parprint('indicees', indicees, end=': ')
                parprint('result, expected:', gd.integrate(full), result)
                if gridrefinement < 4:
                    #The highest level of gridrefinement gets wrong electron numbers
                    equal(gd.integrate(full), result, 1.e-8)
                else:
                    equal(gd.integrate(full), result, 1.e-4)

        hp = HirshfeldPartitioning(calc)
        vr = hp.get_effective_volume_ratios()
        parprint('Hirshfeld:', vr)
        if len(lastres):
            equal(vr, lastres.pop(0), 1.e-10)
        results.append(vr)

    # Wigner-Seitz ----------------------------------------

    if 1:
        ws = WignerSeitz(calc.density.finegd, mol, calc)

        vr = ws.get_effective_volume_ratios()
        parprint('Wigner-Seitz:', vr)
        if len(lastres):
            equal(vr, lastres.pop(0), 1.e-10)
        results.append(vr)

    return results
Ejemplo n.º 2
0
def run(lastres=[]):
    results = []

    # Hirshfeld ----------------------------------------

    if 1:

        hd = HirshfeldDensity(calc)

        # check for the number of electrons
        expected = [[None, 10],
                    [[0, 1, 2], 10],
                    [[1, 2], 2],
                    [[0], 8],
                    ]
        #expected = [[[0, 2], 9], ]
        #expected = [[None, 10], ]
        for gridrefinement in [1, 2, 4]:
            #Test for all gridrefinements for get_all_electron_density
            parprint('grid refinement', gridrefinement)
            for result in expected:
                indicees, result = result
                full, gd = hd.get_density(indicees, gridrefinement)
                parprint('indicees', indicees, end=': ') 
                parprint('result, expected:', gd.integrate(full), result)
                if gridrefinement < 4:
                    #The highest level of gridrefinement gets wrong electron numbers
                    equal(gd.integrate(full), result, 1.e-8)
                else:
                    equal(gd.integrate(full), result, 1.e-5)

        hp = HirshfeldPartitioning(calc)
        vr = hp.get_effective_volume_ratios()
        parprint('Hirshfeld:', vr)
        if len(lastres):
            equal(vr, lastres.pop(0), 1.e-10)
        results.append(vr)

    # Wigner-Seitz ----------------------------------------

    if 1:
        ws = WignerSeitz(calc.density.finegd, mol, calc)

        vr = ws.get_effective_volume_ratios()
        parprint('Wigner-Seitz:', vr)
        if len(lastres):
            equal(vr, lastres.pop(0), 1.e-10)
        results.append(vr)

    return results
Ejemplo n.º 3
0
 def get_effective_volume_ratios(self):
     """Return the list of effective volume to free volume ratios."""
     ratios = []
     self.hdensity = HirshfeldDensity(self.calculator)
     for a, atom in enumerate(self.atoms):
         ratios.append(self.get_effective_volume_ratio(a))
     return np.array(ratios)
Ejemplo n.º 4
0
try:
    calc = GPAW(gpwname + 'notfound', txt=None)
    #    calc = GPAW(gpwname, txt=None)
    mol = calc.get_atoms()
except:
    mol = Cluster(molecule('H2O'))
    mol.minimal_box(3, h=h)
    calc = GPAW(nbands=6, h=h, txt=None)
    calc.calculate(mol)
    calc.write(gpwname)

# Hirshfeld ----------------------------------------

if 1:

    hd = HirshfeldDensity(calc)

    # check for the number of electrons
    expected = [
        [None, 10],
        [[0, 1, 2], 10],
        [[1, 2], 2],
        [[0], 8],
    ]
    #expected = [[[0, 2], 9], ]
    #expected = [[None, 10], ]
    for result in expected:
        indicees, result = result
        full, gd = hd.get_density(indicees)
        parprint('indicees', indicees, end=': ')
        parprint('result, expected:', gd.integrate(full), result)
Ejemplo n.º 5
0
#    calc = GPAW(gpwname, txt=None)
    mol = calc.get_atoms()
except:
    mol = Cluster(molecule('H2O'))
    mol.minimal_box(3, h=h)
    calc = GPAW(nbands=6,
                h = h, 
                txt=None)
    calc.calculate(mol)
    calc.write(gpwname)

# Hirshfeld ----------------------------------------

if 1:

    hd = HirshfeldDensity(calc)

    # check for the number of electrons
    expected = [[None, 10],
                [[0, 1, 2], 10],
                [[1, 2], 2],
                [[0], 8],
                ]
    #expected = [[[0, 2], 9], ]
    #expected = [[None, 10], ]
    for result in expected:
        indicees, result = result
        full, gd = hd.get_density(indicees)
        parprint('indicees', indicees, end=': ') 
        parprint('result, expected:', gd.integrate(full), result)
        equal(gd.integrate(full), result, 1.e-8)