SpinHalfFermionSite

  • full name: tenpy.networks.site.SpinHalfFermionSite

  • parent module: tenpy.networks.site

  • type: class

Inheritance Diagram

Inheritance diagram of tenpy.networks.site.SpinHalfFermionSite

Methods

SpinHalfFermionSite.__init__([cons_N, ...])

SpinHalfFermionSite.add_op(name, op[, ...])

Add one on-site operators.

SpinHalfFermionSite.change_charge([...])

Change the charges of the site (in place).

SpinHalfFermionSite.charge_to_JW_signs(charges)

Convert charge values to Jordan-Wigner parity.

SpinHalfFermionSite.from_hdf5(hdf5_loader, ...)

Load instance from a HDF5 file.

SpinHalfFermionSite.get_hc_op_name(name)

Return the hermitian conjugate of a given operator.

SpinHalfFermionSite.get_op(name)

Return operator of given name.

SpinHalfFermionSite.multiply_op_names(names)

Multiply operator names together.

SpinHalfFermionSite.multiply_operators(operators)

Multiply local operators (possibly given by their names) together.

SpinHalfFermionSite.op_needs_JW(name)

Whether an (composite) onsite operator is fermionic and needs a Jordan-Wigner string.

SpinHalfFermionSite.remove_op(name)

Remove an added operator.

SpinHalfFermionSite.rename_op(old_name, new_name)

Rename an added operator.

SpinHalfFermionSite.save_hdf5(hdf5_saver, ...)

Export self into a HDF5 file.

SpinHalfFermionSite.sort_charge([bunch])

Sort the leg charges (in place).

SpinHalfFermionSite.state_index(label)

Return index of a basis state from its label.

SpinHalfFermionSite.state_indices(labels)

Same as state_index(), but for multiple labels.

SpinHalfFermionSite.test_sanity()

Sanity check, raises ValueErrors, if something is wrong.

SpinHalfFermionSite.valid_opname(name)

Check whether 'name' labels a valid onsite-operator.

Class Attributes and Properties

SpinHalfFermionSite.dim

Dimension of the local Hilbert space.

SpinHalfFermionSite.onsite_ops

Dictionary of on-site operators for iteration.

class tenpy.networks.site.SpinHalfFermionSite(cons_N='N', cons_Sz='Sz', filling=1.0)[source]

Bases: Site

Create a Site for spinful (spin-1/2) fermions.

Local states are:

empty (vacuum), up (one spin-up electron), down (one spin-down electron), and full (both electrons)

Local operators can be built from creation operators.

Warning

Using the Jordan-Wigner string (JW) in the correct way is crucial to get correct results, otherwise you just describe hardcore bosons!

operator

description

Id

Identity \(\mathbb{1}\)

JW

Sign for the Jordan-Wigner string \((-1)^{n_{\uparrow}+n_{\downarrow}}\)

JWu

Partial sign for the Jordan-Wigner string \((-1)^{n_{\uparrow}}\)

JWd

Partial sign for the Jordan-Wigner string \((-1)^{n_{\downarrow}}\)

Cu

Annihilation operator spin-up \(c_{\uparrow}\) (up to ‘JW’-string on sites left of it).

Cdu

Creation operator spin-up \(c^\dagger_{\uparrow}\) (up to ‘JW’-string on sites left of it).

Cd

Annihilation operator spin-down \(c_{\downarrow}\) (up to ‘JW’-string on sites left of it). Includes JWu such that it anti-commutes onsite with Cu, Cdu.

Cdd

Creation operator spin-down \(c^\dagger_{\downarrow}\) (up to ‘JW’-string on sites left of it). Includes JWu such that it anti-commutes onsite with Cu, Cdu.

Nu

Number operator \(n_{\uparrow}= c^\dagger_{\uparrow} c_{\uparrow}\)

Nd

Number operator \(n_{\downarrow}= c^\dagger_{\downarrow} c_{\downarrow}\)

NuNd

Dotted number operators \(n_{\uparrow} n_{\downarrow}\)

Ntot

Total number operator \(n_t= n_{\uparrow} + n_{\downarrow}\)

