Hi,
I want to calculate the expectation value of Sx, Sy and Sz after TDVP evolution. I use psi.expectation_value('Sx'),psi.expectation_value('Sy'),psi.expectation_value('Sz') to do the calculation but it appears error information:
ValueError: <Site, d=2, ops={'Sz', 'Id', 'Sp', 'Sm', 'JW'}> doesn't have the operator 'Sx'
It only allows me to calculate the expectation value of above five operators. May I know what should I do to calculate psi.expectation_value('Sx') and psi.expectation_value('Sy') ?
The state psi is initialized as product states and then goes through TDVP evolution:
Model_XXZ = XXZChain(model_params)
psi = MPS.from_product_state(Model_XXZ.lat.mps_sites(), product_state, bc=Model_XXZ.lat.bc_MPS, form='B')
tdvp_params = {
'start_time': 0,
'dt': delta_t,
'trunc_params': {
'chi_max': chi,
'svd_min': 1.e10,
'trunc_cut': None
}
}
tdvp_engine = tdvp.TDVPEngine(psi, Model_XXZ, tdvp_params)
Asking about how to calculate expectation values after TDVP evolution

 Posts: 5
 Joined: 31 Oct 2022, 23:18
Re: Asking about how to calculate expectation values after TDVP evolution
The XXZ chain by default turns on Sz conservation. Hence, there is no operator 'Sx' or 'Sy', because they don't conserve the Sz charge. Due to Sz conservation, you immediately know that expectation values of Sx and Sy are zero.
See also this FAQ question
However, note that the correlations <Sx_i Sx_j> in general can be nonzero. To calculate them, decompose them with
\(S^{\pm} = S^x \pm i S^y\), i.e. e.g. \(S^x = 0.5(S^+ + S^)\) in terms of the Sp and Sm operators,
and measure
See also this FAQ question
However, note that the correlations <Sx_i Sx_j> in general can be nonzero. To calculate them, decompose them with
\(S^{\pm} = S^x \pm i S^y\), i.e. e.g. \(S^x = 0.5(S^+ + S^)\) in terms of the Sp and Sm operators,
and measure
psi.correlation_function('Sp', 'Sm')
.
 Posts: 5
 Joined: 31 Oct 2022, 23:18
