#pragma once
#include "model.hpp"

/**
 * @brief Transverse Field Ising Model in 1 dimension
 * @details
 *  The nearest neighbor interaction is in z direction, the magnetic field in x direction.
 *  The Hamiltonian is:
 *  \f[ H = -J \sum_{\langle i,j\rangle} \sigma_{z,i} \sigma_{z,j} - B \sum_i \sigma_{x,j} \f]
 *
 *  The middle bonds are:
 *  \f[ B_i = J \, \sigma^z_i \otimes \sigma^z_{i+1} + \frac{B}{2} \,\sigma^x_i \otimes I + \frac{B}{2} \, I \otimes \sigma^x_{i+1} \f]
 *
 *  The MPO is:
 *  \f[ W = \begin{pmatrix} 
 *          \mathbbm{1} & \sigma_z & -B \, \sigma_x \\
 *          0 & 0 & -J\,\sigma_z \\
 *          0 & 0 & \mathbbm{1} 
 *      \end{pmatrix} 
 *  \f]
 */ 
template<typename T>
class TransverseFieldIsingModel1D : public Model1D<T> {
    public:
        TransverseFieldIsingModel1D(size_t L, T J, T B) : Model1D<T>(L, 2), J(J), B(B) {
            this->initH_Bonds();
            this->initH_MPO();
        }
        inline const T& getJ() const { return J; }
        inline const T& getB() const { return B; }
        
        virtual std::string format() const override {
            return std::format("TransverseFieldIsingModel1D(L={},J={},B={})", this->L, this->J, this->B);
        } 
    protected:
        void initH_Bonds() override;

        void initH_MPO() override;
    private:
        T J;
        T B;
        static PauliMatrices<T> pm;
};

