def compute_field(): mesh = CuboidMesh(nx=1, ny=1, nz=1, dx=2.0, dy=2.0, dz=2.0, unit_length=1e-9, periodicity=(True, True, False)) sim = Sim(mesh, name='relax') sim.driver.set_tols(rtol=1e-10, atol=1e-14) sim.driver.alpha = 0.5 sim.driver.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m((0, 0, 1)) # sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag(pbc_2d=True) sim.add(demag) field = demag.compute_field() print(field) np.save('m0.npy', sim.spin)
def test_compute_field(): """In an infinite film, we expect the demag tensor to be (0, 0, -1), and thus the magnetisation, if aligned in 0, 0, 1 direction, to create a demag field pointing with equal strength in the opposite direction. """ mesh = CuboidMesh(nx=1, ny=1, nz=1, dx=2.0, dy=2.0, dz=2.0, unit_length=1e-9, periodicity=(True, True, False)) sim = Sim(mesh, name='relax') sim.set_tols(rtol=1e-10, atol=1e-14) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m((0, 0, 1)) demag = Demag(pbc_2d=True) sim.add(demag) field = demag.compute_field() print((1 + field[2] / 8.6e5)) assert abs(1 + field[2] / 8.6e5) < 1e-10
def compute_field(): mesh = CuboidMesh(nx=1, ny=1, nz=1, dx=2.0, dy=2.0, dz=2.0, unit_length=1e-9, periodicity=(True, True, False)) sim = Sim(mesh, name='relax') sim.set_tols(rtol=1e-10, atol=1e-14) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m((0,0,1)) # sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag(pbc_2d=True) sim.add(demag) field=demag.compute_field() print field np.save('m0.npy', sim.spin)
def relax_system(mesh): sim = Sim(mesh, name='relax') sim.driver.set_tols(rtol=1e-10, atol=1e-10) sim.driver.alpha = 0.1 sim.driver.gamma = 2.211e5 sim.Ms = spatial_Ms print(sim.Ms) sim.set_m(init_m) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) dmi = DMI(D=4e-3) sim.add(dmi) dmi2 = DMI(D=2e-3, dmi_type="interfacial") sim.add(dmi2) anis = UniaxialAnisotropy(-3e4, axis=(0, 0, 1)) sim.add(anis) sim.relax(dt=1e-13, stopping_dmdt=5e4, max_steps=5000, save_m_steps=100, save_vtk_steps=50) #np.save('m0.npy', sim.spin) fd = demag.compute_field(sim.spin) fe = exch.compute_field(sim.spin) fdmi = dmi.compute_field(sim.spin) fdmi2 = dmi2.compute_field(sim.spin) fanis = anis.compute_field(sim.spin) np.savetxt( "test_fields.txt", np.transpose([ np.concatenate((sim.Ms, sim.Ms, sim.Ms, [0.0])), np.concatenate((sim.spin, [100])), np.concatenate((fd, [demag.compute_energy()])), np.concatenate((fe, [exch.compute_energy()])), np.concatenate((fdmi, [dmi.compute_energy()])), np.concatenate((fdmi2, [dmi2.compute_energy()])), np.concatenate((fanis, [anis.compute_energy()])) ]), header= "Generated by Fidimag. Size=20x5x3, 2.5nm x 2.5nm x 3nm, Ms=8.0e5A/m, A=1.3e-11 J/m," + " D=4e-3 J/m^2, D_int=2e-3 J/m^2, Ku=-3e4 J/m^3 axis=(0,0,1).\n Ms " + "".ljust(20) + " m0 " + "".ljust(20) + "demag" + "".ljust(20) + "exch" + "".ljust(22) + "dmi" + "".ljust(22) + "dmi_interfacial" + "".ljust(22) + "anis")
def test_with_oommf_spatial_Ms(A=1e-11): def spatial_Ms(pos): x, y = pos[0], pos[1] if x**2 + y**2 < 5**2: return 2e4 else: return 0 init_m0 = ( r'return [list [expr {sin($x * 1e9) + $y * 1e9 + $z * 2.3e9}] ' + r' [expr {cos($x * 1e9) + $y * 1e9 + $z * 1.3e9}] ' + r'0 ' + r'] ') init_Ms = """ if { ($x * $x + $y * $y) < 5e-9 * 5e-9 } { return 2e4 } else { return 0 } """ mesh = CuboidMesh(nx=12, ny=10, nz=2, dx=0.5, unit_length=1e-9) sim = Sim(mesh) sim.Ms = spatial_Ms def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) field = exch.compute_field() field_oommf = compute_exch_field(mesh, init_m0=init_m0, A=A, spatial_Ms=init_Ms) mx0, mx1, mx2 = compare_fields(field_oommf, field) assert max([mx0, mx1, mx2]) < 1e-12 field = demag.compute_field() field_oommf = compute_demag_field(mesh, spatial_Ms=init_Ms, init_m0=init_m0) mx0, mx1, mx2 = compare_fields(field_oommf, field) assert max([mx0, mx1, mx2]) < 1e-11
def test_with_oommf_spatial_Ms(A=1e-11): def spatial_Ms(pos): x, y = pos[0], pos[1] if x ** 2 + y ** 2 < 5 ** 2: return 2e4 else: return 0 init_m0 = (r'return [list [expr {sin($x * 1e9) + $y * 1e9 + $z * 2.3e9}] ' + r' [expr {cos($x * 1e9) + $y * 1e9 + $z * 1.3e9}] ' + r'0 ' + r'] ') init_Ms = """ if { ($x * $x + $y * $y) < 5e-9 * 5e-9 } { return 2e4 } else { return 0 } """ mesh = CuboidMesh(nx=12, ny=10, nz=2, dx=0.5, unit_length=1e-9) sim = Sim(mesh) sim.Ms = spatial_Ms def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) field = exch.compute_field() field_oommf = compute_exch_field( mesh, init_m0=init_m0, A=A, spatial_Ms=init_Ms) mx0, mx1, mx2 = compare_fields(field_oommf, field) assert max([mx0, mx1, mx2]) < 1e-12 field = demag.compute_field() field_oommf = compute_demag_field( mesh, spatial_Ms=init_Ms, init_m0=init_m0) mx0, mx1, mx2 = compare_fields(field_oommf, field) assert max([mx0, mx1, mx2]) < 1e-11
def relax_system(mesh): sim = Sim(mesh, name='relax') sim.driver.set_tols(rtol=1e-10, atol=1e-10) sim.driver.alpha = 0.5 sim.driver.gamma = 2.211e5 sim.Ms = 8.0e5 sim.do_precession = False sim.set_m((1, 0.25, 0.1)) # sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=100, save_vtk_steps=50) np.save('m0.npy', sim.spin)
def apply_field1(mesh): sim = Sim(mesh, name='dyn') sim.driver.set_tols(rtol=1e-10, atol=1e-10) sim.driver.alpha = 0.02 sim.driver.gamma = 2.211e5 sim.Ms = 8.0e5 sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) mT = 0.001 / mu0 print("Applied field = {}".format(mT)) zeeman = Zeeman([-24.6 * mT, 4.3 * mT, 0], name='H') sim.add(zeeman, save_field=True) ts = np.linspace(0, 1e-9, 201) for t in ts: sim.driver.run_until(t) print('sim t=%g' % t)
def relax_system(mesh): sim = Sim(mesh, chi=1e-3, name='relax', driver='llbar_full') sim.set_tols(rtol=1e-7, atol=1e-7) sim.Ms = 8.0e5 sim.alpha = 0.1 sim.beta = 0 sim.gamma = 2.211e5 sim.set_m((1, 0.25, 0.1)) # sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) mT = 795.7747154594767 zeeman = Zeeman([-100 * mT, 4.3 * mT, 0], name='H') sim.add(zeeman, save_field=True) demag = Demag() sim.add(demag) ONE_DEGREE_PER_NS = 17453292.52 sim.relax(dt=1e-12, stopping_dmdt=0.01, max_steps=5000, save_m_steps=100, save_vtk_steps=50) np.save('m0.npy', sim.spin)
def relax_system(mesh): sim = Sim(mesh, name='relax') sim.driver.set_tols(rtol=1e-10, atol=1e-14) sim.driver.alpha = 0.5 sim.driver.gamma = 2.211e5 sim.Ms = spatial_Ms sim.driver.do_precession = False sim.set_m(init_m) # sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag(pbc_2d=True) sim.add(demag) mT = 795.7747154594767 ONE_DEGREE_PER_NS = 17453292.52 sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=100, save_vtk_steps=50) np.save('m0.npy', sim.spin)
def excite_system(mesh): # Specify the stt dynamics in the simulation sim = Sim(mesh, name='fidimag', driver='llg_stt') sim.driver.set_tols(rtol=1e-8, atol=1e-8) sim.driver.alpha = 0.1 sim.driver.gamma = 2.211e5 sim.Ms = 8.0e5 sim.driver.p = 1 sim.set_m(np.load('npys/m0_cpu.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) sim.add(Demag()) sim.driver.jx = -1e12 sim.driver.beta = 0.05 ts = np.linspace(0, 8e-9, 801) for t in ts: print('time', t) sim.driver.run_until(t)
def test_demag_field_oommf_large(Ms=8e5, A=1.3e-11): mesh = CuboidMesh(nx=150, ny=50, nz=1, dx=2.5, dy=2.5, dz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) demag_field = demag.compute_field() exch_field = exch.compute_field() #exact = demag.compute_exact() init_m0 = """ return [list [expr {sin($x*1e9)+$y*1e9+$z*2.3e9}] [expr {cos($x*1e9)+$y*1e9+$z*1.3e9}] 0] """ #demag_oommf = compute_demag_field(mesh, Ms=Ms, init_m0=init_m0) #exch_oommf = compute_exch_field(mesh, Ms=Ms, init_m0=init_m0, A=A) omf_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),'omfs','test_demag_field_oommf_large_Demag.ohf') ovf = OMF2(omf_file) demag_oommf = ovf.get_all_mags() omf_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),'omfs','test_demag_field_oommf_large_Exchange.ohf') ovf = OMF2(omf_file) exch_oommf = ovf.get_all_mags() mx0, mx1, mx2 = compare_fields(demag_oommf, demag_field) #print mx0, mx1, mx2 assert max([mx0,mx1,mx2])< 5e-10 mx0, mx1, mx2 = compare_fields(exch_oommf, exch_field) #print mx0, mx1, mx2 assert max([mx0, mx1, mx2]) < 1e-11
def elongated_part_sim(): sim = Sim(mesh) sim.Ms = lambda r: cylinder(r, centre, 8) sim.add(UniformExchange(A=A)) sim.add(UniaxialAnisotropy(Kx, axis=(0, 1, 0))) # Anisotropy along y sim.add(Demag()) return sim
def test_demag_field_oommf(Ms=6e5): mesh = CuboidMesh(nx=5, ny=2, nz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms demag = Demag() sim.add(demag) def init_m(pos): x = pos[0] if x <= 2: return (1, 0, 0) elif x >= 4: return (0, 0, 1) else: return (0, 1, 0) sim.set_m(init_m) field = demag.compute_field() exact = demag.compute_exact() init_m0 = """ if { $x <=2e-9 } { return "1 0 0" } elseif { $x >= 4e-9 } { return "0 0 1" } else { return "0 1 0" } """ field_oommf = compute_demag_field(mesh, Ms=Ms, init_m0=init_m0) mx0, mx1, mx2 = compare_fields(field_oommf, exact) print mx0, mx1, mx2 assert max([mx0, mx1, mx2]) < 2e-14 mx0, mx1, mx2 = compare_fields(field_oommf, field) print mx0, mx1, mx2 assert np.max(abs(field - field_oommf)) < 2e-9
def test_demag_field_oommf(Ms=6e5): mesh = CuboidMesh(nx=5, ny=2, nz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms demag = Demag() sim.add(demag) def init_m(pos): x = pos[0] if x <= 2: return (1, 0, 0) elif x >= 4: return (0, 0, 1) else: return (0, 1, 0) sim.set_m(init_m) field = demag.compute_field() exact = demag.compute_exact() init_m0 = """ if { $x <=2e-9 } { return "1 0 0" } elseif { $x >= 4e-9 } { return "0 0 1" } else { return "0 1 0" } """ field_oommf = compute_demag_field(mesh, Ms=Ms, init_m0=init_m0) mx0, mx1, mx2 = compare_fields(field_oommf, exact) print(mx0, mx1, mx2) assert max([mx0, mx1, mx2]) < 2e-14 mx0, mx1, mx2 = compare_fields(field_oommf, field) print(mx0, mx1, mx2) assert np.max(abs(field - field_oommf)) < 2e-9
def test_energy(Ms=8e5, A=1.3e-11, D=1.32e-3): mesh = CuboidMesh(nx=40, ny=50, nz=1, dx=2.5, dy=2.5, dz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) demag_energy = demag.compute_energy() exch_energy = exch.compute_energy() # init_m0=""" # return [list [expr {sin($x*1e9)+$y*1e9+$z*2.3e9}] [expr {cos($x*1e9)+$y*1e9+$z*1.3e9}] 0] #""" #field_oommf = compute_exch_field(mesh, Ms=Ms, init_m0=init_m0, A=A) exch_energy_oommf = 1.9885853028738599e-19 demag_energy_oommf = 5.5389695779175673e-19 dmi_energy_oommf = 2.6657360769014251e-20 print(demag_energy, exch_energy) assert abs(exch_energy - exch_energy_oommf) / exch_energy_oommf < 3e-15 assert abs(demag_energy - demag_energy_oommf) / demag_energy_oommf < 1e-10
def test_demag_field_oommf_large(Ms=8e5, A=1.3e-11): mesh = CuboidMesh(nx=150, ny=50, nz=1, dx=2.5, dy=2.5, dz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) demag_field = demag.compute_field() exch_field = exch.compute_field() #exact = demag.compute_exact() init_m0 = ( r'return [list [expr {sin($x * 1e9) + $y * 1e9 + $z * 2.3e9}] ' + r' [expr {cos($x * 1e9) + $y * 1e9 + $z * 1.3e9}] ' + r'0 ' + r'] ') demag_oommf = compute_demag_field(mesh, Ms=Ms, init_m0=init_m0) exch_oommf = compute_exch_field(mesh, Ms=Ms, init_m0=init_m0, A=A) mx0, mx1, mx2 = compare_fields(demag_oommf, demag_field) #print mx0, mx1, mx2 assert max([mx0, mx1, mx2]) < 5e-10 mx0, mx1, mx2 = compare_fields(exch_oommf, exch_field) #print mx0, mx1, mx2 assert max([mx0, mx1, mx2]) < 1e-11
def test_demag_field_oommf_large(Ms=8e5, A=1.3e-11): mesh = CuboidMesh(nx=150, ny=50, nz=1, dx=2.5, dy=2.5, dz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) demag_field = demag.compute_field() exch_field = exch.compute_field() #exact = demag.compute_exact() init_m0 = (r'return [list [expr {sin($x * 1e9) + $y * 1e9 + $z * 2.3e9}] ' + r' [expr {cos($x * 1e9) + $y * 1e9 + $z * 1.3e9}] ' + r'0 ' + r'] ') demag_oommf = compute_demag_field(mesh, Ms=Ms, init_m0=init_m0) exch_oommf = compute_exch_field(mesh, Ms=Ms, init_m0=init_m0, A=A) mx0, mx1, mx2 = compare_fields(demag_oommf, demag_field) #print mx0, mx1, mx2 assert max([mx0, mx1, mx2]) < 5e-10 mx0, mx1, mx2 = compare_fields(exch_oommf, exch_field) #print mx0, mx1, mx2 assert max([mx0, mx1, mx2]) < 1e-11
def setup_simulation(mesh, m0, simulation_name, integrator="sundials", use_jac=False): sim = Sim(mesh, name=simulation_name, integrator=integrator, use_jac) sim.set_m(m0) sim.Ms = Ms sim.alpha = alpha sim.gamma = gamma sim.add(UniformExchange(A)) sim.add(Demag()) return sim
def test_energy(Ms=8e5, A=1.3e-11, D=1.32e-3): mesh = CuboidMesh(nx=40, ny=50, nz=1, dx=2.5, dy=2.5, dz=3, unit_length=1e-9) sim = Sim(mesh) sim.Ms = Ms exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) demag_energy = demag.compute_energy() exch_energy = exch.compute_energy() # init_m0=""" # return [list [expr {sin($x*1e9)+$y*1e9+$z*2.3e9}] [expr {cos($x*1e9)+$y*1e9+$z*1.3e9}] 0] #""" #field_oommf = compute_exch_field(mesh, Ms=Ms, init_m0=init_m0, A=A) exch_energy_oommf = 1.9885853028738599e-19 demag_energy_oommf = 5.5389695779175673e-19 dmi_energy_oommf = 2.6657360769014251e-20 print demag_energy, exch_energy assert abs(exch_energy - exch_energy_oommf) / exch_energy_oommf < 3e-15 assert abs(demag_energy - demag_energy_oommf) / demag_energy_oommf < 1e-10
def run(integrator, jacobian): name = "sim_" + integrator if integrator == "sundials": name += "_J1" if jacobian else "_J0" sim = Sim(mesh, name, integrator, use_jac=jacobian) sim.Ms = 0.86e6 sim.driver.alpha = 0.5 sim.set_m((1, 0, 1)) sim.add(UniformExchange(A=13e-12)) sim.add(Demag()) ts = np.linspace(0, 3e-10, 61) for t in ts: sim.run_until(t)
def test_compute_field(): """In an infinite film, we expect the demag tensor to be (0, 0, -1), and thus the magnetisation, if aligned in 0, 0, 1 direction, to create a demag field pointing with equal strength in the opposite direction. """ mesh = CuboidMesh(nx=1, ny=1, nz=1, dx=2.0, dy=2.0, dz=2.0, unit_length=1e-9, periodicity=(True, True, False)) sim = Sim(mesh, name='relax') sim.driver.set_tols(rtol=1e-10, atol=1e-14) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m((0, 0, 1)) demag = Demag(pbc_2d=True) sim.add(demag) field = demag.compute_field() print((1 + field[2] / 8.6e5)) assert abs(1 + field[2] / 8.6e5) < 1e-10
def excite_system(mesh): sim = Sim(mesh, name='dyn') sim.driver.set_tols(rtol=1e-10, atol=1e-14) sim.driver.alpha = 0.01 sim.driver.gamma = 2.211e5 sim.Ms = spatial_Ms # sim.set_m(init_m) sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) demag = Demag(pbc_2d=True) sim.add(demag) mT = 795.7747154594767 sigma = 0.08e-9 def gaussian_fun(t): return np.exp(-0.5 * (t / sigma)**2) zeeman = TimeZeeman((80 * mT, 0, 0), time_fun=gaussian_fun, name='hx') #zeeman = Zeeman((100*mT,0,0), name='hx') sim.add(zeeman, save_field=True) ts = np.linspace(0, 1e-9, 501) for t in ts: print('time', t) print('length:', sim.spin_length()[0:200]) sim.run_until(t) sim.save_vtk()
sim.add(exch) dmi = DMI(D=(args.D * 1e-3), type='interfacial') sim.add(dmi) if args.B: zeeman = Zeeman((0, 0, args.B / mu0)) sim.add(zeeman, save_field=True) if args.k_u: # Uniaxial anisotropy along + z-axis sim.add(UniaxialAnisotropy(args.k_u, axis=(0, 0, 1))) if args.Demag: print 'Using Demag!' sim.add(Demag()) # ------------------------------------------------------------------------- # Load magnetisation profile --------------------------------------------- # Change the skyrmion initial configuration according to the # chirality of the system (give by the DMI constant) if args.initial_state_skyrmion_down: if args.D > 0: sim.set_m(lambda x: generate_skyrmion_down(x, -1)) else: sim.set_m(lambda x: generate_skyrmion_down(x, 1)) elif args.initial_state_skyrmion_up: if args.D > 0:
def test_with_oommf_spatial_Ms(A=1e-11): def spatial_Ms(pos): x, y = pos[0], pos[1] if x**2 + y**2 < 5**2: return 2e4 else: return 0 init_m0 = """ return [list [expr {sin($x*1e9)+$y*1e9+$z*2.3e9}] [expr {cos($x*1e9)+$y*1e9+$z*1.3e9}] 0] """ init_Ms = """ if { $x*$x + $y*$y < 5e-9*5e-9 } { return 2e4 } else { return 0 } """ mesh = CuboidMesh(nx=12, ny=10, nz=2, dx=0.5, unit_length=1e-9) sim = Sim(mesh) sim.Ms = spatial_Ms exch = UniformExchange(A=A) sim.add(exch) demag = Demag() sim.add(demag) def init_m(pos): x, y, z = pos return (np.sin(x) + y + 2.3 * z, np.cos(x) + y + 1.3 * z, 0) sim.set_m(init_m) field = exch.compute_field() #field_oommf = compute_exch_field(mesh, init_m0=init_m0, A=A, spatial_Ms=init_Ms) omf_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),'omfs','test_with_oommf_spatial_Ms_Exchange.ohf') ovf = OMF2(omf_file) field_oommf = ovf.get_all_mags() mx0, mx1, mx2 = compare_fields(field_oommf, field) assert max([mx0, mx1, mx2]) < 1e-12 field = demag.compute_field() #field_oommf = compute_demag_field(mesh, spatial_Ms=init_Ms, init_m0=init_m0) omf_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),'omfs','test_with_oommf_spatial_Ms_Demag.ohf') ovf = OMF2(omf_file) field_oommf = ovf.get_all_mags() mx0, mx1, mx2 = compare_fields(field_oommf, field) assert max([mx0, mx1, mx2]) < 1e-11