dN

Total number operator compared to the filling \(\Delta n = n_t-filling\)

Sx, Sy, Sz

Spin operators \(S^{x,y,z}\), in particular \(S^z = \frac{1}{2}( n_\uparrow - n_\downarrow )\)

Sp, Sm

Spin flips \(S^{\pm} = S^{x} \pm i S^{y}\), e.g. \(S^{+} = c^\dagger_\uparrow c_\downarrow\)

The spin operators are defined as \(S^\gamma = (c^\dagger_{\uparrow}, c^\dagger_{\downarrow}) \sigma^\gamma (c_{\uparrow}, c_{\downarrow})^T\), where \(\sigma^\gamma\) are spin-1/2 matrices (i.e. half the pauli matrices).

cons_N

cons_Sz

qmod

excluded onsite operators

'N'

'Sz'

[1, 1]

Sx, Sy

'N'

'parity'

[1, 4]

'N'

None

[1]

'parity'

'Sz'

[2, 1]

Sx, Sy

'parity'

'parity'

[2, 4]

'parity'

None

[2]

None

'Sz'

[1]

Sx, Sy

None

'parity'

[4]

None

None

[]

Parameters:
  • cons_N ('N' | 'parity' | None) – Whether particle number is conserved, c.f. table above.

  • cons_Sz ('Sz' | 'parity' | None) – Whether spin is conserved, c.f. table above.

  • filling (float) – Average filling. Used to define dN.

cons_N

Whether particle number is conserved, c.f. table above.

Type:

'N' | 'parity' | None

cons_Sz

Whether spin is conserved, c.f. table above.

Type:

'Sz' | 'parity' | None

filling

Average filling. Used to define dN.

Type:

float

add_op(name, op, need_JW=False, hc=None, permute_dense=None)[source]

Add one on-site operators.

Parameters:
  • name (str) – A valid python variable name, used to label the operator. The name under which op is added as attribute to self.

  • op (np.ndarray | Array) – A matrix acting on the local hilbert space representing the local operator. Dense numpy arrays are automatically converted to Array. LegCharges have to be [leg, leg.conj()]. We set labels 'p', 'p*'.

  • need_JW (bool) – Whether the operator needs a Jordan-Wigner string. If True, add name to need_JW_string.

  • hc (None | False | str) – The name for the hermitian conjugate operator, to be used for hc_ops. By default (None), try to auto-determine it. If False, disable adding entries to hc_ops.

  • permute_dense (bool | None) – Flag to enable/disable permutations when converting op from numpy to np_conserved arrays. If True, the operator is permuted with perm to account for permutations induced by sorting charges; False disables the permutations. By default (None), the value of used_sort_charge is used.

change_charge(new_leg_charge=None, permute=None)[source]

Change the charges of the site (in place).

Parameters:
  • new_leg_charge (LegCharge | None) – The new charges to be used. If None, use trivial charges.

  • permute (ndarray | None) – The permutation applied to the physical leg, which also gets used to adjust state_labels and perm. If you sorted the previous leg with perm_qind, new_leg_charge = leg.sort(), use old_leg.perm_flat_from_perm_qind(perm_qind). Ignored if None.

charge_to_JW_signs(charges)[source]

Convert charge values to Jordan-Wigner parity.

Often, charge conservation contains the (parity of) the total fermion number. This information is enough to lift a Jordan-Wigner string applied on the left of a given bond to the virtual leg of an MPS: given the total parity number of fermions parity[alpha] = N_fermions[alpha] % 2 in each Schmidt state |alpha>, simply send |alpha> --> (-1)**parity[alpha] |alpha>. Given the charges values of the Schmidt states |alpha>, this function returns the corresponding (-1)**parity Jordan-Wigner signs.

Parameters:

charges (2D or 1D array) – Charge values, last dimension is len chinfo.qnumber. We choose the convention that these charge values correspond to an “incoming” leg with qconj=+1.

Returns:

Should only have values +1 or -1.

Return type:

JW_signs

property dim

Dimension of the local Hilbert space.

classmethod from_hdf5(hdf5_loader, h5gr, subpath)[source]

