Beispiel #1
0
def check_water_hf_sto3g(scheme, expecting, needs_padb=True, **kwargs):
    if needs_padb:
        proatomdb = get_proatomdb_hf_sto3g()
        kwargs['proatomdb'] = proatomdb

    # Get the IOData
    fn_fchk = context.get_fn('test/water_sto3g_hf_g03.fchk')
    mol = IOData.from_file(fn_fchk)
    dm_full = mol.get_dm_full()

    # Create a grid for the partitioning
    rtf = ExpRTransform(5e-4, 2e1, 120)
    rgrid = RadialGrid(rtf)

    # Do the partitioning
    mode = 'only' if kwargs.get('local', True) else 'discard'
    grid = BeckeMolGrid(mol.coordinates,
                        mol.numbers,
                        mol.pseudo_numbers, (rgrid, 110),
                        random_rotate=False,
                        mode=mode)
    moldens = mol.obasis.compute_grid_density_dm(dm_full, grid.points)
    WPartClass = wpart_schemes[scheme]
    wpart = WPartClass(mol.coordinates, mol.numbers, mol.pseudo_numbers, grid,
                       moldens, **kwargs)
    names = wpart.do_all()
    check_names(names, wpart)
    assert abs(wpart['charges'] - expecting).max() < 2e-3
    assert abs(wpart['charges'] -
               wpart['cartesian_multipoles'][:, 0]).max() < 1e-3
    assert abs(wpart['charges'] - wpart['pure_multipoles'][:, 0]).max() < 1e-3

    check_proatom_splines(wpart)
    return wpart
Beispiel #2
0
def check_fake(scheme, pseudo, dowcor, local, absmean, **kwargs):
    if pseudo:
        sys, ugrid, mol_dens, proatomdb = get_fake_pseudo_oo()
    else:
        sys, ugrid, mol_dens, proatomdb = get_fake_co()

    if dowcor:
        wcor_numbers = range(119)
    else:
        wcor_numbers = []

    CPartClass = cpart_schemes[scheme]
    cpart = CPartClass(sys, ugrid, local, mol_dens, proatomdb, wcor_numbers,
                       **kwargs)

    cpart.do_charges()
    charges = cpart['charges']
    print abs(charges.sum()), abs(charges).mean(), abs(
        abs(charges).mean() - absmean)
    assert abs(charges.sum()) < 1e-2
    assert abs(abs(charges).mean() - absmean) < 1e-3

    if kwargs.get('greedy', False):
        # In case of a greedy algorithm, one should compare the proatoms
        # in the partitioning object with proatoms directly evaluate with the
        # proatom splines
        check_proatom_splines(cpart)
Beispiel #3
0
def check_msa_hf_lan(scheme, expecting, needs_padb=True, **kwargs):
    if needs_padb:
        proatomdb = get_proatomdb_hf_lan()
        kwargs['proatomdb'] = proatomdb

    # Get the IOData
    fn_fchk = context.get_fn('test/monosilicic_acid_hf_lan.fchk')
    mol = IOData.from_file(fn_fchk)
    dm_full = mol.get_dm_full()

    # Create a grid for the partitioning
    rtf = ExpRTransform(5e-4, 2e1, 120)
    rgrid = RadialGrid(rtf)

    # Do the partitioning, both with local and global grids
    mode = 'only' if kwargs.get('local', True) else 'discard'
    grid = BeckeMolGrid(mol.coordinates,
                        mol.numbers,
                        mol.pseudo_numbers, (rgrid, 110),
                        random_rotate=False,
                        mode=mode)
    moldens = mol.obasis.compute_grid_density_dm(dm_full, grid.points)
    WPartClass = wpart_schemes[scheme]
    wpart = WPartClass(mol.coordinates, mol.numbers, mol.pseudo_numbers, grid,
                       moldens, **kwargs)
    wpart.do_charges()
    assert abs(wpart['charges'] - expecting).max() < 4e-3

    check_proatom_splines(wpart)
Beispiel #4
0
def check_water_hf_sto3g(scheme, expecting, needs_padb=True, **kwargs):
    if needs_padb:
        proatomdb = get_proatomdb_hf_sto3g()
        kwargs['proatomdb'] = proatomdb

    # Get the IOData
    fn_fchk = context.get_fn('test/water_sto3g_hf_g03.fchk')
    mol = IOData.from_file(fn_fchk)
    dm_full = mol.get_dm_full()

    # Create a grid for the partitioning
    rtf = ExpRTransform(5e-4, 2e1, 120)
    rgrid = RadialGrid(rtf)

    # Do the partitioning
    mode = 'only' if kwargs.get('local', True) else 'discard'
    grid = BeckeMolGrid(mol.coordinates, mol.numbers, mol.pseudo_numbers, (rgrid, 110), random_rotate=False, mode=mode)
    moldens = mol.obasis.compute_grid_density_dm(dm_full, grid.points)
    WPartClass = wpart_schemes[scheme]
    wpart = WPartClass(mol.coordinates, mol.numbers, mol.pseudo_numbers, grid, moldens,  **kwargs)
    names = wpart.do_all()
    check_names(names, wpart)
    assert abs(wpart['charges'] - expecting).max() < 2e-3
    assert abs(wpart['charges'] - wpart['cartesian_multipoles'][:,0]).max() < 1e-3
    assert abs(wpart['charges'] - wpart['pure_multipoles'][:,0]).max() < 1e-3

    if kwargs.get('greedy', False):
        check_proatom_splines(wpart)

    return wpart
