def test_init_invalid_args(self): for H in self.invalid_args: with pytest.raises((TypeError, ValueError)): term = mm.Zeeman(H=H) with pytest.raises(AttributeError): term = mm.Zeeman(wrong=1)
def test_repr(self): for H in self.valid_args: zeeman = mm.Zeeman(H) assert repr(zeeman) == 'Zeeman(H={}, name=\"{}\")'.format( H, "zeeman") zeeman = mm.Zeeman(H=(1, 0, 1), name="test_name") assert repr(zeeman) == "Zeeman(H=(1, 0, 1), name=\"test_name\")"
def test_repr(self): for H in self.valid_args: zeeman = mm.Zeeman(H) assert repr(zeeman) == ('Zeeman(H={}, ' 'name=\'{}\')'.format(H, 'zeeman')) zeeman = mm.Zeeman(H=(1, 0, 1), name='test_name') assert repr(zeeman) == 'Zeeman(H=(1, 0, 1), name=\'test_name\')'
def test_init_valid_args(self): for H in self.valid_args: term = mm.Zeeman(H=H) check_term(term) assert hasattr(term, 'H') assert term.name == 'zeeman' assert re.search(r'^Zeeman\(H=.+\)$', repr(term))
def test_dict_values(self): name = 'slonczewski_scalar_values' J = {'r1': 1e12, 'r2': 5e12} mp = {'r1': (0, 0, 1), 'r2': (0, 1, 0)} P = {'r1': 0.4, 'r2': 0.35} Lambda = {'r1': 2, 'r2': 1.5} eps_prime = {'r1': 0, 'r2': 1} H = (0, 0, 1e6) Ms = 1e6 mesh = df.Mesh(region=self.region, n=self.n, subregions=self.subregions) system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.Slonczewski(J=J, mp=mp, P=P, Lambda=Lambda, eps_prime=eps_prime) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=20) # Check if it runs. self.calculator.delete(system)
def test_field_scalar(self): name = 'zhangli_field_scalar' mesh = df.Mesh(region=self.region, cell=self.cell) def u_fun(pos): x, y, z = pos if y <= 0: return 0 else: return 1 H = (0, 0, 1e6) u = df.Field(mesh, dim=1, value=u_fun) beta = 0.5 Ms = 1e6 system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.ZhangLi(u=u, beta=beta) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=50) # u=0 region value = system.m((1e-9, -4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1 * Ms, Ms))) < 1e-3 # u!=0 region value = system.m((1e-9, 4e-9, 3e-9)) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) > 1 self.calculator.delete(system)
def test_dict_scalar(self): name = 'zhangli_dict_scalar' H = (0, 0, 1e6) u = {'r1': 0, 'r2': 1} beta = 0.5 Ms = 1e6 mesh = df.Mesh(region=self.region, cell=self.cell, subregions=self.subregions) system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.ZhangLi(u=u, beta=beta) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=50) # u=0 region value = system.m((1e-9, -4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1 * Ms, Ms))) < 1e-3 # u!=0 region value = system.m((1e-9, 4e-9, 3e-9)) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) > 1 self.calculator.delete(system)
def test_exchange_dmi_zeeman(self): name = 'exchange_dmi_zeeman' mesh = df.Mesh(region=self.region, cell=self.cell, subregions=self.subregions) # Very weak DMI and strong Zeeman to make the final # magnetisation uniform. A = {'r1': 1e-12, 'r2': 3e-12, 'r1:r2': 2e-12} D = {'r1': 1e-9, 'r2': 0, 'r1:r2': 5e-9} H = df.Field(mesh, dim=3, value=(1e10, 0, 0)) Ms = 1e6 system = mm.System(name=name) system.energy = mm.Exchange(A=A) + \ mm.DMI(D=D, crystalclass='Cnv') + \ mm.Zeeman(H=H) system.m = df.Field(mesh, dim=3, value=(1, 0.3, 0), norm=Ms) md = self.calculator.MinDriver() md.drive(system) value = system.m(mesh.region.random_point()) assert np.linalg.norm(np.subtract(value, (Ms, 0, 0))) < 1 self.calculator.delete(system)
def test_field_values(self): name = 'slonczewski_scalar_values' mesh = df.Mesh(region=self.region, n=self.n) J = df.Field(mesh, dim=1, value=0.5e12) mp = df.Field(mesh, dim=3, value=(1, 0, 0)) P = df.Field(mesh, dim=1, value=0.5) Lambda = df.Field(mesh, dim=1, value=2) eps_prime = df.Field(mesh, dim=1, value=1) H = (0, 0, 1e6) Ms = 1e6 system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.Slonczewski(J=J, mp=mp, P=P, Lambda=Lambda, eps_prime=eps_prime) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=20) # Check if it runs. self.calculator.delete(system)
def test_dirname(calculator): name = 'specifying_dirname' mydirname = './my_dirname' p1 = (0, 0, 0) p2 = (5e-9, 5e-9, 5e-9) n = (2, 2, 2) Ms = 1e6 A = 1e-12 H = (0, 0, 1e6) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(region=region, n=n) system = mm.System(name=name) system.energy = mm.Exchange(A=A) + mm.Zeeman(H=H) system.dynamics = (mm.Precession(gamma0=mm.consts.gamma0) + mm.Damping(alpha=1)) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) md = calculator.MinDriver() md.drive(system, dirname=mydirname) dirname = os.path.join(mydirname, name, 'drive-0') assert os.path.exists(dirname) system.energy.zeeman.H = (1e6, 0, 0) td = calculator.TimeDriver() td.drive(system, t=100e-12, n=10, dirname=mydirname) dirname = os.path.join(mydirname, name, 'drive-1') assert os.path.exists(dirname) shutil.rmtree(mydirname)
def test_scalar_dict(self): name = 'dynamics_scalar_dict' H = (0, 0, 1e6) gamma0 = 2.211e5 alpha = {'r1': 0, 'r2': 1} Ms = 1e6 mesh = df.Mesh(region=self.region, n=self.n, subregions=self.subregions) system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = (mm.Precession(gamma0=gamma0) + mm.Damping(alpha=alpha)) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=50) # alpha=0 region value = system.m((1e-9, -4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0, Ms))) > 1 # alpha!=0 region value = system.m((1e-9, 4e-9, 3e-9)) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) < 1e-3 self.calculator.delete(system)
def setup(self): A = 1e-12 self.exchange = mm.Exchange(A=A) H = (0, 0, 1.2e6) self.zeeman = mm.Zeeman(H=H) K1 = 1e4 K2 = 3e2 u = (0, 1, 0) self.uniaxialanisotropy = mm.UniaxialAnisotropy(K1=K1, K2=K2, u=u) self.demag = mm.Demag() D = 1e-3 crystalclass = 't' self.dmi = mm.DMI(D=D, crystalclass=crystalclass) K1 = 5e6 u1 = (0, 0, 1) u2 = (0, 1, 0) self.cubicanisotropy = mm.CubicAnisotropy(K1=K1, u1=u1, u2=u2) self.terms = [ self.exchange, self.zeeman, self.uniaxialanisotropy, self.demag, self.dmi, self.cubicanisotropy ] self.invalid_terms = [ 1, 2.5, 0, 'abc', [3, 7e-12], [self.exchange, self.zeeman] ]
def test_field(self): name = 'precession_field' mesh = df.Mesh(region=self.region, n=self.n) def value_fun(pos): x, y, z = pos if y <= 0: return 0 else: return 2.211e5 H = (0, 0, 1e6) gamma0 = df.Field(mesh, dim=1, value=value_fun) Ms = 1e6 system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.Precession(gamma0=gamma0) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=50) # gamma=0 region value = system.m((1e-9, -4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1*Ms, Ms))) < 1e-3 # gamma!=0 region value = system.m((1e-9, 4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1*Ms, Ms))) > 1 self.calculator.delete(system)
def test_dict(self): name = 'precession_dict' H = (0, 0, 1e6) gamma0 = {'r1': 0, 'r2': 2.211e5} Ms = 1e6 mesh = df.Mesh(region=self.region, n=self.n, subregions=self.subregions) system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.Precession(gamma0=gamma0) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=50) # gamma=0 region value = system.m((1e-9, -4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1*Ms, Ms))) < 1e-3 # gamma!=0 region value = system.m((1e-9, 4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1*Ms, Ms))) > 1 self.calculator.delete(system)
def test_field(self): name = 'damping_field' mesh = df.Mesh(region=self.region, n=self.n) def value_fun(pos): x, y, z = pos if y <= 0: return 0 else: return 1 H = (0, 0, 1e6) alpha = df.Field(mesh, dim=1, value=value_fun) Ms = 1e6 system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.dynamics = mm.Damping(alpha=alpha) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.2e-9, n=50) # alpha=0 region value = system.m((1e-9, -4e-9, 3e-9)) assert np.linalg.norm(np.cross(value, (0, 0.1 * Ms, Ms))) < 1e-3 # alpha!=0 region value = system.m((1e-9, 4e-9, 3e-9)) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) < 1e-3 self.calculator.delete(system)
def test_outputstep(calculator): name = 'output_step' p1 = (0, 0, 0) p2 = (5e-9, 5e-9, 5e-9) n = (2, 2, 2) Ms = 1e6 A = 1e-12 H = (0, 0, 1e6) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(region=region, n=n) system = mm.System(name=name) system.energy = mm.Exchange(A=A) + mm.Zeeman(H=H) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) md = calculator.MinDriver() md.drive(system, output_step=True) dirname = os.path.join(name, 'drive-0') assert os.path.exists(dirname) assert len(system.table.data.index) > 1 calculator.delete(system)
def test_field(self): name = 'zeeman_field' def value_fun(pos): x, y, z = pos if x <= 0: return (1e6, 0, 0) else: return (0, 0, 1e6) mesh = df.Mesh(region=self.region, cell=self.cell) H = df.Field(mesh, dim=3, value=value_fun) Ms = 1e6 system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.m = df.Field(mesh, dim=3, value=(0, 1, 0), norm=Ms) md = self.calculator.MinDriver() md.drive(system) value = system.m((-2e-9, -2e-9, -2e-9)) assert np.linalg.norm(np.subtract(value, (Ms, 0, 0))) < 1e-3 value = system.m((2e-9, 2e-9, 2e-9)) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) < 1e-3 # time-dependent - sin system.energy = mm.Zeeman(H=H, wave='sin', f=1e9, t0=1e-12) mesh = df.Mesh(region=self.region, cell=self.cell) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.1e-9, n=20) # time-dependent - sinc system.energy = mm.Zeeman(H=H, wave='sinc', f=1e9, t0=0) mesh = df.Mesh(region=self.region, cell=self.cell) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.1e-9, n=20) self.calculator.delete(system)
def test_dict(self): name = 'zeeman_dict' H = {'r1': (1e5, 0, 0), 'r2': (0, 0, 1e5)} Ms = 1e6 system = mm.System(name=name) system.energy = mm.Zeeman(H=H) mesh = df.Mesh(region=self.region, cell=self.cell, subregions=self.subregions) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) md = self.calculator.MinDriver() md.drive(system) assert np.linalg.norm(np.subtract(system.m['r1'].average, (Ms, 0, 0))) < 1 assert np.linalg.norm(np.subtract(system.m['r2'].average, (0, 0, Ms))) < 1 # time-dependent - sin system.energy = mm.Zeeman(H=H, wave='sin', f=1e9, t0=1e-12) mesh = df.Mesh(region=self.region, cell=self.cell, subregions=self.subregions) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.1e-9, n=20) # time-dependent - sinc system.energy = mm.Zeeman(H=H, wave='sinc', f=1e9, t0=0) mesh = df.Mesh(region=self.region, cell=self.cell, subregions=self.subregions) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.1e-9, n=20) self.calculator.delete(system)
def setup(self): p1 = (0, 0, 0) p2 = (5e-9, 5e-9, 5e-9) n = (5, 5, 5) self.Ms = 1e6 A = 1e-12 H = (0, 0, 1e6) region = df.Region(p1=p1, p2=p2) self.mesh = df.Mesh(region=region, n=n) self.energy = mm.Exchange(A=A) + mm.Zeeman(H=H) self.m = df.Field(self.mesh, dim=3, value=(0, 1, 0), norm=self.Ms)
def setup(self): p1 = (0, 0, 0) p2 = (5e-9, 5e-9, 5e-9) n = (2, 2, 2) self.Ms = 1e6 A = 1e-12 H = (0, 0, 1e6) region = df.Region(p1=p1, p2=p2) self.mesh = df.Mesh(region=region, n=n) self.energy = mm.Exchange(A=A) + mm.Zeeman(H=H) self.precession = mm.Precession(gamma0=mm.consts.gamma0) self.damping = mm.Damping(alpha=1) self.m = df.Field(self.mesh, dim=3, value=(0, 0.1, 1), norm=self.Ms)
def test_repr_latex(self): for H in self.valid_args: zeeman = mm.Zeeman(H) latex = zeeman._repr_latex_() # Assert some characteristics of LaTeX string. assert latex[0] == latex[-1] == '$' assert latex[1] == '-' assert '\\mu_{0}' in latex assert '\mathbf{H}' in latex assert '\mathbf{m}' in latex assert '\cdot' in latex assert 'M_\\text{s}' in latex
def test_vector(self): name = 'zeeman_vector' H = (0, 0, 1e6) Ms = 1e6 system = mm.System(name=name) # time-independent system.energy = mm.Zeeman(H=H) mesh = df.Mesh(region=self.region, cell=self.cell) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) md = self.calculator.MinDriver() md.drive(system) value = system.m(mesh.region.random_point()) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) < 1e-3 # time-dependent - sin system.energy = mm.Zeeman(H=H, wave='sin', f=1e9, t0=1e-12) mesh = df.Mesh(region=self.region, cell=self.cell) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.1e-9, n=20) # time-dependent - sinc system.energy = mm.Zeeman(H=H, wave='sinc', f=1e9, t0=0) mesh = df.Mesh(region=self.region, cell=self.cell) system.m = df.Field(mesh, dim=3, value=(1, 1, 1), norm=Ms) td = self.calculator.TimeDriver() td.drive(system, t=0.1e-9, n=20) self.calculator.delete(system)
def test_multiple_drives(calculator): name = 'multiple_drives' p1 = (0, 0, 0) p2 = (5e-9, 5e-9, 5e-9) n = (2, 2, 2) Ms = 1e6 A = 1e-12 H = (0, 0, 1e6) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(region=region, n=n) system = mm.System(name=name) system.energy = mm.Exchange(A=A) + mm.Zeeman(H=H) system.dynamics = (mm.Precession(gamma0=mm.consts.gamma0) + mm.Damping(alpha=1)) system.m = df.Field(mesh, dim=3, value=(0, 0.1, 1), norm=Ms) md = calculator.MinDriver() md.drive(system) dirname = os.path.join(name, 'drive-0') assert os.path.exists(dirname) system.energy.zeeman.H = (1e6, 0, 0) td = calculator.TimeDriver() td.drive(system, t=100e-12, n=10) dirname = os.path.join(name, 'drive-1') assert os.path.exists(dirname) E = calculator.compute(system.energy.zeeman.energy, system) dirname = os.path.join(name, 'compute-0') assert os.path.exists(dirname) td.drive(system, t=100e-12, n=10) dirname = os.path.join(name, 'drive-2') assert os.path.exists(dirname) Heff = calculator.compute(system.energy.zeeman.effective_field, system) dirname = os.path.join(name, 'compute-1') assert os.path.exists(dirname) assert len(os.listdir(name)) == 5 calculator.delete(system)
def test_skyrmion(calculator): name = 'skyrmion' Ms = 1.1e6 A = 1.6e-11 D = 4e-3 K = 0.51e6 u = (0, 0, 1) H = (0, 0, 2e5) p1 = (-50e-9, -50e-9, 0) p2 = (50e-9, 50e-9, 10e-9) cell = (5e-9, 5e-9, 5e-9) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(p1=p1, p2=p2, cell=cell) system = mm.System(name=name) system.energy = (mm.Exchange(A=A) + mm.DMI(D=D, crystalclass='Cnv') + mm.UniaxialAnisotropy(K=K, u=u) + mm.Demag() + mm.Zeeman(H=H)) def Ms_fun(pos): x, y, z = pos if (x**2 + y**2)**0.5 < 50e-9: return Ms else: return 0 def m_init(pos): x, y, z = pos if (x**2 + y**2)**0.5 < 10e-9: return (0, 0.1, -1) else: return (0, 0.1, 1) system.m = df.Field(mesh, dim=3, value=m_init, norm=Ms_fun) md = calculator.MinDriver() md.drive(system) # Check the magnetisation at the sample centre. value = system.m((0, 0, 0)) assert value[2] / Ms < -0.97 # Check the magnetisation at the sample edge. value = system.m((50e-9, 0, 0)) assert value[2] / Ms > 0.5 self.calculator.delete(system)
def setup(self): name = 'compute_tests' p1 = (0, 0, 0) p2 = (10e-9, 2e-9, 2e-9) cell = (2e-9, 2e-9, 2e-9) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(region=region, cell=cell) self.system = mm.System(name=name) self.system.energy = ( mm.Exchange(A=1e-12) + mm.Demag() + mm.Zeeman(H=(8e6, 0, 0)) + mm.UniaxialAnisotropy(K=1e4, u=(0, 0, 1)) + mm.CubicAnisotropy(K=1e3, u1=(1, 0, 0), u2=(0, 1, 0))) self.system.m = df.Field(mesh, dim=3, value=(0, 0, 1), norm=8e6)
def test_single_pbc(self): name = 'mesh_single_pbc' Ms = 1e6 H = (0, 0, 5e6) mesh = df.Mesh(region=self.region, cell=self.cell, bc=self.bc) system = mm.System(name=name) system.energy = mm.Zeeman(H=H) system.m = df.Field(mesh, dim=3, value=(1, 0, 0), norm=Ms) md = self.calculator.MinDriver() md.drive(system) value = system.m(mesh.region.random_point()) assert np.linalg.norm(np.subtract(value, (0, 0, Ms))) < 1e-3 self.calculator.delete(system)
def setup(self): self.exchange = mm.Exchange(A=1e-12) self.zeeman = mm.Zeeman(H=(0, 0, 1.2e6)) self.uniaxialanisotropy = mm.UniaxialAnisotropy(K=1e4, u=(0, 1, 0)) self.demag = mm.Demag() self.dmi = mm.DMI(D=1e-3, crystalclass='T') self.cubicanisotropy = mm.CubicAnisotropy(K={ 'r1': 1e6, 'r2': 5e6 }, u1=(0, 0, 1), u2=(0, 1, 0)) self.terms = [ self.exchange, self.zeeman, self.uniaxialanisotropy, self.demag, self.dmi, self.cubicanisotropy ] self.invalid_terms = [1, 2.5, 0, 'abc', [3, 7e-12], [self.exchange, 2]]
def test_stdprob4(calculator): name = 'stdprob4' L, d, th = 500e-9, 125e-9, 3e-9 # (m) cell = (5e-9, 5e-9, 3e-9) # (m) p1 = (0, 0, 0) p2 = (L, d, th) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(region=region, cell=cell) Ms = 8e5 # (A/m) A = 1.3e-11 # (J/m) system = mm.System(name=name) system.energy = mm.Exchange(A=A) + mm.Demag() gamma0 = 2.211e5 # (m/As) alpha = 0.02 system.dynamics = mm.Precession(gamma0=gamma0) + mm.Damping(alpha=alpha) system.m = df.Field(mesh, dim=3, value=(1, 0.25, 0.1), norm=Ms) md = calculator.MinDriver() md.drive(system) # updates system.m in-place H = (-24.6e-3 / mm.consts.mu0, 4.3e-3 / mm.consts.mu0, 0) system.energy += mm.Zeeman(H=H) td = calculator.TimeDriver() td.drive(system, t=1e-9, n=200) t = system.table.data['t'].values my = system.table.data['my'].values assert abs(min(t) - 5e-12) < 1e-20 assert abs(max(t) - 1e-9) < 1e-20 # Eye-norm test. assert 0.7 < max(my) < 0.8 assert -0.5 < min(my) < -0.4 calculator.delete(system)
def test_exchange_zeeman(self): name = 'energy_exchange_zeeman' A = 1e-12 H = (1e6, 0, 0) Ms = 1e6 mesh = df.Mesh(region=self.region, cell=self.cell) system = mm.System(name=name) system.energy = mm.Exchange(A=A) + mm.Zeeman(H=H) system.m = df.Field(mesh, dim=3, value=(0, 1, 0), norm=Ms) md = self.calculator.MinDriver() md.drive(system) value = system.m(mesh.region.random_point()) assert np.linalg.norm(np.subtract(value, (Ms, 0, 0))) < 1e-3 self.calculator.delete(system)
def test_freestyle(self): container = self.dmi + self.zeeman # single term is not allowed check_container(container) assert 'D' in container._repr_latex_() assert len(container) == 2 assert mm.Zeeman(H=(0, 0, 1e6)) in container # same type term present? assert 'dmi' in dir(container) assert len(list(container)) == 2 container -= mm.DMI(D=1e-3, crystalclass='T') check_container(container) assert len(container) == 1 assert mm.DMI(D=1e-2, crystalclass='Cnv') not in container assert self.exchange not in container assert self.zeeman in container assert container.zeeman == self.zeeman container = self.demag + container check_container(container) assert len(container) == 2