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")
Example #2
0
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()
Example #3
0
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()
Example #4
0
def test_sim_basic_square():
    testmesh = mesh.Mesh((10, 20, 30), (3, 3, 3), scale=1e-9)
    a = sim.Sim(testmesh, 1e4)
    a.add_energy(Demag())
Example #5
0
def test_demag_mif():
    demag = Demag()
    mif_string = demag.get_mif()
    assert 'Specify Oxs_Demag {}' in mif_string
    assert demag.__repr__() == "This is the energy class of type Demag"
Example #6
0
def test_demag_formatting():
    demag = Demag()
    mif_string = demag.get_mif()
    assert mif_string[0] == 'S'
    assert mif_string[-1] == '\n'
    assert mif_string[-2] == '\n'
Example #7
0
def test_demag_formatting():
    demag = Demag()
    mif_string = demag.get_mif()
    assert mif_string[0] == 'S'
    assert mif_string[-1] == '\n'
    assert mif_string[-2] == '\n'
Example #8
0
def test_demag_mif():
    demag = Demag()
    mif_string = demag.get_mif()
    assert 'Specify Oxs_Demag {}' in mif_string
    assert demag.__repr__() == "This is the energy class of type Demag"