Load instance from a HDF5 file.

This method reconstructs a class instance from the data saved with save_hdf5().

Parameters:
  • hdf5_loader (Hdf5Loader) – Instance of the loading engine.

  • h5gr (Group) – HDF5 group which is represent the object to be constructed.

  • subpath (str) – The name of h5gr with a '/' in the end.

Returns:

obj – Newly generated class instance containing the required data.

Return type:

cls

get_hc_op_name(name)[source]

Return the hermitian conjugate of a given operator.

Parameters:

name (str) – The name of the operator to be conjugated. Multiple operators separated by whitespace are interpreted as an operator product, exactly as get_op() does.

Returns:

hc_op_name – Operator name for the hermitian conjugate operator.

Return type:

str

get_op(name)[source]

Return operator of given name.

Parameters:

name (str) – The name of the operator to be returned. In case of multiple operator names separated by whitespace, we multiply them together to a single on-site operator (with the one on the right acting first).

Returns:

op – The operator given by name, with labels 'p', 'p*'. If name already was an npc Array, it’s directly returned.

Return type:

np_conserved

multiply_op_names(names)[source]

Multiply operator names together.

Join the operator names in names such that get_op returns the product of the corresponding operators.

Parameters:

names (list of str) – List of valid operator labels.

Returns:

combined_opname – A valid operator name Operator name representing the product of operators in names.

Return type:

str

multiply_operators(operators)[source]

Multiply local operators (possibly given by their names) together.

Parameters:

operators (list of {str | Array}) – List of valid operator names (to be translated with get_op()) or directly on-site operators in the form of npc arrays with 'p', 'p*' label. The operators are multiplied left-to-right.

Returns:

combined_operator – The product of the given operators in a left-to-right multiplication following the usual mathematical convention. For example, if operators=['Sz', 'Sp', 'Sx'], the final operator is equivalent to site.get_op('Sz Sp Sx'), with the 'Sx' operator acting first on any physical state.

Return type:

Array

property onsite_ops

Dictionary of on-site operators for iteration.

Single operators are accessible as attributes.

op_needs_JW(name)[source]

Whether an (composite) onsite operator is fermionic and needs a Jordan-Wigner string.

Parameters:

name (str) – The name of the operator, as in get_op().

Returns:

needs_JW – Whether the operator needs a Jordan-Wigner string, judging from need_JW_string.

Return type:

bool

remove_op(name)[source]

Remove an added operator.

Parameters:

name (str) – The name of the operator to be removed.

rename_op(old_name, new_name)[source]

Rename an added operator.

Parameters:
  • old_name (str) – The old name of the operator.

  • new_name (str) – The new name of the operator.

save_hdf5(hdf5_saver, h5gr, subpath)[source]

Export self into a HDF5 file.

This method saves all the data it needs to reconstruct self with from_hdf5().

This implementation saves the content of __dict__ with save_dict_content(), storing the format under the attribute 'format'.

Parameters:
  • hdf5_saver (Hdf5Saver) – Instance of the saving engine.

  • h5gr (:class`Group`) – HDF5 group which is supposed to represent self.

  • subpath (str) – The name of h5gr with a '/' in the end.

sort_charge(bunch=True)[source]

Sort the leg charges (in place).

Parameters:

bunch (bool) – Whether to also group equal charges into larger blocks (usually a good idea).

Returns:

perm – The permutation

Return type:

1D ndarray

state_index(label)[source]

Return index of a basis state from its label.

Parameters:

label (int | string) – either the index directly or a label (string) set before.

Returns:

state_index – the index of the basis state associated with the label.

Return type:

int

state_indices(labels)[source]

Same as state_index(), but for multiple labels.

test_sanity()[source]

Sanity check, raises ValueErrors, if something is wrong.

valid_opname(name)[source]

Check whether ‘name’ labels a valid onsite-operator.

Parameters:

name (str) – Label for the operator. Can be multiple operator(labels) separated by whitespace, indicating that they should be multiplied together.

Returns:

validTrue if name is a valid argument to get_op().

Return type:

bool