示例#1
0
def example_FDE_fragments():
    # For the purpose of the example, define xyz files here:
    xyz1 = io.StringIO('''3

    O         0.00000000000000     -2.29819386240000      1.63037963360000
    H        -0.76925379540000     -2.28223123190000      2.22684542850000
    H         0.76925379540000     -2.28223123190000      2.22684542850000''')

    xyz2 = io.StringIO('''3

    O         0.00000000000000      2.29819386240000      1.63037963360000
    H        -0.76925379540000      2.28223123190000      2.22684542850000
    H         0.76925379540000      2.28223123190000      2.22684542850000''')

    xyz3 = io.StringIO('''3

    O         0.00000000000000      0.00000000000000     -0.26192472620000
    H         0.00000000000000      0.77162768440000      0.34261631290000
    H         0.00000000000000     -0.77162768440000      0.34261631290000''')

    # Read the Molecule from file
    m_h2o_1 = Molecule()
    m_h2o_1.readxyz(xyz1, 1)
    m_h2o_2 = Molecule()
    m_h2o_2.readxyz(xyz2, 1)
    m_mol = Molecule()
    m_mol.readxyz(xyz3, 1)

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

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

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

    frags = gather(schedule(Fragment)(r_h2o_1, m_h2o_1, isfrozen=True),
                   schedule(Fragment)(r_h2o_2, m_h2o_2, isfrozen=True),
                   Fragment(None, m_mol))

    job_fde = adf_fragmentsjob(templates.singlepoint. overlay(settings), frags,
                               job_name="test_fde_fragments")

    # Perform FDE job and get dipole
    # This gets the dipole moment of the active subsystem only
    dipole_fde = run(job_fde.dipole)

    print('FDE dipole:', dipole_fde)

    return dipole_fde
示例#2
0
文件: fde.py 项目: SCM-NV/qmworks
def adf_fragmentsjob(settings, frags, caps=None, fragment_settings=None, job_name='fde'):
    mol_tot = Molecule()
    frag_settings = Settings()
    cap_ids = {}
    if caps:
        for i, cap in enumerate(caps):
            cap_id = 'cap' + str(i + 1)
            for a in cap.mol:
                cap_ids[a.coords] = cap_id
            path = cap.result.kf.path
            key = cap_id + ' ' + path + ' type=FDEsubstract &'
            frag_settings.specific.adf.fragments[key] = fragment_settings
    for i, frag in enumerate(frags):
        frag_id = 'frag' + str(i + 1)
        if frag.result:
            for a in frag.mol:
                a.properties.adf.fragment = frag_id
                if a.coords in cap_ids:
                    a.properties.adf.fragment += '  fs=' + cap_ids[a.coords]
            path = frag.result.kf.path
            key = frag_id + ' ' + path + ' subfrag=active'
            if frag.isfrozen:
                key += ' type=FDE'
                if fragment_settings:
                    key += ' &'
                    frag_settings.specific.adf.fragments[key] = fragment_settings
                else:
                    frag_settings.specific.adf.fragments[key] = ""
            else:
                frag_settings.specific.adf.fragments[key] = ""
        mol_tot += frag.mol
    frag_settings.specific.adf.fde.PW91k = ""
    return adf(settings.overlay(frag_settings), mol_tot, job_name=job_name)
示例#3
0
文件: fde.py 项目: boyuezhong/qmflows
def adf_fragmentsjob(settings,
                     frags,
                     caps=None,
                     fragment_settings=None,
                     job_name='fde'):
    mol_tot = Molecule()
    frag_settings = Settings()
    cap_ids = {}
    if caps:
        for i, cap in enumerate(caps):
            cap_id = 'cap' + str(i + 1)
            for a in cap.mol:
                cap_ids[a.coords] = cap_id
            path = cap.result.kf.path
            key = cap_id + ' ' + path + ' type=FDEsubstract &'
            frag_settings.specific.adf.fragments[key] = fragment_settings
    for i, frag in enumerate(frags):
        frag_id = 'frag' + str(i + 1)
        if frag.result:
            for a in frag.mol:
                a.properties.adf.fragment = frag_id
                if a.coords in cap_ids:
                    a.properties.adf.fragment += '  fs=' + cap_ids[a.coords]
            path = frag.result.kf.path
            key = frag_id + ' ' + path + ' subfrag=active'
            if frag.isfrozen:
                key += ' type=FDE'
                if fragment_settings:
                    key += ' &'
                    frag_settings.specific.adf.fragments[
                        key] = fragment_settings
                else:
                    frag_settings.specific.adf.fragments[key] = ""
            else:
                frag_settings.specific.adf.fragments[key] = ""
        mol_tot += frag.mol
    frag_settings.specific.adf.fde.PW91k = ""
    return adf(settings.overlay(frag_settings), mol_tot, job_name=job_name)
