schmidt_utils

Utilities for generating the most significant Schmidt states.

Classes

StoppingCondition

Describes a stopping condition for enumerating Schmidt states.

Functions

lowest_sums

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 intbool function is_sector().

Note

Does not affect methods __call__() and truncate() directly, but is_sector() is used in lowest_sums() to filter the subsets on the fly.

chi_max: int | None = None

Maximum number of Schmidt states to keep.

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:

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:

bool

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:

int

Returns:

Number of Schmidt states to keep

Note

The logic used within the function is based on the TeNpy function truncate().

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 a in order of increasing sum, until trunc_par is satisfied. The subsets are then truncated according to trunc_par.truncate.

For generating the leading Schmidt values, a should 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.

  • filled_right (int | None) –

    Number of filled orbitals on the right side, used to offset sector labels in the stopping condition.

    filled_right is ignored if filled_left is given too.

Return type:

tuple[ndarray, ndarray]

Returns:

  • sums – The lowest subset sums of a, sorted, cut off according to trunc_par.

  • sets – The subsets of a that realise these sums as a boolean array.