In [1]:
from pmesh.pm import ParticleMesh, RealField, ComplexField
# a 8^3 mesh
pm = ParticleMesh(Nmesh=[8,8,8])
# initialize a RealField
rfield = RealField(pm)
# shape
print("shape = ", rfield.shape)
# set entire mesh to unity
rfield[...] = 1.0
# print the mean of the underlying array
print("mean = ", rfield.value.mean())
In [2]:
# perform the forward FFT
cfield = rfield.r2c()
# stores Nmesh/2+1 in z axis b/c of conjugate symmetry
print("shape = ", cfield.shape)
# k=0 mode is the mean value of configuration space field
print("mean of configuration space field from k=0 = ", cfield[0,0,0])
# perform the inverse FFT
rfield2 = cfield.c2r()
# print the mean of the underlying array
print("mean of real field = ", rfield2.value.mean())