import math from nmag.common import SI, degrees_per_ns, Tesla, mu0, at, every from nmag.nmag5 import Simulation, MagMaterial # Applied field Happ_dir = [0, 0, 10] # in mT # Material definition mat = MagMaterial("Py", Ms=SI(860e3, "A/m"), exchange_coupling=SI(13e-12, "J/m"), llg_gamma_G=SI(221017, "m/s A"), llg_damping=SI(0.014)) sim = Simulation("nmag_no_stt", do_demag=False) nm = SI(1e-9, "m") sim.load_mesh("mesh.nmesh", [("cube", mat)], unit_length=nm) sim.set_m([1, 0.01, 0.01]) sim.set_H_ext(Happ_dir, 0.001 * Tesla / mu0) # Define the tolerances for the simulation ns = SI(1e-9, "s") sim.set_params(stopping_dm_dt=0 * degrees_per_ns, ts_rel_tol=1e-8, ts_abs_tol=1e-8, ts_pc_rel_tol=1e-3, ts_pc_abs_tol=1e-8, demag_dbc_rel_tol=1e-6, demag_dbc_abs_tol=1e-6) sim.relax(save=[("averages", every("time", 0.01 * ns))], do=[("exit", at("time", 10 * ns))])
Ms=SI(9.0e5, "A/m"), exchange_coupling=SI(2.0e-11, "J/m"), llg_gamma_G=SI(2.3245e5, "m/s A"), llg_damping=SI(0.01), anisotropy = anis) mat.sl_P = 0.76 # Polarisation mat.sl_lambda = 2.0 # lambda parameter mat.sl_d = SI(2.5e-9, "m") # Free layer thickness sim = Simulation(do_sl_stt=True, do_demag=False) sim.load_mesh("disc.nmesh.h5", [("region1", mat)], unit_length=nm) sim.set_m([0.01, 0.01, 1 ]) sim.set_H_ext(Happ_dir, 0.001*Tesla/mu0) # Direction of the polarization
v = (1.0e-9, dz, -dy) vn = (1.0e-9**2 + dy*dy + dz*dz)**0.5 return tuple(vi/vn for vi in v) sim.set_m(m0) sim.set_H_ext([0, 0, 0], SI("A/m")) # Direction of the polarization sim.model.quantities["sl_fix"].set_value(Value([0, 1, 0])) # Current density sim.model.quantities["sl_current_density"].set_value(Value(SI(0.1e12, "A/m^2"))) if do_relaxation: print "DOING RELAXATION" sim.relax(save=[("fields", at("time", 0*ps) | at("convergence"))]) sim.save_m_to_file(relaxed_m) sys.exit(0) else: print "DOING DYNAMICS" sim.load_m_from_h5file(relaxed_m) sim.set_params(stopping_dm_dt=0*degrees_per_ns) sim.relax(save=[("averages", every("time", 5*ps))], do=[("exit", at("time", 10000*ps))]) #ipython()
v = (1.0e-9, dz, -dy) vn = (1.0e-9**2 + dy * dy + dz * dz)**0.5 return tuple(vi / vn for vi in v) sim.set_m(m0) sim.set_H_ext([0, 0, 0], SI("A/m")) # Direction of the polarization sim.model.quantities["sl_fix"].set_value(Value([0, 1, 0])) # Current density sim.model.quantities["sl_current_density"].set_value(Value(SI(0.1e12, "A/m^2"))) if do_relaxation: print "DOING RELAXATION" sim.relax(save=[("fields", at("time", 0 * ps) | at("convergence"))]) sim.save_m_to_file(relaxed_m) sys.exit(0) else: print "DOING DYNAMICS" sim.load_m_from_h5file(relaxed_m) sim.set_params(stopping_dm_dt=0 * degrees_per_ns) sim.relax(save=[("averages", every("time", 5 * ps))], do=[("exit", at("time", 10000 * ps))]) # ipython()
llg_damping=SI(0.014), anisotropy=anis) mat.sl_P = 0.4 # Polarisation mat.sl_lambda = 2.0 # lambda parameter mat.sl_d = SI(5.0e-9, "m") # Free layer thickness sim = Simulation(do_sl_stt=True, do_demag=False) sim.load_mesh(mesh_filename, [("region1", mat)], unit_length=nm) sim.set_m([1, 0.01, 0.01]) sim.set_H_ext(Happ_dir, 0.001*Tesla/mu0) # Direction of the polarization theta_rad = math.pi*theta/180.0 phi_rad = math.pi*phi/180.0 P_direction = [math.sin(theta_rad)*math.cos(phi_rad), math.sin(theta_rad)*math.sin(phi_rad), math.cos(theta_rad)] # Set the polarization direction and current density sim.model.quantities["sl_fix"].set_value(Value(P_direction)) sim.model.quantities["sl_current_density"].set_value(Value(current_density)) # Define the tolerances for the simulation sim.set_params(stopping_dm_dt=0*degrees_per_ns, ts_rel_tol=1e-8, ts_abs_tol=1e-8, ts_pc_rel_tol=1e-3, ts_pc_abs_tol=1e-8, demag_dbc_rel_tol=1e-6, demag_dbc_abs_tol=1e-6) sim.relax(save=[("averages", every("time", 5*ps))], do=[("exit", at("time", 10000*ps))])
# From left to right: # (1) the name of the parameter to set, # (2) the units of measurement to use for these last two numbers, # (3) the value of the parameter on the first layer, # (4) the value on the second layer. vs = {"alpha": ( SI(1), 0.5, 0.5), # damping "Ms": ( SI("A/m"), 0.69e6, 0.80e6), # saturation mag. "A": ( SI("J/m"), 20e-12, 13.9e-12), # exchange coupling "K1": (SI("J/m^3"), 4e6, 0.0)} # anisotropy constant # We need to compute exchange_factor = 2*A/(mu0*Ms) def exchange_factor(i): A = vs["A"][0] * vs["A"][1+i] Ms = vs["Ms"][0] * vs["Ms"][1+i] return -float((2.0*A/(mu0*Ms))/SI("A m")) vs["exchange_factor"] = (SI("A m"), exchange_factor(0), exchange_factor(1)) vs.pop("A") # Set the anisotropy constant K1 units, first, second = vs.pop("K1") q = anisotropy.quantities["a0_K1"] q.set_value(Value(create_setter(first, second), units)) # Set all the other quantities for name, (units, first, second) in vs.iteritems(): q = sim.model.quantities[name] q.set_value(Value(create_setter(first, second), units)) ps = SI(1e-12, "s") sim.relax(save=[('fields', every('time', 10*ps))])