示例#1
0
def main(pdb_path, splitAt, work_dir):

    monomers = create_monomers(pdb_path, splitAt, work_dir)

    settings = Settings()
    settings.basis = "DZP"
    #    settings.functional = "CAMY-B3LYP"
    settings.specific.adf.basis.core = "None"
    settings.specific.adf.symmetry = "Nosym"
    settings.specific.adf.xc.hybrid = "CAMY-B3LYP"
    settings.specific.adf.xc.xcfun = ""

    fde_settings = Settings()
    #    fde_settings.functional = "camy-b3lyp"
    fde_settings.specific.adf.xc.hybrid = "CAMY-B3LYP"
    fde_settings.specific.adf.xc.xcfun = ""
    fde_settings.basis = "DZP"
    fde_settings.specific.adf.symmetry = "Nosym"
    fde_settings.specific.adf.fde.PW91k = ""
    fde_settings.specific.adf.fde.fullgrid = ""
    fde_settings.specific.adf.allow = "Partialsuperfrags"
    fde_settings.specific.adf.fde.GGAPOTXFD = "Becke"
    fde_settings.specific.adf.fde.GGAPOTCFD = "LYP"

    # Read input from molfiles
    jobs = chain(*list(
        map(lambda xs: create_jobs(settings, fde_settings, *xs),
            enumerate(monomers))))

    run(gather(*jobs), n_processes=2)
示例#2
0
def main(file_xyz, cell, restart, basis, basis_folder):
    # Define which systems need to be calculated
    system = Molecule(file_xyz)

    # Set path for basis set
    basisCP2K = join(basis_folder, "BASIS_MOLOPT")
    potCP2K = join(basis_folder, "GTH_POTENTIALS")

    # Settings specifics
    s = templates.geometry
    s.basis = basis
    s.potential = "GTH-PBE"
    s.cell_parameters = cell
    s.specific.cp2k.force_eval.dft.basis_set_file_name = basisCP2K
    s.specific.cp2k.force_eval.dft.potential_file_name = potCP2K
    s.specific.cp2k.force_eval.dft.uks = ''
    s.specific.cp2k.force_eval.dft.charge = '1'
    s.specific.cp2k.force_eval.dft.multiplicity = '2'
    s.specific.cp2k.force_eval.dft.wfn_restart_file_name = '{}'.format(restart)

    # =======================
    # Compute OPT files with CP2k
    # =======================

    result = run(cp2k(s, system))

    # ======================
    # Output the results
    # ======================

    print(result.energy)
示例#3
0
def test_freq():
    """
    Do some constraint optimizations then launch a freq calc.
    """

    mol = Molecule("test/test_files/ethene.xyz", "xyz")
    geo_opt = dftb(templates.geometry, mol)
    freq_calc = dftb(templates.freq, geo_opt.molecule, job_name="freq")
    r = run(freq_calc)
    assert int(r.frequencies[0]) == 831
    assert len(r.frequencies) == 12
示例#4
0
def test_adf_props():
    """
    Get properties from ADF freq calc
    """

    mol = rdkitTools.smiles2rdkit('F[H]')
    result = run(adf(templates.freq, mol, job_name='adf_FH'))
    expected_energy = -0.30
    assert abs(result.energy - expected_energy) < 0.01
    assert len(result.dipole) == 3
    expected_frequency = 3359.23
    assert abs(result.frequencies[1] - expected_frequency) < 0.01
    assert len(result.charges) == 2
    assert abs(result.charges[0] + result.charges[1]) < 1e-6
示例#5
0
def test_dftb_props():
    """
    Get properties from DFTB freq calc
    """

    mol = rdkitTools.smiles2rdkit('F[H]')
    result = run(dftb(templates.freq, mol, job_name='dftb_FH'))
    expected_energy = -4.76
    assert abs(result.energy - expected_energy) < 0.01
    assert len(result.dipole) == 3
    expected_frequency = 3293.85
    assert abs(result.frequencies - expected_frequency) < 0.01
    assert len(result.charges) == 2
    assert abs(result.charges[0] + result.charges[1]) < 1e-6
