def test_base(self): """Basic tests for PWWave""" vectors = np.array([1.,0,0, 0,1,0, 0,0,1]) vectors.shape = (3, 3) mesh_443 = Mesh3D((4, 4, 3), vectors) mesh_444 = Mesh3D((4, 4, 4), vectors) repr(mesh_444); str(mesh_444) assert not mesh_443 == mesh_444
def test_base(self): """Basic tests for PWWave""" vectors = np.array([1.,0,0, 0,1,0, 0,0,1]) vectors.shape = (3,3) mesh_443 = Mesh3D( (4,4,3), vectors) mesh_444 = Mesh3D( (4,4,4), vectors) print(mesh_444) self.assertNotEqual(mesh_443, mesh_444)
def __init__(self, filepath): """ Initialize the object from a Netcdf file. """ super().__init__(filepath) self.reader = reader = WFK_Reader(filepath) assert reader.has_pwbasis_set # Read the electron bands self._ebands = reader.read_ebands() self.npwarr = reader.npwarr self.nband_sk = reader.nband_sk # FFT mesh (augmented divisions reported in the WFK file) self.fft_mesh = Mesh3D(reader.fft_divs, self.structure.lattice_vectors()) # Build G-spheres for each k-point gspheres = len(self.kpoints) * [None] ecut = reader.ecut for k, kpoint in enumerate(self.kpoints): gvec_k, istwfk = reader.read_gvecs_istwfk(k) gspheres[k] = GSphere(ecut, self.structure.reciprocal_lattice, kpoint, gvec_k, istwfk=istwfk) self._gspheres = tuple(gspheres) # Save reference to the reader. self.reader = reader
def test_fft(self): """FFT transforms""" vectors = np.array([1., 0, 0, 0, 1, 0, 0, 0, 1]) vectors.shape = (3, 3) mesh = Mesh3D((12, 3, 5), vectors) extra_dims = [(), 1, (2, ), (3, 4)] types = [np.float, np.complex] for exdim in extra_dims: for typ in types: fg = mesh.random(dtype=typ, extra_dims=exdim) fr = mesh.fft_g2r(fg) same_fg = mesh.fft_r2g(fr) self.assert_almost_equal(fg, same_fg) int_r = mesh.integrate(fr) int_g = fg[..., 0, 0, 0] self.assert_almost_equal(int_r, int_g)