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
Exemple #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
Exemple #3
0
    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)

    hp = HirshfeldPartitioning(calc)
    vr = hp.get_effective_volume_ratios()
    parprint('Hirshfeld:', vr)
#    equal(vr[1], vr[2], 1.e-3)

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

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

    vr = ws.get_effective_volume_ratios()
    parprint('Wigner-Seitz:', vr)
Exemple #4
0
    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)

    hp = HirshfeldPartitioning(calc)
    vr = hp.get_effective_volume_ratios()
    parprint('Hirshfeld:', vr)
#    equal(vr[1], vr[2], 1.e-3)

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

if 1:
    ws = WignerSeitz(calc.density.finegd, mol, calc)
    
    vr = ws.get_effective_volume_ratios()
    parprint('Wigner-Seitz:', vr)