H_norms = [0.05, 0.1, [], 1.0, 1.1, [], 2.0, 2.2, [], 3.8, 3.82, [], 4.2, 4.25, [], 4.5, 4.6, [], 5.0] # Selected norms for the second part of the simulation H_norms = [0] selected_H_norms = [0.5, 1.0, 1.5, 2.0, 3.0, 3.2, [], 5.0] selected_H_norms = [0] H_scale = 1 H_norms = sets.float_set(H_norms, H_scale) selected_H_norms = sets.float_set(selected_H_norms, H_scale) H_unit = T/mu0 # The unit for these values is T (Tesla) # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = sets.vector_set(direction=H_direction, norm_list=H_norms) # A small deviation to avoid points of unstable equilibrium H_dev = [0.0001, 0.0001, 0.0001] new_Hs = [] for H in Hs: new_Hs.append([Hi+H_devi for Hi, H_devi in zip(H, H_dev)]) new_Hs.append(H) Hs = new_Hs #-------------------------------------------- ## Aux. functions # This function returns a function to set the external field # We need this because the field acting on iron will be higher # at borders (non uniform in space).
3.8, 3.82, [], 4.2, 4.25, [], 4.5, 4.6, [], 5.0, 5.5, [], 12.0]) selected_B_norms = \ sets.float_set([0.0, 0.5, [], 3.5, 3.8, 3.9, 4.0, 4.1, 4.5, 5.0, [], 12.0]) delta_B = [0.002, 0.002, 0.002] # Tilt vector in T #tilted_B_norms = [B_norm + delta_B for B_norm in B_norms] #selected_B_norms = [B_norm + delta_B for B_norm in selected_B_norms] # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = [] delta_H = [dBi*B_unit/mu0 for dBi in delta_B] for H in sets.vector_set(direction=B_direction, norm_list=B_norms, units=B_unit/mu0): # remember that H = B/mu0 Hs.append([Hi + dHi for Hi, dHi in zip(H, delta_H)]) Hs.append(H) #-------------------------------------------- ## Determine if we should run the pre simulation or the post simulation # First we determine for what stages we have to compute the dynamics i = 0 j = 1 selected_stages = [] for B_norm in B_norms: selected_B_norm = selected_B_norms[i] if abs(B_norm - selected_B_norm) < 1e-5:
#The list of values taken by the norm of the applied field H_norms = [0.05, 0.1, [], 1.0, 1.1, [], 2.0, 2.2, [], 3.8, 3.82, [], 4.2, 4.25, [], 4.5, 4.6, [], 5.0, 5.5, [], 8.0] selected_H_norms = [3.6, 4.0, 4.2] H_norms = sets.float_set(H_norms, H_scale) selected_H_norms = sets.float_set(selected_H_norms, H_scale) #print H_norms[32] #sys.exit(0) H_unit = T/mu0 # The unit for these values is T (Tesla) # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = sets.vector_set(direction=H_direction, norm_list=H_norms) # A small deviation to avoid points of unstable equilibrium H_dev = [0.0001, 0, 0.0001] Hs = [[Hi+H_devi for Hi, H_devi in zip(H, H_dev)] for H in Hs] H_pinning_norm = -10.0 H_pinning, = sets.vector_set(direction=H_direction, norm_list=[H_pinning_norm]) #-------------------------------------------- ## The current density for spin-torque calculations j = [SI(4e12, "A/m^2"), 0.0, 0.0]
exchange_coupling = SI(13.0e-12, "J/m") # Exchange coupling constant m_sat = SI(0.86e6, "A/m") # Saturation magnetisation #-------------------------------------------- ## The initial configuration and how the applied field should change m0 = [1, 0, 1] # Initial direction for the magnetisation H_direction = [1, 1, 1] # The direction of the applied field #The list of values taken by the norm of the applied field H_norms = [10.0, 9.5, [], -10.0] H_unit = SI(1e6, "A/m") # The unit for these values # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = sets.vector_set(direction=H_direction, norm_list=H_norms, units=H_unit) #-------------------------------------------- ## Here we set up the simulation # Create the material mat_Py = nmag.MagMaterial( name="Py", Ms=m_sat, exchange_coupling=exchange_coupling, anisotropy=nmag.uniaxial_anisotropy( axis=[1,0,0], K1=SI(5e6, "J/m^3")), llg_gamma_G=SI(0.2211e6, "m/A s"), llg_damping=SI(0.5), llg_normalisationfactor=SI(0.001e12, "1/s"))
) mesh_name = "uniaxial_1d" mesh_unit = SI(1e-9, "m") layers = [(-10.0, 10.0)] discretization = 1.0 new_mesh = True # -------------------------------------------- ## The initial configuration and how the applied field should change m0 = [1, 0, 1] # Initial direction for the magnetisation # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = sets.vector_set(direction=[1, -2, 3], norm_list=[-3.0, [200], 3.0], units=SI(1e6, "A/m")) # -------------------------------------------- ## Here we set up the simulation # Create the simulation object sim = nmag.Simulation("uniaxial_1d", do_demag=False) # Creates the mesh from the layer structure mesh_file_name = "%s.nmesh" % mesh_name if not os.path.exists(mesh_file_name) or new_mesh: print "Creating the mesh" mesh_lists = unidmesher.mesh_1d(layers, discretization) unidmesher.write_mesh(mesh_lists, out=mesh_file_name) # Load the mesh
# The list of values taken by the norm of the applied field H_norms = [0.6, 0.4, 0.2, 0.16, "...", 0, -0.005, "...", -0.045, -0.0455, "...", # should contain Hc: we map it better! -0.058] #, -0.065, "...", -0.2] #H_norms = [0.6, 0.594186, "...", -0.2] # For now we stick at what we do with magpar # The direction of the applied field H_direction = [1, 1, 1] # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation # Note we express all in terms of the saturation magnetisation. Hs = sets.vector_set(direction=H_direction, norm_list=H_norms, units=material.m_sat) # Initial magnetisation def m0((x, y, z), mag_type): import math x = 1.0/math.sqrt(3) return [x, x, x] def out(line, header=False, file="dyn.dat"): import os if header and os.path.exists(file): return f = open(file, "a") f.write(line) f.close() out("# d/l_ex Hc/Ms Mr_x/Ms Mr_y/Ms\n", header=True)
B_norms = \ sets.float_set([0.0, 0.1, [], 2.0, 2.25, [], 3.8, 3.82, [], 4.2, 4.25, [], 4.5, 4.6, [], 5.0, 5.5, [], 12.0]) selected_B_norms = \ sets.float_set([0.0, 0.5, [], 3.5, 3.8, 3.9, 4.0, 4.1, 4.5, 5.0, [], 12.0]) delta_B = 0.01 # Tilt amplitude used to induce oscillations tilted_B_norms = [B_norm + delta_B for B_norm in B_norms] selected_B_norms = [B_norm + delta_B for B_norm in selected_B_norms] # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = sets.vector_set(direction=B_direction, norm_list=B_norms, units=B_unit/mu0) # remember that H = B/mu0 Hs_tilted = sets.vector_set(direction=B_direction, norm_list=tilted_B_norms, units=B_unit/mu0) # A small deviation to avoid points of unstable equilibrium H_dev = [SI(0.005e6, "A/m"), SI(0.005e6, "A/m"), 0] Hs = [[Hi+H_devi for Hi, H_devi in zip(H, H_dev)] for H in Hs] Hs_tilted = [[Hi+H_devi for Hi, H_devi in zip(H, H_dev)] for H in Hs_tilted] #-------------------------------------------- ## The current density for spin-torque calculations
return directions['m_Fe3O4'] def m0_CoFe2O4(r): return directions['m_CoFe2O4'] # The direction of the applied field B_direction = [0.0, 1.0, 0.0] #The list of values taken by the norm of the applied field B_norms = [-5.0, -4.9, [], 5.0] B_unit = Tesla # The unit for these values # From the norms and the direction (which is constant) we derive # all the values that the applied field will take during the simulation Hs = sets.vector_set(direction=B_direction, norm_list=sets.float_set(B_norms), units=B_unit/mu0) # remember that H = B/mu0 # A small deviation to avoid points of unstable equilibrium H_dev = [SI(0.005e6, "A/m")]*3 Hs = [[Hi+H_devi for Hi, H_devi in zip(H, H_dev)] for H in Hs] #-------------------------------------------- ## Here we set up the simulation # Create the simulation object sim = nmag.Simulation("run", do_demag=False, adjust_tolerances=False) # Set the coupling between the two magnetisations Fe3O4_CoFe2O4_lc = Fe3O4_CoFe2O4_sup_lc*mesh_unit*discretization