# DensityMatrixMixer¶

Inheritance Diagram Methods

 DensityMatrixMixer.__init__(options, ...) DensityMatrixMixer.mix_rho(engine, theta, ...) Calculated reduced density matrices of theta with a perturbation by the mixer. DensityMatrixMixer.perturb_svd(engine, ...) Mix extra terms to theta and perform an SVD. DensityMatrixMixer.svd_from_rho(engine, ...) Diagonalize rho_L, rho_R to rewrite theta as U S V with canonical U/V. Update the amplitude, possibly disable the mixer.

Class Attributes and Properties

 DensityMatrixMixer.update_sites how many sites the theta in perturb_svd should have
class tenpy.algorithms.dmrg.DensityMatrixMixer(options, sweep_activated)[source]

Bases: Mixer

Mixer based on density matrices.

This mixer constructs density matrices as described in the original paper .

The mixer interjects at the svd theta = U S VH with U-> A[i0] and VH -> B[i0+1] being the new tensors in the MPS. Given theta, one way to get the U is to calculate and diagonalize the reduced density matrices rho_L = tr_R |theta><theta|, and similarly diagonalize rho_R for VH.

With the mixer, we perturb the rho_L when the left environment needs to be updated (i.e., we’re moving to the right), and similarly perturb rho_R when updating the right environment. Note that for iDMRG there are cases where both rho_R and rho_L are perturbed.

The perturbation of rho_L is

$rho_L = tr_R(|\theta><\theta|) \rightarrow tr_R(|\theta><\theta|) + a \sum_l h_l tr_R(|\theta><\theta|) h_l^\dagger$

where a is the (small) perturbation amplitude and h_l are the left parts of the Hamiltonian going accross the center bond (i0, i0+1). This perturbs singular values on the order of that amplitude.

Pictorially, the left density matrix rho_L is given by:

|     update_LP=False           update_LP=True
|
|    .---theta---.            .---theta----.
|    |   |   |   |            |   |    \   |
|            |   |           LP---H0-.  \  |
|    |   |   |   |            |   |   \  | |
|    .---theta*--.                  mixL | |
|                             |   |   /  | |
|                            LP*--H0*-  /  |
|                             |   |    /   |
|                             .---theta*---.


Here, the mixL is a diagonal matrix with mostly the amplitude on the diagonal, except for the IdL and IdR indices of the MPO, which are 1. and 0., respectively.

The right density matrix rho_R is mirrored accordingly.

Note that the SubspaceExpansion mixer does mathematically the same, but circumvents the explicit contraction of the

update_sites = 2

how many sites the theta in perturb_svd should have

perturb_svd(engine, theta, i0, update_LP, update_RP)[source]

Mix extra terms to theta and perform an SVD.

We calculate the left and right reduced density using the mixer (which might include applications of H). These density matrices are diagonalized and truncated such that we effectively perform a svd for the case mixer.amplitude=0.

Parameters
• engine (SingleSiteDMRGEngine | TwoSiteDMRGEngine) – The DMRG engine calling the mixer.

• theta (Array) – The optimized wave function, prepared for svd.

• i0 (int) – Site index; theta lives on i0, i0+1.

• update_LP (bool) – Whether to calculate the next env.LP[i0+1], i.e. whether to perturb rho_L.

• update_RP (bool) – Whether to calculate the next env.RP[i0], i.e., whether to perturb rho_R.

Returns

• U (Array) – Left-canonical part of theta. Labels '(vL.p0)', 'vR'.

• S (2D Array) – General center matrix such that theta = U.S.VH

• VH (Array) – Right-canonical part of theta. Labels 'vL', '(p1.vR)'.

• err (TruncationError) – The truncation error introduced.

• S_a (1D ndarray) – Approximation of the actual singular values of theta.

svd_from_rho(engine, rho_L, rho_R, theta, i0)[source]

Diagonalize rho_L, rho_R to rewrite theta as U S V with canonical U/V.

If rho_L and rho_R were the actual density matrices of theta, this function just performs an SVD by diagonalizing rho_L with U and rho_R with VH and then rewriting theta == U (U^dagger theta VH^dagger VH) = U S V. Since the actual rho_L and rho_R passed as arguments are perturbed by mix_rho

Returns

As defined in perturb_svd().

Return type

U, S, VH, err, S_a

mix_rho(engine, theta, i0, update_LP, update_RP)[source]

Calculated reduced density matrices of theta with a perturbation by the mixer.

Parameters
• engine (DMRGEngine) – The DMRG engine calling the mixer.

• theta (Array) – Ground state of the effective Hamiltonian, prepared for svd.

• i0 (int) – Site index; theta lives on sites i0, i0+1.

• update_LP (bool) – Whether to perturb rho_L and rho_R, respectively. (At least one of them is True when the mixer is enabled.)

• update_RP (bool) – Whether to perturb rho_L and rho_R, respectively. (At least one of them is True when the mixer is enabled.)

Returns

rho_L, rho_R – A (hermitian) square array with labels '(vL.p0)', '(vL*.p0*)', or '(p1.vR)', '(p1*.vR*)', respectively.

Return type

Array

update_amplitude(sweeps)[source]

Update the amplitude, possibly disable the mixer.

Parameters

sweeps (int) – The number of performed sweeps, to check if we need to disable the mixer.

Returns

mixer – Returns self if we should continue mixing, or None, if the mixer should be disabled.

Return type

Mixer | None