# # (C) 2006 Dr. Thomas Fischbacher # Exchange spring computation using nmag # # XXX Ad anisotropy: this is new and hot. Perhaps it would be nice to # also provide a function to plot an energy hypersurface in 3d - so # that we can use the very same function definition to both # auto-generate a plot and use it in the simulation! import nmag1 as mag, nmesh as nm, sys, math, time import nfem # for debugging mag.set_intensive_parameters( ["H_x", "H_y", "H_z"], # may also set T,p,E, etc. external_magnetization=["H_x", "H_y", "H_z"]) # mag.set_default_order(1) # default anyway... mag.set_features({ "demag": False, "exchange": True, "timestep": True }) # XXX change usage! mat_Dy = mag.MagMaterial( "Dy", Ms=2.5, A=0.0, # A = exchange constant anisotropy=( 2, lambda r: -4.0 * r[2] * r[2]
# # (C) 2006 Dr. Thomas Fischbacher # Exchange spring computation using nmag # # XXX Ad anisotropy: this is new and hot. Perhaps it would be nice to # also provide a function to plot an energy hypersurface in 3d - so # that we can use the very same function definition to both # auto-generate a plot and use it in the simulation! import nmag1 as mag, nmesh as nm, sys, math, time import nfem # for debugging mag.set_intensive_parameters(["H_x","H_y","H_z"], # may also set T,p,E, etc. external_magnetization=["H_x","H_y","H_z"]) mag.set_default_order(2) mag.set_features({"demag":False,"exchange":True,"timestep":True}) # XXX change usage! mat_Dy = mag.MagMaterial("Dy",Ms=2.5,A=0.0, # A = exchange constant anisotropy=(2,lambda r: -4.0*r[2]*r[2]), extra_H="H_total_Dy(0) -= mag[0]*2.5;", ) mat_Fe = mag.MagMaterial("Fe",Ms=1.2,A=4.0, extra_H="""H_total_Fe(0) -= mag[0]*1.2; if(X(0)<0.01 || X(0)>2.99) /* pin the M field at boundaries */ { H_total_Fe(0)=0.0;
# # (C) 2006 Dr. Thomas Fischbacher # Relaxation of the homogeneously magnetized sphere import nmag1 as mag, nmesh as nm, sys, math, time import nfem # for debugging #mag.set_intensive_parameters(["H_x","H_y","H_z"], # may also set T,p,E, etc. # external_magnetization=["H_x","H_y","H_z"]) # ^ XXX not used yet, as we are going to use the experimental cvode integrator... mag.set_intensive_parameters([]) # mag.set_default_order(1) # default anyway... mag.set_features({"demag":True,"exchange":True,"timestep":True}) # XXX change usage! mat_Py = mag.MagMaterial("Py",Ms=1.0,A=13.0, # A = exchange constant ) mag.defregion("Py", nm.ellipsoid([3.0,3.0,3.0]), mag_mat=mat_Py) mag.set_meshing_parameters(cache_name="exchange-spring-mesh", bounding_box=([-4.0,-4.0,-4.0],[4.0,4.0,4.0]), a0=1.0, max_steps=600, ) mag.create_mesh()
import time # Note: we should make a habit of always starting out by defining # the additional intensive parameters of our model. #This adds a Zeeman field: PermAlloy = mag.MagMaterial("Funny", extra_H=""" h_total_Funny[0] += 0.0; h_total_Funny[1] += 1.0; h_total_Funny[2] += 0.0; """) mag.set_default_material(PermAlloy) mag.set_intensive_parameters(["T", "p", "H_x", "H_y", "H_z"]) #mag.defregion("Ball 1",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[-3.0,0.0,0.0])])) print "OK 1" sys.stdout.flush() #mag.defregion("Ball 2",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[3.0,0.0,0.0])])) mag.defregion( "Ball 2", nm.ellipsoid([2.0, 2.0, 2.0], transform=[("shift", [3.0, 0.0, 0.0])])) # Note: clearly, we DO need a better way to specify geometries. Ideally, I would like to be # able to write instead: #
import time # Note: we should make a habit of always starting out by defining # the additional intensive parameters of our model. #This adds a Zeeman field: PermAlloy=mag.MagMaterial("Funny",extra_H=""" h_total_Funny[0] += 0.0; h_total_Funny[1] += 1.0; h_total_Funny[2] += 0.0; """) mag.set_default_material(PermAlloy) mag.set_intensive_parameters(["T","p","H_x","H_y","H_z"]) #mag.defregion("Ball 1",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[-3.0,0.0,0.0])])) print "OK 1" sys.stdout.flush() #mag.defregion("Ball 2",nm.ellipsoid([3.0,3.0,3.0],transform=[("shift",[3.0,0.0,0.0])])) mag.defregion("Ball 2",nm.ellipsoid([2.0,2.0,2.0],transform=[("shift",[3.0,0.0,0.0])])) # Note: clearly, we DO need a better way to specify geometries. Ideally, I would like to be # able to write instead: # # mag.defregion("Ball 1",nm.shifted([-3,0,0],nm.sphere(3))) # mag.defregion("Ball 2",nm.shifted([ 3,0,0],nm.sphere(3)))