示例#1
0
def load(file_or_basis_name, symb):
    '''Convert the basis of the given symbol to internal format

    Args:
        file_or_basis_name : str
            Case insensitive basis set name. Special characters will be removed.
        symb : str
            Atomic symbol, Special characters will be removed.

    Examples:
        Load DZVP-GTH of carbon 

    >>> cell = gto.Cell()
    >>> cell.basis = {'C': load('gth-dzvp', 'C')}
    '''
    if os.path.isfile(file_or_basis_name):
        try:
            return parse_cp2k.load(file_or_basis_name, symb)
        except RuntimeError:
            with open(file_or_basis_name, 'r') as fin:
                return parse_cp2k.parse(fin.read())

    name = file_or_basis_name.lower().replace(' ', '').replace('-', '').replace('_', '')
    if name not in ALIAS:
        return pyscf.gto.basis.load(file_or_basis_name, symb)
    basmod = ALIAS[name]
    symb = ''.join(i for i in symb if i.isalpha())
    b = parse_cp2k.load(os.path.join(os.path.dirname(__file__), basmod), symb)
    return b
示例#2
0
def load(file_or_basis_name, symb, optimize=OPTIMIZE_CONTRACTION):
    '''Convert the basis of the given symbol to internal format

    Args:
        file_or_basis_name : str
            Case insensitive basis set name. Special characters will be removed.
        symb : str
            Atomic symbol, Special characters will be removed.

    Examples:
        Load DZVP-GTH of carbon 

    >>> cell = gto.Cell()
    >>> cell.basis = {'C': load('gth-dzvp', 'C')}
    '''
    if os.path.isfile(file_or_basis_name):
        try:
            return parse_cp2k.load(file_or_basis_name, symb)
        except RuntimeError:
            with open(file_or_basis_name, 'r') as fin:
                return parse_cp2k.parse(fin.read())

    name = _mol_basis._format_basis_name(file_or_basis_name)
    if '@' in name:
        split_name = name.split('@')
        assert len(split_name) == 2
        name = split_name[0]
        contr_scheme = _mol_basis._convert_contraction(split_name[1])
    else:
        contr_scheme = 'Full'

    if name not in ALIAS:
        return _mol_basis.load(file_or_basis_name, symb)

    basmod = ALIAS[name]
    symb = ''.join(i for i in symb if i.isalpha())
    b = parse_cp2k.load(os.path.join(os.path.dirname(__file__), basmod), symb)

    if contr_scheme != 'Full':
        b = _mol_basis._truncate(b, contr_scheme, symb, split_name)
    return b
示例#3
0
def parse(string, optimize=OPTIMIZE_CONTRACTION):
    '''Parse the basis text in CP2K format, return an internal basis format
    which can be assigned to :attr:`Cell.basis`

    Args:
        string : Blank linke and the lines of "BASIS SET" and "END" will be ignored

    Examples:

    >>> cell = gto.Cell()
    >>> cell.basis = {'C': gto.basis.parse("""
    ... C DZVP-GTH
    ...   2
    ...   2  0  1  4  2  2
    ...         4.3362376436   0.1490797872   0.0000000000  -0.0878123619   0.0000000000
    ...         1.2881838513  -0.0292640031   0.0000000000  -0.2775560300   0.0000000000
    ...         0.4037767149  -0.6882040510   0.0000000000  -0.4712295093   0.0000000000
    ...         0.1187877657  -0.3964426906   1.0000000000  -0.4058039291   1.0000000000
    ...   3  2  2  1  1
    ...         0.5500000000   1.0000000000
    ... #
    ... """)}
    '''
    return parse_cp2k.parse(string)