theta = 40.0; phi = 90.0 # Polarization direction length, width, thick = (12.5*nm, 12.5*nm, 5*nm) # System geometry I = SI(5e-5, "A"); current_density = I/(length*width) # Applied current Happ_dir = [0.2, 0.2, 10.0] # Applied field (mT) # Create the mesh, if it does not exist mesh_filename = "film.nmesh.h5" if not os.path.exists(mesh_filename): mesh_geo = \ ("algebraic3d\n" "solid cube = orthobrick (0, 0, 0; %s, %s, %s) -maxh = 2.5;\n" "tlo cube;\n" % tuple(map(lambda x: float(x/nm), (length, width, thick)))) netgen_mesh_from_string(mesh_geo, mesh_filename, keep_geo=True) # Material definition anis = uniaxial_anisotropy(axis=[0, 0, 1], K1=-SI(0.1e6, "J/m^3")) 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), 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)
# One dimensional magnetic system studied using nsim import math from nmag import vector_set, SI import nmag.nmag5 as nmag from nsim.si_units.si import mu0, Tesla, degrees_per_ns #-------------------------------------------- #--- Details about the layers and the mesh and the material # Choose Co as a material anisotropy = \ nmag.uniaxial_anisotropy(axis=[(1.0/3)**0.5, (1.0/3)**0.5, (1.0/3)**0.5], K1=SI(0.7e6, "J/m^3"), K2=SI(0.18e6, "J/m^3")) anisotropy.declare("SpaceField", "K1") mat_Co = nmag.MagMaterial( name="Co", Ms=SI(1.42444e6, "A/m"), exchange_coupling=SI(3.02e-11, "J/m"), anisotropy=anisotropy, llg_gamma_G=SI(0.2211e6, "m/ A s"), llg_normalisationfactor=SI(0.001e12, "1/s")) mesh_name = "uniaxial_1d" mesh_unit = SI(1e-9, "m") new_mesh = True #-------------------------------------------- ## The initial configuration and how the applied field should change
import os, sys, math from nmag.constants import degrees_per_ns, mu0 from nmag.common import * # import every, at, etc. # New Nmag5 imports: import nmag5 under the name "nmag" from nmag.nmag5 import MagMaterial, Simulation, uniaxial_anisotropy, SI from nsim.model import Value anisotropy = \ uniaxial_anisotropy(axis=[0, 0, 1], K1=SI(0.0, "J/m^3")) mag = \ MagMaterial(name="a", Ms=SI(0.5e6, "A/m"), exchange_coupling=SI(13e-12, "J/m"), anisotropy=anisotropy, llg_damping=0.5, llg_gamma_G=SI(0.2211e6, "m/A s")) # Create the simulation object sim = Simulation() # We want some constants to be spatially dependent sim.declare("spacefield", "alpha", "Ms", "gamma_G", "exchange_factor") anisotropy.declare("spacefield", "K1") # Load the mesh mats = [("bottom", mag), ("top", mag)] sim.load_mesh("spatially.nmesh.h5", mats, unit_length=SI(1e-9, "m"))