def main(path_xyz):

    molecules = create_molecules(path_xyz)
    
    jobs = [create_dftb_job(m, i) for i, m in enumerate(molecules)]

    # Extract dipoles
    ds = gather(*[j.dipole for j in jobs])

    # Extract charges
    cs = gather(*[j.charges for j in jobs])

    # Run the workflow
    dipoles, charges = run(gather(ds, cs), folder='charges')

    # Print the dipoles
    np.savetxt('dipoles.txt', dipoles)
    save_coordinates_charges(molecules, charges)
示例#7
0
def test_ADFGeometry_Constraint():
    """
    Test "freeze" and "selected_atoms" keywords for constrained geometry
    optimizations.
    """
    an = plams.Molecule('test/test_files/an.xyz', 'xyz')
    # optimize only H atoms
    s = Settings()
    s.freeze = [1, 2, 3]
    result1 = adf(templates.geometry.overlay(s), an)
    geom1 = result1.molecule

    # optimize only H atoms
    s = Settings()
    s.selected_atoms = ['H']
    result2 = adf(templates.geometry.overlay(s), an)
    geom2 = result2.molecule

    r = run(gather(geom1, geom2), n_processes=1)

    assert str(r[0]) == str(r[1])
示例#8
0
def test_linear_ts():
    """
    compute a first approximation to the TS.
    """
    # Read the Molecule from file
    cnc = Molecule('test/test_files/C-N-C.mol', 'mol')

    # User define Settings
    settings = Settings()
    settings.functional = "pbe"
    settings.basis = "SZ"
    settings.specific.dftb.dftb.scc

    constraint1 = Distance(0, 4)
    constraint2 = Distance(2, 3)

    # scan input
    pes = PES(cnc,
              constraints=[constraint1, constraint2],
              offset=[2.3, 2.3],
              get_current_values=False,
              nsteps=2,
              stepsize=[0.1, 0.1])

    # returns a set of results object containing the output of
    # each point in the scan
    lt = pes.scan([dftb, adf], settings)

    # Gets the object presenting the molecule
    # with the maximum energy calculated from the scan
    apprTS = select_max(lt, "energy")

    # Run the TS optimization, using the default TS template
    ts = run(apprTS)

    expected_energy = -3.219708290363864

    assert abs(ts.energy - expected_energy) < 0.02
示例#9
0
def main(file_xyz, cell, restart, basis, basis_folder):
    """
    Define which systems need to be calculated
    """
    system = Molecule(file_xyz)

    # Set path for basis set
    basisCP2K = join(basis_folder, "BASIS_MOLOPT")
    potCP2K = join(basis_folder, "GTH_POTENTIALS")

    # Settings specifics
    s = templates.singlepoint
    del s.specific.cp2k.force_eval.dft.print.mo
    s.basis = basis
    s.potential = "GTH-PBE"
    s.cell_parameters = cell
    s.specific.cp2k.force_eval.dft.basis_set_file_name = basisCP2K
    s.specific.cp2k.force_eval.dft.potential_file_name = potCP2K
    s.specific.cp2k.force_eval.dft.print.pdos.nlumo = '1000'
    s.specific.cp2k.force_eval.dft.wfn_restart_file_name = '{}'.format(restart)
    s.specific.cp2k.force_eval.dft.scf.ot.minimizer = 'DIIS'
    s.specific.cp2k.force_eval.dft.scf.ot.n_diis = 7
    s.specific.cp2k.force_eval.dft.scf.ot.preconditioner = 'FULL_SINGLE_INVERSE'
    s.specific.cp2k['global']['run_type'] = 'energy'

    # =======================
    # Compute OPT files with CP2k
    # =======================

    result = run(cp2k(s, system))

    # ======================
    # Output the results
    # ======================

    print(result.energy)
