Exponentiation of operator / String order parameter

How do I use this algorithm? What does that parameter do?
Post Reply
on0001st
Posts: 12
Joined: 27 Aug 2018, 09:30

Exponentiation of operator / String order parameter

Post by on0001st »

I am trying to calculate string order parameter and I was wondering how should I go about doing it?

I have tried looking through model.py, sites.py and charges.py but I do not see a clear way to exponentiate the operators for the calculation of the expectation values. My idea was to do something like

Code: Select all

O_z = psi.expectation_value('Sz', sites=[i])+np.sum(psi.expectation_value(exp(1j*np.pi*'Sz'), sites=[i+1,...,j-1]))+psi.expectation_value('Sz', sites=[j])
for example but I am unable to figure out how should I perform the exponentiation of the S_z operators.

Thanks!
Leon
Posts: 13
Joined: 23 Jul 2018, 09:08
Location: University of Kent

Re: Exponentiation of operator

Post by Leon »

Scipy has a method for matrix exponentiation in scipy.linalg.expm.
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Exponentiation of operator

Post by Johannes »

Since exponentiating a matrix is often needed for tensor networks, the scipy.linalg.expm function is also implemented for np_conserved Arrays.

When you talk about string order parameters, do you really want to calculate that?
What you wrote suggests that you try to calculate something like
\( \langle A_i \rangle + \sum_{i < k < j} \langle B_k \rangle + \langle C_j \rangle \)
This is different from the usual definition of String order parameters, which would look something like
\( \langle A_i \prod_{i < k < j} B_k C_j \rangle \)
Note that the latter is just a single expectation value!
To calculate the latter, use the MPS.correlation_function and provide \(B_k\) as argument "opstr".

Moreover, let me note that if you look at Spin-1/2, choosing \(B_k = \exp(i \pi S_z) \) is probably not what you want, because then B_k would just be minus the identity matrix.
on0001st
Posts: 12
Joined: 27 Aug 2018, 09:30

Re: Exponentiation of operator

Post by on0001st »

Thank you so much for the help, expm is exactly what I was looking for!

I was also suspecting what I wrote to be slightly wrong but I was not sure, hence I posted it here to double check.

I am a little bit confused with
Johannes wrote: 21 Feb 2019, 13:43 Moreover, let me note that if you look at Spin-1/2, choosing \(B_k=exp⁡(iπS_z)\) is probably not what you want, because then B_k would just be minus the identity matrix.
. Calculating \(Bk=exp⁡(iπS_z)\) for spin-1/2 does not return the identity matrix. I get \(\begin{bmatrix} i & 0\\ 0 & -i
\end{bmatrix}\). Am I doing something wrong?
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Exponentiation of operator

Post by Johannes »

Oh, sorry, I had the Pauli Sz in mind, and the factor 1/2 of course matters. My bad ;)
on0001st
Posts: 12
Joined: 27 Aug 2018, 09:30

Re: Exponentiation of operator

Post by on0001st »

Ah okay!

So I have been trying to implement the matrix exponentiation for the correlation_function function but I am still facing some difficulties.

When I try to use either scipy.linalg.expm('Sz') or tenpy.linalg.np_conserved.npc('Sz') directly, I get 'str' object has no attribute 'rank'. Yet when I try scipy.linalg.expm(np.array([[1,0,0],[0,0,0],[0,0,-1]])) directly, the object has no attribute 'chinfo'. I tried to create Sz from scratch with charge info and legcharge but with no success.

Sorry for my lack of understanding of the code but how do I use expm properly?
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Exponentiation of operator

Post by Johannes »

The np_conserved.expm() expects a np_conserved Array, not a numpy array or string (it doesn't know anything about what you might mean with "Sz"). Therefore, you should get the Sz-operator as an np_conserved.Array, preferably out of your "Site" classes. Assuming that you have a uniform spin chain,
you would do something like

Code: Select all

Sz = psi.sites[0].Sz
Bk = npc.expm(1.j * np.pi * Sz)
string_order_parameter = psi.correlation_function("Sz", "Sz", opstr=Bk, str_on_first=False)
edit: corrected Bk = npc.expm(Sz) to Bk = npc.expm(1.j * np.pi * Sz)
on0001st
Posts: 12
Joined: 27 Aug 2018, 09:30

Re: Exponentiation of operator / String order parameter

Post by on0001st »

Thank you so much for the help!

Other than by extracting Sz from the site class, is it possible to code up Sz explicitly and then convert it into a np_conserved array? What would be the proper procedure for it?
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Exponentiation of operator / String order parameter

Post by Johannes »

I just noticed an error in my last post above, see the edit. I hope that was clear anyways...
gopal
Posts: 6
Joined: 20 Sep 2020, 16:43

Re: Exponentiation of operator / String order parameter

Post by gopal »

Regarding the string correlation function, the documentation about correlation_function[https://tenpy.readthedocs.io/en/latest/ ... n_function]says that "if given as a list, opstr[r] is inserted at site r". I am not sure how to do that. In the case of "ops1", I can define the position by sites1. Can you say how to define the position of the string operator i.e. "r" of opstr[r]? In particular(below), I want to have opstr at sites (i,i+2,i+4) only.

Code: Select all

psi.correlation_function("dN","dN",sites1=[i],sites2=[i+6],opstr=npc.expm(1.j*np.pi*dN), str_on_first=True)
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Exponentiation of operator / String order parameter

Post by Johannes »

The correlation function is built with the intention that the i and j are multiple values; that's why the position r of opstr[r] is the index inside the MPS, not relative to i:

Code: Select all

opstrs = [s.Id if j % 2 == 0 else npc.expm(1.j * np.pi * Sz)
        for j, s in enumerate(psi.sites)]
psi.correlation_function("dN","dN",sites1=[i],sites2=[i+6],opstr=opstrs, str_on_first=True)
leonardobellinato
Posts: 1
Joined: 28 Nov 2023, 19:06

Re: Exponentiation of operator / String order parameter

Post by leonardobellinato »

Hallo, I have to’ Calculate the String and parity Order Parameter. For the string order Parameter I have used the answers given above. However, I seem to not get the parity parameter correct. It is defined exactly the same way as the string order parameter but without the Sz operators, I.e. only exp(i pi Sz). I wanted to ask how I could code it? Furthermore, differently from what was shown above I have to multiply multiple exponential functions with Sz of different sites and then do the correlation function. Any help would be much appreciated. I have tried to simply substitute Sz with Id but it does not work.

Thank You Very Much in advance
Post Reply