multi_sites_combine_charges

  • full name: tenpy.networks.site.multi_sites_combine_charges

  • parent module: tenpy.networks.site

  • type: function

tenpy.networks.site.multi_sites_combine_charges(sites, same_charges=[])[source]

Adjust the charges of the given sites (in place) such that they can be used together.

When we want to contract tensors corresponding to different Site instances, these sites need to share a single ChargeInfo. This function adjusts the charges of these sites such that they can be used together.

Parameters
  • sites (list of Site) – The sites to be combined. Modified in place.

  • same_charges ([[(int, int|str), (int, int|str), ...], ...]) – Defines which charges actually are the same, i.e. their quantum numbers are added up. Each charge is specified by a tuple (s, i)= (int, int|str), where s gives the index of the site within sites and i the index or name of the charge in the ChargeInfo of this site.

Returns

perms – For each site the permutation performed on the physical leg to sort by charges.

Return type

list of ndarray

Examples

>>> ferm = SpinHalfFermionSite(cons_N='N', cons_Sz='Sz')
>>> spin = SpinSite(1.0, 'Sz')
>>> ferm.leg.chinfo is spin.leg.chinfo
False
>>> print(spin.leg)
+1
0 [[-1]
1  [ 1]]
2
>>> multi_sites_combine_charges([ferm, spin], same_charges=[[(0, 'Sz'), (1, 0)]])
[array([0, 1, 2, 3]), array([0, 1])]
>>> # no permutations where needed
>>> ferm.leg.chinfo is spin.leg.chinfo
True
>> ferm.leg.chinfo.names
['N', 'Sz']
>>> print(spin.leg)
+1
0 [[ 0 -1]
1  [ 0  1]]
2