def relax_system(mesh): 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((1,1,1)) # sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) dmi = DMI(D=1e-3) sim.add(dmi) zeeman = Zeeman((0, 0, 2e4)) sim.add(zeeman, save_field=True) sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=50) np.save('m0.npy', sim.spin)
def relax_system(mesh): sim = Sim(mesh, name='relax') sim.set_tols(rtol=1e-6, atol=1e-6) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m(init_m) #sim.set_m((0,0.1,1)) #sim.set_m(np.load('m0.npy')) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) dmi = DMI(D=1.3e-3) sim.add(dmi) anis = UniaxialAnisotropy(-3.25e4, axis=(0, 0, 1)) sim.add(anis) zeeman = Zeeman((0, 0, 6.014576e4)) sim.add(zeeman, save_field=True) sim.relax(dt=1e-13, stopping_dmdt=0.5, max_steps=5000, save_m_steps=None, save_vtk_steps=50) np.save('m0.npy', sim.spin)
def run_fidimag(mesh): mu0 = 4 * np.pi * 1e-7 Ms = 8.6e5 A = 16e-12 D = -3.6e-3 K = 510e3 sim = Sim(mesh) sim.set_tols(rtol=1e-10, atol=1e-10) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = Ms sim.do_precession = False sim.set_m((0, 0, 1)) sim.add(UniformExchange(A)) sim.add(DMI(D, dmi_type='interfacial')) sim.add(UniaxialAnisotropy(K, axis=(0, 0, 1))) sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=50) m = sim.spin return m.copy()
def relax_system(mesh): # Only relaxation sim = Sim(mesh, name='relax') # Simulation parameters sim.set_tols(rtol=1e-8, atol=1e-10) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False # The initial state passed as a function sim.set_m(init_m) # sim.set_m(np.load('m0.npy')) # Energies A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) anis = UniaxialAnisotropy(5e4) sim.add(anis) # dmi = DMI(D=8e-4) # sim.add(dmi) # Start relaxation and save the state in m0.npy sim.relax(dt=1e-14, stopping_dmdt=0.00001, max_steps=5000, save_m_steps=None, save_vtk_steps=None) np.save('m0.npy', sim.spin)
def relax_system(mesh): # Only relaxation sim = Sim(mesh, name='relax') # Simulation parameters sim.driver.set_tols(rtol=1e-8, atol=1e-10) sim.driver.alpha = 0.5 sim.driver.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False # The initial state passed as a function sim.set_m(init_m) # sim.set_m(np.load('m0.npy')) # Energies A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) anis = UniaxialAnisotropy(5e4) sim.add(anis) # Start relaxation and save the state in m0.npy sim.relax(dt=1e-14, stopping_dmdt=0.00001, max_steps=5000, save_m_steps=None, save_vtk_steps=None) np.save('m0.npy', sim.spin)
def run_fidimag(mesh): mu0 = 4 * np.pi * 1e-7 Ms = 8.6e5 A = 16e-12 D = -3.6e-3 K = 510e3 sim = Sim(mesh) sim.set_tols(rtol=1e-10, atol=1e-10) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = Ms sim.do_precession = False sim.set_m((0, 0, 1)) sim.add(UniformExchange(A)) sim.add(DMI(D, type='interfacial')) sim.add(UniaxialAnisotropy(K, axis=(0, 0, 1))) sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=50) m = sim.spin return m.copy()
def test_dw_dmi(mesh=mesh, do_plot=False): Ms = 8.0e5 sim = Sim(mesh, name='relax') sim.set_m(m_init_dw) sim.set_tols(rtol=1e-8, atol=1e-12) sim.Ms = Ms sim.alpha = 0.5 sim.do_precession = False A = 1.3e-11 D = 4e-4 Kx = 8e4 Kp = -6e5 sim.add(UniformExchange(A)) sim.add(DMI(D)) sim.add(UniaxialAnisotropy(Kx, axis=[1, 0, 0], name='Kx')) sim.relax(stopping_dmdt=0.01) xs = np.array([p[0] for p in mesh.coordinates]) mx, my, mz = analytical(xs, A=A, D=D, K=Kx) mxyz = sim.spin.copy() mxyz = mxyz.reshape(-1, 3) assert max(abs(mxyz[:, 0] - mx)) < 0.002 assert max(abs(mxyz[:, 1] - my)) < 0.002 assert max(abs(mxyz[:, 2] - mz)) < 0.0006 if do_plot: save_plot(mxyz, mx, my, mz)
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 = 8.6e5 sim.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) dmi = DMI(D=1e-3) sim.add(dmi) zeeman = Zeeman((0, 0, 2e4)) sim.add(zeeman, save_field=True) sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=50) np.save("m0.npy", sim.spin)
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-6, atol=1e-6) sim.driver.alpha = 0.5 sim.driver.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m(init_m) exch = UniformExchange(A=1.3e-11) sim.add(exch) dmi = DMI(D=-4e-3) sim.add(dmi) zeeman = Zeeman((0, 0, 4e5)) sim.add(zeeman, save_field=True) sim.relax(dt=1e-13, stopping_dmdt=1e-2, save_m_steps=None, save_vtk_steps=50) np.save('m0.npy', sim.spin)
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 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 relax_system(mesh): sim = Sim(mesh, name='relax') sim.set_tols(rtol=1e-6, atol=1e-6) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m(init_m) exch = UniformExchange(A=1.3e-11) sim.add(exch) dmi = DMI(D=-4e-3) sim.add(dmi) zeeman = Zeeman((0, 0, 4e5)) sim.add(zeeman, save_field=True) sim.relax(dt=1e-13, stopping_dmdt=1e-2, save_m_steps=None, save_vtk_steps=50) 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 test_dw_dmi(mesh=mesh, do_plot=False): Ms = 8.0e5 sim = Sim(mesh, name='relax') sim.set_m(m_init_dw) sim.driver.set_tols(rtol=1e-8, atol=1e-12) sim.Ms = Ms sim.alpha = 0.5 sim.do_precession = False A = 1.3e-11 D = 4e-4 Kx = 8e4 Kp = -6e5 sim.add(UniformExchange(A)) sim.add(DMI(D)) sim.add(UniaxialAnisotropy(Kx, axis=[1, 0, 0], name='Kx')) sim.driver.relax(stopping_dmdt=0.01) xs = np.array([p[0] for p in mesh.coordinates]) mx, my, mz = analytical(xs, A=A, D=D, K=Kx) mxyz = sim.spin.copy() mxyz = mxyz.reshape(-1, 3) assert max(abs(mxyz[:, 0] - mx)) < 0.002 assert max(abs(mxyz[:, 1] - my)) < 0.002 assert max(abs(mxyz[:, 2] - mz)) < 0.0006 if do_plot: save_plot(mxyz, mx, my, mz)
def setup_domain_wall_cobalt(node_count=NODE_COUNT, A=A_Co, Ms=Ms_Co, K1=K1_Co, length=LENGTH, do_precession=True, unit_length=UNIT_LENGTH): a = length / node_count # cell size mesh = CuboidMesh(dx=a, dy=a, dz=a, nx=node_count, ny=1, nz=1, unit_length=unit_length) sim = Sim(mesh, "dw_cobalt") sim.Ms = Ms sim.set_m(lambda r: initial_m(r, length)) sim.do_precession = do_precession sim.add(UniformExchange(A)) sim.add(UniaxialAnisotropy(K1, (0, 0, 1))) sim.pins = lambda r: 1 if (r[0] < a or r[0] > LENGTH - a) else 0 return sim
def relax_system_only_exchange(mesh): sim = Sim(mesh, name='relax_exchange_only') sim.set_tols(rtol=1e-6, atol=1e-6) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m(init_m_BP) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) sim.relax(dt=1e-13, stopping_dmdt=0.5, max_steps=5000, save_m_steps=None, save_vtk_steps=50) np.save('m0.npy', sim.spin)
def relax_system_only_exchange(mesh): sim = Sim(mesh, name='relax_exchange_only') sim.driver.set_tols(rtol=1e-6, atol=1e-6) sim.driver.alpha = 0.5 sim.driver.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_precession = False sim.set_m(init_m_BP) A = 1.3e-11 exch = UniformExchange(A=A) sim.add(exch) sim.relax(dt=1e-13, stopping_dmdt=0.5, max_steps=5000, save_m_steps=None, save_vtk_steps=50) 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.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 relax_system(mesh): sim = Sim(mesh, name='relax') sim.set_tols(rtol=1e-10, atol=1e-10) sim.alpha = 0.5 sim.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)
nz=nz, dx=dx, dy=dy, dz=dz, unit_length=1e-9, pbc=(True, True, False)) # Initiate Fidimag simulation --------------------------------------------- sim = Sim(mesh, name=args.sim_name) # sim.driver.set_tols(rtol=1e-10, atol=1e-14) sim.driver.alpha = args.alpha # sim.driver.gamma = 2.211e5 if args.no_precession: sim.do_precession = False # Material parameters ----------------------------------------------------- sim.Ms = args.Ms exch = UniformExchange(A=args.A) 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)
x, y = pos[0] - radius, pos[1] - radius if x ** 2 + y ** 2 < radius ** 2: return (0, 0, 1) else: return (0, 0, -1) # Prepare simulation # We define the cylinder with the Magnetisation function sim = Sim(mesh, name='skyrmion') sim.Ms = cylinder # To get a faster relaxation, we tune the LLG equation parameters sim.do_precession = False sim.alpha = 0.5 # Initial magnetisation: sim.set_m(init_m) # Energies: # Exchange sim.add(UniformExchange(A=A)) # Bulk DMI sim.add(DMI(D=D)) # Relax the system sim.relax(dt=1e-12, stopping_dmdt=0.0001, max_steps=5000,