Skip to content

Commit

Permalink
Upgrade docstring for ci wavefunctions (Issue #22)
Browse files Browse the repository at this point in the history
1. Use upgraded docstring format (from pydocstring) to inherit
docstrings.
  • Loading branch information
kimt33 committed Sep 17, 2017
1 parent 61f6a57 commit e4277f0
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 392 deletions.
86 changes: 9 additions & 77 deletions wfns/wavefunction/ci/ci_pairs.py
Original file line number Diff line number Diff line change
@@ -1,103 +1,34 @@
"""CI Pairs Wavefunction.
"""
"""CI Pairs Wavefunction."""
from __future__ import absolute_import, division, print_function
import numpy as np
from wfns.wavefunction.ci.doci import DOCI
from wfns.wavefunction.geminals.ap1rog import AP1roG
from wfns.backend.sd_list import sd_list
from wfns.backend import slater
from pydocstring.wrapper import docstring_class

__all__ = []


@docstring_class(indent_level=1)
class CIPairs(DOCI):
r"""CI Pairs Wavefunction.
DOCI wavefunction with only first order pairwise excitations
DOCI wavefunction with only first order pairwise excitations.
Attributes
----------
nelec : int
Number of electrons
nspin : int
Number of spin orbitals (alpha and beta)
dtype : {np.float64, np.complex128}
Data type of the wavefunction
params : np.ndarray
Parameters of the wavefunction
_spin : float
Total spin of each Slater determinant
:math:`\frac{1}{2}(N_\alpha - N_\beta)`
Default is no spin (all spins possible)
_seniority : int
Number of unpaired electrons in each Slater determinant
sd_vec : tuple of int
List of Slater determinants used to construct the CI wavefunction
dict_sd_index : dictionary of int to int
Dictionary from Slater determinant to its index in sd_vec
Properties
----------
nspatial : int
Number of spatial orbitals
spin : float, None
Spin of the wavefunction
Spin is zero (singlet)
seniority : int, None
Seniority (number of unpaired electrons) of the wavefunction
Seniority is zero
template_params : np.ndarray
Template of the wavefunction parameters
Depends on the attributes given
nparams : int
Number of parameters
params_shape : 2-tuple of int
Shape of the parameters
Methods
-------
__init__(self, nelec, nspin, dtype=None, params=None, sd_vec=None, spin=None, seniority=None)
Initializes wavefunction
assign_nelec(self, nelec)
Assigns the number of electrons
assign_nspin(self, nspin)
Assigns the number of spin orbitals
assign_params(self, params)
Assigns the parameters of the wavefunction
assign_dtype(self, dtype)
Assigns the data type of parameters used to define the wavefunction
assign_spin(self, spin=None)
Assigns the spin of the wavefunction
assign_seniority(self, seniority=None)
Assigns the seniority of the wavefunction
assign_sd_vec(self, sd_vec=None)
Assigns the tuple of Slater determinants used in the CI wavefunction
get_overlap(self, sd, deriv=None)
Gets the overlap from cache and compute if not in cache
Default is no derivatization
to_ap1rog(self, exc_lvl=0)
Returns the CIPairs wavefunction as a AP1roG wavefunction
"""

def assign_sd_vec(self, sd_vec=None):
"""Set the list of Slater determinants for the CI Pairs wavefunction.
"""
Ignores user input and uses the Slater determinants for the FCI wavefunction (within the
given spin)
Parameters
----------
sd_vec : iterable of int
List of Slater determinants (in the form of integers that describe the occupation as a
bitstring)
Raises
------
ValueError
If the sd_vec is not `None` (default value)
If the sd_vec is not `None` (default value).
Note
----
Needs to have `nelec`, `nspin`, `spin`, `seniority`
"""
if sd_vec is None:
super().assign_sd_vec(sd_list(self.nelec, self.nspatial, num_limit=None, exc_orders=[2],
Expand All @@ -113,7 +44,8 @@ def to_ap1rog(self):
Returns
-------
ap1rog : wfns.wavefunction.geminals.ap1rog.AP1roG
AP1roG wavefunction
AP1roG wavefunction.
"""
# select Slater determinant with largest contributor as the reference Slater determinant
ref_sd_ind = np.argsort(np.abs(self.params))[-1]
Expand Down
Loading

0 comments on commit e4277f0

Please sign in to comment.