pyscf.ccn package

Submodules

pyscf.ccn.cc module

pyscf.ccn.cc.kernel_ea_d(cc, t2, nroots=1, tolerance=1e-10)[source]

EOM-EA kernel (doubles only). Args:

cc (object): one of pyscf ccsd objects; t2 (numpy.ndarray): the t2 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-EA energies and amplitudes.

pyscf.ccn.cc.kernel_ea_s(cc, t1, nroots=1, tolerance=1e-10)[source]

EOM-EA kernel (singles). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-EA energies and amplitudes.

pyscf.ccn.cc.kernel_ea_sd(cc, t1, t2, nroots=1, tolerance=1e-10)[source]

EOM-EA kernel (singles and doubles). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; t2 (numpy.ndarray): the t2 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-EA energies and amplitudes.

pyscf.ccn.cc.kernel_ea_sdt(cc, t1, t2, t3, nroots=1, tolerance=1e-10)[source]

EOM-EA kernel (singles, doubles and triples). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; t2 (numpy.ndarray): the t2 amplitudes; t3 (numpy.ndarray): the t3 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-EA energies and amplitudes.

pyscf.ccn.cc.kernel_ground_state_d(cc, tolerance=1e-10, maxiter=50)[source]

A ground-state kernel (doubles only). Args:

cc (object): one of pyscf ccsd objects; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state amplitudes and energy.

pyscf.ccn.cc.kernel_ground_state_s(cc, tolerance=1e-10, maxiter=50)[source]

A ground-state kernel (singles). Args:

cc (object): one of pyscf ccsd objects; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state amplitudes and energy.

pyscf.ccn.cc.kernel_ground_state_sd(cc, tolerance=1e-10, maxiter=50)[source]

A ground-state kernel (singles and doubles). Args:

cc (object): one of pyscf ccsd objects; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state amplitudes and energy.

pyscf.ccn.cc.kernel_ground_state_sdt(cc, tolerance=1e-10, maxiter=50)[source]

A ground-state kernel (singles, doubles and triples). Args:

cc (object): one of pyscf ccsd objects; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state amplitudes and energy.

pyscf.ccn.cc.kernel_ip_d(cc, t2, nroots=1, tolerance=1e-10)[source]

EOM-IP kernel (doubles only). Args:

cc (object): one of pyscf ccsd objects; t2 (numpy.ndarray): the t2 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-IP energies and amplitudes.

pyscf.ccn.cc.kernel_ip_s(cc, t1, nroots=1, tolerance=1e-10)[source]

EOM-IP kernel (singles). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-IP energies and amplitudes.

pyscf.ccn.cc.kernel_ip_sd(cc, t1, t2, nroots=1, tolerance=1e-10)[source]

EOM-IP kernel (singles and doubles). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; t2 (numpy.ndarray): the t2 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-IP energies and amplitudes.

pyscf.ccn.cc.kernel_ip_sdt(cc, t1, t2, t3, nroots=1, tolerance=1e-10)[source]

EOM-IP kernel (singles, doubles and triples). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; t2 (numpy.ndarray): the t2 amplitudes; t3 (numpy.ndarray): the t3 amplitudes; nroots (int): the number of roots to find; tolerance (float): tolerance to converge to;

Returns:

EOM-IP energies and amplitudes.

pyscf.ccn.cc.kernel_lambda_d(cc, t2, tolerance=1e-10, maxiter=50)[source]

A ground-state lambda kernel (doubles only). Args:

cc (object): one of pyscf ccsd objects; t2 (numpy.ndarray): the t2 amplitudes; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state lambda amplitudes.

pyscf.ccn.cc.kernel_lambda_s(cc, t1, tolerance=1e-10, maxiter=50)[source]

A ground-state lambda kernel (singles). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state lambda amplitudes.

pyscf.ccn.cc.kernel_lambda_sd(cc, t1, t2, tolerance=1e-10, maxiter=50)[source]

A ground-state lambda kernel (singles and doubles). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; t2 (numpy.ndarray): the t2 amplitudes; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state lambda amplitudes.

pyscf.ccn.cc.kernel_lambda_sdt(cc, t1, t2, t3, tolerance=1e-10, maxiter=50)[source]

A ground-state lambda kernel (singles, doubles and triples). Args:

cc (object): one of pyscf ccsd objects; t1 (numpy.ndarray): the t1 amplitudes; t2 (numpy.ndarray): the t2 amplitudes; t3 (numpy.ndarray): the t3 amplitudes; tolerance (float): tolerance to converge to; maxiter (int): the maximal number of iterations;

Returns:

Ground state lambda amplitudes.

pyscf.ccn.equations module

pyscf.ccn.equations.energy_gs_d(oovv, t2)[source]
pyscf.ccn.equations.energy_gs_s(ov, oovv, t1)[source]
pyscf.ccn.equations.energy_gs_sd(ov, oovv, t1, t2)[source]
pyscf.ccn.equations.energy_gs_sdt(ov, oovv, t1, t2)[source]
pyscf.ccn.equations.eq_ea_d(oo, ov, vv, oovv, ovvo, ovvv, vvvv, r_ea2, t2)[source]
pyscf.ccn.equations.eq_ea_s(ov, vv, oovv, ovvv, r_ea1, t1)[source]
pyscf.ccn.equations.eq_ea_sd(oo, ov, vv, oovo, oovv, ovvo, ovvv, vvvo, vvvv, r_ea1, r_ea2, t1, t2)[source]
pyscf.ccn.equations.eq_ea_sdt(oo, ov, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvvo, vvvv, r_ea1, r_ea2, r_ea3, t1, t2, t3)[source]
pyscf.ccn.equations.eq_gs_d(oo, vv, oooo, oovv, ovvo, vvoo, vvvv, t2)[source]
pyscf.ccn.equations.eq_gs_s(oo, ov, vo, vv, oovo, oovv, ovvo, ovvv, t1)[source]
pyscf.ccn.equations.eq_gs_sd(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvoo, vvvo, vvvv, t1, t2)[source]
pyscf.ccn.equations.eq_gs_sdt(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvoo, vvvo, vvvv, t1, t2, t3)[source]
pyscf.ccn.equations.eq_ip_d(oo, ov, vv, oooo, oovo, oovv, ovvo, r_ip2, t2)[source]
pyscf.ccn.equations.eq_ip_s(oo, ov, oovo, oovv, r_ip1, t1)[source]
pyscf.ccn.equations.eq_ip_sd(oo, ov, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, r_ip1, r_ip2, t1, t2)[source]
pyscf.ccn.equations.eq_ip_sdt(oo, ov, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvvo, vvvv, r_ip1, r_ip2, r_ip3, t1, t2, t3)[source]
pyscf.ccn.equations.eq_lambda_d(oo, vv, oooo, oovv, ovvo, vvvv, a2, t2)[source]
pyscf.ccn.equations.eq_lambda_s(oo, ov, vv, oovo, oovv, ovvo, ovvv, a1, t1)[source]
pyscf.ccn.equations.eq_lambda_sd(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvvo, vvvv, a1, a2, t1, t2)[source]
pyscf.ccn.equations.eq_lambda_sdt(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvoo, vvvo, vvvv, a1, a2, a3, t1, t2, t3)[source]

pyscf.ccn.pyscf_helpers module

pyscf.ccn.pyscf_helpers.a2v(amplitudes)[source]

List of amplitudes into a single array.

pyscf.ccn.pyscf_helpers.a2v_sym(amplitudes, ixs)[source]

Symmetric amplitudes into vector. Args:

amplitudes (iterable): amplitudes to join; ixs (iterable): indexes of lower-triangle parts;

Returns:

A numpy array with amplitudes joined.

pyscf.ccn.pyscf_helpers.eris_hamiltonian(eris)[source]

Retrieves Hamiltonian matrix elements from pyscf ERIS. Args:

eris (pyscf.cc.ccsd.ERIS): pyscf ERIS;

Returns:

A dict with Hamiltonian matrix elements.

pyscf.ccn.pyscf_helpers.kernel_eig(hamiltonian, equations, amplitudes, tolerance=1e-09)[source]

Coupled-cluster solver (eigenvalue problem). Args:

hamiltonian (dict): hamiltonian matrix elements or pyscf ERIS; equations (callable): coupled-cluster equations; amplitudes (iterable): starting amplitudes (a list of OrderedDicts); tolerance (float): convergence criterion;

Returns:

Resulting coupled-cluster amplitudes and energy if specified.

pyscf.ccn.pyscf_helpers.kernel_solve(hamiltonian, equations, initial_guess, tolerance=1e-09, debug=False, diis=True, equation_energy=None, dim_spec=None, maxiter=50)[source]

