Esempio n. 1
0
def test_selected_atoms_with_orca():
    mol = molkit.from_smiles('CO')
    s = Settings()
    s.selected_atoms = ["H"]
    expected_settings = Settings({
        'selected_atoms': ['H'],
        'specific': {
            'orca': {
                'geom': {
                    'Constraints': {
                        '_end': '{ C 0 C }{ C 1 C }'
                    }
                }
            }
        }
    })
    assert str(orca.generic2specific(s, mol)) == str(expected_settings)
    s.selected_atoms = [3, 4, 5, 6]
    expected_settings = Settings({
        'selected_atoms': [3, 4, 5, 6],
        'specific': {
            'orca': {
                'geom': {
                    'Constraints': {
                        '_end': '{ C 0 C }{ C 1 C }'
                    }
                }
            }
        }
    })
    assert str(orca.generic2specific(s, mol)) == str(expected_settings)
Esempio n. 2
0
def test_freeze_with_adf():
    mol = molkit.from_smiles('CO')
    s = Settings()
    s.freeze = ["C", "O"]
    expected_settings = Settings({
        'freeze': ["C", "O"],
        'specific': {
            'adf': {
                'constraints': {
                    'atom 1': '',
                    'atom 2': ''
                },
                'geometry': {
                    'optim': 'cartesian'
                }
            }
        }
    })
    assert str(adf.generic2specific(s, mol)) == str(expected_settings)
    s.freeze = [1, 2]
    expected_settings = Settings({
        'freeze': [1, 2],
        'specific': {
            'adf': {
                'constraints': {
                    'atom 1': '',
                    'atom 2': ''
                },
                'geometry': {
                    'optim': 'cartesian'
                }
            }
        }
    })
    assert str(adf.generic2specific(s, mol)) == str(expected_settings)
Esempio n. 3
0
def test_selected_atoms_with_adf():
    mol = molkit.from_smiles('CO')
    s = Settings()
    s.selected_atoms = ["H"]
    expected_settings = Settings({
        'selected_atoms': ['H'],
        'specific': {
            'adf': {
                'constraints': {
                    'atom 1': '',
                    'atom 2': ''
                },
                'geometry': {
                    'optim': 'cartesian'
                }
            }
        }
    })
    assert str(adf.generic2specific(s, mol)) == str(expected_settings)
    s.selected_atoms = [3, 4, 5, 6]
    expected_settings = Settings({
        'selected_atoms': [3, 4, 5, 6],
        'specific': {
            'adf': {
                'constraints': {
                    'atom 1': '',
                    'atom 2': ''
                },
                'geometry': {
                    'optim': 'cartesian'
                }
            }
        }
    })
    assert str(adf.generic2specific(s, mol)) == str(expected_settings)
Esempio n. 4
0
def test_freeze_with_orca():
    mol = molkit.from_smiles('CO')
    s = Settings()
    s.freeze = ["C", "O"]
    expected_settings = Settings({
        'freeze': ['C', 'O'],
        'specific': {
            'orca': {
                'geom': {
                    'Constraints': {
                        '_end': '{ C 0 C }{ C 1 C }'
                    }
                }
            }
        }
    })
    assert str(orca.generic2specific(s, mol)) == str(expected_settings)
    s.freeze = [1, 2]
    expected_settings = Settings({
        'freeze': [1, 2],
        'specific': {
            'orca': {
                'geom': {
                    'Constraints': {
                        '_end': '{ C 0 C }{ C 1 C }'
                    }
                }
            }
        }
    })
    assert str(orca.generic2specific(s, mol)) == str(expected_settings)