示例#10
0
plams.init()

# User Defined imports
from qmworks.packages.SCM import dftb, adf

# from qmworks.components import adffragmentsjob

rdmol = Chem.MolFromPDBFile('Dialanine.pdb')
supermol = rdopp.add_prot_Hs(rdmol)

# settings = Settings ()
# settings.functional = 'bp86'
#
# settings.basis = 'DZP'
# settings.specific.adf.basis.core = 'Large'

# supermolecule calculation
# supermol_job =  adf(templates.singlepoint.overlay(settings), supermol, job_name = 'supermol_singlepoint')
supermol_job =  dftb(templates.singlepoint, supermol, job_name = 'supermol_singlepoint')
# supermol_dipole = supermol_results.get_dipole_vector()

#frags,caps = rdkitTools.partition_protein(supermol, cap=None)
frags, caps = rdopp.partition_protein(supermol, cap=None)
# mfcc_job = mfcc(adf, frags, caps, settings)
mfcc_job = mfcc(dftb, frags, caps)

supermol_result, mfcc_result = run(gather(supermol_job, mfcc_job))

print(supermol_result.dipole)
print(mfcc_result.dipole)
示例#11
0
def workflow_oscillator_strength(
        package_name: str,
        project_name: str,
        package_args: Dict,
        guess_args: Dict = None,
        geometries: List = None,
        dictCGFs: Dict = None,
        enumerate_from: int = 0,
        calc_new_wf_guess_on_points: str = None,
        path_hdf5: str = None,
        package_config: Dict = None,
        work_dir: str = None,
        initial_states: Any = None,
        final_states: Any = None,
        traj_folders: List = None,
        hdf5_trans_mtx: str = None,
        nHOMO: int = None,
        couplings_range: Tuple = None,
        calculate_oscillator_every: int = 50,
        convolution: str = 'gaussian',
        broadening: float = 0.1,  # eV
        energy_range: Tuple = None,  # eV
        geometry_units='angstrom',
        **kwargs):
    """
    Compute the oscillator strength

    :param package_name: Name of the package to run the QM simulations.
    :param project_name: Folder name where the computations
    are going to be stored.
    :param geometry:string containing the molecular geometry.
    :param package_args: Specific settings for the package
    :param guess_args: Specific settings for guess calculate with `package`.
    :type package_args: dict
    :param initial_states: List of the initial Electronic states.
    :type initial_states: [Int]
    :param final_states: List containing the sets of possible electronic
    states.
    :type final_states: [[Int]]
    :param calc_new_wf_guess_on_points: Points where the guess wave functions
    are calculated.
    :param package_config: Parameters required by the Package.
    :param  convolution: gaussian | lorentzian
    :param calculate_oscillator_every: step to compute the oscillator strengths
    :returns: None
    """
    # Start logging event
    file_log = '{}.log'.format(project_name)
    logging.basicConfig(filename=file_log,
                        level=logging.DEBUG,
                        format='%(levelname)s:%(message)s  %(asctime)s\n',
                        datefmt='%m/%d/%Y %I:%M:%S %p')

    # Point calculations Using CP2K
    mo_paths_hdf5 = calculate_mos(package_name,
                                  geometries,
                                  project_name,
                                  path_hdf5,
                                  traj_folders,
                                  package_args,
                                  guess_args,
                                  calc_new_wf_guess_on_points,
                                  enumerate_from,
                                  package_config=package_config)

    # geometries in atomic units
    molecules_au = [
        change_mol_units(parse_string_xyz(gs)) for gs in geometries
    ]

    # Construct initial and final states ranges
    initial_states, final_states = build_transitions(initial_states,
                                                     final_states, nHOMO)

    # Schedule the function the compute the Oscillator Strenghts
    scheduleOscillator = schedule(calcOscillatorStrenghts)

    oscillators = gather(*[
        scheduleOscillator(i,
                           project_name,
                           mo_paths_hdf5,
                           dictCGFs,
                           mol,
                           path_hdf5,
                           hdf5_trans_mtx=hdf5_trans_mtx,
                           initial_states=initial_states,
                           final_states=final_states)
        for i, mol in enumerate(molecules_au)
        if i % calculate_oscillator_every == 0
    ])

    energies, promised_cross_section = create_promised_cross_section(
        oscillators, broadening, energy_range, convolution,
        calculate_oscillator_every)

    cross_section, data = run(gather(promised_cross_section, oscillators),
                              folder=work_dir)

    # Transform the energy to nm^-1
    energies_nm = energies * 1240

    # Save cross section
    np.savetxt(
        'cross_section_cm.txt',
        np.stack((energies, energies_nm, cross_section, cross_section * 1e16),
                 axis=1),
        header=
        'Energy[eV] Energy[nm^-1] photoabsorption_cross_section[cm^2] photoabsorption_cross_section[^2]'
    )

    # molar extinction coefficients (e in M-1 cm-1)
    nA = physical_constants['Avogadro constant'][0]
    cte = np.log(10) * 1e3 / nA
    extinction_coefficients = cross_section / cte
    np.savetxt(
        'molar_extinction_coefficients.txt',
        np.stack((energies, energies_nm, extinction_coefficients), axis=1),
        header='Energy[eV] Energy[nm^-1] Extinction_coefficients[M^-1 cm^-1]')

    print("Data: ", data)
    print("Calculation Done")

    # Write data in human readable format
    write_information(data)

    return data
