import time
import nmag
from nmag import SI

start = time.time()

mat_Py = nmag.MagMaterial(name="Py",
                          Ms=SI(0.86e6,"A/m"),
                          exchange_coupling=SI(13.0e-12, "J/m"),
                          llg_damping=0.5)

sim = nmag.Simulation("nmag_bar")

sim.load_mesh("bar.nmesh.h5",
              [("Py", mat_Py)],
              unit_length=SI(1e-9,"m"))

sim.set_m([1,0,1])

dt = SI(5e-12, "s") 

for i in range(0, 61):
    sim.advance_time(dt*i)              #compute time development
    sim.save_data()                     #save averages

print "Simulation took {:.3} s.".format(time.time() - start)
