pyscf.qmmm package#

Submodules#

pyscf.qmmm.itrf module#

QM/MM helper functions that modify the QM methods.

class pyscf.qmmm.itrf.QMMM[source]#

Bases: object

class pyscf.qmmm.itrf.QMMMGrad(scf_grad)[source]#

Bases: object

contract_hcore_mm(dm, mol=None)#

Nuclear gradients of the electronic energy with respect to MM atoms:

… math::

g = sum_{ij} frac{partial hcore_{ij}}{partial R_{I}} P_{ji},

where I represents MM atoms.

Args:
dmarray

The QM density matrix.

dump_flags(verbose=None)[source]#
get_hcore(mol=None)[source]#

(QM 1e grad) + <-d/dX i|q_mm/r_mm|j>

grad_hcore_mm(dm, mol=None)[source]#

Nuclear gradients of the electronic energy with respect to MM atoms:

… math::

g = sum_{ij} frac{partial hcore_{ij}}{partial R_{I}} P_{ji},

where I represents MM atoms.

Args:
dmarray

The QM density matrix.

grad_nuc(mol=None, atmlst=None)[source]#
grad_nuc_mm(mol=None)[source]#

Nuclear gradients of the QM-MM nuclear energy (in the form of point charge Coulomb interactions) with respect to MM atoms.

to_gpu()[source]#
class pyscf.qmmm.itrf.QMMMPostSCF(method, mm_mol=None)[source]#

Bases: QMMM

to_gpu()#
undo_qmmm()[source]#
class pyscf.qmmm.itrf.QMMMSCF(method, mm_mol=None)[source]#

Bases: QMMM

Gradients()#
dump_flags(verbose=None)[source]#
energy_nuc()[source]#
get_hcore(mol=None)[source]#
nuc_grad_method()[source]#
to_gpu()[source]#
undo_qmmm()[source]#
pyscf.qmmm.itrf.add_mm_charges(scf_method, atoms_or_coords, charges, radii=None, unit=None)[source]#

Embedding the one-electron (non-relativistic) potential generated by MM point charges into QM Hamiltonian.

The total energy includes the regular QM energy, the interaction between the nuclei in QM region and the MM charges, and the static Coulomb interaction between the electron density and the MM charges. It does not include the static Coulomb interactions of the MM point charges, the MM energy, the vdw interaction or other bonding/non-bonding effects between QM region and MM particles.

Args:

scf_method : a HF or DFT object

atoms_or_coords2D array, shape (N,3)

MM particle coordinates

charges1D array

MM particle charges

Kwargs:
radii1D array

The Gaussian charge distribution radii of MM atoms.

unitstr

Bohr, AU, Ang (case insensitive). Default is the same to mol.unit

Returns:

Same method object as the input scf_method with modified 1e Hamiltonian

Note:

1. if MM charge and X2C correction are used together, function mm_charge needs to be applied after X2C decoration (.x2c method), eg mf = mm_charge(scf.RHF(mol).x2c()), [(0.5,0.6,0.8)], [-0.5]). 2. Once mm_charge function is applied on the SCF object, it affects all the post-HF calculations eg MP2, CCSD, MCSCF etc

Examples:

>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = mm_charge(dft.RKS(mol), [(0.5,0.6,0.8)], [-0.3])
>>> mf.kernel()
-101.940495711284
pyscf.qmmm.itrf.add_mm_charges_grad(scf_grad, atoms_or_coords, charges, radii=None, unit=None)[source]#

Apply the MM charges in the QM gradients’ method. It affects both the electronic and nuclear parts of the QM fragment.

Args:
scf_grada HF or DFT gradient object (grad.HF or grad.RKS etc)

Once the add_mm_charges_grad was applied, it affects all post-HF calculations eg MP2, CCSD, MCSCF etc

coords2D array, shape (N,3)

MM particle coordinates

charges1D array

MM particle charges

Kwargs:
radii1D array

The Gaussian charge distribution radii of MM atoms.

unitstr

Bohr, AU, Ang (case insensitive). Default is the same to mol.unit

Returns:

Same gradeints method object as the input scf_grad method

Examples:

>>> from pyscf import gto, scf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = mm_charge(scf.RHF(mol), [(0.5,0.6,0.8)], [-0.3])
>>> mf.kernel()
-101.940495711284
>>> hfg = mm_charge_grad(grad.hf.RHF(mf), coords, charges)
>>> hfg.kernel()
[[-0.25912357 -0.29235976 -0.38245077]
 [-1.70497052 -1.89423883  1.2794798 ]]
