def calc_productAndTS(name): smiles = 'C1' + name + 'C1' mol = rdkitTools.smiles2plams(smiles) mol.properties.smiles = smiles product = dftb(templates.geometry.overlay(settings), mol, job_name=name + "_product") constraint1 = "dist 1 2" constraint2 = "dist 4 5" sv1 = startvalue[name[0]] sv2 = startvalue[name[2]] # scan input if name[0] == name[2]: # symmetric molecule scan = { 'constraint': [constraint1, constraint2], 'surface': { 'nsteps': 4, 'start': [sv1, sv2], 'stepsize': [0.1, 0.1] } } else: scan = { 'constraint': constraint1, 'surface': { 'nsteps': 4, 'start': sv1, 'stepsize': 0.1 }, 'scan': { 'constraint': constraint2, 'surface': { 'nsteps': 4, 'start': sv2, 'stepsize': 0.1 } } } # PES = gathered (promised) result objects for each point in the scan PES = PES_scan(dftb, settings, product.molecule, scan, job_name=name + "_PESscan") # get the object presenting the molecule with the maximum energy calculated from the scan apprTS = select_max(PES, 'energy') # perform the TS optimization using the default TS template TS = dftb(templates.ts.overlay(settings), apprTS.molecule, job_name=name + "_TS") return product, TS
def calc_reactant(name): smiles = {'C': '[CH2]=', 'N': '[NH]=', 'O': 'O='}[name[0]] +\ {'N': '[NH+]', 'O': '[O+]', 'S': '[S+]'}[name[1]] +\ {'C': '[CH2-]', 'N': '[NH-]', 'O': '[O-]'}[name[2]] mol = rdkitTools.smiles2plams(smiles) mol.properties.smiles = smiles return dftb(templates.geometry.overlay(settings), mol, job_name=name + "_reactant")
def calc_reactant(name): smiles = {'C': '[CH]#', 'N': '[N]#'}[name[0]] + "[N+]" +\ {'C': '[CH2-]', 'N': '[NH-]', 'O': '[O-]'}[name[2]] mol = rdkitTools.smiles2plams(smiles) mol.properties.smiles = smiles reactant = adf(templates.geometry.overlay(settings), dftb(templates.geometry.overlay(settings), mol, job_name=name + "_reactant_DFTB").molecule, job_name=name + "_reactant") return reactant
def calc_productAndTS(name): smiles = 'C1' + name[0] + "=" + name[1:] + 'C1' mol = rdkitTools.smiles2plams(smiles) mol.properties.smiles = smiles product = adf(templates.geometry.overlay(settings), dftb(templates.geometry.overlay(settings), mol, job_name=name + "_product_DFTB").molecule, job_name=name + "_product") constraint1 = Distance(1, 0) constraint2 = Distance(4, 3) # scan input pes = PES(product.molecule, constraints=[constraint1, constraint2], offset=[2.0, 2.0], get_current_values=False, nsteps=5, stepsize=[0.1, 0.1]) # PES = gathered (promised) result objects for each point in the scan pesscan = pes.scan([dftb, adf], settings, job_name=name + "_PES") # get the object presenting the molecule with the maximum energy # calculated from the scan apprTS = select_max(pesscan, 'energy') DFTB_freq = dftb(templates.freq.overlay(settings), apprTS.molecule, job_name=name + "_DFTBfreq") t = Settings() t.specific.adf.geometry.inithess = DFTB_freq.kf.path # Run the TS optimization, using the default TS template TS = adf(templates.ts.overlay(settings).overlay(t), DFTB_freq.molecule, job_name=name + "_TS") adf_freq = adf(templates.freq.overlay(settings), TS.molecule, job_name=name + "_freq") return product, adf_freq
def test_SerMolecule(): mol = rdkitTools.smiles2plams("c1ccccc1CC") registry = packages.registry() encoded_molecule = registry.deep_encode(mol) decoded_molecule = registry.deep_decode(encoded_molecule) assert len(mol) == len(decoded_molecule)
name = a1 + a2 + a3 reverse = a3 + a2 + a1 if reverse in reaction_names: # skip duplicates continue reaction_names.add(name) print(name) # 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:
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)
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: # Prepare reactant1 job r1mol = rdkitTools.smiles2plams(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 = rdkitTools.smiles2plams(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
reaction_names = set() for a1 in ('C', 'N'): for a3 in ('C', 'N', 'O'): name = a1 + 'N' + a3 reaction_names.add(name) print(name) # generate all jobs job_list = [] for name in reaction_names: reactant = calc_reactant(name) product, adf_freq = calc_productAndTS(name) job_list.append(gather(reactant, product, adf_freq)) # Need also the energy of ethene acetylene = rdkitTools.smiles2plams('C#C') E_acetylene_job = adf(templates.geometry.overlay(settings), acetylene, job_name="acetylene").energy # Actual execution of the jobs E_acetylene, results = run(gather(E_acetylene_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: