Example #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
Example #2
0
def create_alpha_paths(lattice_cte):
    """
    Create all the initial and final paths between gamma alpha and Chi_bb
    """
    def zip_path_coord(initials, finals):
        return concat([
            list(zip(itertools.repeat(init), fs))
            for init, fs in zip(initials, finals)
        ])

    initial_alpha_pos = [(2, 0, 0), (0, 2, 0), (0, 0, 2)]

    final_alpha_x = [(1, 1, 0), (1, -1, 0), (1, 0, 1), (1, 0, -1)]
    final_alpha_y = [swap(t, 0, 1) for t in final_alpha_x]
    final_alpha_z = [swap(t, 1, 2) for t in final_alpha_y]

    final_positives = [final_alpha_x, final_alpha_y, final_alpha_z]

    positives = zip_path_coord(initial_alpha_pos, final_positives)

    initial_alpha_neg = [
        mirror_axis(t, i) for i, t in enumerate(initial_alpha_pos)
    ]

    final_negatives = [
        list(map(lambda xs: mirror_axis(xs, i), fs))
        for i, fs in enumerate(final_positives)
    ]

    negatives = zip_path_coord(initial_alpha_neg, final_negatives)

    paths = concat([positives, negatives])

    return map_fun(lambda x: x * 2 * pi / lattice_cte, paths)
def calc_orbital_Slabels(name, fss):
    """
    Most quantum packages use standard basis set which contraction is
    presented usually by a format like:
    c def2-SV(P)
    # c     (7s4p1d) / [3s2p1d]     {511/31/1}
    this mean that this basis set for the Carbon atom uses 7 ``s`` CGF,
    4 ``p`` CGF and 1 ``d`` CGFs that are contracted in 3 groups of 5-1-1
    ``s`` functions, 3-1 ``p`` functions and 1 ``d`` function. Therefore
    the basis set format can be represented by [[5,1,1], [3,1], [1]].

    On the other hand Cp2k uses a special basis set ``MOLOPT`` which
    format explanation can be found at: `C2pk
    <https://github.com/cp2k/cp2k/blob/e392d1509d7623f3ebb6b451dab00d1dceb9a248/cp2k/data/BASIS_MOLOPT>`_.

    :parameter name: Quantum package name
    :type name: string
    :parameter fss: Format basis set
    :type fss: [Int] | [[Int]]
    """
    def funSlabels(d, l, fs):
        if isinstance(fs, list):
            fs = sum(fs)
        labels = [d[l]] * fs
        return labels

    angularM = ['s', 'p', 'd', 'f', 'g']
    if name == 'cp2k':
        dict_Ord_Labels = dict_cp2kOrder_spherical
    else:
        raise NotImplementedError

    return concat(
        [funSlabels(dict_Ord_Labels, l, fs) for l, fs in zip(angularM, fss)])
Example #4
0
def test_concatMap():
    """
    concatMap f == concat (map f)
    """
    f = lambda x: [x * 2]
    xs = [1, 2]
    assert concatMap(f, xs) == list(concat(map(f, xs)))
Example #5
0
def create_beta_paths(lattice_cte):
    """
    Create all the initial and final paths between gamma alpha and Chi_bb
    """
    gammas_beta = [(1, 1, 1), (-1, 1, 1), (1, -1, 1), (1, 1, -1), (-1, -1, 1),
                   (1, -1, -1), (-1, 1, -1), (-1, -1, -1)]

    paths = concat([mirror_cube(gamma) for gamma in gammas_beta])

    return map_fun(lambda x: x * 2 * pi / lattice_cte, paths)
def calc_orbital_Clabels(name, fss):
    """
    Labels of the Cartesian CGFs
    """
    def funClabels(d, l, fs):
        if isinstance(fs, list):
            fs = sum(fs)
        labels = [d[l]] * fs
        return labels

    angularM = ['s', 'p', 'd', 'f', 'g']
    if name == 'cp2k':
        dict_Ord_Labels = dict_cp2kOrd_cartesian
    if name == 'turbomole':
        dict_Ord_Labels = dict_turbomoleOrd_cartesian
        raise NotImplementedError

    return concat(
        [funClabels(dict_Ord_Labels, l, fs) for l, fs in zip(angularM, fss)])
Example #7
0
    def fun2(ess, css, fs):
        def funAcc(acc, x):
            n, xs = acc
            return (n + x, xs + [n + x])

        def accum(l, n, xs):
            def go(t, k):
                index, acc = t
                xss = css[index:k + index]
                yss = ess[index:k + index]
                rss = expandBasis_turbomole(l, yss, xss)

                return (index + k, acc + rss)

            return reduce(go, xs, (n, []))

        # print(fs)
        fss = str2ListofList(fs)
        # snd . foldl' funAcc (0,[0]) (map sum fss)
        lens = snd(reduce(funAcc, list(map(sum, fss)), (0, [0])))
        return concat(
            [snd(accum(l, n, xs)) for (l, n, xs) in zip(orbLabels, lens, fss)])
Example #8
0
def concatSwapCoeff(xss, m, n):
    if n == 0:
        return concat(swapCoeff(m)(cs.coeffs[:] for cs in xss))
    else:
        xs = concat(swapCoeff(m)(cs.coeffs[:] for cs in xss[:-1]))
        return xs + concat(swapCoeff(n)([list(xss[-1].lastCoeffs)]))
Example #9
0
 def zip_path_coord(initials, finals):
     return concat([
         list(zip(itertools.repeat(init), fs))
         for init, fs in zip(initials, finals)
     ])
Example #10
0
def test_concat():
    """
    Test list concatenation
    """
    xss = [[1], [2]]
    assert concat(xss) == [1, 2]