Exemplo n.º 1
0
def cp2k_input(range_orbitals,
               cell_parameters,
               cell_angles,
               added_mos,
               basis="DZVP-MOLOPT-SR-GTH",
               potential="GTH-PBE"):
    """
    # create ``Settings`` for the Cp2K Jobs.
    """
    # Main Cp2k Jobs
    cp2k_args = Settings()
    cp2k_args.basis = fun_format(basis)
    cp2k_args.potential = fun_format(potential)
    cp2k_args.cell_parameters = cell_parameters
    cp2k_args.cell_angles = cell_angles
    main_dft = cp2k_args.specific.cp2k.force_eval.dft
    main_dft.scf.added_mos = added_mos
    main_dft.scf.max_scf = 40
    main_dft.scf.eps_scf = 5e-4
    main_dft['print']['mo']['mo_index_range'] = '"{} {}"'.format(
        *range_orbitals)
    cp2k_args.specific.cp2k.force_eval.subsys.cell.periodic = fun_format(
        'None')

    # Setting to calculate the wave function used as guess
    cp2k_OT = Settings()
    cp2k_OT.basis = fun_format(basis)
    cp2k_OT.potential = fun_format(potential)
    cp2k_OT.cell_parameters = cell_parameters
    cp2k_OT.cell_angles = cell_angles
    ot_dft = cp2k_OT.specific.cp2k.force_eval.dft
    ot_dft.scf.scf_guess = fun_format('atomic')
    ot_dft.scf.ot.minimizer = fun_format('DIIS')
    ot_dft.scf.ot.n_diis = 7
    ot_dft.scf.ot.preconditioner = fun_format('FULL_SINGLE_INVERSE')
    ot_dft.scf.added_mos = 0
    ot_dft.scf.eps_scf = 1e-06
    ot_dft.scf.scf_guess = fun_format('restart')
    cp2k_OT.specific.cp2k.force_eval.subsys.cell.periodic = fun_format('None')

    return cp2k_args, cp2k_OT
Exemplo n.º 2
0
def fun_ethylene(scratch_path):
    """
    Test Ethylene singlw
    """
    project_name = 'ethylene'

    # create Settings for the Cp2K Jobs
    s = Settings()
    s.basis = "DZVP-MOLOPT-SR-GTH"
    s.potential = "GTH-PBE"
    s.cell_parameters = [12.74] * 3
    dft = s.specific.cp2k.force_eval.dft
    dft.scf.added_mos = 20
    dft.scf.eps_scf = 1e-4

    dft['print']['ao_matrices']['overlap'] = ''
    dft['print']['ao_matrices']['filename'] = join(scratch_path, 'overlap.out')

    # Copy the basis and potential to a tmp file
    shutil.copy('test/test_files/BASIS_MOLOPT', scratch_path)
    shutil.copy('test/test_files/GTH_POTENTIALS', scratch_path)
    # Cp2k configuration files
    basiscp2k = join(scratch_path, 'BASIS_MOLOPT')
    potcp2k = join(scratch_path, 'GTH_POTENTIALS')
    cp2k_config = {"basis": basiscp2k, "potential": potcp2k}

    # HDF5 path
    path_hdf5 = join(scratch_path, 'ethylene.hdf5')

    # all_geometries type :: [String]
    path_xyz = 'test/test_files/ethylene.xyz'
    geometries = split_file_geometries(path_xyz)

    # Input/Output Files
    file_xyz = join(scratch_path, 'coordinates.xyz')
    file_inp = join(scratch_path, 'ethylene.inp')
    file_out = join(scratch_path, 'ethylene.out')
    file_MO = join(scratch_path, 'mo_coeffs.out')

    files = JobFiles(file_xyz, file_inp, file_out, file_MO)

    schedule_job = schedule(prepare_job_cp2k)

    promise = schedule_job(geometries[0],
                           files,
                           s,
                           scratch_path,
                           project_name=project_name,
                           hdf5_file=path_hdf5,
                           wfn_restart_job=None,
                           store_in_hdf5=True,
                           nHOMOS=25,
                           nLUMOS=25,
                           package_config=cp2k_config)

    cp2k_result = run(promise)

    path_properties = cp2k_result.orbitals

    with h5py.File(path_hdf5) as f5:
        assert (all(p in f5 for p in path_properties))