detect_legcharge
full name: tenpy.linalg.np_conserved.detect_legcharge
parent module:
tenpy.linalg.np_conserved
type: function
- tenpy.linalg.np_conserved.detect_legcharge(flat_array, chargeinfo, legcharges, qtotal=None, qconj=1, cutoff=None)[source]
Calculate a missing LegCharge by looking for nonzero entries of a flat array.
- Parameters:
flat_array (ndarray) – A flat array, in which we look for non-zero entries.
chargeinfo (
ChargeInfo
) – The nature of the charge.legcharges (list of
LegCharge
) – One LegCharge for each dimension of flat_array, except for one entry which isNone
. This missing entry is to be calculated.qconj ({+1, -1}) – qconj for the new calculated LegCharge.
qtotal (charges) – Desired total charge of the array. Defaults to zeros.
cutoff (float) – Blocks with
np.max(np.abs(block)) > cutoff
are considered as zero. Defaults toQCUTOFF
.
- Returns:
new_legcharges – A copy of the given legcharges with the
None
replaced by a compatible LegCharge. The new legcharge is ‘bunched’, but not sorted!- Return type:
list of
LegCharge
See also
detect_grid_outer_legcharge
similar functionality if the flat array is given by a ‘grid’.
detect_qtotal
detects the total charge, if all legs are known.