示例#12
0
def generate_pyxaid_hamiltonians(package_name: str,
                                 project_name: str,
                                 package_args: Dict,
                                 guess_args: Dict = None,
                                 geometries: List = None,
                                 dictCGFs: Dict = None,
                                 calc_new_wf_guess_on_points: str = None,
                                 path_hdf5: str = None,
                                 enumerate_from: int = 0,
                                 package_config: Dict = None,
                                 dt: float = 1,
                                 traj_folders: List = None,
                                 work_dir: str = None,
                                 basisname: str = None,
                                 hdf5_trans_mtx: str = None,
                                 nHOMO: int = None,
                                 couplings_range: Tuple = None,
                                 algorithm='levine',
                                 ignore_warnings=False,
                                 tracking=True) -> None:
    """
    Use a md trajectory to generate the hamiltonian components to run PYXAID
    nonadiabatic molecular dynamics.

    :param package_name: Name of the package to run the QM simulations.
    :param project_name: Folder name where the computations
    are going to be stored.
    :param package_args: Specific Settings for the package that will compute
    the MOs.
    :param geometries: List of string cotaining the molecular geometries
    numerical results.
    :paramter dictCGFS: Dictionary from Atomic Label to basis set
    :param calc_new_wf_guess_on_points: Calculate a guess wave function either
    in the first point or on each point of the trajectory.
    :param path_hdf5: path to the HDF5 file were the data is going to be stored.
    :param enumerate_from: Number from where to start enumerating the folders
    create for each point in the MD.
    :param hdf5_trans_mtx: Path into the HDF5 file where the transformation
    matrix (from Cartesian to sphericals) is stored.
    :param dt: Time used in the dynamics (femtoseconds)
    :param package_config: Parameters required by the Package.
    :type package_config: Dict
    :param nHOMO: index of the H**O orbital.
    :param couplings_range: Range of MO use to compute the nonadiabatic
    coupling matrix.

    :returns: None
    """
    # Start logging event
    file_log = '{}.log'.format(project_name)
    logging.basicConfig(filename=file_log,
                        level=logging.DEBUG,
                        format='%(levelname)s:%(message)s  %(asctime)s\n',
                        datefmt='%m/%d/%Y %I:%M:%S %p')

    # Log initial config information
    log_config(work_dir, path_hdf5, algorithm)

    # prepare Cp2k Jobs
    # Point calculations Using CP2K
    mo_paths_hdf5 = calculate_mos(package_name,
                                  geometries,
                                  project_name,
                                  path_hdf5,
                                  traj_folders,
                                  package_args,
                                  guess_args,
                                  calc_new_wf_guess_on_points,
                                  enumerate_from,
                                  package_config=package_config,
                                  ignore_warnings=ignore_warnings)

    # Overlap matrix at two different times
    promised_overlaps = calculate_overlap(project_name,
                                          path_hdf5,
                                          dictCGFs,
                                          geometries,
                                          mo_paths_hdf5,
                                          hdf5_trans_mtx,
                                          enumerate_from,
                                          nHOMO=nHOMO,
                                          couplings_range=couplings_range)

    # Calculate Non-Adiabatic Coupling
    schedule_couplings = schedule(lazy_couplings)
    promised_crossing_and_couplings = schedule_couplings(promised_overlaps,
                                                         path_hdf5,
                                                         project_name,
                                                         enumerate_from,
                                                         nHOMO,
                                                         dt,
                                                         tracking,
                                                         algorithm=algorithm)

    # Write the results in PYXAID format
    path_hamiltonians = join(work_dir, 'hamiltonians')
    if not os.path.exists(path_hamiltonians):
        os.makedirs(path_hamiltonians)

    # Inplace scheduling of write_hamiltonians function.
    # Equivalent to add @schedule on top of the function
    schedule_write_ham = schedule(write_hamiltonians)

    # Number of matrix computed
    nPoints = len(geometries) - 2

    # Write Hamilotians in PYXAID format
    promise_files = schedule_write_ham(path_hdf5,
                                       mo_paths_hdf5,
                                       promised_crossing_and_couplings,
                                       nPoints,
                                       path_dir_results=path_hamiltonians,
                                       enumerate_from=enumerate_from,
                                       nHOMO=nHOMO,
                                       couplings_range=couplings_range)

    run(promise_files, folder=work_dir)

    remove_folders(traj_folders)
