Closed TanTsiChen closed 6 years ago
Yes I had forgot to test the cyclic case and hadn't added the final, extra odd gate between sites (n-1, 0)
. It seems to be working fine now - I'll add your example as a unit test case.
Note that the compression will not be optimal in the PBC case - might be worth having a play around with split_opts
.
Yes I had forgot to test the cyclic case and hadn't added the final, extra odd gate between sites
(n-1, 0)
. It seems to be working fine now - I'll add your example as a unit test case.Note that the compression will not be optimal in the PBC case - might be worth having a play around with
split_opts
.
Oh, i had tried to add the final gate, but i forget that in python the counting is from 0 to n-1, not 1 to n (i'm just starting using python :-D)
Oh, i had tried to add the final gate, but i forget that in python the counting is from 0 to n-1, not 1 to n (i'm just starting using python :-D)
Don't worry it soon becomes second nature!
I've pushed a fix here. Let me know if this resolves the issue for you and then I will close this.
Oh, i had tried to add the final gate, but i forget that in python the counting is from 0 to n-1, not 1 to n (i'm just starting using python :-D)
Don't worry it soon becomes second nature!
I've pushed a fix here. Let me know if this resolves the issue for you and then I will close this.
Okay, it well works now.
Just to elaborate on the bit about compression (in response to email):
The difference is that in the OBC you can always put the MPS in canonical form.
In [1]: import quimb.tensor as qtn
In [2]: psi = qtn.MPS_rand_state(20, 10)
In [3]: psi.show()
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o
| | | | | | | | | | | | | | | | | | | |
In [4]: psi.canonize(10)
Out[4]: <MatrixProductState(tensors=20, structure='I{}', nsites=20)>
In [5]: psi.show()
2 4 8 10 10 10 10 10 10 10 10 10 10 10 10 10 8 4 2
>->->->-->-->-->-->-->-->--o--<--<--<--<--<--<-<-<-<
| | | | | | | | | | | | | | | | | | | |
which means that the norm of the whole state is equivalent to the norm of, here, site 10.
In [6]: psi[10].H @ psi[10]
Out[6]: 1.0000000000000002
This means that when you locally compress the tensor/bond at site 10 you are optimally choosing the best singular values for preserving the norm overall.
This isn't (generally) possible with a PBC MPS:
In [7]: psi = qtn.MPS_rand_state(20, 10, cyclic=True)
In [8]: psi.show()
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--+
| | | | | | | | | | | | | | | | | | | |
In [9]: psi.canonize(10)
Out[9]: <MatrixProductState(tensors=20, structure='I{}', nsites=20)>
In [10]: psi.show()
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
+--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--o--+
| | | | | | | | | | | | | | | | | | | |
In [11]: psi[10].H @ psi[10]
Out[11]: 8.392361350641236
This doesn't mean you can't still compress by locally discarding singular values, just that it won't be optimal.
EDIT: just to be a bit clearer, in TEBD, the algorithm tries to move the 'orthogonality' center around with it so that the compression after each gate is applied is optimal.
Dear Johnnie I'm trying to do a quench, like for a up state with periodic boundary condition (PBC), and use the Hamiltonian qtn.NNI_ham_ising(L=10, j=4, bx=1, cyclic=True) to do the time-evolution. The result shows that the NNI doesn't have a periodic boundary condition, if you check the energy of in & out state (by using the Hamiltonian qtn.MPO_ham_ising(L=10, j=4, bx=1, cyclic=True)), the energy is not conversed, and if you use the Hamiltonian without PBC (qtn.MPO_ham_ising(L=10, j=4, bx=1)), you will see that the energy conversed though the time-evolution. Qicheng Tang