Coupled-cluster solver (linear systems). Args:

hamiltonian (dict): hamiltonian matrix elements or pyscf ERIS; equations (callable): coupled-cluster equations; initial_guess (OrderedDict): starting amplitudes; tolerance (float): convergence criterion; debug (bool): prints iterations if True; diis (bool, DIIS): converger for iterations; equation_energy (callable): energy equation; dim_spec (iterable): if initial_guess is a dict, this parameter defines shapes of arrays in ‘ov’ notation (list of strings); maxiter (int): maximal number of iterations;

Returns:

Resulting coupled-cluster amplitudes and energy if specified.

pyscf.ccn.pyscf_helpers.koopmans_guess_ea(nocc, nvir, amplitudes, n, **kwargs)[source]

Koopman’s guess for EA-EOM-CC amplitudes. Args:

nocc (int): occupied space size; nvir (int): virtual space size; amplitudes (OrderedDict): an ordered dict with variable name-variable order pairs; n (int): the root number; kwargs: keyword arguments to numpy.zeros.

Returns:

An ordered dict with variable name-initial guess pairs.

pyscf.ccn.pyscf_helpers.koopmans_guess_ip(nocc, nvir, amplitudes, n, **kwargs)[source]

Koopman’s guess for IP-EOM-CC amplitudes. Args:

nocc (int): occupied space size; nvir (int): virtual space size; amplitudes (OrderedDict): an ordered dict with variable name-variable order pairs; n (int): the root number; kwargs: keyword arguments to numpy.zeros.

Returns:

An ordered dict with variable name-initial guess pairs.

pyscf.ccn.pyscf_helpers.ltri_ix_amplitudes(a)[source]

Collects lower-triangular indexes of antisymetric amplitudes. Args:

a (MetaArray): amplitudes to process;

Returns:

Lower-triangular indexes.

pyscf.ccn.pyscf_helpers.oneshot(equations, *args)[source]

A one-shot calculation. Args:

equations (callable): coupled-cluster equations; args (iterable): amplitudes and hamiltonian matrix elements as dicts;

Returns:

Results of the calculation.

pyscf.ccn.pyscf_helpers.res2amps(residuals, e_occ, e_vir, constant=None)[source]

Converts residuals into amplitudes update. Args:

residuals (iterable): a list of residuals; e_occ (array): occupied energies; e_vir (array): virtual energies; virtual spaces; constant (float): a constant in the denominator;

Returns:

A list of updates to amplitudes.

pyscf.ccn.pyscf_helpers.v2a(vec, like)[source]

Array into a list amplitudes.

pyscf.ccn.pyscf_helpers.v2a_sym(a, labels, shapes, ixs)[source]

Decompresses the antisymmetric array. Args:

a (numpy.ndarray): array to decompress; labels (iterable): array’s axes’ labels; shapes (iterable): arrays’ shapes; ixs (iterable): indexes of lower-triangle parts;

Returns:

Decompressed amplitude tensors.

pyscf.ccn.test module

class pyscf.ccn.test.H2OTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

classmethod setUpClass()[source]

H20 molecule test vs ORCA-MRCC data.

ORCA reference energies:

HF -75.97354725 CCS – CCSD -76.185805898396 CCSDT -76.189327633478

test_ea_sd()[source]

CCSD EOM iterations (EA).

test_ip_sd()[source]

CCSD EOM iterations (IP).

test_iter_d()[source]

CCD iterations.

test_iter_sd()[source]

CCSD iterations.

test_lambda_sd()[source]

CCSD lambda iterations.

class pyscf.ccn.test.H2Tests(methodName='runTest')[source]

Bases: unittest.case.TestCase

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

test_ea_sd()[source]

CCSD EOM iterations (EA).

test_ip_sd()[source]

CCSD EOM iterations (IP).

test_iter_s()[source]

CCS iterations.

test_iter_sd()[source]

CCSD iterations.

test_iter_sdt()[source]

CCSDT iterations (there are no triple excitations for a 2-electron system).

test_lambda_sd()[source]

CCSD lambda iterations.

class pyscf.ccn.test.OTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

classmethod setUpClass()[source]

Oxygen atom test vs ORCA-MRCC data.

ORCA version 3.0.3

Input example:

! cc-pvdz UHF TightSCF

%mrcc

method “CCSDT” ETol 10

end

%pal nprocs 4 end

  • xyzfile 0 1 initial.xyz

