Exemplo n.º 1
0
def test__gradient():
    """ test the gradient pipeline
    """
    basis = 'sto-3g'
    geo = (('O', (0.0, 0.0, -0.110)), ('H', (0.0, -1.635, 0.876)),
           ('H', (-0.0, 1.635, 0.876)))
    mult_vals = [1, 2]
    charge_vals = [0, 1]

    for prog in elstruct.writer.gradient_programs():
        methods = list(elstruct.program_nondft_methods(prog))
        dft_methods = list(elstruct.program_dft_methods(prog))
        if dft_methods:
            methods.append(numpy.random.choice(dft_methods))

        for method in methods:
            for mult, charge in zip(mult_vals, charge_vals):
                for orb_type in (elstruct.program_method_orbital_types(
                        prog, method, singlet=(mult == 1))):

                    vals = _test_pipeline(
                        script_str=SCRIPT_DCT[prog],
                        writer=elstruct.writer.gradient,
                        readers=(
                            elstruct.reader.energy,
                            elstruct.reader.gradient,
                        ),
                        args=(prog, geo, charge, mult, method, basis),
                        kwargs={'orb_type': orb_type},
                    )
                    # Print the value for Psi4 since it was run and read
                    if prog == elstruct.par.Program.PSI4:
                        print('grad\n', vals)
Exemplo n.º 2
0
def test__hessian():
    """ test the hessian pipeline
    """
    basis = 'sto-3g'
    geom = (('O', (0.0, 0.0, -0.110)), ('H', (0.0, -1.635, 0.876)),
            ('H', (-0.0, 1.635, 0.876)))
    mult_vals = [1, 2]
    charge_vals = [0, 1]

    for prog in elstruct.writer.hessian_programs():
        methods = list(elstruct.program_nondft_methods(prog))
        dft_methods = list(elstruct.program_dft_methods(prog))
        if dft_methods:
            methods.append(numpy.random.choice(dft_methods))

        for method in methods:
            for mult, charge in zip(mult_vals, charge_vals):
                for orb_type in (elstruct.program_method_orbital_types(
                        prog, method, singlet=(mult == 1))):

                    vals = _test_pipeline(
                        script_str=SCRIPT_DCT[prog],
                        writer=elstruct.writer.hessian,
                        readers=(
                            elstruct.reader.energy_(prog, method),
                            elstruct.reader.hessian_(prog),
                        ),
                        args=(geom, charge, mult, method, basis, prog),
                        kwargs={'orb_type': orb_type},
                    )
                    print(vals)