:py:mod:`quimb.tensor.tensor_1d_tebd` ===================================== .. py:module:: quimb.tensor.tensor_1d_tebd .. autoapi-nested-parse:: Tools for performing TEBD like algorithms in 1D. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: quimb.tensor.tensor_1d_tebd.LocalHam1D quimb.tensor.tensor_1d_tebd.TEBD Functions ~~~~~~~~~ .. autoapisummary:: quimb.tensor.tensor_1d_tebd.OTOC_local Attributes ~~~~~~~~~~ .. autoapisummary:: quimb.tensor.tensor_1d_tebd.NNI .. py:class:: LocalHam1D(L, H2, H1=None, cyclic=False) Bases: :py:obj:`quimb.tensor.tensor_arbgeom_tebd.LocalHamGen` An simple interacting hamiltonian object used, for instance, in TEBD. Once instantiated, the ``LocalHam1D`` hamiltonian stores a single term per pair of sites, cached versions of which can be retrieved like ``H.get_gate_expm((i, i + 1), -1j * 0.5)`` etc. :param L: The size of the hamiltonian. :type L: int :param H2: The sum of interaction terms. If a dict is given, the keys should be nearest neighbours like ``(10, 11)``, apart from any default term which should have the key ``None``, and the values should be the sum of interaction terms for that interaction. :type H2: array_like or dict[tuple[int], array_like] :param H1: The sum of single site terms. If a dict is given, the keys should be integer sites, apart from any default term which should have the key ``None``, and the values should be the sum of single site terms for that site. :type H1: array_like or dict[int, array_like], optional :param cyclic: Whether the hamiltonian has periodic boundary conditions or not. :type cyclic: bool, optional .. attribute:: terms The terms in the hamiltonian, combined from the inputs such that there is a single term per pair. :type: dict[tuple[int], array] .. rubric:: Examples A simple, translationally invariant, interaction-only ``LocalHam1D``:: >>> XX = pauli('X') & pauli('X') >>> YY = pauli('Y') & pauli('Y') >>> ham = LocalHam1D(L=100, H2=XX + YY) The same, but with a translationally invariant field as well:: >>> Z = pauli('Z') >>> ham = LocalHam1D(L=100, H2=XX + YY, H1=Z) Specifying a default interaction and field, with custom values set for some sites:: >>> H2 = {None: XX + YY, (49, 50): (XX + YY) / 2} >>> H1 = {None: Z, 49: 2 * Z, 50: 2 * Z} >>> ham = LocalHam1D(L=100, H2=H2, H1=H1) Specifying the hamiltonian entirely through site specific interactions and fields:: >>> H2 = {(i, i + 1): XX + YY for i in range(99)} >>> H1 = {i: Z for i in range(100)} >>> ham = LocalHam1D(L=100, H2=H2, H1=H1) .. seealso:: :obj:`SpinHam1D` .. py:method:: mean_norm() Computes the average frobenius norm of local terms. .. py:method:: build_mpo_propagator_trotterized(x, site_tag_id='I{}', tags=None, upper_ind_id='k{}', lower_ind_id='b{}', shape='lrud', contract_sites=True, **split_opts) Build an MPO representation of ``expm(H * x)``, i.e. the imaginary or real time propagator of this local 1D hamiltonian, using a first order trotterized decomposition. :param x: The time to evolve for. Note this does **not** include the imaginary prefactor of the Schrodinger equation, so real ``x`` corresponds to imaginary time evolution, and vice versa. :type x: float :param site_tag_id: A string specifiying how to tag the tensors at each site. Should contain a ``'{}'`` placeholder. It is used to generate the actual tags like: ``map(site_tag_id.format, range(len(arrays)))``. :type site_tag_id: str :param tags: Global tags to attach to all tensors. :type tags: str or sequence of str, optional :param upper_ind_id: A string specifiying how to label the upper physical site indices. Should contain a ``'{}'`` placeholder. It is used to generate the actual indices like: ``map(upper_ind_id.format, range(len(arrays)))``. :type upper_ind_id: str :param lower_ind_id: A string specifiying how to label the lower physical site indices. Should contain a ``'{}'`` placeholder. It is used to generate the actual indices like: ``map(lower_ind_id.format, range(len(arrays)))``. :type lower_ind_id: str :param shape: String specifying layout of the tensors. E.g. 'lrud' (the default) indicates the shape corresponds left-bond, right-bond, 'up' physical index, 'down' physical index. End tensors have either 'l' or 'r' dropped from the string if not periodic. :type shape: str, optional :param contract_sites: Whether to contract all the decomposed factors at each site to yield a single tensor per site, by default True. :type contract_sites: bool, optional :param split_opts: Supplied to :func:`~quimb.tensor.tensor_core.tensor_split`. .. py:method:: __repr__() Return repr(self). .. py:data:: NNI .. py:class:: TEBD(p0, H, dt=None, tol=None, t0=0.0, split_opts=None, progbar=True, imag=False) Class implementing Time Evolving Block Decimation (TEBD) [1]. [1] Guifré Vidal, Efficient Classical Simulation of Slightly Entangled Quantum Computations, PRL 91, 147902 (2003) :param p0: Initial state. :type p0: MatrixProductState :param H: Dense hamiltonian representing the two body interaction. Should have shape ``(d * d, d * d)``, where ``d`` is the physical dimension of ``p0``. :type H: LocalHam1D or array_like :param dt: Default time step, cannot be set as well as ``tol``. :type dt: float, optional :param tol: Default target error for each evolution, cannot be set as well as ``dt``, which will instead be calculated from the trotter orderm length of time, and hamiltonian norm. :type tol: float, optional :param t0: Initial time. Defaults to 0.0. :type t0: float, optional :param split_opts: Compression options applied for splitting after gate application, see :func:`~quimb.tensor.tensor_core.tensor_split`. :type split_opts: dict, optional :param imag: Enable imaginary time evolution. Defaults to false. :type imag: bool, optional .. seealso:: :obj:`quimb.Evolution` .. py:property:: pt The MPS state of the system at the current time. .. py:property:: err .. py:attribute:: TARGET_TOL :value: 1e-13 .. py:method:: choose_time_step(tol, T, order) Trotter error is ``~ (T / dt) * dt^(order + 1)``. Invert to find desired time step, and scale by norm of interaction term. .. py:method:: _get_gate_from_ham(dt_frac, sites) Get the unitary (exponentiated) gate for fraction of timestep ``dt_frac`` and sites ``sites``, cached. .. py:method:: sweep(direction, dt_frac, dt=None, queue=False) Perform a single sweep of gates and compression. This shifts the orthonognality centre along with the gates as they are applied and split. :param direction: Which direction to sweep. Right is even bonds, left is odd. :type direction: {'right', 'left'} :param dt_frac: What fraction of dt substep to take. :type dt_frac: float :param dt: Overide the current ``dt`` with a custom value. :type dt: float, optional .. py:method:: _step_order2(tau=1, **sweep_opts) Perform a single, second order step. .. py:method:: _step_order4(**sweep_opts) Perform a single, fourth order step. .. py:method:: step(order=2, dt=None, progbar=None, **sweep_opts) Perform a single step of time ``self.dt``. .. py:method:: _compute_sweep_dt_tol(T, dt, tol, order) .. py:method:: update_to(T, dt=None, tol=None, order=4, progbar=None) Update the state to time ``T``. :param T: The time to evolve to. :type T: float :param dt: Time step to use. Can't be set as well as ``tol``. :type dt: float, optional :param tol: Tolerance for whole evolution. Can't be set as well as ``dt``. :type tol: float, optional :param order: Trotter order to use. :type order: int, optional :param progbar: Manually turn the progress bar off. :type progbar: bool, optional .. py:method:: _set_progbar_desc(progbar) .. py:method:: at_times(ts, dt=None, tol=None, order=4, progbar=None) Generate the time evolved state at each time in ``ts``. :param ts: The times to evolve to and yield the state at. :type ts: sequence of float :param dt: Time step to use. Can't be set as well as ``tol``. :type dt: float, optional :param tol: Tolerance for whole evolution. Can't be set as well as ``dt``. :type tol: float, optional :param order: Trotter order to use. :type order: int, optional :param progbar: Manually turn the progress bar off. :type progbar: bool, optional :Yields: **pt** (*MatrixProductState*) -- The state at each of the times in ``ts``. This is a copy of internal state used, so inplace changes can be made to it. .. py:function:: OTOC_local(psi0, H, H_back, ts, i, A, j=None, B=None, initial_eigenstate='check', **tebd_opts) The out-of-time-ordered correlator (OTOC) generating by two local operator A and B acting on site 'i', note it's a function of time. :param psi0: The initial state in MPS form. :type psi0: MatrixProductState :param H: The Hamiltonian for forward time-evolution. :type H: LocalHam1D :param H_back: The Hamiltonian for backward time-evolution, should have only sign difference with 'H'. :type H_back: LocalHam1D :param ts: The time to evolve to. :type ts: sequence of float :param i: The site where the local operators acting on. :type i: int :param A: The operator to act with. :type A: array :param initial_eigenstate: To check the psi0 is or not eigenstate of operator B. If psi0 is the eigenstate of B, it will run a simpler version of OTOC calculation automatically. :type initial_eigenstate: {'check', Flase, True} :rtype: The OTOC