ORCA reference energies:

HF -74.6652538779 CCS -74.841686696943 CCSD -74.819248718982 CCSDT -74.829163218204

test_ea_sd()[source]

CCSD EOM iterations (EA).

test_ip_sd()[source]

CCSD EOM iterations (IP).

test_iter_s()[source]

CCS iterations.

test_iter_sd()[source]

CCSD iterations.

test_lambda_sd()[source]

CCSD lambda iterations.

class pyscf.ccn.test.utilTests(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_p()[source]

pyscf.ccn.util module

class pyscf.ccn.util.Intervals(*args)[source]

Bases: object

add(fr, to)[source]

Adds an interval. Args:

fr (float): from; to (float): to;

class pyscf.ccn.util.MetaArray(array, dtype=None, order=None, **kwargs)[source]

Bases: numpy.ndarray

Array with metadata (StackOverflow copy-paste).

class pyscf.ccn.util.OneToOne(source=None)[source]

Bases: dict

clear()None.  Remove all items from D.[source]
copy()a shallow copy of D[source]
inv()[source]

Inverts the one-to-one correspondence. Returns:

An inverted correspondence.

update([E, ]**F)None.  Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

withdraw(other)[source]

Withdraws items from this one-to-one. Inverse of self.update. Args:

other (dict): key-values pairs to withdraw;

class pyscf.ccn.util.ReadOnlySCWrapper(data)[source]

Bases: collections.abc.Mapping

to_list()[source]
class pyscf.ccn.util.StrictCounter(iterable=None, /, **kwds)[source]

Bases: collections.Counter

applied_count_condition(condition)[source]

Applies a given condition on counts and returns a copy of StrictCounter. Args:

condition (callable): a condition to apply;

Returns:

A StrictCounter with a condition applied.

clean()[source]

Removes zero counts. Returns:

An instance of StrictCounter with all zero counts removed.

is_empty()[source]

Checks if empty. Returns:

True if all counts are zero.

positive_only()[source]

Removes negative and zero counts. Returns:

An instance of StrictCounter with positive counts only.

readonly()[source]

Returns a read-only mapping to self. Returns:

A read-only mapping.

to_list()[source]

Makes a list of this counter with repeating elements. Returns:

A list with elements from this counter.

pyscf.ccn.util.d2t(d)[source]

Dict into tuple.

pyscf.ccn.util.e(*args)[source]

Numpy optimized einsum.

pyscf.ccn.util.ltri_ix(n, ndims)[source]

Generates lower-triangular part indexes in arbitrary dimensions. Args:

n (int): dimension size; ndims (int): number of dimensions;

Returns:

Indexes in a tuple of arrays.

pyscf.ccn.util.meta(a, **kwargs)[source]

Prepares an array with metadata. Args:

a (numpy.ndarray): a numpy array; **kwargs: metadata to save;

Returns:

An array enhanced with metadata.

pyscf.ccn.util.p(spec, tensor)[source]

Antisymmetrizes tensor. Args:

spec (str): a string specifying tensor indexes. Each tensor dimension is represented by the corresponding symbol in the string using the following rules:

  1. Tensor dimensions which do not need to be antisymmetrized are represented by same symbols;

  2. Each pair of tensor dimensions with different symbols will be antisymmetrized;

3. The symbol . (dot) is a special symbol: the corresponding dimension marked by this symbol will not be touched;

tensor (numpy.ndarray): a tensor to antisymmetrize;

Returns:

An antisymmetrized tensor.

Examples:

>>> import numpy
>>> from numpy import testing
>>> a = numpy.arange(12).reshape(2, 2, 3)
>>> s = p("ab.", a)  # permutes first and second dimensions
>>> testing.assert_allclose(s, a - numpy.swapaxes(a, 0, 1))
True
>>> s = p("aa.", a)  # does nothing
>>> testing.assert_allclose(s, a)
True
pyscf.ccn.util.p_count(permutation, destination=None, debug=False)[source]

Counts permutations. Args:

permutation (iterable): a list of unique integers from 0 to N-1 or any iterable of unique entries if normal is provided; destination (iterable): ordered elements from permutation; debug (bool): prints debug information if True;

Returns:

The number of permutations needed to achieve this list from a 0..N-1 series.

pyscf.ccn.util.readonly

alias of pyscf.ccn.util.ReadOnlySCWrapper

Module contents