Skip to content

Commit

Permalink
util: add script to fix the gauge saved by previous writeLattice
Browse files Browse the repository at this point in the history
  • Loading branch information
jxy committed Jul 29, 2023
1 parent 10cdf4e commit 3eedc61
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions util/fix_bad_gauge_20230728.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if __name__=='__main__':
import sys
import numpy
import tensorflow as tf
from nthmc.lib import gauge, group, lattice, field, fieldio

fn = sys.argv[1]
g,lat = fieldio.readLattice(fn)
ndim = len(lat)
tf.print(g.shape)
tf.print(lat)

# reverse read
g = numpy.transpose(g, axes=list(range(1, ndim+1))+[0]+list(range(ndim+1, ndim+3)))
# now g is in the wrong storage order

# the wrong transpose in previous writeLattice would leave the wrong shape as
g = numpy.reshape(g, (lat[3], ndim, lat[0], lat[1], lat[2], 3, 3))

# reverse the wrong transpose in previous writeLattice (above again)
g = numpy.transpose(g, axes=list(range(1, ndim+1))+[0]+list(range(ndim+1, ndim+3)))
# now g is in the correct in-memory order

# check plaquette
gg = gauge.Gauge([gauge.Transporter(lattice.Lattice(tf.constant(g[i]),nd=ndim,batch_dim=-1), field.Path(i+1)) for i in range(ndim)])
for pl in gauge.plaquette(gg):
print(pl.numpy())
tf.print('plaq:',gauge.plaq(gg))

outfn = fn+'.fixed.lime'
print(f'writing out: {outfn}')
fieldio.writeLattice(g, outfn)

0 comments on commit 3eedc61

Please sign in to comment.