def test_llge(self): mesh = RectangularMesh((10,10,10), (1e-9,1e-9,1e-9)) f1, f2, M, H, dM = Field(mesh), Field(mesh), VectorField(mesh), VectorField(mesh), VectorField(mesh) # dM = f1*MxH + f2*Mx(MxH) f1.fill(10) f2.fill(20) M.fill((5,10,15)) H.fill((20,25,30)) magneto.llge(f1, f2, M, H, dM) for idx in range(dM.size()): self.assertEqual(dM.get(idx), (-60750.0, -13500.0, 29250.0))
def test_llge(self): mesh = RectangularMesh((10, 10, 10), (1e-9, 1e-9, 1e-9)) f1, f2 = Field(mesh), Field(mesh) M, H, dM = VectorField(mesh), VectorField(mesh), VectorField(mesh) # dM = f1*MxH + f2*Mx(MxH) f1.fill(10) f2.fill(20) M.fill((5, 10, 15)) H.fill((20, 25, 30)) magneto.llge(f1, f2, M, H, dM) for idx in range(dM.size()): self.assertEqual(dM.get(idx), (-60750.0, -13500.0, 29250.0))
def calculate_minimizer_dM(self, state): # TODO other LLG terms? if not self.__valid_factors: self.__initFactors() if hasattr(state.cache, "minimizer_dM"): return state.cache.minimizer_dM result = state.cache.minimizer_dM = VectorField(self.system.mesh) # Get effective field H_tot = self.calculate_H_tot(state) # TODO do this in every step? zero = Field(self.system.mesh) zero.fill(0.0) magneto.llge(zero, self.__f2, state.M, H_tot, result) return result
def calculate_dMdt(self, state): if not self.__valid_factors: self.__initFactors() if hasattr(state.cache, "dMdt"): return state.cache.dMdt dMdt = state.cache.dMdt = VectorField(self.system.mesh) # Get effective field H_tot = self.calculate_H_tot(state) # Basic term magneto.llge(self.__f1, self.__f2, state.M, H_tot, dMdt) # Optional other terms for dMdt_str in self.llge_terms: dMdt_i = getattr(state, dMdt_str) dMdt.add(dMdt_i) return dMdt
def calculate_dMdt(self, state): if not self.__valid_factors: self.__initFactors() if hasattr(state.cache, "dMdt"): return state.cache.dMdt dMdt = state.cache.dMdt = VectorField(self.system.mesh) # Get effective field H_tot = self.calculate_H_tot(state) # Basic term magneto.llge(self.__f1, self.__f2, state.M, H_tot, dMdt) # Optional other terms for dMdt_id in self.llge_terms: dMdt_i = getattr(state, dMdt_id) dMdt.add(dMdt_i) return dMdt
def calculate_minimizer_dM_minimize_BB(self, state): # TODO other LLG terms? if not self.__valid_factors: self.__initFactors() if hasattr(state.cache, "minimizer_dM_minimize_BB"): return state.cache.minimizer_dM_minimize_BB result = state.cache.minimizer_dM_minimize_BB = VectorField( self.system.mesh) # Get effective field H_tot = self.calculate_H_tot(state) # TODO do this in every step? zero = Field(self.system.mesh) zero.fill(0.0) # changed; set llge coefficient to 1.0 for minimization factor = Field(self.system.mesh) factor.fill(1.) magneto.llge(zero, factor, state.M, H_tot, result) return result