Re: Asking about how to calculate expectation values after TDVP evolution
Hi, thanks you for your reply!
When I try to use exact diagonalization to calculate the time evolution, I find the expectation values of Sx and Sy of the final state are not zero.
Also, assume the reduced density matrix of a single site is ([a b],[c,d]), if the expectation values of Sx and Sy are zero, that means b=c=0, which I find is not true.
I don't understand why you say the expectation values of Sx and Sy are zero...could you please explain why?
When I try to use exact diagonalization to calculate the time evolution, I find the expectation values of Sx and Sy of the final state are not zero.
Also, assume the reduced density matrix of a single site is ([a b],[c,d]), if the expectation values of Sx and Sy are zero, that means b=c=0, which I find is not true.
I don't understand why you say the expectation values of Sx and Sy are zero...could you please explain why?
Re: Asking about how to calculate expectation values after TDVP evolution
This is really standard arguments from quantum mechanics:
You can use Sz conseration, if \( [H,S^z] = 0\), where \(S^z = \sum_i S^z_i\). In that case, you *choose* to work in fixed magnetization sectors and write an initial state with \(S^z \psi_0\rangle = m \hbar  \psi_0 \rangle \), where \(m\in \mathbb{R}\) is a fixed number, the quantum number. Since \(H\) commutes with \(S^z\), you directly get \(S^z \psi(t)\rangle = m \hbar  \psi(t) \rangle \), i.e. it remains an eigenstate of \(S^z\) with the same quantum number.
As I said, you can express \(S^x_i = 0.5( S^+_i + S^_i)\) in terms of the ladder operators, for which \([S^z, S^+_i] = \hbar \).
Then standard arguments of quantum mechanics show
\[ m \hbar \langle \psi  S^+_i  \psi \rangle = \langle \psi  S^+_i S^z  \psi \rangle = \langle \psi  (S^z + \hbar) S^+_i  \psi \rangle = (m+1) \hbar \langle \psi  S^+_i  \psi \rangle, \]
so we must have \( \langle \psi  S^+_i  \psi \rangle = 0 \). Take the complex conjugate, and you see also \( \langle \psi  S^_i  \psi \rangle = 0 \), so \( \langle \psi  S^x_i \psi \rangle = 0.5( \langle \psi  S^+_i \psi \rangle + \langle \psi  S^_i \psi \rangle ) = 0 \).
If you get nonzero expectation values in exact diagonalization (ED), either your ED didn't conserve Sz properly, or you didn't start from the same initial state (with fixed particle number). Of course, you could also choose to write an initial state like \(\rightarrow \cdots \rangle \), which is not an eigenstate of \(S^z\). But charge conservation tells you that the problem of time evolution can be split into evolving separately within each charge sector.
You can use Sz conseration, if \( [H,S^z] = 0\), where \(S^z = \sum_i S^z_i\). In that case, you *choose* to work in fixed magnetization sectors and write an initial state with \(S^z \psi_0\rangle = m \hbar  \psi_0 \rangle \), where \(m\in \mathbb{R}\) is a fixed number, the quantum number. Since \(H\) commutes with \(S^z\), you directly get \(S^z \psi(t)\rangle = m \hbar  \psi(t) \rangle \), i.e. it remains an eigenstate of \(S^z\) with the same quantum number.
As I said, you can express \(S^x_i = 0.5( S^+_i + S^_i)\) in terms of the ladder operators, for which \([S^z, S^+_i] = \hbar \).
Then standard arguments of quantum mechanics show
\[ m \hbar \langle \psi  S^+_i  \psi \rangle = \langle \psi  S^+_i S^z  \psi \rangle = \langle \psi  (S^z + \hbar) S^+_i  \psi \rangle = (m+1) \hbar \langle \psi  S^+_i  \psi \rangle, \]
so we must have \( \langle \psi  S^+_i  \psi \rangle = 0 \). Take the complex conjugate, and you see also \( \langle \psi  S^_i  \psi \rangle = 0 \), so \( \langle \psi  S^x_i \psi \rangle = 0.5( \langle \psi  S^+_i \psi \rangle + \langle \psi  S^_i \psi \rangle ) = 0 \).
If you get nonzero expectation values in exact diagonalization (ED), either your ED didn't conserve Sz properly, or you didn't start from the same initial state (with fixed particle number). Of course, you could also choose to write an initial state like \(\rightarrow \cdots \rangle \), which is not an eigenstate of \(S^z\). But charge conservation tells you that the problem of time evolution can be split into evolving separately within each charge sector.

 Posts: 5
 Joined: 31 Oct 2022, 23:18
Re: Asking about how to calculate expectation values after TDVP evolution
Hi, thank you for your reply!
I did use Haarrandom state as initial state rather than an eigenstate of Sz when I use exact diagnalization to calculate the time evolution, and this make the Sx and Sy nonzero. May I know how can I get the expectation value of Sx and Sy for random initial state? Thanks!
I did use Haarrandom state as initial state rather than an eigenstate of Sz when I use exact diagnalization to calculate the time evolution, and this make the Sx and Sy nonzero. May I know how can I get the expectation value of Sx and Sy for random initial state? Thanks!
Re: Asking about how to calculate expectation values after TDVP evolution
A Haar random state has (almost) maximal entanglement and can thus *not* be compressed into an MPS (for large system sizes without significant truncation).
If you have a given Haar random state, you could try to convert it to a np_conserved Array and then into an MPS (without charge conservation, so set conserve=None in the model!), using MPS.from_full
If you have a given Haar random state, you could try to convert it to a np_conserved Array and then into an MPS (without charge conservation, so set conserve=None in the model!), using MPS.from_full

 Posts: 5
 Joined: 31 Oct 2022, 23:18
Re: Asking about how to calculate expectation values after TDVP evolution
Thank you very much! I just realized I met the problem because there is Sz conservation in XXZChain. Once I set conserve to None, it works well!