pyscf.ccn package¶
Submodules¶
pyscf.ccn.cc module¶
-
pyscf.ccn.cc.
kernel_ea_d
(cc, t2, nroots=1, tolerance=1e-10)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶
-
pyscf.ccn.equations.
energy_gs_s
(ov, oovv, t1)¶
-
pyscf.ccn.equations.
energy_gs_sd
(ov, oovv, t1, t2)¶
-
pyscf.ccn.equations.
energy_gs_sdt
(ov, oovv, t1, t2)¶
-
pyscf.ccn.equations.
eq_ea_d
(oo, ov, vv, oovv, ovvo, ovvv, vvvv, r_ea2, t2)¶
-
pyscf.ccn.equations.
eq_ea_s
(ov, vv, oovv, ovvv, r_ea1, t1)¶
-
pyscf.ccn.equations.
eq_ea_sd
(oo, ov, vv, oovo, oovv, ovvo, ovvv, vvvo, vvvv, r_ea1, r_ea2, t1, t2)¶
-
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)¶
-
pyscf.ccn.equations.
eq_gs_d
(oo, vv, oooo, oovv, ovvo, vvoo, vvvv, t2)¶
-
pyscf.ccn.equations.
eq_gs_s
(oo, ov, vo, vv, oovo, oovv, ovvo, ovvv, t1)¶
-
pyscf.ccn.equations.
eq_gs_sd
(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvoo, vvvo, vvvv, t1, t2)¶
-
pyscf.ccn.equations.
eq_gs_sdt
(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvoo, vvvo, vvvv, t1, t2, t3)¶
-
pyscf.ccn.equations.
eq_ip_d
(oo, ov, vv, oooo, oovo, oovv, ovvo, r_ip2, t2)¶
-
pyscf.ccn.equations.
eq_ip_s
(oo, ov, oovo, oovv, r_ip1, t1)¶
-
pyscf.ccn.equations.
eq_ip_sd
(oo, ov, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, r_ip1, r_ip2, t1, t2)¶
-
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)¶
-
pyscf.ccn.equations.
eq_lambda_d
(oo, vv, oooo, oovv, ovvo, vvvv, a2, t2)¶
-
pyscf.ccn.equations.
eq_lambda_s
(oo, ov, vv, oovo, oovv, ovvo, ovvv, a1, t1)¶
-
pyscf.ccn.equations.
eq_lambda_sd
(oo, ov, vo, vv, oooo, oovo, oovv, ovoo, ovvo, ovvv, vvvo, vvvv, a1, a2, t1, t2)¶
-
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)¶
pyscf.ccn.pyscf_helpers module¶
-
pyscf.ccn.pyscf_helpers.
a2v
(amplitudes)¶ List of amplitudes into a single array.
-
pyscf.ccn.pyscf_helpers.
a2v_sym
(amplitudes, ixs)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ 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)¶ Collects lower-triangular indexes of antisymetric amplitudes. Args:
a (MetaArray): amplitudes to process;
- Returns:
Lower-triangular indexes.
-
pyscf.ccn.pyscf_helpers.
oneshot
(equations, *args)¶ 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)¶ 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)¶ Array into a list amplitudes.
-
pyscf.ccn.pyscf_helpers.
v2a_sym
(a, labels, shapes, ixs)¶ 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')¶ Bases:
unittest.case.TestCase
-
classmethod
setUpClass
()¶ H20 molecule test vs ORCA-MRCC data.
ORCA reference energies:
HF -75.97354725 CCS – CCSD -76.185805898396 CCSDT -76.189327633478
-
test_ea_sd
()¶ CCSD EOM iterations (EA).
-
test_ip_sd
()¶ CCSD EOM iterations (IP).
-
test_iter_d
()¶ CCD iterations.
-
test_iter_sd
()¶ CCSD iterations.
-
test_lambda_sd
()¶ CCSD lambda iterations.
-
classmethod
-
class
pyscf.ccn.test.
H2Tests
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
classmethod
setUpClass
()¶ Hook method for setting up class fixture before running tests in the class.
-
test_ea_sd
()¶ CCSD EOM iterations (EA).
-
test_ip_sd
()¶ CCSD EOM iterations (IP).
-
test_iter_s
()¶ CCS iterations.
-
test_iter_sd
()¶ CCSD iterations.
-
test_iter_sdt
()¶ CCSDT iterations (there are no triple excitations for a 2-electron system).
-
test_lambda_sd
()¶ CCSD lambda iterations.
-
classmethod
-
class
pyscf.ccn.test.
OTests
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
classmethod
setUpClass
()¶ 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
()¶ CCSD EOM iterations (EA).
-
test_ip_sd
()¶ CCSD EOM iterations (IP).
-
test_iter_s
()¶ CCS iterations.
-
test_iter_sd
()¶ CCSD iterations.
-
test_lambda_sd
()¶ CCSD lambda iterations.
-
classmethod
pyscf.ccn.util module¶
-
class
pyscf.ccn.util.
Intervals
(*args)¶ Bases:
object
-
add
(fr, to)¶ Adds an interval. Args:
fr (float): from; to (float): to;
-
-
class
pyscf.ccn.util.
MetaArray
(array, dtype=None, order=None, **kwargs)¶ Bases:
numpy.ndarray
Array with metadata (StackOverflow copy-paste).
-
class
pyscf.ccn.util.
OneToOne
(source=None)¶ Bases:
dict
-
clear
() → None. Remove all items from D.¶
-
copy
() → a shallow copy of D¶
-
inv
()¶ Inverts the one-to-one correspondence. Returns:
An inverted correspondence.
-
update
([E, ]**F) → None. Update D from dict/iterable E and F.¶ 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)¶ Withdraws items from this one-to-one. Inverse of self.update. Args:
other (dict): key-values pairs to withdraw;
-
-
class
pyscf.ccn.util.
StrictCounter
(iterable=None, /, **kwds)¶ Bases:
collections.Counter
-
applied_count_condition
(condition)¶ 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
()¶ Removes zero counts. Returns:
An instance of StrictCounter with all zero counts removed.
-
is_empty
()¶ Checks if empty. Returns:
True if all counts are zero.
-
positive_only
()¶ Removes negative and zero counts. Returns:
An instance of StrictCounter with positive counts only.
-
readonly
()¶ Returns a read-only mapping to self. Returns:
A read-only mapping.
-
to_list
()¶ Makes a list of this counter with repeating elements. Returns:
A list with elements from this counter.
-
-
pyscf.ccn.util.
d2t
(d)¶ Dict into tuple.
-
pyscf.ccn.util.
e
(*args)¶ Numpy optimized einsum.
-
pyscf.ccn.util.
ltri_ix
(n, ndims)¶ 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)¶ 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)¶ 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:
Tensor dimensions which do not need to be antisymmetrized are represented by same symbols;
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)¶ 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