def run_scf_qmmm_solvent(mol, fname_pqr, solvent_radii, solvent_lebedev_order): from pyscf import scf, qmmm # , solvent import ddcosmo_qmmm """ There is one key difference between pyscf.solvent.ddcosmo and ddcosmo_qmmm. The former (pyscf) generates the grid points of both QM and MM regions, which are used to estimate the electronic density. 'ddcosmo_qmmm' does not generate the grid points in the MM region. """ mm_atm_list, mm_xyz_list, mm_q_list = parmed_load_pqr(fname_pqr) mm_mol = qmmm.create_mm_mol(mm_atm_list, mm_q_list, unit='Bohr') qmmm_sol = ddcosmo_qmmm.DDCOSMO(mol, mm_mol) #wat_radius = 1.4*ang2bohr #qmmm_sol.radii_table = radii.VDW + wat_radius qmmm_sol.radii_table = solvent_radii qmmm_sol.lebedev_order = solvent_lebedev_order # ddCOSMO-QMMM-SCF mf = mol.RHF() mf = mf.QMMM(mm_xyz_list, mm_q_list) mf = ddcosmo_qmmm.ddcosmo_for_scf(mf, qmmm_sol) # mf.DDCOSMO(qmmm_sol) mf.run(verbose=0) #print('DONE RHF/MM/SOLVENT', mf.e_tot) return mf
def _pyscf_qmmm(qm_atnm, qm_crds, qm_basis, qm_chg_tot, mm_crds, mm_q_list, l_esp=False, esp_opts={}): atm_list = [] for ia, xyz in enumerate(qm_crds): sym = qm_atnm[ia] # .split(':')[0] atm_list.append([sym, (xyz[0], xyz[1], xyz[2])]) #print(ia, sym, xyz) #print('qm_chg_tot', qm_chg_tot) qm_mol = _pyscf_mol_build(atm_list, qm_basis, qm_chg_tot) mm_mol = qmmm.create_mm_mol(mm_crds, mm_q_list, unit='Bohr') mf = qmmm.qmmm_for_scf(scf.RHF(qm_mol), mm_mol) mf.run() ener_QMMM = mf.e_tot grds_QM = mf.Gradients().kernel() qm_dm = mf.make_rdm1() grds_MM = _pyscf_mm_gradients(qm_mol, qm_dm, mm_mol) esp_chg = None if l_esp: esp_chg = esp_atomic_charges(qm_mol, qm_dm, esp_opts) return ener_QMMM, grds_QM, grds_MM, esp_chg
# load all modeuls from pyscf import __all__ mol = gto.M(atom=''' C 0.000000 0.000000 -0.542500 O 0.000000 0.000000 0.677500 H 0.000000 0.9353074360871938 -1.082500 H 0.000000 -0.9353074360871938 -1.082500 ''', verbose=4) numpy.random.seed(1) coords = numpy.random.random((5, 3)) * 10 charges = (numpy.arange(5) + 1.) * .1 mm_atoms = [('C', c) for c in coords] mm_mol = qmmm.create_mm_mol(mm_atoms, charges) # Make a giant system include both QM and MM particles qmmm_mol = mol + mm_mol # The solvent model is based on the giant system sol = solvent.DDCOSMO(qmmm_mol) # According to Lipparini's suggestion in issue #446 sol.radii_table = radii.VDW # # The order to apply solvent model and QM/MM charges does not affect results # # ddCOSMO-QMMM-SCF #