Beispiel #1
0
def readTurbomoleBasis(path):
    """Read Turbomole basis set"""
    bss = topParseB.parseFile(path)
    atoms = [xs.atomLabel.lower() for xs in bss]
    names = concat([xs.basisName.upper().split() for xs in bss])
    formats = [xs.format[:] for xs in bss]
    formats_int = map(lambda fss: [[int(x) for x in xs] for xs in fss], formats)
    rss = [rs.coeffs[:] for rs in bss]
    rawData = [[x.contractions[:] for x in rss[i]] for i in range(len(rss))]
    fst = lambda xs: xs[0]
    snd = lambda xs: xs[1]
    expos = list(
        map(
            mapFloat,
            [concatMap(fst, swapCoeff(2, rawData[i])) for i in range(len(rawData))],
        )
    )
    coeffs = list(
        map(
            mapFloat,
            [concatMap(snd, swapCoeff(2, rawData[i])) for i in range(len(rawData))],
        )
    )
    basisData = zipWith(AtomBasisData)(expos)(coeffs)
    basiskey = zipWith3(AtomBasisKey)(atoms)(names)(formats_int)

    return basiskey, basisData
Beispiel #2
0
def test_zipwith3():
    """
    zipWith f xs ys zs ==  map (f) (zip  xs ys zs)
    """
    @curry
    def f(x, y, z):
        return x * y + z

    xs = range(3)
    ys = range(3, 6)
    zs = range(6, 9)

    assert zipWith3(f)(xs)(ys)(zs) == [
        f(x, y, z) for (x, y, z) in zip(xs, ys, zs)
    ]
Beispiel #3
0
def readCp2KBasis(path):
    """
    Read the Contracted Gauss function primitives format from a text file.

    :param path: Path to the file containing the basis.
    :type path: String
    """
    bss = topParseBasis.parseFile(path)
    atoms = ["".join(xs.atom[:]).lower() for xs in bss]
    names = [" ".join(xs.basisName[:]).upper() for xs in bss]
    formats = [list(map(int, xs.format[:])) for xs in bss]
    # for example 2 0 3 7 3 3 2 1 there are sum(3 3 2 1) =9 Lists
    # of Coefficients + 1 lists of exponents
    nCoeffs = [int(sum(xs[4:]) + 1) for xs in formats]
    rss = zipWith(swapCoeff2)(nCoeffs)(list(map(float, cs.coeffs[:]))
                                       for cs in bss)
    tss = [headTail(xs) for xs in rss]
    basisData = [AtomBasisData(xs[0], xs[1]) for xs in tss]
    basiskey = zipWith3(AtomBasisKey)(atoms)(names)(formats)

    return (basiskey, basisData)