# generate all jobs
job_list = []
for name in reaction_names:
    reactant = calc_reactant(name)
    product, TS = calc_productAndTS(name)
    job_list.append(gather(reactant, product, TS))

# Need also the energy of ethene
ethene = rdkitTools.smiles2plams('C=C')
E_ethene_job = dftb(templates.geometry.overlay(settings),
                    ethene,
                    job_name="ethene").energy

# Actual execution of the jobs
E_ethene, results = run(gather(E_ethene_job, gather(*job_list)), n_processes=1)


def bond_distance(r1, r2):
    return sqrt(sum((x - y)**2 for x, y in zip(r1, r2)))


# extract table from results
table = {}
for reactant, product, TS in results:

    # Retrieve the molecular coordinates
    mol = TS.molecule
    d1 = bond_distance(mol.atoms[0].coords, mol.atoms[1].coords)
    d2 = bond_distance(mol.atoms[3].coords, mol.atoms[4].coords)
    Eact = (TS.energy - E_ethene - reactant.energy) * hartree2kcal
示例#14
0
plams.init()

hartree2kcal = 627.5095


def bond_distance(r1, r2):
    return sqrt(sum((x - y)**2 for x, y in zip(r1, r2)))


startvalue = {'C': 2.1, 'N': 1.9, 'O': 1.8}

settings = Settings()
settings.specific.dftb.dftb.scc

ethene = rdkitTools.smiles2plams('C=C')
E_ethene = run(dftb(templates.geometry.overlay(settings), ethene)).energy

