Exemple #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
Exemple #2
0
def check_jbw_coarse(local):
    # This test is not supposed to generate meaningful numbers. The cube data
    # is too coarse and the reference atoms may have little similarities with
    # the DFT density.

    # Load the cube file
    fn_cube = context.get_fn('test/jbw_coarse_aedens.cube')
    sys = System.from_file(fn_cube)
    mol_dens = sys.extra['cube_data']
    ugrid = sys.grid

    # Load some pro-atoms
    proatomdb = ProAtomDB.from_refatoms(numbers=[8, 14],
                                        max_kation=0,
                                        max_anion=0)

    # Run the partitioning
    cpart = HirshfeldCPart(sys, ugrid, local, mol_dens, proatomdb, range(119))

    # Do some testing
    if local:
        names = cpart.do_all()
        check_names(names, cpart)
    else:
        cpart.do_charges()
        wcor = cpart.get_wcor()
        assert abs(cpart['populations'].sum() -
                   ugrid.integrate(wcor, mol_dens)) < 1e-10
Exemple #3
0
def check_jbw_coarse(local):
    # This test is not supposed to generate meaningful numbers. The cube data
    # is too coarse and the reference atoms may have little similarities with
    # the DFT density.

    # Load the cube file
    fn_cube = context.get_fn('test/jbw_coarse_aedens.cube')
    mol = IOData.from_file(fn_cube)
    moldens = mol.cube_data
    ugrid = mol.grid

    # Load some pro-atoms
    proatomdb = ProAtomDB.from_refatoms(numbers=[8,14], max_kation=0, max_anion=0)

    # Run the partitioning
    cpart = HirshfeldCPart(mol.coordinates, mol.numbers, mol.pseudo_numbers,
                           ugrid, moldens, proatomdb, local=local,
                           wcor_numbers=range(119))

    # Do some testing
    assert cpart.local == local
    if local:
        names = cpart.do_all()
        check_names(names, cpart)
    else:
        cpart.do_charges()
        wcor = cpart.get_wcor()
        assert abs(cpart['pseudo_populations'].sum() - ugrid.integrate(wcor, moldens)) < 1e-10
Exemple #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
Exemple #5
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)