BosonSite

Inheritance Diagram

Inheritance diagram of tenpy.networks.site.BosonSite

Methods

BosonSite.__init__([Nmax, conserve, filling])

Initialize self.

BosonSite.add_op(name, op[, need_JW])

Add one on-site operators.

BosonSite.change_charge([new_leg_charge, …])

Change the charges of the site (in place).

BosonSite.from_hdf5(hdf5_loader, h5gr, subpath)

Load instance from a HDF5 file.

BosonSite.get_op(name)

Return operator of given name.

BosonSite.multiply_op_names(names)

Multiply operator names together.

BosonSite.op_needs_JW(name)

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

BosonSite.remove_op(name)

Remove an added operator.

BosonSite.rename_op(old_name, new_name)

Rename an added operator.

BosonSite.save_hdf5(hdf5_saver, h5gr, subpath)

Export self into a HDF5 file.

BosonSite.state_index(label)

Return index of a basis state from its label.

BosonSite.state_indices(labels)

Same as state_index(), but for multiple labels.

BosonSite.test_sanity()

Sanity check, raises ValueErrors, if something is wrong.

BosonSite.valid_opname(name)

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

Class Attributes and Properties

BosonSite.dim

Dimension of the local Hilbert space.

BosonSite.onsite_ops

Dictionary of on-site operators for iteration.

class tenpy.networks.site.BosonSite(Nmax=1, conserve='N', filling=0.0)[source]

Bases: tenpy.networks.site.Site

Create a Site for up to Nmax bosons.

Local states are vac, 1, 2, ... , Nc. (Exception: for parity conservation, we sort as vac, 2, 4, ..., 1, 3, 5, ....)

operator

description

Id, JW

Identity \(\mathbb{1}\)

B

Annihilation operator \(b\)

Bd

Creation operator \(b^\dagger\)

N

Number operator \(n= b^\dagger b\)

NN

\(n^2\)

dN

\(\delta n := n - filling\)

dNdN

\((\delta n)^2\)

P

Parity \(Id - 2 (n \mod 2)\).

conserve

qmod

excluded onsite operators

'N'

[1]

'parity'

[2]

None

[]

Parameters
  • Nmax (int) – Cutoff defining the maximum number of bosons per site. The default Nmax=1 describes hard-core bosons.

  • conserve (str) – Defines what is conserved, see table above.

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

conserve

Defines what is conserved, see table above.

Type

str

filling

Average filling. Used to define dN.

Type

float

add_op(name, op, need_JW=False)[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, the function adds name to need_JW_string.

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 permuation applied to the physical leg, which gets used to adjust state_labels and perm. If you sorted the previous leg with perm_qind, new_leg_charge = leg.sort(), use leg.perm_flat_from_perm_qind(perm_qind). Ignored if None.

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_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 Operatorname representing the product of operators in names.

Return type

str

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.

state_index(label)[source]

Return index of a basis state from its label.

Parameters

label (int | string) – eather 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