molecules = set()
result = {}
for a1 in ('C', 'N', 'O'):
    for a2 in ('N', 'O', 'S'):
        for a3 in ('C', 'N', 'O'):
            # reactant
            smiles = 'C1' + a1 + a2 + a3 + 'C1'
            reverse = 'C1' + a3 + a2 + a1 + 'C1'
            if reverse in molecules:  # skip duplicates
                continue
            molecules.add(smiles)
            print(smiles)
            product = rdkitTools.smiles2plams(smiles)
            E_product = dftb(templates.geometry.overlay(settings),
示例#15
0
        'nsteps': 6,
        'start': [2.3, 2.3],
        'stepsize': [0.1, 0.1]
    }
}

# returns a set of results object containing the output of
# each point in the scan
lt = PES_scan([dftb, adf], settings, cnc, scan)

# Gets the object presenting the molecule
# with the maximum energy calculated from the scan
apprTS = select_max(lt, "energy")

appr_hess = dftb(templates.freq.overlay(settings), apprTS.molecule)

t = Settings()
t.specific.adf.geometry.inithess = appr_hess.archive.path

# Run the TS optimization with ADF, using initial hessian from DFTB freq calculation
ts = run(adf(templates.ts.overlay(settings).overlay(t), appr_hess.molecule),
         n_processes=1)

# Retrieve the molecular coordinates
mol = ts.molecule
r1 = mol.atoms[0].coords
r2 = mol.atoms[4].coords

print("TS Bond distance:", bond_distance(r1, r2))
print("TS Energy:", ts.energy)
示例#16
0
    reactant = calc_reactant(name)
    product, adf_freq = calc_productAndTS(name)
    job_list.append(gather(reactant, product, adf_freq))

# Need also the energy of ethene
ethene = rdkitTools.smiles2rdkit('C=C')
E_ethene_job = adf(templates.geometry.overlay(settings),
                   ethene,
                   job_name="ethene").energy

# finalize and draw workflow
wf = gather(E_ethene_job, gather(*job_list))
draw_workflow("wf.svg", wf._workflow)

# Actual execution of the jobs
E_ethene, results = run(wf, n_processes=2)


def bond_distance(r1, r2):
    return sqrt(sum((x - y)**2 for x, y in zip(r1, r2)))


# extract table from results
table = {}
for reactant, product, TS in results:
    # Retrieve the molecular coordinates
    mol = TS.molecule
    d1 = bond_distance(mol.atoms[0].coords, mol.atoms[1].coords)
    d2 = bond_distance(mol.atoms[3].coords, mol.atoms[4].coords)

    Eact = (TS.energy - E_ethene - reactant.energy) * hartree2kcal
示例#17
0
    t = Settings()
    t.specific.adf.geometry.inithess = DFTBfreq.kf.path
    TS = adf(templates.ts.overlay(settings).overlay(t), DFTBfreq.molecule, job_name=name + "_TS")

    # Perform a freq calculation
    TSfreq = adf(templates.freq.overlay(settings), TS.molecule, job_name=name + "_freq")

  # Add the jobs to the job list
    job_list.append(gather(r1job, r2job, pjob, TSfreq, TS.optcycles))

# Finalize and draw workflow
wf = gather(*job_list)
draw_workflow("wf.svg", wf._workflow)

# Actual execution of the jobs
results = run(wf, n_processes=1)

# Extract table from results
table = {}
for r1result, r2result, presult, tsresult, optcycles in results:
    # Retrieve the molecular coordinates
    mol = tsresult.molecule
    d1 = bond1.get_current_value(mol)
    d2 = bond2.get_current_value(mol)

    Eact = (tsresult.energy - r1result.energy - r2result.energy) * hartree2kcal
    Ereact = (presult.energy - r1result.energy - r2result.energy) * hartree2kcal
    name = presult.molecule.properties.name
    smiles = presult.molecule.properties.smiles
    nnegfreq = sum([f < 0 for f in tsresult.frequencies])
    table[name] = [smiles, Eact, Ereact, d1, d2, nnegfreq, optcycles]
