コード例 #1
0
ファイル: test_utils.py プロジェクト: SCM-NV/qmworks
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)))
コード例 #2
0
def test_opt_gamess():
    """
    Test Optimization in Gamess using methanol in water.
    """
    methanol = Molecule('test/test_files/ion_methanol.xyz')
    methanol.properties['symmetry'] = 'Cs'

    s = Settings()
    s.specific.gamess.contrl.nzvar = 12
    s.specific.gamess.system.timlim = 2
    s.specific.gamess.system.mwords = 2
    s.specific.gamess.pcm.solvnt = 'water'
    s.specific.gamess.basis.gbasis = 'sto'
    s.specific.gamess.basis.ngauss = 3
    s.specific.gamess.guess.guess = 'huckel'
    s.specific.gamess.stapt.optol = '1d-5'
    s.specific.gamess.zmat["izmat(1)"] = "1,1,2,  1,2,3,  1,3,4,  1,3,5,  1,3,6, \n"\
                                         "2,1,2,3,  2,2,3,4,  2,2,3,5,  2,2,3,6, \n"\
                                         "3,1,2,3,4,  3,1,2,3,5,  3,1,2,3,6"

    inp = templates.geometry.overlay(s)
    methanol_geometry = gamess(inp, methanol, work_dir='/tmp')

    mol_opt = run(methanol_geometry.molecule)

    coords = concat([a.coords for a in mol_opt.atoms])

    expected_coords = [
        -0.9956983464, 0.9204754677, -0.0002616586, -0.72585581, -0.0802380791,
        2.18166e-05, 0.741292161, 0.0371204735, -1.69738e-05, 1.1448441964,
        0.5632291664, -0.9026112278, 1.1448447102, 0.562978981, 0.9027182521,
        1.1454516521, -0.9993402516, 1.04943e-05
    ]

    assert abs(sum(zipWith(operator.sub)(coords)(expected_coords))) < 1e-7
コード例 #3
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)))
コード例 #4
0
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)])
コード例 #5
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)
コード例 #6
0
ファイル: test_opt_gamess.py プロジェクト: SCM-NV/qmworks
def test_opt_gamess():
    """
    Test Optimization in Gamess using methanol in water.
    """
    methanol = Molecule('test/test_files/ion_methanol.xyz')
    methanol.properties['symmetry'] = 'Cs'

    s = Settings()
    s.specific.gamess.contrl.nzvar = 12
    s.specific.gamess.system.timlim = 2
    s.specific.gamess.system.mwords = 2
    s.specific.gamess.pcm.solvnt = 'water'
    s.specific.gamess.basis.gbasis = 'sto'
    s.specific.gamess.basis.ngauss = 3
    s.specific.gamess.guess.guess = 'huckel'
    s.specific.gamess.stapt.optol = '1d-5'
    s.specific.gamess.zmat["izmat(1)"] = "1,1,2,  1,2,3,  1,3,4,  1,3,5,  1,3,6, \n"\
                                         "2,1,2,3,  2,2,3,4,  2,2,3,5,  2,2,3,6, \n"\
                                         "3,1,2,3,4,  3,1,2,3,5,  3,1,2,3,6"

    inp = templates.geometry.overlay(s)
    methanol_geometry = gamess(inp, methanol, work_dir='/tmp')

    mol_opt = run(methanol_geometry.molecule)

    coords = concat([a.coords for a in mol_opt.atoms])

    expected_coords = [-0.9956983464, 0.9204754677, -0.0002616586, -0.72585581,
                       -0.0802380791, 2.18166e-05, 0.741292161, 0.0371204735,
                       -1.69738e-05, 1.1448441964, 0.5632291664, -0.9026112278,
                       1.1448447102, 0.562978981, 0.9027182521,
                       1.1454516521, -0.9993402516, 1.04943e-05]

    assert abs(sum(zipWith(operator.sub)(coords)(expected_coords))) < 1e-7
コード例 #7
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)
コード例 #8
0
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)])
コード例 #9
0
ファイル: turbomoleParser.py プロジェクト: mrauha/qmflows
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
コード例 #10
0
ファイル: test_opt_orca.py プロジェクト: SCM-NV/qmworks
def test_methanol_opt_orca():
    """
    Run a methanol optimization and retrieve the optimized geom.
    """
    methanol = Molecule('test/test_files/methanol.xyz')

    s = Settings()
    s.specific.orca.main = "RKS B3LYP SVP Opt TightSCF SmallPrint"

    opt = orca(s, methanol)

    mol_opt = run(opt.molecule)

    expected_coords = [-1.311116, -0.051535, -0.000062, 0.097548, 0.033890,
                       -0.000077, -1.683393, -1.092152, -0.000066,
                       -1.734877, 0.448868, 0.891460, -1.734894, 0.448881,
                       -0.891567, 0.460481, -0.857621, -0.000038]

    coords = concat([a.coords for a in mol_opt.atoms])

    assert abs(sum(zipWith(operator.sub)(coords)(expected_coords))) < 1e-7
コード例 #11
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)])
コード例 #12
0
def test_concat():
    """
    Test list concatenation
    """
    xss = [[1], [2]]
    assert concat(xss) == [1, 2]
コード例 #13
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)]))
コード例 #14
0
ファイル: test_utils.py プロジェクト: SCM-NV/qmworks
def test_concat():
    """
    Test list concatenation
    """
    xss = [[1], [2]]
    assert concat(xss) == [1, 2]
コード例 #15
0
 def zip_path_coord(initials, finals):
     return concat([
         list(zip(itertools.repeat(init), fs))
         for init, fs in zip(initials, finals)
     ])