示例#4
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)
settings.specific.orca.basis.basis = "_6_31G"
settings.specific.orca.basis.pol = "_d"
settings.specific.orca.basis.diff = "_p"
settings.specific.dftb.dftb.scc.ndiis = 4
settings.specific.dftb.dftb.scc.Mixing = 0.1
settings.specific.dftb.dftb.scc.iterations = 300


job_list = []
# Loop over all reactions
for name, r1_smiles, r2_smiles, p_smiles in reactions:

  # Prepare reactant1 job
    r1_mol =  molkit.from_smiles(r1_smiles)
    r1_dftb = dftb(templates.geometry.overlay(settings), r1_mol, job_name=name + "_r1_DFTB")
    r1 =      adf(templates.geometry.overlay(settings), r1_dftb.molecule, job_name=name + "_r1")
    r1_freq = adf(templates.freq.overlay(settings), r1.molecule, job_name=name + "_r1_freq")

  # Prepare reactant2 job
    r2s_mol =  molkit.from_smiles(r2_smiles, nconfs=10, forcefield='mmff', rms=0.1)
    r2s_dftb = [dftb(templates.geometry.overlay(settings), r2_mol, job_name=name + "_r2_DFTB") for r2_mol in r2s_mol]
    r2_dftb = select_min(gather(*r2s_dftb), 'energy')
    r2 =      adf(templates.geometry.overlay(settings), r2_dftb.molecule, job_name=name + "_r2")
    r2_freq = adf(templates.freq.overlay(settings), r2.molecule, job_name=name + "_r2_freq")

# Prepare product job
    ps_mol =  molkit.from_smiles(p_smiles, nconfs=10, forcefield='mmff', name=name, rms=0.1)
    ps_dftb = [dftb(templates.geometry.overlay(settings), p_mol, job_name=name + "_ps_DFTB") for p_mol in ps_mol]
    p_dftb = select_min(gather(*ps_dftb), 'energy')
    p =      adf(templates.geometry.overlay(settings), p_dftb.molecule, job_name=name + "_p")
    p_freq = adf(templates.freq.overlay(settings), p.molecule, job_name=name + "_p_freq")
示例#6
0
# User define Settings
settings = Settings()
settings.functional = "pbe"
settings.basis = "TZ2P"
settings.specific.dftb.dftb.scc


job_list = []
# Loop over all reactions
for name, reactant1, reactant2, product in reactions[:1]:

  # Prepare reactant1 job
    r1mol = molkit.from_smiles(reactant1)
    r1job = adf(
        templates.geometry.overlay(settings),
        dftb(templates.geometry.overlay(settings), r1mol,
             job_name=name + "_r1_DFTB").molecule,
        job_name=name + "_r1")

  # Prepare reactant2 job
    r2mol = molkit.from_smiles(reactant2)
    r2job = adf(
        templates.geometry.overlay(settings),
        dftb(templates.geometry.overlay(settings), r2mol,
             job_name=name + "_r2_DFTB").molecule,
        job_name=name + "_r2")

  # Prepare product job
    pmol = molkit.from_smiles(product)
    pmol.properties.name = name
    pjob = adf(
示例#7
0
# 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
workflow = adf(templates.ts.overlay(settings).overlay(t), appr_hess.molecule)

with XenonKeeper() as Xe:
    xenon_config = XenonConfig(jobs_scheme='slurm', location=None)

    job_config = RemoteJobConfig(
        registry=registry,
        prefix='/home/jhidding/venv',

        # the working_dir should exist and contain a file called worker.sh
        working_dir='/home/jhidding/qm-test',
        init=init,
        finish=finish,
        time_out=1)

    ts = run_xenon(Xe, 4, xenon_config, job_config, workflow)
示例#8
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")

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

from noodles.run.xenon import (XenonKeeper, XenonConfig, RemoteJobConfig,
                               run_xenon)

with XenonKeeper() as Xe:
    xenon_config = XenonConfig(jobs_scheme='slurm', location=None)

    job_config = RemoteJobConfig(
        registry=registry,
        prefix='/home/jhidding/venv',

        # the working_dir should exist and contain a file called worker.sh
        working_dir='/home/jhidding/qm-test',
        init=init,
        finish=finish,