示例#18
0
HH = plams.Molecule("H_Mes2PCBH2_TS3series1.xyz")
HH.guess_bonds()
newmol = rdkitTools.apply_template(HH, template)
# Change the 2 hydrogens to dummy atoms
temp = rdkitTools.modify_atom(newmol, 47, '*')
temp = rdkitTools.modify_atom(temp, 48, '*')
# Put coordinates of dummy atoms to 0.0, this will force generating new
# coordinates for the new atoms
temp.atoms[47].move_to((0.0, 0.0, 0.0))
temp.atoms[48].move_to((0.0, 0.0, 0.0))

# Replace dummy atoms by new groups, generate coordinates only for new atoms
job_list = []
for mod, smirks in list_of_modifications.items():
    print(mod)
    temp2 = rdkitTools.apply_smirks(temp, smirks)[0]
    temp2 = rdkitTools.apply_smirks(temp2, smirks)[0]
    freeze = rdkitTools.gen_coords(temp2)
    # rdkitTools.write_molblock(temp2)
    # generate job
    s = Settings()
    s.freeze = [a + 1 for a in freeze]
    partial_geometry = adf(templates.geometry.overlay(s),
                           temp2,
                           job_name="partial_opt_" + mod)
    job_list.append(
        adf(templates.ts, partial_geometry.molecule, job_name="ts_" + mod))

results = run(gather(*job_list), n_processes=1)
示例#19
0
文件: mo_cp2k.py 项目: miroi/qmworks
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))
示例#20
0
def calculate_ETR(
        package_name: str, project_name: str, package_args: Dict,
        path_time_coeffs: str=None, geometries: List=None,
        initial_conditions: List=None, path_hdf5: str=None,
        basis_name: str=None,
        enumerate_from: int=0, package_config: Dict=None,
        calc_new_wf_guess_on_points: str=None, guess_args: Dict=None,
        work_dir: str=None, traj_folders: List=None,
        dictCGFs: Dict=None, orbitals_range: Tuple=None,
        pyxaid_HOMO: int=None, pyxaid_Nmin: int=None, pyxaid_Nmax: int=None,
        fragment_indices: None=List, dt: float=1, **kwargs):
    """
    Use a md trajectory to calculate the Electron transfer rate.

    :param package_name: Name of the package to run the QM simulations.
    :param project_name: Folder name where the computations
    are going to be stored.
    :param package_args: Specific settings for the package.
    :param path_hdf5: Path to the HDF5 file that contains the
    numerical results.
    :param geometries: List of string cotaining the molecular geometries.
    :paramter dictCGFS: Dictionary from Atomic Label to basis set
    :type     dictCGFS: Dict String [CGF],
              CGF = ([Primitives], AngularMomentum),
              Primitive = (Coefficient, Exponent)
    :param calc_new_wf_guess_on_points: number of Computations that used a
                                        previous calculation as guess for the
                                        wave function.
    :param nHOMO: index of the H**O orbital.
    :param couplings_range: Range of MO use to compute the nonadiabatic
    :param pyxaid_range: range of HOMOs and LUMOs used by pyxaid.
    :param enumerate_from: Number from where to start enumerating the folders
                           create for each point in the MD.
    :param traj_folders: List of paths to where the CP2K MOs are printed.
     :param package_config: Parameters required by the Package.
    :param fragment_indices: indices of atoms belonging to a fragment.
    :param dt: integration time used in the molecular dynamics.
    :returns: None
    """
    # Start logging event
    file_log = '{}.log'.format(project_name)
    logging.basicConfig(filename=file_log, level=logging.DEBUG,
                        format='%(levelname)s:%(message)s  %(asctime)s\n',
                        datefmt='%m/%d/%Y %I:%M:%S %p')

    # prepare Cp2k Job point calculations Using CP2K
    mo_paths_hdf5 = calculate_mos(
        package_name, geometries, project_name, path_hdf5, traj_folders,
        package_args, guess_args, calc_new_wf_guess_on_points,
        enumerate_from, package_config=package_config)

    # geometries in atomic units
    molecules_au = [change_mol_units(parse_string_xyz(gs))
                    for gs in geometries]

    # Time-dependent coefficients
    time_depend_coeffs = read_time_dependent_coeffs(path_time_coeffs)
    msg = "Reading time_dependent coefficients from: {}".format(path_time_coeffs)
    logger.info(msg)

    # compute_overlaps_ET
    scheduled_overlaps = schedule(compute_overlaps_ET)
    fragment_overlaps = scheduled_overlaps(
        project_name, molecules_au, basis_name, path_hdf5, dictCGFs,
        mo_paths_hdf5, fragment_indices, enumerate_from, package_name)

    # Delta time in a.u.
    dt_au = dt * femtosec2au

    # Indices relation between the PYXAID active space and the orbitals
    # stored in the HDF5
    map_index_pyxaid_hdf5 = create_map_index_pyxaid(
        orbitals_range, pyxaid_HOMO, pyxaid_Nmin, pyxaid_Nmax)

    # Number of ETR points calculated with the MD trajectory
    n_points = len(geometries) - 2

    # Read the swap between Molecular orbitals obtained from a previous
    # Coupling calculation
    swaps = read_swaps(path_hdf5, project_name)

    # Electron transfer rate for each frame of the Molecular dynamics
    scheduled_photoexcitation = schedule(compute_photoexcitation)
    etrs = scheduled_photoexcitation(
        path_hdf5, time_depend_coeffs, fragment_overlaps,
        map_index_pyxaid_hdf5, swaps, n_points, dt_au)

    # Execute the workflow
    electronTransferRates, path_overlaps = run(
        gather(etrs, fragment_overlaps), folder=work_dir)

    for i, mtx in enumerate(electronTransferRates):
        write_ETR(mtx, dt, i)

    write_overlap_densities(path_hdf5, path_overlaps, dt)
