Esempio n. 1
0
def test_freq():
    """Do some constraint optimizations then launch a freq calc."""
    mol = Molecule(PATH_MOLECULES / "ethene.xyz", "xyz")
    geo_opt = dftb(templates.geometry, mol)
    freq_calc = dftb(templates.freq, geo_opt.molecule, job_name="freq")
    r = run(freq_calc)
    assertion.eq(int(r.frequencies[0]), 831)
    assertion.len_eq(r.frequencies, 12)
Esempio n. 2
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
Esempio n. 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
Esempio n. 4
0
def test_dftb_opt_mock(mocker: MockFixture):
    """Mock a geometry optimization using DFTB."""
    jobname = "dftb_geometry"
    job = dftb(templates.geometry, WATER, job_name=jobname)

    run_mocked = mock_runner(mocker, jobname)
    rs = run_mocked(job)

    # check the properties
    assertion.isfinite(rs.energy)
    assertion.len_eq(rs.dipole, 3)
    assertion.isinstance(rs.molecule, Molecule)
Esempio n. 5
0
def example_H2O2_TS():
    """
    This example generates an approximate TS for rotation in hydrogen peroxide
    using DFTB, and performs a full TS optimization in Orca.
    It illustrates using a hessian from one package, DFTB in this case,
    to initialize a TS optimization in another, i.e. Orca in this case
    """

    # Generate hydrogen peroxide molecule
    h2o2 = molkit.from_smarts('[H]OO[H]')

    # Define dihedral angle
    dihe = Dihedral(1, 2, 3, 4)

    # Constrained geometry optimization with DFTB
    # The dihedral is set to 0.0 to obtain an approximate TS
    s1 = Settings()
    s1.constraint.update(dihe.get_settings(0.0))
    dftb_opt = dftb(templates.geometry.overlay(s1), h2o2)

    # Calculate the DFTB hessian
    dftb_freq = dftb(templates.freq, dftb_opt.molecule)

    # Transition state calculation using the DFTB hessian as starting point
    s2 = Settings()
    s2.inithess = dftb_freq.hessian
    orca_ts = orca(templates.ts.overlay(s2), dftb_opt.molecule)

    # Execute the workflow
    result = run(orca_ts)

    # Analyse the result
    ts_dihe = round(dihe.get_current_value(result.molecule))
    n_optcycles = result.optcycles

    print('Dihedral angle (degrees): {:.0f}'.format(ts_dihe))
    print('Number of optimization cycles: {:d}'.format(n_optcycles))

    return ts_dihe, n_optcycles
