Ejemplo n.º 1
0
def test_gradient_failures(options, failures, path):
    """Either output file or the regex lines are removed from the failures. Each list of failures is a STEP """

    options_obj, input_obj, molecule = optavc.initialize_optavc(options)

    for step in range(4):

        calc_obj, calc_type = optavc.create_calc_objects("OPT",
                                                         molecule,
                                                         options_obj,
                                                         input_obj,
                                                         path=f'{path}')
        grad_obj = calc_obj.create_opt_gradient(iteration=step)

        if options_obj.xtpl:

            for index, xtpl_obj in enumerate(grad_obj.calc_objects):
                print(index, xtpl_obj.options.name)
                print(xtpl_obj.path)
                if index < 4:
                    true_failures = failures[step][1]
                else:
                    true_failures = failures[step][0]

                iterative_collect_failures(xtpl_obj, true_failures, 10)

        else:
            true_failures = failures[step]
            iterative_collect_failures(grad_obj, true_failures, 10)
Ejemplo n.º 2
0
def test_complex_molecule():
    """This is to make sure that atom labels are properly read especially for assigning mixed basis sets """

    basic_options = {
        'template_file_path': "templates/mixed_basis.dat",
        'input_name': "input.dat",
        'output_name': "output.dat",
        'program': 'psi4',
        'energy_regex': r"\s*\*\s*CCSD\(T\)\stotal\senergy\s+=\s*(-\d*.\d*)",
        'maxiter': 100,
        #'cluster': 'Vulcan',
        'name': 'test',
        'nslots': 4,
        'print': 3,
        'resub': True,
        'max_force_g_convergence': 1e-7,
        'ensure_bt_convergence': True,
        'hessian_write': True,
        'sleepy_sleep_time': 10
    }

    options_obj, input_obj, molecule = optavc.initialize_optavc(basic_options)
    calc_obj, calc_type = optavc.create_calc_objects('OPT', molecule,
                                                     options_obj, input_obj)
    grad_obj = calc_obj.create_opt_gradient(iteration=0)
    assert len(grad_obj.calculations) == 247
Ejemplo n.º 3
0
def test_xtpl_grad(option1, option2, option3, option4, expected):

    # Don't pay attention to the template names they don't correspond to necessarily
    # sensible combinations of calcs - we're just tricking optavc into different numbers
    # of calculations as being unique

    mp2_qz = r"\s*MP2\/QZ\scorrelation\senergy\s*(-\d*.\d*)"
    mp2_tz = r"\s*MP2\/TZ\scorrelation\senergy\s*(-\d*.\d*)"
    scf_qz = r"\s*SCF\/QZ\s+reference\senergy\s*(-\d*.\d*)"
    scf_tz = r"\s*SCF\/TZ\s+reference\senergy\s*(-\d*.\d*)"

    options = {
        'template_file_path': f"templates/calc_1_template.dat",
        'program': 'psi4',
        'energy_regex': r"\s*\*\s*CCSD\(T\)\stotal\senergy\s+=\s*(-\d*.\d*)",
        'xtpl_templates': option1,
        'xtpl_programs': "psi4",
        'xtpl_regexes': [[mp2_qz, mp2_tz], [scf_qz, scf_tz]],
        'xtpl_basis_sets': [[4, 3], [4, 3]],
        'xtpl_names': option3,
        'delta_templates': option2,
        'delta_programs': 'psi4',
        'delta_names': option4,
        'delta_regexes': [["doesn't actually matter", "also doesnt matter"]]
    }

    options_obj, input_obj, molecule = optavc.initialize_optavc(options)
    calc_obj, calc_type = optavc.create_calc_objects('OPT', molecule,
                                                     options_obj, input_obj)

    for iteration in range(10):
        xtpl_obj = calc_obj.create_opt_gradient(iteration)

        for index, xtpl_grad_obj in enumerate(xtpl_obj.calc_objects):
            assert xtpl_grad_obj.options.name == f'{expected[index]}--{iteration:02d}'
            assert xtpl_grad_obj.path == os.path.realpath(
                f'STEP{iteration:02d}/{expected[index]}')

            for singlepoint in xtpl_grad_obj.calculations:
                assert singlepoint.path == os.path.realpath(
                    f'STEP{iteration:02d}/{expected[index]}/'
                    f'{singlepoint.disp_num}')
                assert singlepoint.options.name == (
                    f'{expected[index]}--{iteration:02d}-'
                    f'{singlepoint.disp_num}')
Ejemplo n.º 4
0
def test_hessian_failures(options, failures, path):
    """ the actual molecule doesn't really matter as long as it has the right number
    of displacements. Pretend that template1 and template2 are different (they're the same)
    our test hessian is actually the same calc twice. We pretend here that the ccsd and hf are pulled out of the same
    # output file for the qz and tz calculations """

    options_obj, input_obj, molecule = optavc.initialize_optavc(options)
    calc_obj, calc_type = optavc.create_calc_objects('HESS',
                                                     molecule,
                                                     options_obj,
                                                     input_obj,
                                                     path=f'{path}')

    if calc_obj.options.xtpl:

        for i in range(2):
            true_failures = failures[i]
            hess_obj = calc_obj.calc_objects[i]

    else:
        true_failures = failures
        hess_obj = calc_obj

    iterative_collect_failures(hess_obj, true_failures, 10)
Ejemplo n.º 5
0
def test_standard_grad():

    options = {
        'template_file_path': f"templates/calc_1_template.dat",
        'program': 'psi4',
        'energy_regex': r"\s*\*\s*CCSD\(T\)\stotal\senergy\s+=\s*(-\d*.\d*)",
        'name': 'test',
    }

    options_obj, input_obj, molecule = optavc.initialize_optavc(options)
    calc_obj, calc_type = optavc.create_calc_objects('OPT', molecule,
                                                     options_obj, input_obj)

    for iteration in range(99):
        grad_obj = calc_obj.create_opt_gradient(iteration)
        assert grad_obj.path == os.path.realpath(f'STEP{iteration:02d}')
        assert grad_obj.options.name == f'test--{iteration:02d}'

        for singlepoint in grad_obj.calculations:
            assert singlepoint.path == os.path.realpath(
                f'./STEP{iteration:02d}/'
                f'{singlepoint.disp_num}')
            assert singlepoint.options.name == (f'test--{iteration:02d}-'
                                                f'{singlepoint.disp_num}')