示例#21
0
plams.init()

# Read the Molecule from file
m_h2o_1 = Molecule('FDE-H2O-1.xyz')
m_h2o_2 = Molecule('FDE-H2O-2.xyz')
m_mol   = Molecule('FDE-mol.xyz')

m_tot = m_mol + m_h2o_1 + m_h2o_2

print(m_tot)

settings = Settings()
settings.basis = 'SZ'
settings.specific.adf.nosymfit = ''

# Prepare first water molecule
r_h2o_1 = adf(templates.singlepoint.overlay(settings), m_h2o_1, job_name="h2o_1")

# Prepare second water molecule
r_h2o_2 = adf(templates.singlepoint.overlay(settings), m_h2o_2, job_name="h2o_2")

frozen_frags = [Fragment(r_h2o_1, [m_h2o_1]),
                Fragment(r_h2o_2, [m_h2o_2])]

fde_res = run(fragmentsjob(settings, m_mol, *frozen_frags))

print(fde_res.dipole)


示例#22
0
constraint2 = "dist 3 4"

# scan input
scan = {
    'constraint': [constraint1, constraint2],
    'surface': {
        'nsteps': 6,
        'start': [2.3, 2.3],
        'stepsize': [0.1, 0.1]
    }
}

# returns a set of results object containing the output of
# each point in the scan
lt = PES_scan([dftb, adf], settings, cnc, scan)

# Gets the object presenting the molecule
# with the maximum energy calculated from the scan
apprTS = select_max(lt, "energy")

# Run the TS optimization, using the default TS template
ts = run(adf(templates.ts.overlay(settings), apprTS.molecule), n_processes=2)

# Retrieve the molecular coordinates
mol = ts.molecule
r1 = mol.atoms[0].coords
r2 = mol.atoms[4].coords

print("TS Bond distance:", bond_distance(r1, r2))
print("TS Energy:", ts.energy)