#nmag.set_global_log_level('debug') #nmag.set_log_level('debug') intensive_param_by_name = {"H_x": 0.1, "H_y": 0.0, "H_z": 0.0} # very slightly pulling in x-direction def test_anisotropy_energy(v): # direction is unit-normalized! print "DDD anisotropy dir=", v result = (1.0 * v[0] * v[0] + 2.0 * v[1] * v[1] + 3.5 * v[2] * v[2]) return result * 0.0 mat_Py = nmag.MagMaterial( "Py", Ms=SI(1e6, "A/m"), J=SI(13.0e-12, "J/m"), #Ms=1., #Matteo, very strange: if I use the SI units above, #J=13., #then I get a wierd magsim-brain failure! anisotropy_order=2, anisotropy=test_anisotropy_energy) sim = nmag.SimulationContext("sphere") # sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults... sim.timestepper_tuning_params = [1e-6, 1e-6, 2, 300] sim.defregion("Py", nm.ellipsoid([3.0, 3.0, 3.0]), mag_mat=mat_Py) def initial_magnetization_0(coords, mag_type):
# very slightly pulling in x-direction def test_anisotropy_energy(v): # direction is unit-normalized! print "DDD anisotropy dir=", v result = (1.0 * v[0] * v[0] + 2.0 * v[1] * v[1] + 3.5 * v[2] * v[2]) return result mat_Py = nmag.MagMaterial("Py", Ms=1.0, J=13.0, anisotropy_order=2, anisotropy=test_anisotropy_energy) mat_Fe = nmag.MagMaterial("Fe", Ms=SI(1.7e6, "A/m"), J=SI(2.07e-11, "J/m")) sim = nmag.SimulationContext("sphere") # sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults... sim.timestepper_tuning_params = [1e-6, 1e-6, 4, 300] sim.set_magnetization([0.0, 1.0, 0.0]) # ^ just to show we can place set_magnetization() where we want... sim.defregion("Py", nmesh.ellipsoid([2.0, 2.0, 2.0], transform=[('shift', [5, 0, 0])]), mag_mat=mat_Py) sim.defregion("Fe", nmesh.ellipsoid([2.0, 2.0, 2.0]), mag_mat=mat_Fe)
import nmag2.si_units as si_units #produce more output for now nmag.set_global_log_level('debug') nmag.set_log_level('debug') intensive_param_by_name={"H_x":0.0,"H_y":0.0,"H_z":0.0} # very slightly pulling in x-direction def test_anisotropy_energy(v): # direction is unit-normalized! print "DDD anisotropy dir=",v result=(1.0*v[0]*v[0]+2.0*v[1]*v[1]+3.5*v[2]*v[2]) return result*0.0 mat_Py = nmag.MagMaterial("Py", Ms=SI(1e6,"A/m"), exchange_coupling=SI(13.0e-12,"J/m"), #Ms=1., #J=13., anisotropy_order=2, anisotropy=test_anisotropy_energy ) sim=nmag.SimulationContext("sphere") # sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults... sim.timestepper_tuning_params=[1e-6,1e-6,4,300] sim.set_magnetization([0.0,1.0,0.0]) # ^ just to show we can place set_magnetization() where we want...
import ocaml #need this as long as we use ocaml.probe_field from nmag2.si_units import SI time_init = time.time() #produce more output for now #nmag.set_global_log_level('debug') #nmag.set_log_level('debug') intensive_param_by_name = {"H_x": 0.1, "H_y": 0.0, "H_z": 0.0} # very slightly pulling in x-direction mat_Py = nmag.MagMaterial( "Py", Ms=SI(1e6, "A/m"), exchange_coupling=SI(13.0e-12, "J/m"), ) sim = nmag.SimulationContext("sphere") # sim.timestepper_tuning_params=[1e-6,1e-6,2,300] # These are the defaults... sim.timestepper_tuning_params = [1e-6, 1e-6, 2, 300] sim.defregion("Py", nm.ellipsoid([3.0, 3.0, 3.0]), mag_mat=mat_Py) def initial_magnetization(coords, mag_type): return [ 0.8 * math.sin(coords[0] / 1.0) * 1e6, 0.8 * math.cos(coords[0] / 1.0) * 1e6, 0.6 * 1e6