-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelicity.py
30 lines (24 loc) · 854 Bytes
/
helicity.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
# calculate the correlation parts of the helicity modulus
import torch
import math
from args import args
from utils import default_dtype_torch
def helicity(sample):
sample=sample*2*math.pi # angular
# output = torch.zeros(args.batch_size,
# dtype=default_dtype_torch,
# device=sample.device)
# calculate the derivation of energy
term = torch.sin(sample[:, :, 1:, :] - sample[:, :, :-1, :])
term = term.sum(dim=(1, 2, 3))
output = term
term = torch.sin(sample[:, :, :, 1:] - sample[:, :, :, :-1])
term = term.sum(dim=(1, 2, 3))
output += term
term = torch.sin(sample[:, :, 0, :] - sample[:, :, -1, :])
term = term.sum(dim=(1, 2))
output += term
term = torch.sin(sample[:, :, :, 0] - sample[:, :, :, -1])
term = term.sum(dim=(1, 2))
output += term
return output