def test_2(self): mesh = RectangularMesh((10,10,10), (1e-9,1e-9,1e-9)) M = VectorField(mesh); M.fill((-8e5,0,0)) Ms = Field(mesh); Ms.fill(8e5) Ms.set(0, 0) Ms.set(0, 8e5) self.assertFalse(Ms.isUniform()) sam = magneto.scaled_abs_max(M, Ms) self.assertEqual(1.0, sam)
def test_2(self): mesh = RectangularMesh((10, 10, 10), (1e-9, 1e-9, 1e-9)) M = VectorField(mesh); M.fill((-8e5, 0, 0)) Ms = Field(mesh); Ms.fill(8e5) Ms.set(0, 0) Ms.set(0, 8e5) self.assertFalse(Ms.isUniform()) sam = magneto.scaled_abs_max(M, Ms) self.assertEqual(1.0, sam)
def right_rotate_field(M): pbc, pbc_rep = M.mesh.periodic_bc pbc2, pbc_rep2 = "", pbc_rep if "x" in pbc: pbc2 += "y" if "y" in pbc: pbc2 += "z" if "z" in pbc: pbc2 += "x" nn = M.mesh.num_nodes dd = M.mesh.delta mesh = RectangularMesh((nn[2], nn[0], nn[1]), (dd[2], dd[0], dd[1]), pbc2, pbc_rep2) M2 = Field(mesh) for x, y, z in M.mesh.iterateCellIndices(): a = M.get(x,y,z) M2.set(z,x,y, a) return M2
def right_rotate_field(M): pbc, pbc_rep = M.mesh.periodic_bc pbc2, pbc_rep2 = "", pbc_rep if "x" in pbc: pbc2 += "y" if "y" in pbc: pbc2 += "z" if "z" in pbc: pbc2 += "x" nn = M.mesh.num_nodes dd = M.mesh.delta mesh = RectangularMesh((nn[2], nn[0], nn[1]), (dd[2], dd[0], dd[1]), pbc2, pbc_rep2) M2 = Field(mesh) for x, y, z in M.mesh.iterateCellIndices(): a = M.get(x, y, z) M2.set(z, x, y, a) return M2