SpinHalfSite¶
full name: tenpy.networks.site.SpinHalfSite
parent module:
tenpy.networks.site
type: class
-
class
tenpy.networks.site.
SpinHalfSite
(conserve='Sz')[source]¶ Bases:
tenpy.networks.site.Site
Spin-1/2 site.
Local states are
up
(0) anddown
(1). Local operators are the usual spin-1/2 operators, e.g.Sz = [[0.5, 0.], [0., -0.5]]
,Sx = 0.5*sigma_x
for the Pauli matrix sigma_x.operator
description
Id, JW
Identity \(\mathbb{1}\)
Sx, Sy, Sz
Spin components \(S^{x,y,z}\), equal to half the Pauli matrices.
Sigmax, Sigmay, Sigmaz
Pauli matrices \(\sigma^{x,y,z}\)
Sp, Sm
Spin flips \(S^{\pm} = S^{x} \pm i S^{y}\)
conserve
qmod
excluded onsite operators
'Sz'
[1]
Sx, Sy, Sigmax, Sigmay
'parity'
[2]
–
None
[]
–
- Parameters
- conservestr
Defines what is conserved, see table above.
- Attributes
- conservestr
Defines what is conserved, see table above.
Methods
add_op
(self, name, op[, need_JW])Add one on-site operators.
change_charge
(self[, new_leg_charge, permute])Change the charges of the site (in place).
get_op
(self, name)Return operator of given name.
multiply_op_names
(self, names)Multiply operator names together.
op_needs_JW
(self, name)Whether an (composite) onsite operator is fermionic and needs a Jordan-Wigner string.
remove_op
(self, name)Remove an added operator.
rename_op
(self, old_name, new_name)Rename an added operator.
state_index
(self, label)Return index of a basis state from its label.
state_indices
(self, labels)Same as
state_index()
, but for multiple labels.test_sanity
(self)Sanity check, raises ValueErrors, if something is wrong.
valid_opname
(self, name)Check whether ‘name’ labels a valid onsite-operator.
-
add_op
(self, name, op, need_JW=False)¶ Add one on-site operators.
- Parameters
- namestr
A valid python variable name, used to label the operator. The name under which op is added as attribute to self.
- opnp.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_JWbool
Whether the operator needs a Jordan-Wigner string. If
True
, the function adds name toneed_JW_string
.
-
change_charge
(self, new_leg_charge=None, permute=None)¶ 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.- permutendarray | None
The permuation applied to the physical leg, which gets used to adjust
state_labels
andperm
. If you sorted the previous leg withperm_qind, new_leg_charge = leg.sort()
, useleg.perm_flat_from_perm_qind(perm_qind)
. Ignored ifNone
.
- new_leg_charge
-
property
dim
¶ Dimension of the local Hilbert space.
-
get_op
(self, name)¶ Return operator of given name.
- Parameters
- namestr
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
np_conserved
The operator given by name, with labels
'p', 'p*'
. If name already was an npc Array, it’s directly returned.
- op
-
multiply_op_names
(self, names)¶ Multiply operator names together.
Join the operator names in names such that get_op returns the product of the corresponding operators.
- Parameters
- nameslist of str
List of valid operator labels.
- Returns
- combined_opnamestr
A valid operator name Operatorname representing the product of operators in names.
-
property
onsite_ops
¶ Dictionary of on-site operators for iteration.
Single operators are accessible as attributes.
-
op_needs_JW
(self, name)¶ Whether an (composite) onsite operator is fermionic and needs a Jordan-Wigner string.
- Parameters
- namestr
The name of the operator, as in
get_op()
.
- Returns
- needs_JWbool
Whether the operator needs a Jordan-Wigner string, judging from
need_JW_string
.
-
remove_op
(self, name)¶ Remove an added operator.
- Parameters
- namestr
The name of the operator to be removed.
-
rename_op
(self, old_name, new_name)¶ Rename an added operator.
- Parameters
- old_namestr
The old name of the operator.
- new_namestr
The new name of the operator.
-
state_index
(self, label)¶ Return index of a basis state from its label.
- Parameters
- labelint | string
eather the index directly or a label (string) set before.
- Returns
- state_indexint
the index of the basis state associated with the label.
-
state_indices
(self, labels)¶ Same as
state_index()
, but for multiple labels.
-
test_sanity
(self)¶ Sanity check, raises ValueErrors, if something is wrong.