Esempio n. 5
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. 6
0
def test_adf_props():
    """
    Get properties from ADF freq calc
    """

    mol = molkit.from_smiles('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 = 3480.90
    assert abs(result.frequencies[1] - expected_frequency) < 0.1
    assert len(result.charges) == 2
    assert abs(result.charges[0] + result.charges[1]) < 1e-6
Esempio n. 7
0
def example_generic_constraints():
    """
    This examples illustrates that, by using generic keywords, it is possible
    to call different packages interchangeably with the same Settings
    """

    # build hydrogen fluoride molecule
    hydrogen_fluoride = molkit.from_smiles('F[H]')

    # loop over distances
    jobs = []
    for distance in [1.0, 1.1, 1.2]:
        s = Settings()
        s.constraint['dist 1 2'] = distance
        # loop over packages
        for package in [dftb, adf, orca]:
            job_name = package.pkg_name + '_' + str(distance)
            constraint_opt = package(templates.geometry.overlay(s),
                                     hydrogen_fluoride, job_name)
            jobs.append(constraint_opt)

    # run the jobs
    results = run(gather(*jobs))
    energies = [r.energy for r in results]
    names = [r.job_name for r in results]

    # put resulting energies into a dictionary
    table = {'dftb': {}, 'adf': {}, 'orca': {}}
    for r in results:
        package, distance = r.job_name.split('_')
        table[package][distance] = round(r.energy, 6)

    # print table
    hartree_to_kcalpermol = 627.094
    for package in ['dftb', 'adf', 'orca']:
        row = [package]
        for distance in ['1.0', '1.1', '1.2']:
            val = table[package][distance] - table[package]['1.0']
            row.append(round(val * hartree_to_kcalpermol, 2))
        print('{:10s} {:10.2f} {:10.2f} {:10.2f}'.format(*row))

    return names, energies
Esempio n. 8
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. 9
0
def test_hessian_transfer():
    """
    Test DFTB -> Orca hessian transfer
    """
    h2o = molkit.from_smiles('O')
    h2o.properties.symmetry = 'C1'

    h2o_freq = dftb(templates.freq, h2o, job_name="freq").hessian

    s = Settings()
    s.inithess = h2o_freq

    h2o_opt = orca(templates.geometry.overlay(s), h2o, job_name="opt")

    energy = h2o_opt.energy
    dipole = h2o_opt.dipole

    wf = gather(energy, dipole)
    # draw_workflow('wf.svg', wf._workflow)

    print(run(wf))
Esempio n. 10
0
def example_partial_geometry_opt():
    """
    Performa partial optimization freezing the Hydrogen atoms
    """
    methanol = molkit.from_smiles('CO')

    # optimize only H atoms
    s = Settings()
    s.freeze = [1, 2]
    geom_job1 = adf(templates.geometry.overlay(s),
                    methanol,
                    job_name='geom_job1').molecule

    # optimize only H atoms
    s = Settings()
    s.selected_atoms = ['H']
    geom_job2 = adf(templates.geometry.overlay(s),
                    methanol,
                    job_name='geom_job2').molecule

    geom1, geom2 = run(gather(geom_job1, geom_job2), n_processes=1)

    return geom1, geom2
Esempio n. 11
0
def test_freeze_with_gamess():
    mol = molkit.from_smiles('CO')
    s = Settings()
    s.freeze = ["C", "O"]
    expected_settings = Settings({
        'freeze': ['C', 'O'],
        'specific': {
            'gamess': {
                'statpt': 'IFREEZ(1)=1,2,3,4,5,6'
            }
        }
    })
    assert str(gamess.generic2specific(s, mol)) == str(expected_settings)
    s = Settings()
    s.freeze = [1, 2]
    expected_settings = Settings({
        'freeze': [1, 2],
        'specific': {
            'gamess': {
                'statpt': 'IFREEZ(1)=1,2,3,4,5,6'
            }
        }
    })
    assert str(gamess.generic2specific(s, mol)) == str(expected_settings)
Esempio n. 12
0
def test_selected_atoms_with_gamess():
    mol = molkit.from_smiles('CO')
    s = Settings()
    s.selected_atoms = ["H"]
    expected_settings = Settings({
        'selected_atoms': ['H'],
        'specific': {
            'gamess': {
                'statpt': 'IFREEZ(1)=1,2,3,4,5,6'
            }
        }
    })
    assert str(gamess.generic2specific(s, mol)) == str(expected_settings)
    s = Settings()
    s.selected_atoms = [3, 4, 5, 6]
    expected_settings = Settings({
        'selected_atoms': [3, 4, 5, 6],
        'specific': {
            'gamess': {
                'statpt': 'IFREEZ(1)=1,2,3,4,5,6'
            }
        }
    })
    assert str(gamess.generic2specific(s, mol)) == str(expected_settings)
Esempio n. 13
0
def test_SerMolecule():
    mol = molkit.from_smiles("c1ccccc1CC")
    registry = packages.registry()
    encoded_molecule = registry.deep_encode(mol)
    decoded_molecule = registry.deep_decode(encoded_molecule)
    assert len(mol) == len(decoded_molecule)
Esempio n. 14
0
    """get the base job name"""
    name = job.job_name
    return name.split('_')[1]


# 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'
Esempio n. 15
0
bond1 = Distance(1, 0)
bond2 = Distance(4, 3)

# 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
Esempio n. 16
0
settings = Settings()
settings.functional = "b3lyp"
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')
Esempio n. 17
0
from qmflows.molkit import from_smiles

# List of Molecules to simulate
smiles = ['C1=CC2=C(C=C1)C=CC=C2', 'C1CC2(CCCCC2)C=C1']

# Transform the smiles into a format understandable by QMFlows
molecules = [from_smiles(s) for s in smiles]