-
Notifications
You must be signed in to change notification settings - Fork 2
/
staples.py
58 lines (46 loc) · 2.45 KB
/
staples.py
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
import tensorflow as tf
from translate import translate
import lattice as lt
# ************************************************
# "Staples" are the sum of the product of links of the
# plaquettes attached around a given link.
# It is required to smear a given configuration and to compute
# the gauge force for the Hybrid Monte Carlo.
# ************************************************
@tf.function
def sup_staple_trace(links1, links2, links3):
return tf.einsum("kmc,mnc,pnc->kpc", links1, links2, tf.math.conj(links3))
@tf.function
def sdn_staple_trace(links1, links2, links3):
return tf.einsum("mkc,mnc,npc->kpc", tf.math.conj(links1), links2, links3)
def get_staple_fields(cfg: lt.Configuration, no_direction: int = 3):
'''Compute the sum of the links in each plane for the staples around
each direction'''
# The planes where we compute the staple
planes = []
for mu in range(cfg.number_of_dimensions):
for nu in range(cfg.number_of_dimensions):
if mu != no_direction and nu != no_direction and mu != nu:
planes.append([mu, nu])
translated_field = {}
# First collect the required translated fields
for mu, nu in planes:
if not (mu, nu, +1) in translated_field:
translated_field[(mu, nu, +1)] = translate(cfg.gauge_field[mu], nu, +1)
if not (nu, mu, +1) in translated_field:
translated_field[(nu, mu, +1)] = translate(cfg.gauge_field[nu], mu, +1)
if not (mu, nu, -1) in translated_field:
translated_field[(mu, nu, -1)] = translate(cfg.gauge_field[mu], nu, -1)
if not (nu, nu, -1) in translated_field:
translated_field[(nu, nu, -1)] = translate(cfg.gauge_field[nu], nu, -1)
if not (nu, nu, -1, mu, +1) in translated_field:
translated_field[(nu, nu, -1, mu, +1)] = translate(translated_field[(nu, nu, -1)], mu, +1)
staple_fields = [[] for _ in range(cfg.number_of_dimensions)]
for mu, nu in planes:
staple_fields[mu].append(sup_staple_trace(cfg.gauge_field[nu],
translated_field[(mu, nu, +1)],
translated_field[(nu, mu, +1)]))
staple_fields[mu].append(sdn_staple_trace(translated_field[(nu, nu, -1)],
translated_field[(mu, nu, -1)],
translated_field[(nu, nu, -1, mu, +1)]))
return staple_fields