pyscf.grad package

Submodules

pyscf.grad.casci module

CASCI analytical nuclear gradients

Ref. J. Comput. Chem., 5, 589

pyscf.grad.casci.Grad

alias of pyscf.grad.casci.Gradients

class pyscf.grad.casci.Gradients(mc)

Bases: pyscf.grad.rhf.GradientsBasics

Non-relativistic restricted Hartree-Fock gradients

as_scanner(state=None)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1.1', verbose=0)
>>> mc_grad_scanner = mcscf.CASCI(scf.RHF(mol), 4, 4).nuc_grad_method().as_scanner()
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
dump_flags(verbose=None)
grad_elec(mo_coeff=None, ci=None, atmlst=None, verbose=None)
grad_nuc(mol=None, atmlst=None)
hcore_generator(mol=None)
kernel(mo_coeff=None, ci=None, atmlst=None, state=None, verbose=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

pyscf.grad.casci.as_scanner(mcscf_grad, state=None)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1.1', verbose=0)
>>> mc_grad_scanner = mcscf.CASCI(scf.RHF(mol), 4, 4).nuc_grad_method().as_scanner()
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
pyscf.grad.casci.grad_elec(mc_grad, mo_coeff=None, ci=None, atmlst=None, verbose=None)

pyscf.grad.casscf module

CASSCF analytical nuclear gradients

Ref. J. Comput. Chem., 5, 589

pyscf.grad.casscf.Grad

alias of pyscf.grad.casscf.Gradients

class pyscf.grad.casscf.Gradients(mc)

Bases: pyscf.grad.casci.Gradients

Non-relativistic restricted Hartree-Fock gradients

as_scanner()

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1.1', verbose=0)
>>> mc_grad_scanner = mcscf.CASSCF(scf.RHF(mol), 4, 4).nuc_grad_method().as_scanner()
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
grad_elec(mo_coeff=None, ci=None, atmlst=None, verbose=None)
kernel(mo_coeff=None, ci=None, atmlst=None, verbose=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

pyscf.grad.casscf.as_scanner(mcscf_grad)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mcscf
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1.1', verbose=0)
>>> mc_grad_scanner = mcscf.CASSCF(scf.RHF(mol), 4, 4).nuc_grad_method().as_scanner()
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.1'))
>>> etot, grad = mc_grad_scanner(gto.M(atom='N 0 0 0; N 0 0 1.5'))
pyscf.grad.casscf.grad_elec(mc_grad, mo_coeff=None, ci=None, atmlst=None, verbose=None)

pyscf.grad.ccsd module

CCSD analytical nuclear gradients

pyscf.grad.ccsd.Grad

alias of pyscf.grad.ccsd.Gradients

class pyscf.grad.ccsd.Gradients(method)

Bases: pyscf.grad.rhf.GradientsBasics

as_scanner()

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns total CCSD energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the CCSD and the underlying SCF objects (conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, cc
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> cc_scanner = cc.CCSD(scf.RHF(mol)).nuc_grad_method().as_scanner()
>>> e_tot, grad = cc_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = cc_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
grad_elec(t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, d1=None, d2=None, verbose=4)
grad_nuc(mol=None, atmlst=None)
kernel(t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, verbose=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

pyscf.grad.ccsd.as_scanner(grad_cc)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns total CCSD energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the CCSD and the underlying SCF objects (conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, cc
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> cc_scanner = cc.CCSD(scf.RHF(mol)).nuc_grad_method().as_scanner()
>>> e_tot, grad = cc_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = cc_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
pyscf.grad.ccsd.grad_elec(cc_grad, t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, d1=None, d2=None, verbose=4)

pyscf.grad.ccsd_slow module

RCCSD

Ref: JCP 90, 1752 (1989); DOI:10.1063/1.456069

pyscf.grad.ccsd_slow.index_frozen_active(cc)
pyscf.grad.ccsd_slow.kernel(cc, t1, t2, l1, l2, eris=None)

pyscf.grad.ccsd_t module

class pyscf.grad.ccsd_t.Gradients(method)

Bases: pyscf.grad.ccsd.Gradients

grad_elec(t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, verbose=4)
pyscf.grad.ccsd_t.grad_elec(cc_grad, t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, verbose=4)

pyscf.grad.cisd module

CISD analytical nuclear gradients

pyscf.grad.cisd.Grad

alias of pyscf.grad.cisd.Gradients

class pyscf.grad.cisd.Gradients(myci)

Bases: pyscf.grad.rhf.GradientsBasics

as_scanner(state=0)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns total CISD energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the CISD and the underlying SCF objects (conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, ci
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> ci_scanner = ci.CISD(scf.RHF(mol)).nuc_grad_method().as_scanner()
>>> e_tot, grad = ci_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = ci_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
dump_flags(verbose=None)
grad_elec(civec=None, eris=None, atmlst=None, verbose=4)
grad_nuc(mol=None, atmlst=None)
kernel(civec=None, eris=None, atmlst=None, state=None, verbose=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

pyscf.grad.cisd.as_scanner(grad_ci, state=0)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns total CISD energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the CISD and the underlying SCF objects (conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, ci
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> ci_scanner = ci.CISD(scf.RHF(mol)).nuc_grad_method().as_scanner()
>>> e_tot, grad = ci_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = ci_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
pyscf.grad.cisd.grad_elec(cigrad, civec=None, eris=None, atmlst=None, verbose=4)

pyscf.grad.dhf module

Relativistic Dirac-Hartree-Fock

pyscf.grad.dhf.Grad

alias of pyscf.grad.dhf.Gradients

class pyscf.grad.dhf.Gradients(scf_method)

Bases: pyscf.grad.dhf.GradientsBasics

Unrestricted Dirac-Hartree-Fock gradients

as_scanner()

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> hf_scanner = scf.RHF(mol).apply(grad.RHF).as_scanner()
>>> e_tot, grad = hf_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = hf_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
extra_force(atom_id, envs)

Hook for extra contributions in analytical gradients.

Contributions like the response of auxiliary basis in density fitting method, the grid response in DFT numerical integration can be put in this function.

get_veff(mol, dm)
grad_elec(mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)
kernel(mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

make_rdm1e(mo_energy=None, mo_coeff=None, mo_occ=None)
class pyscf.grad.dhf.GradientsBasics(method)

Bases: pyscf.grad.rhf.GradientsBasics

Basic nuclear gradient functions for 4C relativistic methods

get_hcore(mol=None)
get_ovlp(mol=None)
hcore_generator(mol)
pyscf.grad.dhf.get_coulomb_hf(mol, dm, level='SSSS')

Dirac-Hartree-Fock Coulomb repulsion

pyscf.grad.dhf.get_hcore(mol)
pyscf.grad.dhf.get_ovlp(mol)
pyscf.grad.dhf.get_veff(mol, dm, level='SSSS')

Dirac-Hartree-Fock Coulomb repulsion

pyscf.grad.dhf.grad_elec(mf_grad, mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

pyscf.grad.mp2 module

MP2 analytical nuclear gradients

pyscf.grad.mp2.Grad

alias of pyscf.grad.mp2.Gradients

class pyscf.grad.mp2.Gradients(method)

Bases: pyscf.grad.rhf.GradientsBasics

as_scanner()

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns total MP2 energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the MP2 and the underlying SCF objects (max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mp
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> mp2_scanner = mp.MP2(scf.RHF(mol)).nuc_grad_method().as_scanner()
>>> e_tot, grad = mp2_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = mp2_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
grad_elec(t2, atmlst=None, verbose=4)
grad_nuc(mol=None, atmlst=None)
kernel(t2=None, atmlst=None, verbose=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

pyscf.grad.mp2.as_scanner(grad_mp)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns total MP2 energy.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the MP2 and the underlying SCF objects (max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, mp
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> mp2_scanner = mp.MP2(scf.RHF(mol)).nuc_grad_method().as_scanner()
>>> e_tot, grad = mp2_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = mp2_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
pyscf.grad.mp2.grad_elec(mp_grad, t2, atmlst=None, verbose=4)

pyscf.grad.rhf module

Non-relativistic Hartree-Fock analytical nuclear gradients

pyscf.grad.rhf.Grad

alias of pyscf.grad.rhf.Gradients

class pyscf.grad.rhf.Gradients(method)

Bases: pyscf.grad.rhf.GradientsBasics

Non-relativistic restricted Hartree-Fock gradients

as_scanner()

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> hf_scanner = scf.RHF(mol).apply(grad.RHF).as_scanner()
>>> e_tot, grad = hf_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = hf_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
extra_force(atom_id, envs)

Hook for extra contributions in analytical gradients.

Contributions like the response of auxiliary basis in density fitting method, the grid response in DFT numerical integration can be put in this function.

get_veff(mol=None, dm=None)
grad_elec(mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

Electronic part of RHF/RKS gradients

Args:

mf_grad : grad.rhf.Gradients or grad.rks.Gradients object

kernel(mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

make_rdm1e(mo_energy=None, mo_coeff=None, mo_occ=None)
class pyscf.grad.rhf.GradientsBasics(method)

Bases: pyscf.lib.misc.StreamObject

Basic nuclear gradient functions for non-relativistic methods

as_scanner()

Generate Gradients Scanner

dump_flags(verbose=None)
get_hcore(mol=None)
get_j(mol=None, dm=None, hermi=0)
get_jk(mol=None, dm=None, hermi=0)

J = ((-nabla i) j| kl) D_lk K = ((-nabla i) j| kl) D_jk

get_k(mol=None, dm=None, hermi=0)
get_ovlp(mol=None)
grad(*args, **kwargs)

An alias to method kernel Function Signature: grad(self) —————————————-

grad_elec()
grad_nuc(mol=None, atmlst=None)
hcore_generator(mol=None)
kernel()

Kernel function is the main driver of a method. Every method should define the kernel function as the entry of the calculation. Note the return value of kernel function is not strictly defined. It can be anything related to the method (such as the energy, the wave-function, the DFT mesh grids etc.).

optimizer(solver='geometric')

Geometry optimization solver

Kwargs:

solver (string) : geometry optimization solver, can be “geomeTRIC” (default) or “berny”.

symmetrize(de, atmlst=None)

Symmetrize the gradients wrt the point group symmetry of the molecule.

pyscf.grad.rhf.as_scanner(mf_grad)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> hf_scanner = scf.RHF(mol).apply(grad.RHF).as_scanner()
>>> e_tot, grad = hf_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = hf_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
pyscf.grad.rhf.get_hcore(mol)

Part of the nuclear gradients of core Hamiltonian

pyscf.grad.rhf.get_jk(mol, dm)

J = ((-nabla i) j| kl) D_lk K = ((-nabla i) j| kl) D_jk

pyscf.grad.rhf.get_ovlp(mol)
pyscf.grad.rhf.get_veff(mf_grad, mol, dm)

NR Hartree-Fock Coulomb repulsion

pyscf.grad.rhf.grad_elec(mf_grad, mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

Electronic part of RHF/RKS gradients

Args:

mf_grad : grad.rhf.Gradients or grad.rks.Gradients object

pyscf.grad.rhf.grad_nuc(mol, atmlst=None)

Derivatives of nuclear repulsion energy wrt nuclear coordinates

pyscf.grad.rhf.hcore_generator(mf, mol=None)
pyscf.grad.rhf.make_rdm1e(mo_energy, mo_coeff, mo_occ)

Energy weighted density matrix

pyscf.grad.rhf.symmetrize(mol, de, atmlst=None)

Symmetrize the gradients wrt the point group symmetry of the molecule.

pyscf.grad.rks module

Non-relativistic RKS analytical nuclear gradients

pyscf.grad.rks.Grad

alias of pyscf.grad.rks.Gradients

class pyscf.grad.rks.Gradients(mf)

Bases: pyscf.grad.rhf.Gradients

dump_flags(verbose=None)
extra_force(atom_id, envs)

Hook for extra contributions in analytical gradients.

Contributions like the response of auxiliary basis in density fitting method, the grid response in DFT numerical integration can be put in this function.

get_veff(mol=None, dm=None)

First order derivative of DFT effective potential matrix (wrt electron coordinates)

Args:

ks_grad : grad.uhf.Gradients or grad.uks.Gradients object

grid_response = False
pyscf.grad.rks.get_veff(ks_grad, mol=None, dm=None)

First order derivative of DFT effective potential matrix (wrt electron coordinates)

Args:

ks_grad : grad.uhf.Gradients or grad.uks.Gradients object

pyscf.grad.rks.get_vxc(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)
pyscf.grad.rks.get_vxc_full_response(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)

Full response including the response of the grids

pyscf.grad.rks.grids_response_cc(grids)

pyscf.grad.rohf module

Non-relativistic ROHF analytical nuclear gradients

pyscf.grad.rohf.Grad

alias of pyscf.grad.rohf.Gradients

class pyscf.grad.rohf.Gradients(mf)

Bases: pyscf.grad.uhf.Gradients

Non-relativistic ROHF gradients

pyscf.grad.roks module

Non-relativistic ROKS analytical nuclear gradients

pyscf.grad.roks.Grad

alias of pyscf.grad.roks.Gradients

class pyscf.grad.roks.Gradients(mf)

Bases: pyscf.grad.uks.Gradients

Non-relativistic ROHF gradients

pyscf.grad.tdrhf module

pyscf.grad.tdrhf.Grad

alias of pyscf.grad.tdrhf.Gradients

class pyscf.grad.tdrhf.Gradients(td)

Bases: pyscf.grad.rhf.GradientsBasics

as_scanner(state=1)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, tdscf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> td_grad_scanner = scf.RHF(mol).apply(tdscf.TDA).nuc_grad_method().as_scanner()
>>> e_tot, grad = td_grad_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = td_grad_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
cphf_conv_tol = 1e-08
cphf_max_cycle = 20
dump_flags(verbose=None)
grad_elec(xy, singlet, atmlst=None)

Electronic part of TDA, TDHF nuclear gradients

Args:

td_grad : grad.tdrhf.Gradients or grad.tdrks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

grad_nuc(mol=None, atmlst=None)
kernel(xy=None, state=None, singlet=None, atmlst=None)
Args:
stateint

Excited state ID. state = 1 means the first excited state.

pyscf.grad.tdrhf.as_scanner(td_grad, state=1)

Generating a nuclear gradients scanner/solver (for geometry optimizer).

The returned solver is a function. This function requires one argument “mol” as input and returns energy and first order nuclear derivatives.

The solver will automatically use the results of last calculation as the initial guess of the new calculation. All parameters assigned in the nuc-grad object and SCF object (DIIS, conv_tol, max_memory etc) are automatically applied in the solver.

Note scanner has side effects. It may change many underlying objects (_scf, with_df, with_x2c, …) during calculation.

Examples:

>>> from pyscf import gto, scf, tdscf, grad
>>> mol = gto.M(atom='H 0 0 0; F 0 0 1')
>>> td_grad_scanner = scf.RHF(mol).apply(tdscf.TDA).nuc_grad_method().as_scanner()
>>> e_tot, grad = td_grad_scanner(gto.M(atom='H 0 0 0; F 0 0 1.1'))
>>> e_tot, grad = td_grad_scanner(gto.M(atom='H 0 0 0; F 0 0 1.5'))
pyscf.grad.tdrhf.grad_elec(td_grad, x_y, singlet=True, atmlst=None, max_memory=2000, verbose=4)

Electronic part of TDA, TDHF nuclear gradients

Args:

td_grad : grad.tdrhf.Gradients or grad.tdrks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.tdrks module

pyscf.grad.tdrks.Grad

alias of pyscf.grad.tdrks.Gradients

class pyscf.grad.tdrks.Gradients(td)

Bases: pyscf.grad.tdrhf.Gradients

grad_elec(xy, singlet, atmlst=None)

Electronic part of TDA, TDDFT nuclear gradients

Args:

td_grad : grad.tdrhf.Gradients or grad.tdrks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.tdrks.grad_elec(td_grad, x_y, singlet=True, atmlst=None, max_memory=2000, verbose=4)

Electronic part of TDA, TDDFT nuclear gradients

Args:

td_grad : grad.tdrhf.Gradients or grad.tdrks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.tduhf module

pyscf.grad.tduhf.Grad

alias of pyscf.grad.tduhf.Gradients

class pyscf.grad.tduhf.Gradients(td)

Bases: pyscf.grad.tdrhf.Gradients

grad_elec(xy, singlet=None, atmlst=None)

Electronic part of TDA, TDHF nuclear gradients

Args:

td_grad : grad.tduhf.Gradients or grad.tduks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.tduhf.grad_elec(td_grad, x_y, atmlst=None, max_memory=2000, verbose=4)

Electronic part of TDA, TDHF nuclear gradients

Args:

td_grad : grad.tduhf.Gradients or grad.tduks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.tduks module

pyscf.grad.tduks.Grad

alias of pyscf.grad.tduks.Gradients

class pyscf.grad.tduks.Gradients(td)

Bases: pyscf.grad.tdrhf.Gradients

grad_elec(xy, singlet=None, atmlst=None)

Electronic part of TDA, TDDFT nuclear gradients

Args:

td_grad : grad.tdrhf.Gradients or grad.tdrks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.tduks.grad_elec(td_grad, x_y, atmlst=None, max_memory=2000, verbose=4)

Electronic part of TDA, TDDFT nuclear gradients

Args:

td_grad : grad.tdrhf.Gradients or grad.tdrks.Gradients object.

x_ya two-element list of numpy arrays

TDDFT X and Y amplitudes. If Y is set to 0, this function computes TDA energy gradients.

pyscf.grad.uccsd module

UCCSD analytical nuclear gradients

pyscf.grad.uccsd.Grad

alias of pyscf.grad.uccsd.Gradients

class pyscf.grad.uccsd.Gradients(method)

Bases: pyscf.grad.ccsd.Gradients

grad_elec(t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, d1=None, d2=None, verbose=4)
pyscf.grad.uccsd.grad_elec(cc_grad, t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, d1=None, d2=None, verbose=4)

pyscf.grad.uccsd_t module

class pyscf.grad.uccsd_t.Gradients(method)

Bases: pyscf.grad.uccsd.Gradients

grad_elec(t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, verbose=4)
pyscf.grad.uccsd_t.grad_elec(cc_grad, t1=None, t2=None, l1=None, l2=None, eris=None, atmlst=None, verbose=4)

pyscf.grad.ucisd module

UCISD analytical nuclear gradients

pyscf.grad.ucisd.Grad

alias of pyscf.grad.ucisd.Gradients

class pyscf.grad.ucisd.Gradients(myci)

Bases: pyscf.grad.cisd.Gradients

grad_elec(civec=None, eris=None, atmlst=None, verbose=4)
pyscf.grad.ucisd.grad_elec(cigrad, civec=None, eris=None, atmlst=None, verbose=4)

pyscf.grad.uhf module

Non-relativistic unrestricted Hartree-Fock analytical nuclear gradients

pyscf.grad.uhf.Grad

alias of pyscf.grad.uhf.Gradients

class pyscf.grad.uhf.Gradients(method)

Bases: pyscf.grad.rhf.Gradients

Non-relativistic unrestricted Hartree-Fock gradients

get_veff(mol=None, dm=None)
grad_elec(mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

Electronic part of UHF/UKS gradients

Args:

mf_grad : grad.uhf.Gradients or grad.uks.Gradients object

make_rdm1e(mo_energy=None, mo_coeff=None, mo_occ=None)
pyscf.grad.uhf.get_veff(mf_grad, mol, dm)

First order derivative of HF potential matrix (wrt electron coordinates)

Args:

mf_grad : grad.uhf.Gradients or grad.uks.Gradients object

pyscf.grad.uhf.grad_elec(mf_grad, mo_energy=None, mo_coeff=None, mo_occ=None, atmlst=None)

Electronic part of UHF/UKS gradients

Args:

mf_grad : grad.uhf.Gradients or grad.uks.Gradients object

pyscf.grad.uhf.make_rdm1e(mo_energy, mo_coeff, mo_occ)

Energy weighted density matrix

pyscf.grad.uks module

Non-relativistic UKS analytical nuclear gradients

pyscf.grad.uks.Grad

alias of pyscf.grad.uks.Gradients

class pyscf.grad.uks.Gradients(mf)

Bases: pyscf.grad.uhf.Gradients

dump_flags(verbose=None)
extra_force(atom_id, envs)

Hook for extra contributions in analytical gradients.

Contributions like the response of auxiliary basis in density fitting method, the grid response in DFT numerical integration can be put in this function.

get_veff(mol=None, dm=None)

First order derivative of DFT effective potential matrix (wrt electron coordinates)

Args:

ks_grad : grad.uhf.Gradients or grad.uks.Gradients object

grid_response = False
pyscf.grad.uks.get_veff(ks_grad, mol=None, dm=None)

First order derivative of DFT effective potential matrix (wrt electron coordinates)

Args:

ks_grad : grad.uhf.Gradients or grad.uks.Gradients object

pyscf.grad.uks.get_vxc(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)
pyscf.grad.uks.get_vxc_full_response(ni, mol, grids, xc_code, dms, relativity=0, hermi=1, max_memory=2000, verbose=None)

Full response including the response of the grids

pyscf.grad.ump2 module

UMP2 analytical nuclear gradients

pyscf.grad.ump2.Grad

alias of pyscf.grad.ump2.Gradients

class pyscf.grad.ump2.Gradients(method)

Bases: pyscf.grad.mp2.Gradients

grad_elec(t2, atmlst=None, verbose=4)
pyscf.grad.ump2.grad_elec(mp_grad, t2, atmlst=None, verbose=4)

Module contents

Analytical nuclear gradients

Simple usage:

>>> from pyscf import gto, scf, grad
>>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='ccpvdz')
>>> mf = scf.RHF(mol).run()
>>> grad.RHF(mf).kernel()