schmidt_utils
Utilities for generating the most significant Schmidt states.
Classes
Describes a stopping condition for enumerating Schmidt states. |
Functions
Generates subsets of a given set with the lowest sums. |
- class temfpy.schmidt_utils.StoppingCondition(sectors=None, chi_max=None, svd_min=None, degeneracy_tol=None)[source]
Describes a stopping condition for enumerating Schmidt states.
-
sectors:
Callable[[int],bool] |list[int] |int|None= None Specifies which charge sectors to retain.
Internally, all options are converted to a
int→boolfunctionis_sector().Note
Does not affect methods
__call__()andtruncate()directly, butis_sector()is used inlowest_sums()to filter the subsets on the fly.
-
svd_min:
float|None= None Lowest Schmidt value to be kept, as a fraction of the largest one.
Defaults to 1e-6 if not supplied.
-
degeneracy_tol:
float|None= None Don’t cut between neighboring Schmidt values with \(|\log(S_i/S_j)|\) below
degeneracy_tol.In other words, keep either both \(i\) and \(j\) or neither if the Schmidt values are degenerate with a relative error smaller than
degeneracy_tol.Defaults to 1e-12 if not supplied.
- __call__(logvals)[source]
Check if any of the stopping conditions had been satisfied.
Allows for generating slightly more states than the stopping conditions require, to make sure degeneracy requirements are satisfied:
chi_max+ 1 statesSchmidt values down to
svd_min/ exp(degeneracy_tol)
- Parameters:
logvals (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],complex,bytes,str,_NestedSequence[complex|bytes|str]]) – Negative logarithms of Schmidt values. Must be sorted in increasing order.- Return type:
- Returns:
whether more sets need to be generated (
True) or we have enough (False)
Note
Results generated using this function must be passed through
truncate()to finish the truncation considering every stopping condition.
- truncate(logvals)[source]
Finds number of Schmidt states to retain to be consistent with every constraint (including near-degeneracy).
- Parameters:
logvals (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],complex,bytes,str,_NestedSequence[complex|bytes|str]]) – Negative logarithms of Schmidt values. Must be sorted in increasing order.- Return type:
- Returns:
Number of Schmidt states to keep
Note
The logic used within the function is based on the TeNpy function
truncate().
-
sectors:
- temfpy.schmidt_utils.lowest_sums(a, trunc_par, *, filled_left=None, filled_right=None)[source]
Generates subsets of a given set with the lowest sums.
This functions generates all possible subsets of
ain order of increasing sum, untiltrunc_paris satisfied. The subsets are then truncated according totrunc_par.truncate.For generating the leading Schmidt values,
ashould be \(\log(\lambda_R / \lambda_L)\) for the entangled orbitals.Uses the algorithm laid out in https://stackoverflow.com/a/72117947/27202449.
- Parameters:
a (
Union[_Buffer,_SupportsArray[dtype[Any]],_NestedSequence[_SupportsArray[dtype[Any]]],complex,bytes,str,_NestedSequence[complex|bytes|str]]) – The set whose subsets with the lowest sums are to be generated.trunc_par (
StoppingCondition) – Condition to stop generating more subsets and truncate the generated.filled_left (
int|None) – Number of filled orbitals on the left side, used to offset sector labels in the stopping condition.Number of filled orbitals on the right side, used to offset sector labels in the stopping condition.
filled_rightis ignored iffilled_leftis given too.
- Return type:
- Returns:
sums – The lowest subset sums of
a, sorted, cut off according totrunc_par.sets – The subsets of
athat realise these sums as a boolean array.