def print_field(): for i in range(1, 299): x = i * 0.01 probed = mag.probe([x]) m_y_fe = 0.0 m_y_dy = 0.0 if len(probed) == 2: m_y_fe = probed[1][1][1] m_y_dy = probed[0][1][1] elif len(probed) == 1: m_y_fe = probed[0][1][1] print "EDATA ", x, m_y_fe, m_y_dy for i in range(1, 200): #mag.advance_time([0.0,0.5,0.0],time=0.4) # apply an external field in +y direction mag.advance_time([0.0, 2.5, 0.0], steps=1000) print "Total magnetization(%d): " % i, mag.integrate() print "Energy(%d):" % i, mag.total_energy() nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M], 'data%05d.vtk' % i, mesh=mag.default_simulation_context.mesh) sys.stdout.flush() print_field() # ../bin/nsim exchange-spring-ord2.py | perl -ne 'BEGIN{open F, ">ord2.gdata"}END{close F} m/^EDATA (.*)/ and print F "$1\n"'
# nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M],'data%05d.vtk' % 0,mesh=mag.default_simulation_context.mesh) def print_field(): for i in range(1,299): x=i*0.01 probed=mag.probe([x]) m_y_fe = 0.0 m_y_dy = 0.0 if len(probed)==2: m_y_fe=probed[1][1][1] m_y_dy=probed[0][1][1] elif len(probed)==1: m_y_fe=probed[0][1][1] print "EDATA ",x,m_y_fe,m_y_dy for i in range(1,400): #mag.advance_time([0.0,0.5,0.0],time=0.4) # apply an external field in +y direction mag.advance_time([0.0,2.5,0.0],steps=1000) print "Total magnetization(%d): " % i, mag.integrate() print "Energy(%d):" %i,mag.total_energy() # nfem.visual.fields2vtkfile([mag.default_simulation_context.field_M],'data%05d.vtk' % i,mesh=mag.default_simulation_context.mesh) sys.stdout.flush() # nfem.field_entry_wise(mag.default_simulation_context.field_m,debugprint) # so that we have all the sites print_field() # ../bin/nsim exchange-spring-ord2.py | perl -ne 'BEGIN{open F, ">ord2.gdata"}END{close F} m/^EDATA (.*)/ and print F "$1\n"'
if dir == 0: return math.cos(coords[0]) elif dir == 1: return math.sin(coords[0]) else: return 0 mag.set_magnetization([1.0, 0.0, 0.0]) # may also provide a function here! #mag.set_magnetization(initial_M) # may also provide a function here! # NOTE: set_magnetization should also be able # to take just a constant vector as an argument. print "Total magnetization: ", mag.integrate() f = open("data.dat", "w") import nfem import nfem.visual frame = 0 rejected = 0 accepted = 0 last_T = 0 for n in range(1, 5000): time, status = mag.default_simulation_context.timestepper.advance_time(
def initial_M(dof_name,coords): dir=dof_name[1][0] if dir==0: return math.cos(coords[0]) elif dir==1: return math.sin(coords[0]) else: return 0 mag.set_magnetization([1.0,0.0,0.0]) # may also provide a function here! #mag.set_magnetization(initial_M) # may also provide a function here! # NOTE: set_magnetization should also be able # to take just a constant vector as an argument. print "Total magnetization: ", mag.integrate() f=open("data.dat","w") import nfem import nfem.visual frame = 0 rejected = 0 accepted = 0 last_T = 0 for n in range(1,5000):
mag.create_mesh() def initial_M(dof_name, coords): dir = dof_name[1][0] if dir == 0: return math.cos(coords[0]) elif dir == 1: return math.sin(coords[0]) else: return 0 #mag.set_magnetization([1.0,0.0,0.0]) # may also provide a function here! mag.set_magnetization(initial_M) # may also provide a function here! # NOTE: set_magnetization should also be able # to take just a constant vector as an argument. print "Total magnetization: ", mag.integrate() # XXXDDDXXXDDD for n in range(1, 100): print "T=", mag.default_simulation_context.timestepper.advance_time( [0.0, 0.0, 0.0, 0.0, 0.0]) # this needs the intensive params! # time.sleep(1000) # so we do not lose the dynamically generated C code...
# mag.defregion("Ball 1",nm.shifted([-3,0,0],sphere)) # mag.defregion("Ball 2",nm.shifted([ 3,0,0],sphere)) mag.set_meshing_parameters(cache_name="two-balls") mag.create_mesh() def initial_M(dof_name,coords): dir=dof_name[1][0] if dir==0: return math.cos(coords[0]) elif dir==1: return math.sin(coords[0]) else: return 0 #mag.set_magnetization([1.0,0.0,0.0]) # may also provide a function here! mag.set_magnetization(initial_M) # may also provide a function here! # NOTE: set_magnetization should also be able # to take just a constant vector as an argument. print "Total magnetization: ", mag.integrate() # XXXDDDXXXDDD for n in range(1,100): print "T=",mag.default_simulation_context.timestepper.advance_time([0.0,0.0,0.0,0.0,0.0]) # this needs the intensive params! # time.sleep(1000) # so we do not lose the dynamically generated C code...