Пример #1
0
 def compute(M, Ms, A, rotations=1):
     for _ in range(rotations):
         M = right_rotate_vector_field(M)
         Ms = right_rotate_field(Ms); A = right_rotate_field(A)
     H = VectorField(M.mesh)
     nx, ny, nz = M.mesh.num_nodes
     dx, dy, dz = M.mesh.delta
     pbc, pbc_rep = M.mesh.periodic_bc
     bcx, bcy, bcz = "x" in pbc, "y" in pbc, "z" in pbc
     magneto.exchange(nx, ny, nz, dx, dy, dz, bcx, bcy, bcz, Ms, A, M, H)
     for _ in range(rotations): H = left_rotate_vector_field(H)
     return H
Пример #2
0
 def compute(M, Ms, A, rotations=1):
     for _ in range(rotations):
         M = right_rotate_vector_field(M)
         Ms = right_rotate_field(Ms); A = right_rotate_field(A)
     H = VectorField(M.mesh)
     nx, ny, nz = M.mesh.num_nodes
     dx, dy, dz = M.mesh.delta
     pbc, pbc_rep = M.mesh.periodic_bc
     bcx, bcy, bcz = "x" in pbc, "y" in pbc, "z" in pbc
     magneto.exchange(nx, ny, nz, dx, dy, dz, bcx, bcy, bcz, Ms, A, M, H)
     for _ in range(rotations): H = left_rotate_vector_field(H)
     return H
Пример #3
0
    def calculate(self, state, id):
        cache = state.cache

        if id == "H_exch":
            if hasattr(cache, "H_exch"): return cache.H_exch
            H_exch = cache.H_exch = VectorField(self.system.mesh)

            magneto.exchange(state.Ms, state.A, state.M, H_exch)
            return H_exch

        elif id == "E_exch":
            return -MU0 / 2.0 * self.system.mesh.cell_volume * state.M.dotSum(state.H_exch)

        else:
            raise KeyError("ExchangeField.calculate: Can't calculate %s", id)
Пример #4
0
    def pbc_exchange(self, nx, ny, nz):
        dx, dy, dz = 1e-9, 1e-9, 1e-9

        mesh = RectangularMesh((nx, ny, nz), (dx, dy, dz))
        A  = Field(mesh); A.fill(Material.Py().A)
        Ms = Field(mesh); Ms.fill(Material.Py().Ms)
        M  = VectorField(mesh)
        H  = VectorField(mesh)

        for bcx, bcy, bcz in itertools.product([False, True], [False, True], [False, True]):
            M.fill(tuple((random.random()-0.5) * 2e5 for i in range(3)))
            #M.fill((8e5, 8e5, -8e5))
            magneto.exchange(nx, ny, nz, dx, dy, dz, bcx, bcy, bcz, Ms, A, M, H)
            for i in range(nx*ny*nz):
                self.assertEquals(H.get(i), (0.0, 0.0, 0.0))
Пример #5
0
    def calculate(self, state, id):
        cache = state.cache

        if id == "H_exch":
            if hasattr(cache, "H_exch"): return cache.H_exch
            H_exch = cache.H_exch = VectorField(self.system.mesh)

            magneto.exchange(state.Ms, state.A, state.M, H_exch)
            return H_exch

        elif id == "E_exch":
            return -MU0 / 2.0 * self.system.mesh.cell_volume * state.M.dotSum(
                state.H_exch)

        else:
            raise KeyError("ExchangeField.calculate: Can't calculate %s", id)
Пример #6
0
    def do_test(self, M_file, H_file, epsilon):
        # load ref
        M     = readOMF(M_file)
        H_ref = readOMF(H_file)
        H     = VectorField(M.mesh)
        A     = Field(M.mesh); A.fill(Material.Py().A)
        Ms    = Field(M.mesh); Ms.fill(Material.Py().Ms)

        # calculate
        mesh = M.mesh
        nx, ny, nz = mesh.num_nodes
        dx, dy, dz = mesh.delta
        bcx, bcy, bcz = False, False, False
        magneto.exchange(nx, ny, nz, dx, dy, dz, bcx, bcy, bcz, Ms, A, M, H)

        # compare
        self.assertVectorFieldEqual(H_ref, H, epsilon)
Пример #7
0
    def do_test(self, M_file, H_file, epsilon):
        # load ref
        M     = readOMF(M_file)
        H_ref = readOMF(H_file)
        H     = VectorField(M.mesh)
        A     = Field(M.mesh); A.fill(Material.Py().A)
        Ms    = Field(M.mesh); Ms.fill(Material.Py().Ms)

        # calculate
        mesh = M.mesh
        nx, ny, nz = mesh.num_nodes
        dx, dy, dz = mesh.delta
        bcx, bcy, bcz = False, False, False
        magneto.exchange(nx, ny, nz, dx, dy, dz, bcx, bcy, bcz, Ms, A, M, H)

        # compare
        self.assertVectorFieldEqual(H_ref, H, epsilon)
Пример #8
0
    def calculate(self, state, id):
        cache = state.cache

        if id == "H_exch":
            if hasattr(cache, "H_exch"): return cache.H_exch
            H_exch = cache.H_exch = VectorField(self.system.mesh)

            #nx, ny, nz = self.system.mesh.num_nodes
            #dx, dy, dz = self.system.mesh.delta
            #bcx, bcy, bcz = self.__peri_x, self.__peri_y, self.__peri_z

            magneto.exchange(self.system.Ms, self.system.A, state.M, H_exch)
            return H_exch

        elif id == "E_exch":
            return -MU0/2.0 * self.system.mesh.cell_volume * state.M.dotSum(state.H_exch)

        else:
            raise KeyError("ExchangeField.calculate: Can't calculate %s", id)
Пример #9
0
    def calculate(self, state, id):
        cache = state.cache

        if id == "H_exch":
            if hasattr(cache, "H_exch"): return cache.H_exch
            H_exch = cache.H_exch = VectorField(self.system.mesh)

            #nx, ny, nz = self.system.mesh.num_nodes
            #dx, dy, dz = self.system.mesh.delta
            #bcx, bcy, bcz = self.__peri_x, self.__peri_y, self.__peri_z

            magneto.exchange(self.system.Ms, self.system.A, state.M, H_exch)
            return H_exch

        elif id == "E_exch":
            return -MU0 / 2.0 * self.system.mesh.cell_volume * state.M.dotSum(
                state.H_exch)

        else:
            raise KeyError("ExchangeField.calculate: Can't calculate %s", id)