def test_zeeman_formatting(): H = (0.1, -0.5, -8.9e6) zeeman = FixedZeeman(H) mif_string = zeeman.get_mif() assert mif_string[0] == 'S' assert mif_string[-1] == '\n' assert mif_string[-2] == '\n'
def test_zeeman_mif(): H = (0.1, -0.5, -8.9e6) zeeman = FixedZeeman(H) mif_string = zeeman.get_mif() lines = mif_string.split('\n') assert 'Specify Oxs_FixedZeeman {' in lines[0] assert '{ Oxs_UniformVectorField {' in lines[1] assert 'vector' in lines[2] line2 = lines[2].split() assert float(line2[1][1:]) == H[0] assert float(line2[2]) == H[1] assert float(line2[3][0:-1]) == H[2]
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 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 # Create a mesh. mesh = Mesh((lx, ly, lz), (dx, dy, dz)) # Create a simulation object. sim = Sim(mesh, Ms, name='minimisation_example', debug=True) # Add energies. sim.add_energy(Exchange(A)) sim.add_energy(Demag()) sim.add_energy(FixedZeeman(H)) sim.set_evolver(evolver.Minimiser(m_init, Ms, name="./test")) # Set initial magnetisation. # Run simulation. sim.minimise() print("Done")
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()