pyscf.qmmm.itrf.mm_charge(scf_method, atoms_or_coords, charges, radii=None, unit=None)#

Embedding the one-electron (non-relativistic) potential generated by MM point charges into QM Hamiltonian.

The total energy includes the regular QM energy, the interaction between the nuclei in QM region and the MM charges, and the static Coulomb interaction between the electron density and the MM charges. It does not include the static Coulomb interactions of the MM point charges, the MM energy, the vdw interaction or other bonding/non-bonding effects between QM region and MM particles.

Args:

scf_method : a HF or DFT object

atoms_or_coords2D array, shape (N,3)

MM particle coordinates

charges1D array

MM particle charges

Kwargs:
radii1D array

The Gaussian charge distribution radii of MM atoms.

unitstr

Bohr, AU, Ang (case insensitive). Default is the same to mol.unit

Returns:

Same method object as the input scf_method with modified 1e Hamiltonian

Note:

1. if MM charge and X2C correction are used together, function mm_charge needs to be applied after X2C decoration (.x2c method), eg mf = mm_charge(scf.RHF(mol).x2c()), [(0.5,0.6,0.8)], [-0.5]). 2. Once mm_charge function is applied on the SCF object, it affects all the post-HF calculations eg MP2, CCSD, MCSCF etc

Examples:

>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = mm_charge(dft.RKS(mol), [(0.5,0.6,0.8)], [-0.3])
>>> mf.kernel()
-101.940495711284
pyscf.qmmm.itrf.mm_charge_grad(scf_grad, atoms_or_coords, charges, radii=None, unit=None)#

Apply the MM charges in the QM gradients’ method. It affects both the electronic and nuclear parts of the QM fragment.

Args:
scf_grada HF or DFT gradient object (grad.HF or grad.RKS etc)

Once the add_mm_charges_grad was applied, it affects all post-HF calculations eg MP2, CCSD, MCSCF etc

coords2D array, shape (N,3)

MM particle coordinates

charges1D array

MM particle charges

Kwargs:
radii1D array

The Gaussian charge distribution radii of MM atoms.

unitstr

Bohr, AU, Ang (case insensitive). Default is the same to mol.unit

Returns:

Same gradeints method object as the input scf_grad method

Examples:

>>> from pyscf import gto, scf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1', basis='ccpvdz', verbose=0)
>>> mf = mm_charge(scf.RHF(mol), [(0.5,0.6,0.8)], [-0.3])
>>> mf.kernel()
-101.940495711284
>>> hfg = mm_charge_grad(grad.hf.RHF(mf), coords, charges)
>>> hfg.kernel()
[[-0.25912357 -0.29235976 -0.38245077]
 [-1.70497052 -1.89423883  1.2794798 ]]
pyscf.qmmm.itrf.qmmm_for_scf(method, mm_mol)[source]#

Add the potential of MM particles to SCF (HF and DFT) method or CASCI method then generate the corresponding QM/MM method for the QM system.

Args:

mm_mol : MM Mole object

pyscf.qmmm.itrf.qmmm_grad_for_scf(scf_grad)[source]#

Add the potential of MM particles to SCF (HF and DFT) object and then generate the corresponding QM/MM gradients method for the QM system.

pyscf.qmmm.mm_mole module#

Mole class for MM particles

class pyscf.qmmm.mm_mole.Mole(atoms, charges=None, zeta=None)[source]#

Bases: Mole

Mole class for MM particles.

Args:

atoms : geometry of MM particles (unit Bohr).

[[atom1, (x, y, z)],
[atom2, (x, y, z)],
[atomN, (x, y, z)]]
Kwargs:
charges1D array

fractional charges of MM particles

zeta1D array

Gaussian charge distribution parameter. rho(r) = charge * Norm * exp(-zeta * r^2)

get_zetas()[source]#
pyscf.qmmm.mm_mole.create_mm_mol(atoms_or_coords, charges=None, radii=None, unit='Angstrom')[source]#

Create an MM object based on the given coordinates and charges of MM particles.

Args:
atoms_or_coordsarray-like

Cartesian coordinates of MM atoms, in the form of a 2D array: [(x1, y1, z1), (x2, y2, z2), …]

Kwargs:
charges1D array

The charges of MM atoms.

radii1D array

The Gaussian charge distribution radii of MM atoms.

unitstring

The unit of the input. Default is ‘Angstrom’.

Module contents#