introvoyz041/TensorNetworks
02
1#Tensor Networks2 3Implementations of 1D tensor networks algorithms in python.4 5## MPS decomposition 6Basic tensor network algorithm that decomposes an n-rank tensor into a mixed canonical matrix product state (MPS). 7In diagrammatic form, it looks like this8 910 11```python12import mps 13import state_tensor14 15n = 10 # rank of the initial tensor (number of spins)16j = 6 # orthogonality centre cite 17bond_d = 2 #truncated bond dimension of the MPS18psi = state_tensor.random(n) # random state in form of a tensor19 20MPS = mps.MixedCanonical(psi, j, bond_d)21```22 23This form of representing many-body states allows us to perform useful calculations.For example, we can easily calculate 24expectation values of one-site local operator25 2627 28```python29pauli_Z = np.array([[1.0, 0.0], [0.0, -1.0]])30 31MPS.ev_1site(pauli_Z) # = -0.02813418284300012 for parameters as above32 33```34 35 36 37or two-site 38 3940 41 42```python43pauli_ZZ = np.tensordot(pauli_Z, pauli_Z, axes=0)44 45MPS.ev_2site(pauli_ZZ) # = 0.003394449492646695 for parameters as above46```47 48 49 50## MPO based algorithms 51 52A lot of Hamiltonians from many-body quantum mechanics can be represented using matrix product states. This representation 53is called a Matrix Product Operator (MPO) and is useful for calculating expectation values in a given MPS state or finding 54eigenstates of the operator. As an example, I have used the Quantum Transverse 1D Ising Model (QTIM) Hamiltonian in my code55 5657 58```python59import mpo 60 61n = 10 # rank of the MPO62h = 0.1 63hz = 1.064 65MPO = mpo.QTIM(n, h, hz)66```67 68### Expectation value69 70Expectation value of the MPO in a given MPS state 71 7273 74can be efficiently calculated using following scheme75 7677 78```python79MPS.ev_mpo(MPO) # = -0.7637637108962172 in the MPS state as above80```81 82 83### Lowest eigenstate of the MPO Hamiltonian84 85To find eigenstate of our MPO we are gonna minimize <A|H|A> with respect to the bra <A| by zeroing corresponding 86derivative (A is a random state MPS in a mixed canonical gauge). It will lead to an eigen problem in a tensor form87 88 89 90 91The main part of the algorithm for finding the lowest eigenstates involves an iterative minimization process, where each92matrix product state A^k (represented in vectorized form) is minimized using the Lanczos algorithm. The Lanczos algorithm 93is a numerical method used to find the lowest eigenstate of a matrix. In the first left and right sweeps, we start with 94previously calculated L and R tensors. After each Lanczos step, we update these tensors using the following scheme:95 96 97 98(similar procedure for R).99 100After a few sweeps it will converge, and we will obtain lowest eigenstate of our MPO.101 102```python103energy, lowest_eigenstate = mpo.ground_system(MPO) # energy = -19.01833205830135104```105 106## Roadmap107 108Main goals for now (in priority order):109 110- [x] MPS decomposition algorithm 111- [x] MPO Lanczos based algorithms 112- [ ] TDVP113 