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.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)
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 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): # 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.set_tols(rtol=1e-8, atol=1e-10) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.do_procession = 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): 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 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 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, 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.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 apply_field1(mesh): sim = Sim(mesh, name='dyn') sim.set_tols(rtol=1e-10, atol=1e-10) sim.alpha = 0.02 sim.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.run_until(t) print('sim t=%g' % t)
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 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 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_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 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_sim_single_spin(do_plot=False): mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='spin') alpha = 0.1 gamma = 2.21e5 sim.alpha = alpha sim.gamma = gamma sim.mu_s = 1.0 sim.set_m((1, 0, 0)) H0 = 1e5 sim.add(Zeeman((0, 0, H0))) ts = np.linspace(0, 1e-9, 101) mx = [] my = [] mz = [] real_ts = [] for t in ts: sim.run_until(t) real_ts.append(sim.t) print(sim.t, abs(sim.spin_length()[0] - 1)) mx.append(sim.spin[0]) my.append(sim.spin[1]) mz.append(sim.spin[2]) mz = np.array(mz) # print mz a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) print(sim.stat()) if do_plot: ts_ns = np.array(real_ts) * 1e9 plt.plot(ts_ns, mx, ".", label="mx", color='DarkGreen') plt.plot(ts_ns, my, ".", label="my", color='darkslateblue') plt.plot(ts_ns, mz, ".", label="mz", color='m') plt.plot(ts_ns, a_mx, "--", label="analytical", color='b') plt.plot(ts_ns, a_my, "--", color='b') plt.plot(ts_ns, a_mz, "--", color='b') plt.xlabel("time (ns)") plt.ylabel("m") plt.title("integrating a macrospin") plt.legend() plt.savefig("single_spin.pdf") print(("Max Deviation = {0}".format( np.max(np.abs(mz - a_mz))))) assert np.max(np.abs(mz - a_mz)) < 5e-7
def test_sim_single_spin(do_plot=False): mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='spin') alpha = 0.1 gamma = 2.21e5 sim.alpha = alpha sim.gamma = gamma sim.mu_s = 1.0 sim.set_m((1, 0, 0)) H0 = 1e5 sim.add(Zeeman((0, 0, H0))) ts = np.linspace(0, 1e-9, 101) mx = [] my = [] mz = [] real_ts = [] for t in ts: sim.run_until(t) real_ts.append(sim.t) print sim.t, abs(sim.spin_length()[0] - 1) mx.append(sim.spin[0]) my.append(sim.spin[1]) mz.append(sim.spin[2]) mz = np.array(mz) # print mz a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) print sim.stat() if do_plot: ts_ns = np.array(real_ts) * 1e9 plt.plot(ts_ns, mx, ".", label="mx", color='DarkGreen') plt.plot(ts_ns, my, ".", label="my", color='darkslateblue') plt.plot(ts_ns, mz, ".", label="mz", color='m') plt.plot(ts_ns, a_mx, "--", label="analytical", color='b') plt.plot(ts_ns, a_my, "--", color='b') plt.plot(ts_ns, a_mz, "--", color='b') plt.xlabel("time (ns)") plt.ylabel("m") plt.title("integrating a macrospin") plt.legend() plt.savefig("single_spin.pdf") print("Max Deviation = {0}".format( np.max(np.abs(mz - a_mz)))) assert np.max(np.abs(mz - a_mz)) < 5e-7
def run_sim(): mesh = CuboidMesh() sim = Sim(mesh, name='spin') alpha = 0.1 gamma = 2.21e5 sim.alpha = alpha sim.driver.gamma = gamma sim.mu_s = 1.0 sim.set_m((1, 0, 0)) H0 = 1e5 sim.add(Zeeman((0, 0, H0))) sim.driver.run_until(1e-10) sim.driver.run_until(0.5e-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.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_sim_pin(): mesh = CuboidMesh(nx=3, ny=2, nz=1) sim = Sim(mesh) sim.set_m((0, 0.8, 0.6)) sim.alpha = 0.1 sim.gamma = 1.0 sim.pins = pin_fun anis = UniaxialAnisotropy(Ku=1, axis=[0, 0, 1], name='Dx') sim.add(anis) sim.run_until(1.0) print sim.spin assert sim.spin[0] == 0 assert sim.spin[2] != 0
def test_sim_pin(): mesh = CuboidMesh(nx=3, ny=2, nz=1) sim = Sim(mesh, integrator='sundials_openmp') sim.set_m((0, 0.8, 0.6)) sim.alpha = 0.1 sim.driver.gamma = 1.0 sim.pins = pin_fun anis = UniaxialAnisotropy(Ku=1, axis=[0, 0, 1], name='Dx') sim.add(anis) sim.driver.run_until(1.0) print(sim.spin) assert sim.spin[0] == 0 assert sim.spin[2] != 0
def excite_system(mesh, beta=0.0): # Specify the stt dynamics in the simulation sim = Sim(mesh, name='dyn_%g'%beta, driver='llg_stt_cpp') sim.set_tols(rtol=1e-12, atol=1e-12) sim.alpha = 0.1 sim.gamma = 2.211e5 sim.Ms = 8.6e5 # 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) # beta is the parameter in the STT torque sim.a_J = global_const*1e11 sim.p = (1,0,0) sim.beta = beta # The simulation will run for 5 ns and save # 500 snapshots of the system in the process ts = np.linspace(0, 0.5e-9, 21) xs=[] thetas=[] for t in ts: print('time', t) sim.run_until(t) spin = sim.spin.copy() x, theta = extract_dw(spin) xs.append(x) thetas.append(theta) sim.save_vtk() np.savetxt('dw_%g.txt'%beta,np.transpose(np.array([ts, xs,thetas])))
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_procession = 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.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 excite_system(mesh, time=5, snaps=501): # Specify the stt dynamics in the simulation sim = Sim(mesh, name='dyn', driver='llg_stt') # Set the simulation parameters sim.set_tols(rtol=1e-12, atol=1e-14) sim.alpha = 0.05 sim.gamma = 2.211e5 sim.Ms = 8.6e5 # Load the initial state from the npy file saved # in the realxation sim.set_m(np.load('m0.npy')) # Add the 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) # Set the current in the x direction, in A / m # beta is the parameter in the STT torque sim.jx = -1e12 sim.beta = 1 # The simulation will run for x ns and save # 'snaps' snapshots of the system in the process ts = np.linspace(0, time * 1e-9, snaps) for t in ts: print 'time', t sim.run_until(t) sim.save_vtk() sim.save_m()
def excite_system(mesh, time=5, snaps=501): # Specify the stt dynamics in the simulation sim = Sim(mesh, name='dyn', driver='llg_stt') # Set the simulation parameters sim.set_tols(rtol=1e-12, atol=1e-14) sim.alpha = 0.05 sim.gamma = 2.211e5 sim.Ms = 8.6e5 # Load the initial state from the npy file saved # in the realxation sim.set_m(np.load('m0.npy')) # Add the 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) # Set the current in the x direction, in A / m # beta is the parameter in the STT torque sim.jx = -1e12 sim.beta = 1 # The simulation will run for x ns and save # 'snaps' snapshots of the system in the process ts = np.linspace(0, time * 1e-9, snaps) for t in ts: print('time', t) sim.run_until(t) sim.save_vtk() sim.save_m()
def excite_system(mesh): sim = Sim(mesh, name='dyn', driver='llg_stt') sim.set_tols(rtol=1e-8, atol=1e-10) sim.alpha = 0.5 sim.gamma = 2.211e5 sim.Ms = 8.6e5 sim.set_m(np.load('m0.npy')) 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.jx = -5e12 sim.beta = 0 ts = np.linspace(0, 0.5e-9, 101) for t in ts: print 'time', t sim.run_until(t) sim.save_vtk()
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
mesh = CuboidMesh(nx=nx, ny=ny, 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.set_tols(rtol=1e-10, atol=1e-14) sim.alpha = args.alpha # sim.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)
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, save_m_steps=None,
mesh = CuboidMesh(nx=nx, ny=ny, nz=nz, dx=dx, dy=dy, dz=dz, unit_length=1e-9, pbc='xy' ) # Initiate Fidimag simulation --------------------------------------------- sim = Sim(mesh, name=args.sim_name) # sim.set_tols(rtol=1e-10, atol=1e-14) sim.alpha = args.alpha # sim.gamma = 2.211e5 if args.no_precession: sim.do_procession = 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 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,
mesh = FDMesh(nx=500, ny=1, nz=1, dx=2, dy=2, dz=2, unit_length=1e-9) # Initial magnetisation function. def init_m(pos): x = pos[0] if x < 450: return (1, 0, 0) elif 450 <= x < 550: return (0, 1, 1) else: return (-1, 0, 0) sim = Sim(mesh) sim.alpha = alpha sim.gamma = gamma sim.Ms = Ms sim.add(UniformExchange(A)) sim.add(UniaxialAnisotropy(K)) sim.set_m(init_m) sim.relax(dt=1e-13, stopping_dmdt=0.001, max_steps=5000) # Magnetisation x component. mx_simulation = sim.spin.reshape((len(sim.spin) / 3, 3))[:, 0] ################### # Analytic solution ################### d = 1000e-9 # sample length (nm) n_points = 500