Beispiel #5
0
def check_msa_hf_lan(scheme, expecting, needs_padb=True, **kwargs):
    if needs_padb:
        proatomdb = get_proatomdb_hf_lan()
        kwargs['proatomdb'] = proatomdb

    # Get the IOData
    fn_fchk = context.get_fn('test/monosilicic_acid_hf_lan.fchk')
    mol = IOData.from_file(fn_fchk)
    dm_full = mol.get_dm_full()

    # Create a grid for the partitioning
    rtf = ExpRTransform(5e-4, 2e1, 120)
    rgrid = RadialGrid(rtf)

    # Do the partitioning, both with local and global grids
    mode = 'only' if kwargs.get('local', True) else 'discard'
    grid = BeckeMolGrid(mol.coordinates, mol.numbers, mol.pseudo_numbers, (rgrid, 110), random_rotate=False, mode=mode)
    moldens = mol.obasis.compute_grid_density_dm(dm_full, grid.points)
    WPartClass = wpart_schemes[scheme]
    wpart = WPartClass(mol.coordinates, mol.numbers, mol.pseudo_numbers, grid, moldens, **kwargs)
    wpart.do_charges()
    assert abs(wpart['charges'] - expecting).max() < 4e-3

    if kwargs.get('greedy', False):
        check_proatom_splines(wpart)
Beispiel #6
0
def check_fake(scheme, pseudo, dowcor, local, absmean, **kwargs):
    if pseudo:
        coordinates, numbers, pseudo_numbers, ugrid, moldens, proatomdb = get_fake_pseudo_oo()
    else:
        coordinates, numbers, ugrid, moldens, proatomdb = get_fake_co()
        pseudo_numbers = numbers.astype(float)

    if dowcor:
        wcor_numbers = range(119)
    else:
        wcor_numbers = []

    CPartClass = cpart_schemes[scheme]
    cpart = CPartClass(coordinates, numbers, pseudo_numbers, ugrid,
                       moldens, proatomdb, local=local,
                       wcor_numbers=wcor_numbers, **kwargs)

    assert cpart.local == local
    cpart.do_charges()
    charges = cpart['charges']
    #print abs(charges.sum()), abs(charges).mean(), abs(abs(charges).mean() - absmean)
    assert abs(charges.sum()) < 1e-2
    assert abs(abs(charges).mean() - absmean) < 1e-3

    if kwargs.get('greedy', False):
        # In case of a greedy algorithm, one should compare the proatoms
        # in the partitioning object with proatoms directly evaluate with the
        # proatom splines
        check_proatom_splines(cpart)
Beispiel #7
0
def check_water_hf_sto3g(scheme, expecting, needs_padb=True, **kwargs):
    if needs_padb:
        proatomdb = get_proatomdb_hf_sto3g()
        kwargs['proatomdb'] = proatomdb

    # Get the molecule
    fn_fchk = context.get_fn('test/water_sto3g_hf_g03.fchk')
    sys = System.from_file(fn_fchk)
    sys.wfn.update_dm('alpha')

    # Create a grid for the partitioning
    rtf = ExpRTransform(5e-4, 2e1, 120)
    rgrid = RadialGrid(rtf)

    # Do the partitioning
    mode = 'only' if kwargs.get('local', True) else 'discard'
    grid = BeckeMolGrid(sys, (rgrid, 110), random_rotate=False, mode=mode)
    WPartClass = wpart_schemes[scheme]
    wpart = WPartClass(sys, grid,  **kwargs)
    names = wpart.do_all()
    check_names(names, wpart)
    assert abs(wpart['charges'] - expecting).max() < 2e-3
    assert abs(wpart['charges'] - wpart['cartesian_multipoles'][:,0]).max() < 1e-3
    assert abs(wpart['charges'] - wpart['pure_multipoles'][:,0]).max() < 1e-3

    if kwargs.get('greedy', False):
        check_proatom_splines(wpart)
Beispiel #8
0
def check_msa_hf_lan(scheme, expecting, needs_padb=True, **kwargs):
    if needs_padb:
        proatomdb = get_proatomdb_hf_lan()
        kwargs['proatomdb'] = proatomdb

    # Get the molecule
    fn_fchk = context.get_fn('test/monosilicic_acid_hf_lan.fchk')
    sys = System.from_file(fn_fchk)

    # Create a grid for the partitioning
    rtf = ExpRTransform(5e-4, 2e1, 120)
    rgrid = RadialGrid(rtf)

    # Do the partitioning, both with local and global grids
    mode = 'only' if kwargs.get('local', True) else 'discard'
    grid = BeckeMolGrid(sys, (rgrid, 110), random_rotate=False, mode=mode)
    WPartClass = wpart_schemes[scheme]
    wpart = WPartClass(sys, grid, **kwargs)
    wpart.do_charges()
    assert abs(wpart['charges'] - expecting).max() < 4e-3

    if kwargs.get('greedy', False):
        check_proatom_splines(wpart)