File size: 2,147 Bytes
6288873
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from abc import ABC, abstractmethod
from dataclasses import dataclass

import h5py

import jax.numpy as jnp

from varipeps.peps import PEPS_Unit_Cell

from typing import Sequence, Union, List, Optional


@dataclass
class Expectation_Model(ABC):
    """
    Abstract model of an general expectation value calculated for the complete
    unit cell.

    Parameters:
      is_spiral_peps (:obj:`bool`):
        Flag if the expectation value is for a spiral iPEPS ansatz.
    """

    @abstractmethod
    def __call__(
        self,
        peps_tensors: Sequence[jnp.ndarray],
        unitcell: PEPS_Unit_Cell,
        spiral_vectors: Optional[Union[jnp.ndarray, Sequence[jnp.ndarray]]] = None,
        *,
        normalize_by_size: bool = True,
        only_unique: bool = True,
    ) -> Union[jnp.ndarray, List[jnp.ndarray]]:
        """
        Calculate the expectation value for PEPS unitcell depending on the gates
        set in the class.

        Args:
          peps_tensors (:term:`sequence` of :obj:`jax.numpy.ndarray`):
            The sequence of unique PEPS tensors in the unitcell.
          unitcell (:obj:`~varipeps.peps.PEPS_Unit_Cell`):
            The PEPS unitcell.
          spiral_vectors (single or :term:`sequence` of :obj:`jax.numpy.ndarray`):
            If the expectation value is for a spiral iPEPS ansatz, in this
            argument the wavevectors are expected.
        Keyword args:
          normalize_by_size (:obj:`bool`):
            Flag if the expectation value should be normalized by the number
            of tensors in the unitcell.
          only_unique (:obj:`bool`):
            Flag if the expectation value should be calculated just once for
            each unique PEPS tensor in the unitcell.
        Returns:
          :obj:`jax.numpy.ndarray` or :obj:`list` of :obj:`jax.numpy.ndarray`:
            The expectation values for all gates. Single tensor if only one gate
            is applied.
        """
        pass

    @abstractmethod
    def save_to_group(self, grp: h5py.Group):
        pass

    @classmethod
    @abstractmethod
    def load_from_group(cls, grp: h5py.Group):
        pass