Esempio n. 6
0
def test_dftb_props():
    """
    Get properties from DFTB freq calc
    """

    mol = molkit.from_smiles('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 = 3460.92
    assert abs(result.frequencies - expected_frequency) < 0.1
    assert len(result.charges) == 2
    assert abs(result.charges[0] + result.charges[1]) < 1e-6
Esempio n. 7
0
def test_dftb_props():
    """
    Get properties from DFTB freq calc
    """

    mol = molkit.from_smiles('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 = 3460.92
    assert abs(result.frequencies - expected_frequency) < 0.1
    assert len(result.charges) == 2
    assert abs(result.charges[0] + result.charges[1]) < 1e-6
Esempio n. 8
0
def test_dftb_freq_mock(mocker: MockFixture):
    """Mock a geometry optimization using DFTB."""
    jobname = "dftb_freq"
    job = dftb(templates.geometry, WATER, job_name=jobname)

    run_mocked = mock_runner(mocker, jobname)
    rs = run_mocked(job)
    # Check that hessian is symmetric
    hess_list = rs.hessian
    dim = int(np.sqrt(len(hess_list)))
    hess = np.array(hess_list).reshape(dim, dim)
    assertion.isclose(np.sum(hess - hess.T), 0.0)

    # enthalpy and Gibbs free energy
    assertion.isfinite(rs.enthalpy)
    assertion.isfinite(rs.free_energy)

    # frequencies
    assertion.isfinite(np.sum(rs.frequencies))
Esempio n. 9
0
def example_freqs():
    """
    This examples illustrates the possibility to use different packages interchangeably.
    Analytical frequencies are not available for B3LYP in ADF
    This workflow captures the resulting error and submits the same job to ORCA.
    """
    # Generate water molecule
    water = molkit.from_smiles('[OH2]', forcefield='mmff')

    # Pre-optimize the water molecule
    opt_water = dftb(templates.geometry, water, job_name="dftb_geometry")

    jobs = []

    # Generate freq jobs for 3 functionals
    for functional in ['pbe', 'b3lyp', 'blyp']:
        s = Settings()
        s.basis = 'DZ'
        s.functional = functional
        # Try to perform the jobs with adf or orca, take result from  first successful calculation
        freqjob = find_first_job(is_successful, [adf, orca],
                                 templates.freq.overlay(s),
                                 opt_water.molecule,
                                 job_name=functional)
        jobs.append(freqjob)

    # Run workflow
    results = run(gather(*jobs), n_processes=1)

    # extrac results
    freqs = [r.frequencies[-3:] for r in results]
    functionals = ['pbe', 'b3lyp', 'blyp']

    # Print the result
    table = [
        "{:10s}{:10.3f}{:10.3f}{:10.3f}\n".format(fun, *fs)
        for fun, fs in zip(functionals, freqs)
    ]
    print(table)

    return freqs
Esempio n. 10
0
def example_freqs():
    """
    This examples illustrates the possibility to use different packages interchangeably.
    Analytical frequencies are not available for B3LYP in ADF
    This workflow captures the resulting error and submits the same job to ORCA.
    """
    # Generate water molecule
    water = molkit.from_smiles('[OH2]', forcefield='mmff')

    # Pre-optimize the water molecule
    opt_water = dftb(templates.geometry, water, job_name="dftb_geometry")

    jobs = []

    # Generate freq jobs for 3 functionals
    for functional in ['pbe', 'b3lyp', 'blyp']:
        s = Settings()
        s.basis = 'DZ'
        s.functional = functional
        # Try to perform the jobs with adf or orca, take result from  first successful calculation
        freqjob = find_first_job(is_successful, [adf, orca], templates.freq.overlay(s),
                                 opt_water.molecule, job_name=functional)
        jobs.append(freqjob)

    # Run workflow
    results = run(gather(*jobs), n_processes=1)

    # extrac results
    freqs = [r.frequencies[-3:] for r in results]
    functionals = ['pbe', 'b3lyp', 'blyp']

    # Print the result
    table = ["{:10s}{:10.3f}{:10.3f}{:10.3f}\n".format(fun, *fs)
             for fun, fs in zip(functionals, freqs)]
    print(table)

    return freqs
Esempio n. 11
0
# List of Molecules to simulate
smiles = {
    'naphthalene': 'C1=CC2=C(C=C1)C=CC=C2',
    'azulene': 'C1=CC2=CC=CC=CC2=C1',
    'cycloheptatriene': 'C1=CC=C(C=C1)OC1=CC=CC=C1',
    'furaldehyde': 'O=CC1=COC=C1',
    'methylthiophene': 'CC1=C(C=CS1)C#C'
}

# transform the string into a format understandable by Qmflows
molecules = {name: from_smiles(smile) for name, smile in smiles.items()}

# Used DFTB to optimize the geometries
dftb_jobs = {
    name: dftb(templates.geometry, mol, job_name='dftb_{}'.format(name))
    for name, mol in molecules.items()
}
optimized_mols = {name: job.molecule for name, job in dftb_jobs.items()}

# Settings for ADF SAOP single point calculation
s = Settings()
s.basis = 'DZP'
s.specific.adf.basis.core = None
s.specific.adf.xc.model = 'saop'
s.specific.adf.scf.converge = 1e-6
s.specific.adf.symmetry = 'nosym'

# single point calculations using the SAOP functional
singlepoints = [
    adf(s, mol, job_name='adf_{}'.format(name))
Esempio n. 12
0
temp = molkit.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, freeze = molkit.apply_reaction_smarts(temp, smirks, complete=True)
    # generate job
    s = Settings()
    s.freeze = freeze
    s.specific.dftb.dftb.resourcesdir = 'QUASINANO2015'
    partial_geometry = dftb(templates.geometry.overlay(s),
                            temp2,
                            job_name="partial_opt_" + mod)
    freq_dftb = dftb(templates.freq.overlay(s),
                     partial_geometry.molecule,
                     job_name="freq_" + mod)
    s = Settings()
    s.specific.orca.main = "B97-D"
    s.specific.orca.basis.basis = "_6_31G"
    s.specific.orca.basis.pol = "_d"
    s.inithess = freq_dftb.hessian
    ts = orca(templates.ts.overlay(s),
              freq_dftb.molecule,
              job_name="ts_" + mod)
    freq = orca(templates.freq.overlay(s), ts.molecule, job_name="freq" + mod)
    job_list.append(freq)