View source on GitHub |
Wavefunction is the central object for manipulaion in the
fqe.wavefunction.Wavefunction(
param: Optional[List[List[int]]] = None,
broken: Optional[Union[List[str], str]] = None
) -> None
OpenFermion-FQE.
Methods
apply
apply(
hamil: "hamiltonian.Hamiltonian"
) -> "Wavefunction"
Returns a wavefunction subject to application of the Hamiltonian (or more generally, the operator).
Args | |
---|---|
hamil (Hamiltonian) - Hamiltonian to be applied |
Returns | |
---|---|
(Wavefunction) - resulting wave function |
apply_generated_unitary
apply_generated_unitary(
time: float,
algo: str,
hamil: "hamiltonian.Hamiltonian",
accuracy: float = 0.0,
expansion: int = 30,
spec_lim: Optional[List[float]] = None
) -> "Wavefunction"
Perform the exponentiation of fermionic algebras to the wavefunction according the method and accuracy.
Args | |
---|---|
time (float) - the final time value to evolve to
algo (string) - polynomial expansion algorithm to be used hamil (Hamiltonian) - the Hamiltonian used to generate the unitary accuracy (double) - the accuracy to which the system should be evolved expansion (int) - the maximum number of terms in the polynomial expansion spec_lim (List[float]) - spectral range of the Hamiltonian, the length of the list should be 2. Optional. |
Returns | |
---|---|
newwfn (Wavefunction) - a new intialized wavefunction object |
ax_plus_y
ax_plus_y(
sval: complex,
wfn: "Wavefunction"
) -> None
Perform scale and add of the wavefunction. The result will be stored in self.
Args | |
---|---|
sval (complex) - a factor to be multiplied to wfn
wfn (Wavefunction) - a wavefunction to be added to self |
conserve_number
conserve_number() -> bool
Returns if this wave function conserves the number symmetry
conserve_spin
conserve_spin() -> bool
Returns if this wave function conserves the spin (Sz) symmetry
expectationValue
expectationValue(
ops: Union['fqe_operator.FqeOperator', 'hamiltonian.Hamiltonian'],
brawfn: "Wavefunction" = None
) -> Union[complex, numpy.ndarray]
Calculates expectation values given operators
Args | |
---|---|
ops (FqeOperator or Hamiltonian) - operator for which the expectation value is computed
brawfn (Wavefunction) - bra-side wave function for transition quantity (optional) |
Returns | |
---|---|
(complex or numpy.ndarray) - resulting expectation value or RDM |
get_coeff
get_coeff(
key: Tuple[int, int]
) -> numpy.ndarray
Retrieve a vector from a configuration in the wavefunction
key indicates wavefunction sector by [num_alpha, num_beta]
Args | |
---|---|
key (int, int) - a key identifying the configuration to access
vec (int) - an integer indicating which state should be returned |
Returns | |
---|---|
numpy.array(dtype=numpy.complex128) |
max_element
max_element() -> complex
Return the largest magnitude value in the wavefunction
norb
norb() -> int
Return the number of orbitals
norm
norm() -> float
Calculate the norm of the wavefuntion
normalize
normalize() -> None
Generte the wavefunction norm and then scale each element by that value.
print_wfn
print_wfn(
threshold: float = 0.001,
fmt: str = 'str'
) -> None
Print occupations and coefficients to the screen.
Args | |
---|---|
threshhold (float) - only print CI vector values such that :math:|c| > threshold.
fmt (string) - formats print according to argument states (int of list[int]) - an index or indexes indicating which states to print. |
rdm
rdm(
string: str,
brawfn: Optional['Wavefunction'] = None
) -> Union[complex, numpy.ndarray]
Returns rank-1 RDM. The operator order is specified by string. Note that, if the entire RDM is requested for N-broken wave function, this returns a packed format.
Args | |
---|---|
string (str) - character strings that specify the quantity to be computed
brawfn (Wavefunction) - bra-side wave function for transition RDM (optional) |
Returns | |
---|---|
Resulting RDM in numpy.ndarray or element in complex |
read
read(
filename: str,
path: str = os.getcwd()
) -> None
Initialize a wavefunction from a binary file.
Args | |
---|---|
filename (str) - the name of the file to write the wavefunction to.
path (str) - the path to save the file. If no path is given then it is saved in the current working directory. |
save
save(
filename: str,
path: str = os.getcwd()
) -> None
Save the wavefunction into path/filename.
Args | |
---|---|
filename (str) - the name of the file to write the wavefunction to.
path (str) - the path to save the file. If no path is given, then it is saved in the current working directory. |
scale
scale(
sval: complex
) -> None
Scale each configuration space by the value sval
Args | |
---|---|
sval (complex) - value to scale by |
sector
sector(
key
) -> "FqeData"
Return a list of the configuration keys in the wavefunction
sectors
sectors() -> KeysView[Tuple[int, int]]
Return a list of the configuration keys in the wavefunction
set_wfn
set_wfn(
strategy: str = 'ones',
raw_data: Optional[Dict[Tuple[int, int], numpy.ndarray]] = None
) -> None
Set the values of the ciwfn based on an argument or data to initalize from.
Args | |
---|---|
strategy (string) - an option controlling how the values are set
raw_data (numpy.array(dtype=numpy.complex128)) - data to inject into the configuration |
time_evolve
time_evolve(
time: float,
hamil,
inplace: bool = False
) -> "Wavefunction"
Perform time evolution of the wavefunction given Fermion Operators either as raw operations or wrapped up in a Hamiltonian.
Args | |
---|---|
ops (FermionOperators) - FermionOperators which are to be time evolved.
time (float) - the duration by which to evolve the operators |
Returns | |
---|---|
Wavefunction - a wavefunction object that has been time evolved. |
transform
transform(
rotation: numpy.ndarray,
low: Optional[numpy.ndarray] = None,
upp: Optional[numpy.ndarray] = None
) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, 'Wavefunction']
Transform the wavefunction using the orbtial rotation matrix and return the new wavefunction and the permutation matrix for the unitary transformation. This is an internal code, so performs minimal checking
Args | |
---|---|
rotation (numpy.ndarray) - MO rotation matrix, which is unitary
low (numpy.ndarray) - L in the LU decomposition (optional) upp (numpy.ndarray) - U in the LU decomposition (optional) |
Returns | |
---|---|
(numpy.ndarray, numpy.ndarray, numpy.ndarray, 'Wavefunction') - permutation, L, U, and transformed wavefunction |
__add__
__add__(
other: "Wavefunction"
) -> "Wavefunction"
Intrinsic addition function to combine two wavefunctions. This acts to iterate through the wavefunctions, combine coefficients of configurations they have in common and add configurations that are unique to each one. The values are all combined into a new wavefunction object
Args | |
---|---|
other (wavefunction.Wavefunction) - the second wavefunction to add with the local wavefunction |
Returns | |
---|---|
wfn (wavefunction.Wavefunction) - a new wavefunction with the values set by adding together values |
__getitem__
__getitem__(
key: Tuple[int, int]
) -> complex
Element read access to the wave function.
Args | |
---|---|
key (Tuple[int, int]) - a pair of strings for alpha and beta |
Returns | |
---|---|
(complex) - the value of the wave function |
__sub__
__sub__(
other: "Wavefunction"
) -> "Wavefunction"
Intrinsic subtraction function to combine two wavefunctions. This acts to iterate through the wavefunctions, combine coefficients of configurations they have in common and include configurations that are unique to each one. The values are all combined into a new wavefunction object
Args | |
---|---|
other (wavefunction.Wavefunction) - the second wavefunction that will be subtracted from the first wavefunction |
Returns | |
---|---|
wfn (wavefunction.Wavefunction) - a new wavefunction with the values set by subtracting the wfn from the first |