File size: 3,128 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | import numpy as np
import jax.numpy as jnp
from jax import jit
from varipeps.contractions import apply_contraction_jitted
class Overlap_Four_Sites_Square:
@staticmethod
@jit
def calc_overlap(unitcell):
top_left = apply_contraction_jitted(
"ctmrg_top_left", [unitcell[0, 0][0][0].tensor], [unitcell[0, 0][0][0]], []
)
top_left = top_left.reshape(
np.prod(top_left.shape[:3]), np.prod(top_left.shape[3:])
)
top_right = apply_contraction_jitted(
"ctmrg_top_right", [unitcell[0, 1][0][0].tensor], [unitcell[0, 1][0][0]], []
)
top_right = top_right.reshape(
np.prod(top_right.shape[:3]), np.prod(top_right.shape[3:])
)
bottom_left = apply_contraction_jitted(
"ctmrg_bottom_left",
[unitcell[1, 0][0][0].tensor],
[unitcell[1, 0][0][0]],
[],
)
bottom_left = bottom_left.reshape(
np.prod(bottom_left.shape[:3]), np.prod(bottom_left.shape[3:])
)
bottom_right = apply_contraction_jitted(
"ctmrg_bottom_right",
[unitcell[1, 1][0][0].tensor],
[unitcell[1, 1][0][0]],
[],
)
bottom_right = bottom_right.reshape(
np.prod(bottom_right.shape[:3]), np.prod(bottom_right.shape[3:])
)
norm_with_sites = jnp.trace(top_left @ top_right @ bottom_left @ bottom_right)
norm_corners = apply_contraction_jitted(
"overlap_four_sites_square_only_corners",
[
unitcell[0, 0][0][0].tensor,
unitcell[0, 1][0][0].tensor,
unitcell[1, 1][0][0].tensor,
unitcell[1, 0][0][0].tensor,
],
[
unitcell[0, 0][0][0],
unitcell[0, 1][0][0],
unitcell[1, 1][0][0],
unitcell[1, 0][0][0],
],
[],
)
norm_horizontal = apply_contraction_jitted(
"overlap_four_sites_square_transfer_horizontal",
[
unitcell[0, 0][0][0].tensor,
unitcell[0, 1][0][0].tensor,
unitcell[1, 1][0][0].tensor,
unitcell[1, 0][0][0].tensor,
],
[
unitcell[0, 0][0][0],
unitcell[0, 1][0][0],
unitcell[1, 1][0][0],
unitcell[1, 0][0][0],
],
[],
)
norm_vertical = apply_contraction_jitted(
"overlap_four_sites_square_transfer_vertical",
[
unitcell[0, 0][0][0].tensor,
unitcell[0, 1][0][0].tensor,
unitcell[1, 1][0][0].tensor,
unitcell[1, 0][0][0].tensor,
],
[
unitcell[0, 0][0][0],
unitcell[0, 1][0][0],
unitcell[1, 1][0][0],
unitcell[1, 0][0][0],
],
[],
)
return (norm_with_sites * norm_corners) / (norm_horizontal * norm_vertical)
|