def excite_system(mesh): sim = Sim(mesh, name='dyn') # sim.set_options(rtol=1e-10,atol=1e-14) sim.alpha = 0.04 sim.gamma = 1.0 sim.mu_s = 1.0 sim.set_m(np.load('m0.npy')) J = 1.0 exch = UniformExchange(J) sim.add(exch) D = 0.09 dmi = DMI(D) sim.add(dmi) zeeman = Zeeman([0, 0, 3.75e-3], name='H') sim.add(zeeman) w0 = 0.02 def time_fun(t): return np.exp(-w0 * t) hx = TimeZeeman([0, 0, 1e-5], sinc_fun, name='h') sim.add(hx, save_field=True) ts = np.linspace(0, 20000, 5001) for t in ts: sim.run_until(t) print 'sim t=%g' % t
def excite_system(mesh): sim = Sim(mesh, name='dyn', driver='sllg') sim.set_options(dt=1e-14, gamma=const.gamma, k_B=const.k_B) sim.driver.alpha = 0.1 sim.mu_s = const.mu_s_1 sim.T = temperature_gradient sim.set_m(np.load("m0.npy")) J = 50.0 * const.k_B exch = UniformExchange(J) sim.add(exch) D = 0.5 * J dmi = DMI(D) sim.add(dmi) Hz = 0.2 * J / const.mu_s_1 zeeman = Zeeman([0, 0, Hz]) sim.add(zeeman) dt = 2e-14 * 50 # 1e-12 ts = np.linspace(0, 1000 * dt, 501) for t in ts: sim.run_until(t) sim.save_vtk() sim.save_m() print 'sim t=%g' % t
def excite_system(mesh): sim = Sim(mesh, name='dyn', driver='sllg') sim.set_options(dt=1e-14, gamma=const.gamma, k_B=const.k_B) sim.alpha = 0.1 sim.mu_s = const.mu_s_1 sim.T = temperature_gradient sim.set_m(np.load("m0.npy")) J = 50.0 * const.k_B exch = UniformExchange(J) sim.add(exch) D = 0.5 * J dmi = DMI(D) sim.add(dmi) Hz = 0.2 * J / const.mu_s_1 zeeman = Zeeman([0, 0, Hz]) sim.add(zeeman) dt = 2e-14 * 50 # 1e-12 ts = np.linspace(0, 1000 * dt, 501) for t in ts: sim.run_until(t) sim.save_vtk() sim.save_m() print 'sim t=%g' % t
def test_dynamic(): mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='dyn_spin', driver='slonczewski') # sim.set_options(rtol=1e-10,atol=1e-14) sim.gamma = 1.0 sim.mu_s = 1.0 sim.set_m((0.8,0,-1)) Kx = Anisotropy(Ku=-0.05, axis=(0, 0, 1), name='Kz') sim.add(Kx) sim.p = (0,0,1) sim.a_J = 0.0052 sim.alpha = 0.1 ts = np.linspace(0, 1200, 401) for t in ts: sim.run_until(t) mz = sim.spin[2] alpha, K, u = 0.1, 0.05, 0.0052 print(mz, u/(2*alpha*K)) ######################################################### # The system used in this test can be solved analytically, which gives that mz = u/(2*alpha*K), # where K represents the easy-plane anisotropy. ### assert abs(mz - u/(2*alpha*K))/mz< 5e-4
def relax_system_stage2(): mesh = CuboidMesh(nx=140 , ny=140, nz=1) sim = Sim(mesh, name='dyn', driver='llg') sim.alpha = 0.1 sim.do_precession = True sim.gamma = const.gamma sim.mu_s = spatial_mu sim.set_m(np.load('skx.npy')) J = 50 * const.k_B exch = UniformExchange(J) sim.add(exch) D = 0.27 * J dmi = DMI(D) sim.add(dmi) zeeman = Zeeman(spatial_H) sim.add(zeeman) ts = np.linspace(0, 2e-9, 201) for t in ts: sim.run_until(t) sim.save_vtk() sim.save_m() print(t)
def dynamic(mesh): sim = Sim(mesh, name='dyn', driver='slonczewski') # sim.set_options(rtol=1e-10,atol=1e-14) sim.driver.gamma = 1.0 sim.mu_s = 1.0 sim.set_m(np.load('m0.npy')) J = 1.0 exch = UniformExchange(J) sim.add(exch) Kx = Anisotropy(Ku=0.005, axis=(1, 0, 0), name='Kx') sim.add(Kx) sim.p = (0, 0, 1) sim.u0 = 0.03 sim.driver.alpha = 0.1 ts = np.linspace(0, 1e3, 101) for t in ts: sim.run_until(t) sim.save_vtk() print t
def excite_system(mesh, Hy=0): sim = Sim(mesh, name='dyn') sim.driver.set_tols(rtol=1e-10, atol=1e-12) sim.driver.alpha = 0.04 sim.driver.gamma = 1.0 sim.mu_s = 1.0 sim.set_m(np.load('m0.npy')) J = 1.0 exch = UniformExchange(J) sim.add(exch) D = 0.18 dmi = DMI(D) sim.add(dmi) zeeman = Zeeman([0, Hy, 2e-2], name='H') sim.add(zeeman) hx = TimeZeeman([0, 0, 1e-5], sinc_fun, name='h') sim.add(hx, save_field=True) dt = 5 steps = 2001 for i in range(steps): sim.run_until(i * dt) sim.save_m() print("step {}/{}".format(i, steps))
def excite_system(mesh, Hy=0): sim = Sim(mesh, name="dyn") sim.set_options(rtol=1e-10, atol=1e-12) sim.alpha = 0.04 sim.gamma = 1.0 sim.mu_s = 1.0 sim.set_m(np.load("m0.npy")) J = 1.0 exch = UniformExchange(J) sim.add(exch) D = 0.18 dmi = DMI(D) sim.add(dmi) zeeman = Zeeman([0, Hy, 2e-2], name="H") sim.add(zeeman) hx = TimeZeeman([0, 0, 1e-5], sinc_fun, name="h") sim.add(hx, save_field=True) dt = 5 steps = 2001 for i in range(steps): sim.run_until(i * dt)
def excite_system(mesh): sim = Sim(mesh, name='dyn') # sim.set_options(rtol=1e-10,atol=1e-14) sim.driver.alpha = 0.04 sim.driver.gamma = 1.0 sim.mu_s = 1.0 sim.set_m(np.load('m0.npy')) J = 1.0 exch = UniformExchange(J) sim.add(exch) D = 0.09 dmi = DMI(D) sim.add(dmi) zeeman = Zeeman([0, 0, 3.75e-3], name='H') sim.add(zeeman) w0 = 0.02 def time_fun(t): return np.exp(-w0 * t) hx = TimeZeeman([0, 0, 1e-5], sinc_fun, name='h') sim.add(hx, save_field=True) ts = np.linspace(0, 20000, 5001) for t in ts: sim.run_until(t) print 'sim t=%g' % t
def relax_system(mesh, Dx=0.005, Dp=0.01): mat = UnitMaterial() sim = Sim(mesh, name='test_energy') print('Created sim') sim.set_tols(rtol=1e-10, atol=1e-12) sim.alpha = mat.alpha sim.gamma = mat.gamma sim.pins = pin_fun exch = UniformExchange(mat.J) sim.add(exch) print('Added UniformExchange') anis = Anisotropy(Dx, axis=[1, 0, 0], name='Dx') sim.add(anis) print('Added Anisotropy') anis2 = Anisotropy([0, 0, -Dp], name='Dp') sim.add(anis2) print('Added Anisotropy 2') sim.set_m((1, 1, 1)) T = 100 ts = np.linspace(0, T, 201) for t in ts: # sim.save_vtk() sim.run_until(t) print('Running -', t) # sim.save_vtk() np.save('m0.npy', sim.spin)
def dynamic(mesh): sim = Sim(mesh, name='dyn', driver='slonczewski') # sim.set_options(rtol=1e-10,atol=1e-14) sim.gamma = 1.0 sim.mu_s = 1.0 sim.set_m(np.load('m0.npy')) J = 1.0 exch = UniformExchange(J) sim.add(exch) Kx = Anisotropy(Ku=0.005, axis=(1, 0, 0), name='Kx') sim.add(Kx) sim.p = (0,0,1) sim.u0 = 0.03 sim.alpha = 0.1 ts = np.linspace(0, 1e3, 101) for t in ts: sim.run_until(t) sim.save_vtk() print t
def relax_system(mesh, Dx=0.005, Dp=0.01): mat = UnitMaterial() sim = Sim(mesh, name='test_energy') sim.set_tols(rtol=1e-10, atol=1e-12) sim.alpha = mat.alpha sim.gamma = mat.gamma sim.pins = pin_fun exch = UniformExchange(mat.J) sim.add(exch) anis = Anisotropy(Dx, axis=[1, 0, 0], name='Dx') sim.add(anis) anis2 = Anisotropy([0, 0, -Dp], name='Dp') sim.add(anis2) sim.set_m((1, 1, 1)) T = 100 ts = np.linspace(0, T, 201) for t in ts: # sim.save_vtk() sim.run_until(t) # sim.save_vtk() np.save('m0.npy', sim.spin)
def test_dynamic(): mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='dyn_spin', driver='slonczewski') # sim.set_options(rtol=1e-10,atol=1e-14) sim.gamma = 1.0 sim.mu_s = 1.0 sim.set_m((0.8, 0, -1)) Kx = Anisotropy(Ku=-0.05, axis=(0, 0, 1), name='Kz') sim.add(Kx) sim.p = (0, 0, 1) sim.u0 = 0.0052 sim.alpha = 0.1 ts = np.linspace(0, 1200, 401) for t in ts: sim.run_until(t) mz = sim.spin[2] alpha, K, u = 0.1, 0.05, 0.0052 print mz, u / (2 * alpha * K) ######################################################### # The system used in this test can be solved analytically, which gives that mz = u/(2*alpha*K), # where K represents the easy-plane anisotropy. ### assert abs(mz - u / (2 * alpha * K)) / mz < 5e-4
def excite_system(T=0.1, H=0.15): mesh = CuboidMesh(nx=28 * 3, ny=16 * 5, nz=1, pbc='2d') sim = Sim(mesh, name='dyn', driver='sllg') sim.set_options(dt=1e-14, gamma=const.gamma, k_B=const.k_B) sim.alpha = 0.1 sim.mu_s = const.mu_s_1 sim.set_m(random_m) J = 50 * const.k_B exch = UniformExchange(J) sim.add(exch) D = 0.5 * J dmi = DMI(D) sim.add(dmi) Hz = H * J / const.mu_s_1 zeeman = Zeeman([0, 0, Hz]) sim.add(zeeman) sim.T = J / const.k_B * T ts = np.linspace(0, 5e-11, 51) for t in ts: sim.run_until(t) # sim.save_vtk() np.save('m.npy', sim.spin) plot_m(mesh, 'm.npy', comp='z')
def test_sim_spins(do_plot=False): mesh = CuboidMesh(nx=10, ny=5, nz=1) sim = Sim(mesh, name='10spin') alpha = 0.1 gamma = 2.21e5 sim.alpha = alpha sim.gamma = gamma sim.mu_s = 1.0 sim.set_m((1, 0, 0)) print(sim.spin) 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) av = sim.compute_average() mx.append(av[0]) my.append(av[1]) mz.append(av[2]) #sim.save_vtk() mz = np.array(mz) # print mz a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) print(sim.stat()) if do_plot: plot(real_ts, mx, my, mz, a_mx, a_my, a_mz, name='spins.pdf', title='integrating spins') 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_sllg(do_plot=False): mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='spin', driver='sllg') alpha = 0.1 gamma = 2.21e5 sim.set_options(dt=5e-15, gamma=gamma) sim.alpha = alpha sim.mu_s = 1.0 sim.set_m((1, 0, 0)) H0 = 1e5 sim.add(Zeeman((0, 0, H0))) ts = np.linspace(0, 1e-10, 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) a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) if do_plot: plot(real_ts, mx, my, mz, a_mx, a_my, a_mz, name='spin_sllg.pdf', title='integrating a spin') print(("Max Deviation = {0}".format(np.max(np.abs(mz - a_mz))))) assert np.max(np.abs(mz - a_mz)) < 1e-8
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 = Anisotropy(Ku=1.0, axis=[0, 0, 1], name='Dx') sim.add(anis) sim.run_until(1.0) assert sim.spin[0] == 0 assert sim.spin[2] != 0
def test_sim_spins(do_plot=False): mesh = CuboidMesh(nx=10, ny=5, nz=1) sim = Sim(mesh, name='10spin') alpha = 0.1 gamma = 2.21e5 sim.alpha = alpha sim.gamma = gamma sim.mu_s = 1.0 sim.set_m((1, 0, 0)) print(sim.spin) 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) av = sim.compute_average() mx.append(av[0]) my.append(av[1]) mz.append(av[2]) #sim.save_vtk() mz = np.array(mz) # print mz a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) print(sim.stat()) if do_plot: plot(real_ts, mx, my, mz, a_mx, a_my, a_mz, name='spins.pdf', title='integrating spins') print(("Max Deviation = {0}".format( np.max(np.abs(mz - a_mz))))) assert np.max(np.abs(mz - a_mz)) < 5e-7
def relax_system(rtol=1e-10, atol=1e-12): """numerical solution""" mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='relax') sim.set_options(rtol=rtol, atol=atol) sim.alpha = 0.5 sim.gamma = 2.21e5 sim.mu_s = 1.0 sim.set_m((1.0, 0, 0)) sim.add(Zeeman((0, 0, 1e5))) ts = np.linspace(0, 1e-9, 1001) for t in ts: sim.run_until(t)
def disable_test_sim_single_spin_llg_stt(do_plot=False): ni = Nickel() mesh = CuboidMesh(nx=1, ny=1, nz=1) mesh.set_material(ni) ni.alpha = 0.1 sim = Sim(mesh, driver='llg_stt') sim.set_m((1, 0, 0)) H0 = 1 sim.add(Zeeman((0, 0, H0))) dt = 1e-12 ts = np.linspace(0, 200 * dt, 101) precession = ni.gamma / (1 + ni.alpha**2) mz_ref = [] mxyz = [] real_ts = [] for t in ts: sim.run_until(t) real_ts.append(sim.t) print(sim.t, abs(sim.spin_length()[0] - 1), sim.spin) mz_ref.append(np.tanh(precession * ni.alpha * H0 * sim.t)) mxyz.append(np.copy(sim.spin)) mxyz = np.array(mxyz) if do_plot: ts_ns = np.array(real_ts) * 1e9 plt.plot(ts_ns, mxyz[:, 0], ".-", label="mx") plt.plot(ts_ns, mxyz[:, 1], ".-", label="my") plt.plot(ts_ns, mxyz[:, 2], ".-", label="mz") plt.plot(ts_ns, mz_ref, "-", label="analytical") plt.xlabel("time (ns)") plt.ylabel("mz") plt.title("integrating a macrospin") plt.legend() plt.savefig("test_llg_stt.png") print(("Deviation = {0}".format(np.max(np.abs(mxyz[:, 2] - mz_ref))))) assert np.max(np.abs(mxyz[:, 2] - mz_ref)) < 1e-9
def relax_system(rtol=1e-10, atol=1e-12): """numerical solution""" mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name="relax") sim.set_options(rtol=rtol, atol=atol) sim.alpha = 0.5 sim.gamma = 2.21e5 sim.mu_s = 1.0 sim.set_m((1.0, 0, 0)) sim.add(Zeeman((0, 0, 1e5))) ts = np.linspace(0, 1e-9, 1001) for t in ts: sim.run_until(t)
def test_sim_single_spin_sllg(do_plot=False): mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, name='spin', driver='sllg') alpha = 0.1 gamma = 2.21e5 sim.set_options(dt=5e-15, gamma=gamma) sim.alpha = alpha sim.mu_s = 1.0 sim.set_m((1, 0, 0)) H0 = 1e5 sim.add(Zeeman((0, 0, H0))) ts = np.linspace(0, 1e-10, 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) a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) if do_plot: plot(real_ts, mx, my, mz, a_mx, a_my, a_mz, name='spin_sllg.pdf', title='integrating a spin') print(("Max Deviation = {0}".format( np.max(np.abs(mz - a_mz))))) assert np.max(np.abs(mz - a_mz)) < 1e-8
def test_sim_single_spin_vode(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) a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) print sim.stat() if do_plot: plot(real_ts, mx, my, mz, a_mx, a_my, a_mz) 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_vode(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) a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts) print sim.stat() if do_plot: plot(real_ts, mx, my, mz, a_mx, a_my, a_mz) print("Max Deviation = {0}".format(np.max(np.abs(mz - a_mz)))) assert np.max(np.abs(mz - a_mz)) < 5e-7
def dynamic(mesh): sim = Sim(mesh, name='dyn_spin', driver='slonczewski') # sim.set_options(rtol=1e-10,atol=1e-14) sim.driver.gamma = 1.0 sim.mu_s = 1.0 sim.set_m((0.8,0,-1)) Kx = Anisotropy(Ku=-0.05, axis=(0, 0, 1), name='Kz') sim.add(Kx) sim.p = (0,0,1) sim.u0 = 0.005 sim.driver.alpha = 0.1 ts = np.linspace(0, 1200, 401) for t in ts: sim.run_until(t) #sim.save_vtk() print t
def relax_system(mesh): sim = Sim(mesh, name='relax') sim.alpha = 0.1 sim.set_m(init_m) J = 1 exch = UniformExchange(J) sim.add(exch) dmi = DMI(0.05 * J) sim.add(dmi) ts = np.linspace(0, 1, 11) for t in ts: print t, sim.spin_length() - 1 sim.run_until(t) sim.save_vtk() return sim.spin
def dynamic(mesh): sim = Sim(mesh, name='dyn_spin', driver='slonczewski') # sim.set_options(rtol=1e-10,atol=1e-14) sim.gamma = 1.0 sim.mu_s = 1.0 sim.set_m((0.8, 0, -1)) Kx = Anisotropy(Ku=-0.05, axis=(0, 0, 1), name='Kz') sim.add(Kx) sim.p = (0, 0, 1) sim.u0 = 0.005 sim.alpha = 0.1 ts = np.linspace(0, 1200, 401) for t in ts: sim.run_until(t) #sim.save_vtk() print t
def single_spin(alpha=0.01): mat = Material() mesh = CuboidMesh(nx=1, ny=1, nz=1) sim = Sim(mesh, driver='sllg') sim.alpha = alpha sim.gamma = mat.gamma sim.mu_s = mat.mu_s sim.T = 10000 sim.set_m((1, 1, 1)) #sim.add(Zeeman(1,(0, 0, 1))) anis = Anisotropy(mat.K, direction=(0, 0, 1)) sim.add(anis) dt = 0.5e-12 ts = np.linspace(0, 1000 * dt, 1001) sx = [] sy = [] for t in ts: sim.run_until(t) sx.append(sim.spin[0]) sy.append(sim.spin[1]) print(t) plt.plot(sx, sy) plt.xlabel("$S_x$") plt.ylabel("$S_y$") plt.grid() plt.axis((-0.9, 0.9, -0.9, 0.9)) plt.axes().set_aspect('equal') plt.savefig("macrospin.pdf")
def relax_system(mesh): sim = Sim(mesh, name='dmi_2d') sim.driver.alpha = 0.1 sim.driver.gamma=1.76e11 sim.mu_s = 1e-22 J = 1e-20 exch = UniformExchange(J) sim.add(exch) dmi = DMI(0.1 * J) sim.add(dmi) sim.set_m(init_m) ts = np.linspace(0, 5e-10, 101) for t in ts: print(t) sim.run_until(t) #sim.save_vtk() return sim.spin
from fidimag.atomistic import Sim from fidimag.common.cuboid_mesh import CuboidMesh from fidimag.atomistic import UniformExchange, Zeeman from fidimag.atomistic import Constant # Import physical constants from fidimag const = Constant() mesh = CuboidMesh(nx=1, ny=1, dx=1, dy=1) sim = Sim(mesh, name='relax_sk') sim.gamma = const.gamma sim.set_m((1, 0, 0)) sim.add(Zeeman((0, 0, 25.))) sim.run_until(1e-11) sim.set_tols(rtol=1e-10, atol=1e-12) sim.run_until(2e-11)
# Interactive mode (this needs so set up a proper backend # when importing matplotlib for the first time) plt.ion() # Set False to avoid the execution of the following code plt.show(False) # --------------------------------------------------------------------- sim.save_vtk() # Now run the simulation printing the energy for time in times: if not run_from_ipython(): print('Time: ', time, ' s') print('Total energy: ', sim.compute_energy(), ' J') print('\n') sim.run_until(time) # Update the vector data for the plot (the spins do not move # so we don't need to update the coordinates) and redraw m = np.copy(sim.spin) # reshape rows, transpose and filter according to top layer m = m.reshape(-1, 3) quiv.set_UVC(m[:, 0], m[:, 1], m[:, 2]) # Update title ttime.set_text('Time: {:.4f} ns'.format(time * 1e9)) tenergy.set_text('Energy: {:.6e} J'.format(sim.compute_energy())) # fig.show() fig.canvas.draw()
from fidimag.atomistic import Sim from fidimag.common.cuboid_mesh import CuboidMesh from fidimag.atomistic import UniformExchange, Zeeman import fidimag.common.constant as const mesh = CuboidMesh(nx=1, ny=1, dx=1, dy=1) sim = Sim(mesh, name='relax_sk') sim.gamma = const.gamma sim.set_m((1, 0, 0)) sim.add(Zeeman((0, 0, 25.))) sim.run_until(1e-11) sim.set_tols(rtol=1e-10, atol=1e-12) sim.run_until(2e-11)