def main(): from joommf.sim import Sim from joommf.mesh import Mesh from joommf.energies.exchange import Exchange from joommf.energies.demag import Demag from joommf.energies.zeeman import FixedZeeman from joommf.drivers import evolver # Mesh specification. lx = ly = lz = 50e-9 # x, y, and z dimensions (m) dx = dy = dz = 5e-9 # x, y, and z cell dimensions (m) Ms = 8e5 # saturation magnetisation (A/m) A = 1e-11 # exchange energy constant (J/m) H = (1e3, 0, 0) # external magnetic field (A/m) m_init = (0, 0, 1) # initial magnetisation t_sim = 3e-9 # simulation time (s) gamma = 2.21e5 alpha = 0.1 # Create a mesh. mesh = Mesh((lx, ly, lz), (dx, dy, dz)) # Create a simulation object. sim = Sim(mesh, Ms, name='dynamics_example', debug=True) # Add energies. sim.add_energy(Exchange(A)) sim.add_energy(Demag()) sim.add_energy(FixedZeeman(H)) sim.set_evolver( evolver.LLG(t_sim, m_init, Ms, alpha, gamma, name='./Testing')) # Set initial magnetisation. sim.add_output('Magnetization', 100) # Run simulation. sim.run()
def test_llg_formatting(): t = 1.5e-9 m_init = (0, 1, 0) Ms = 1e6 alpha = 0.01 gamma = 2.21e5 name = 'test_llg' evolver_object = evolver.LLG(t, m_init, Ms, alpha, gamma, name) mif_string = evolver_object.get_mif() assert mif_string[0] == 'S' assert mif_string[-1] == '\n' assert mif_string[-2] == '\n'
def test_llg_mif(): t = 1.5e-9 m_init = (0, 1, 0) Ms = 1e6 alpha = 0.01 gamma = 2.21e5 name = 'llgtest' llg = evolver.LLG(t, m_init, Ms, alpha, gamma, name) mif_string = llg.get_mif() lines = mif_string.split('\n') assert 'Specify Oxs_RungeKuttaEvolve' in lines[0] assert 'alpha 0.01000' in lines[1] assert 'gamma_G 221000.00000' in lines[2] assert 'start_dm 0.01' in lines[3]
def test_min_dyn(): import glob from joommf.sim import Sim from joommf.mesh import Mesh from joommf.energies.exchange import Exchange from joommf.energies.demag import Demag from joommf.drivers import evolver from joommf.energies.zeeman import FixedZeeman # Mesh specification. lx = ly = lz = 50e-9 # x, y, and z dimensions (m) dx = dy = dz = 5e-9 # x, y, and z cell dimensions (m) Ms = 8e5 # saturation magnetisation (A/m) A = 1e-11 # exchange energy constant (J/m) H = (1e3, 0, 0) # external magnetic field (A/m) m_init = (1, 0, 1) gamma = 2.21e5 alpha = 0.1 # Create a mesh. mesh = Mesh((lx, ly, lz), (dx, dy, dz)) # Create first simulation object. sim1 = Sim(mesh, Ms, name='multiple_example_part1', debug=True) t_sim = 1e-9 sim1.add_energy(Exchange(A)) sim1.add_energy(Demag()) sim1.add_energy(FixedZeeman(H)) sim1.set_evolver( evolver.Minimiser(m_init, Ms, gamma)) # Set initial magnetisation. # Run simulation. sim1.add_output('Magnetization') sim1.minimise() m_init2 = glob.glob(sim1.mif_filename[:-4] + "*.omf")[-1] sim2 = Sim(mesh, Ms, name='multiple_example_part2', debug=True) sim2.add_energy(Exchange(A)) sim2.add_energy(Demag()) sim2.add_energy(FixedZeeman(H)) sim2.set_evolver( evolver.LLG(t_sim, m_init2, Ms, alpha, gamma, name='evolver')) # Set initial magnetisation. # Run simulation. sim2.run()