def calculate(self, state, id): cache = state.cache if id == "dMdt_ST": if hasattr(cache, "dMdt_ST"): return cache.dMdt_ST dMdt_ST = cache.dMdt_ST = VectorField(self.system.mesh) # Calculate spin torque term due to Zhang & Li nx, ny, nz = self.system.mesh.num_nodes dx, dy, dz = self.system.mesh.delta magneto.fdm_zhangli( nx, ny, nz, dx, dy, dz, self.__do_precess, self.P, self.xi, self.system.Ms, self.system.alpha, state.j, state.M, dMdt_ST, ) return dMdt_ST else: raise KeyError("SpinTorque.calculate: Can't calculate %s", id)
def with_zero_gradient_test(self, dim_x, dim_y, dim_z, uniform): self.setup_stuff(dim_x, dim_y, dim_z, uniform) # No gradient in M -> no spin torque self.M.fill((0.0, 0.0, 0.0)) magneto.fdm_zhangli(self.dim_x, self.dim_y, self.dim_z, self.delta_x, self.delta_y, self.delta_z, True, self.P, self.xi, self.Ms, self.alpha, self.J, self.M, self.dM) self.assertFloatTupleEq((0.0, 0.0, 0.0), self.dM.average(), epsilon=0.001) # spin torque is zero
def with_zero_gradient_test(self, dim_x, dim_y, dim_z, uniform): self.setup_stuff(dim_x, dim_y, dim_z, uniform) # No gradient in M -> no spin torque self.M.fill((0.0, 0.0, 0.0)) magneto.fdm_zhangli( self.dim_x, self.dim_y, self.dim_z, self.delta_x, self.delta_y, self.delta_z, True, self.P, self.xi, self.Ms, self.alpha, self.J, self.M, self.dM ) self.assertFloatTupleEq((0.0, 0.0, 0.0), self.dM.average(), epsilon=0.001) # spin torque is zero
def with_vortex_test(self, dim_x, dim_y, dim_z, uniform): self.setup_stuff(dim_x, dim_y, dim_z, uniform) vortex_fn = vortex.magnetizationFunction(150e-9, 150e-9) for n in range(self.mesh.total_nodes): x, y, z = self.mesh.getPosition(n) self.M.set(n, vortex_fn(self.M, (x, y, z))) magneto.fdm_zhangli( self.dim_x, self.dim_y, self.dim_z, self.delta_x, self.delta_y, self.delta_z, True, self.P, self.xi, self.Ms, self.alpha, self.J, self.M, self.dM ) ref_avg = (340104691300.73352, 337831145947.55255, 7.4024200439453129e-06) #print("Reference <dM>: ", ref_avg) #print("Actual <dM>: ", self.dM.average()) # epsilon must be relatively big... self.assertFloatTupleEq(self.dM.average(), ref_avg, epsilon=1000000.0)