Skip to content

tanlin2013/tnpy

Repository files navigation

tnpy: Tensor Network algorithms implemented in python.


PyPI version Downloads codecov Join the chat at https://gitter.im/tanlin2013/tnpy Code style: black Imports: isort License Docker build Test Status Lint Status


Documentation |


This project is a python implementation of Tensor Network, a numerical approach to quantum many-body systems.

tnpy is built on top of quimb, along with TensorNetwork for tensor contractions, with optimized support for various backend engines (TensorFlow, JAX, PyTorch, and Numpy). For eigen-solver we adopt primme, an iterative multi-method solver with preconditioning.

Currently, we support Matrix Product State (MPS) algorithms, with more are coming...

  • Exact Diagonalization (ED)
  • Finite-sized Density Matrix Renormalization Group (fDMRG)
  • Tree tensor Strong Disorder Renormalization Group (tSDRG)

fDMRG & tSDRG are on alpha-release. For others, please expect edge cases.

Requirements

Dependencies are listed in pyproject.toml, and they are supposed to be installed together with tnpy. Here we just list the essential building blocks.

Also, it's required to have lapack and blas installed in prior to Primme. They can also be installed through pip with mkl-devel.

Installation

  • Using Docker

    docker run --rm -it tanlin2013/tnpy
    
  • Using pip

    • Latest release:
      pip install tnpy
      
    • Development version:
      pip install git+https://github.com/tanlin2013/tnpy@main
      
  • Optional dependencies

Getting started

  1. We provide built-in models. Though it's also possible to register your own one.

    import numpy as np
    from tnpy.finite_dmrg import FiniteDMRG
    from tnpy.model import XXZ
    
    model = XXZ(n=100, delta=0.5)
    fdmrg = FiniteDMRG(
        mpo=model.mpo,
        chi=60  # virtual bond dimensions
    )
    fdmrg.update(tol=1e-8)
    
  2. Compute any physical quantities whatever you want from the obtained state. The resulting MPS is of the type quimb.tensor.MatrixProductState, see here for more details.

    my_mps = fdmrg.mps
    

License

© Tan Tao-Lin, 2023. Licensed under a MIT license.