コード例 #1
0
ファイル: run.py プロジェクト: whshangl/finmag
def run_simulation():
    L = W = 12.5e-9
    H = 2.5e-9
    sim = Sim(mesh, Ms=8.6e5, unit_length=1e-9)
    sim.set_m((1, 0.01, 0.01))
    sim.alpha = 0.014
    sim.gamma = 221017

    H_app_mT = np.array([0.0, 0.0, 10.0])
    H_app_SI = H_app_mT / (1000 * mu0)
    sim.add(Zeeman(tuple(H_app_SI)))

    sim.add(Exchange(1.3e-11))

    I = 5e-5  # current in A
    J = I / (L * W)  # current density in A/m^2
    theta = 40.0 * pi / 180
    phi = pi / 2  # polarisation direction
    p = (sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta))
    sim.llg.use_slonczewski(J=J, P=0.4, d=H, p=p)

    with open(averages_file, "w") as f:
        dt = 10e-12
        t_max = 10e-9
        for t in np.arange(0, t_max, dt):
            sim.run_until(t)
            f.write("{} {} {} {}\n".format(t, *sim.m_average))
コード例 #2
0
ファイル: run.py プロジェクト: whshangl/finmag
def run_sim_with_stt():
    sim = Sim(mesh, Ms=8.6e5)
    sim.set_m((1, 0.01, 0.01))
    sim.alpha = 0.014
    sim.gamma = 221017

    H_app_mT = np.array([0.2, 0.2, 10.0])
    H_app_SI = H_app_mT / (1000 * mu0)
    sim.add(Zeeman(tuple(H_app_SI)))

    sim.add(Exchange(1.3e-11))
    sim.add(UniaxialAnisotropy(1e5, (0, 0, 1)))

    I = 5e-5  # current in A
    J = I / (L * W)  # current density in A/m^2
    theta = 40.0 * pi / 180
    phi = pi / 2  # polarisation direction
    p = (sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta))
    sim.llg.use_slonczewski(J=J, P=0.4, d=5e-9, p=(0, 1, 0))

    with open(averages_with, "w") as f:
        dt = 5e-12
        t_max = 10e-9
        for t in np.arange(0, t_max, dt):
            sim.run_until(t)
            f.write("{} {} {} {}\n".format(t, *sim.m_average))
コード例 #3
0
ファイル: test_std_prob_4.py プロジェクト: whshangl/finmag
def run_simulation(stop_when_mx_eq_zero):
    """
    Runs the simulation using field #1 from the problem description.

    Stores the average magnetisation components regularly, as well as the
    magnetisation when the x-component of the average magnetisation crosses
    the value 0 for the first time.

    """
    mesh = from_geofile(os.path.join(MODULE_DIR, "bar.geo"))

    sim = Simulation(mesh, Ms, name="dynamics", unit_length=1e-9)
    sim.alpha = alpha
    sim.gamma = gamma
    sim.set_m(np.load(m_0_file))
    sim.add(Demag())
    sim.add(Exchange(A))
    """
    Conversion between mu0 * H in mT and H in A/m.

                   mu0 * H = 1               mT
                           = 1 * 1e-3        T
                           = 1 * 1e-3        Vs/m^2
    divide by mu0 with mu0 = 4pi * 1e-7      Vs/Am
    gives                H = 1 / 4pi * 1e4   A/m

    with the unit A/m which is indeed what we want.
    Consequence:
        Just divide the value of mu0 * H in Tesla
        by mu0 to get the value of H in A/m.

    """
    Hx = -24.6e-3 / mu0
    Hy = 4.3e-3 / mu0
    Hz = 0
    sim.add(Zeeman((Hx, Hy, Hz)))

    def check_if_crossed(sim):
        mx, _, _ = sim.m_average
        if mx <= 0:
            print "The x-component of the spatially averaged magnetisation first crossed zero at t = {}.".format(
                sim.t)
            np.save(m_at_crossing_file, sim.m)
            # When this function returns True, it means this event is done
            # and doesn't need to be triggered anymore.
            # When we return False, it means we want to stop the simulation.
            return not stop_when_mx_eq_zero

    sim.schedule(check_if_crossed, every=1e-12)
    sim.schedule('save_averages', every=10e-12, at_end=True)
    sim.schedule('save_vtk', every=10e-12, at_end=True, overwrite=True)
    sim.run_until(2.0e-9)
    return sim.t
コード例 #4
0
def relax_system(mesh):
    sim = Sim(mesh, Ms=8.0e5, unit_length=1e-9)
    sim.gamma = 2.211e5

    sim.alpha = 1

    sim.add(Exchange(A=13e-12))
    sim.add(Demag())

    sim.set_m(init_m)

    sim.relax(stopping_dmdt=0.01)
    np.save('m0.npy', sim.m)
    df.plot(sim._m)
コード例 #5
0
def with_current(mesh):
    sim = Sim(mesh, Ms=8.0e5, unit_length=1e-9, name='stt')
    sim.gamma = 2.211e5

    sim.alpha = 0.1
    sim.set_m(np.load('m0.npy'))

    sim.add(Exchange(A=13e-12))
    sim.add(Demag())

    sim.set_zhangli(init_J, 1.0, 0.05)

    sim.schedule('save_ndt', every=5e-11)
    #sim.schedule('save_vtk', every=5e-11)
    sim.schedule(spin_length, every=5e-11)

    sim.run_until(8e-9)
    df.plot(sim._m)
コード例 #6
0
ファイル: run.py プロジェクト: whshangl/finmag
def run_sim_without_stt():
    sim = Sim(mesh, Ms=8.6e5)
    sim.set_m((1, 0.01, 0.01))
    sim.alpha = 0.014
    sim.gamma = 221017

    H_app_mT = np.array([0.2, 0.2, 10.0])
    H_app_SI = H_app_mT / (1000 * mu0)
    sim.add(Zeeman(tuple(H_app_SI)))

    sim.add(Exchange(1.3e-11))
    sim.add(UniaxialAnisotropy(1e5, (0, 0, 1)))

    with open(averages_without, "w") as f:
        dt = 5e-12
        t_max = 10e-9
        for t in np.arange(0, t_max, dt):
            sim.run_until(t)
            f.write("{} {} {} {}\n".format(t, *sim.m_average))
コード例 #7
0
def run_simulation():
    L = W = 12.5e-9
    H = 5e-9
    sim = Sim(mesh, Ms=8.6e5, unit_length=1e-9)
    sim.set_m((1, 0.01, 0.01))
    sim.alpha = 0.014
    sim.gamma = 221017

    H_app_mT = np.array([0.0, 0.0, 10.0])
    H_app_SI = H_app_mT / (1000 * mu0)
    sim.add(Zeeman(tuple(H_app_SI)))

    sim.add(Exchange(1.3e-11))

    with open(averages_file, "w") as f:
        dt = 10e-12
        t_max = 10e-9
        for t in np.arange(0, t_max, dt):
            sim.run_until(t)
            f.write("{} {} {} {}\n".format(t, *sim.m_average))
コード例 #8
0
ファイル: test_std_prob_4.py プロジェクト: whshangl/finmag
def create_initial_s_state():
    """
    Creates equilibrium s-state by slowly switching off a saturating field.

    """
    mesh = from_geofile(os.path.join(MODULE_DIR, "bar.geo"))

    sim = Simulation(mesh, Ms, name="relaxation", unit_length=1e-9)
    sim.alpha = 0.5  # good enough for relaxation
    sim.gamma = gamma
    sim.set_m((1, 1, 1))
    sim.add(Demag())
    sim.add(Exchange(A))

    # Saturating field of Ms in the [1, 1, 1] direction, that gets reduced
    # every 10 picoseconds until it vanishes after one nanosecond.
    H_initial = Ms * np.array((1, 1, 1)) / sqrt(3)
    H_multipliers = list(np.linspace(0, 1))
    H = Zeeman(H_initial)

    def lower_H(sim):
        try:
            H_mult = H_multipliers.pop()
            print "At t = {} s, lower external field to {} times initial field.".format(
                sim.t, H_mult)
            H.set_value(H_mult * H_initial)
        except IndexError:
            sim.remove_interaction(H.name)
            print "External field is off."
            return True

    sim.add(H)
    sim.schedule(lower_H, every=10e-12)
    sim.run_until(0.5e-9)
    sim.relax()

    np.save(m_0_file, sim.m)
    print "Saved magnetisation to {}.".format(m_0_file)
    print "Average magnetisation is ({:.2g}, {:.2g}, {:.2g}).".format(
        *sim.m_average)
コード例 #9
0
ファイル: run_validation.py プロジェクト: whshangl/finmag
def run_simulation():
    L = W = 12.5e-9
    H = 5e-9
    mesh = df.BoxMesh(df.Point(0, 0, 0), df.Point(L, W, H), 5, 5, 2)
    sim = Sim(mesh, Ms=860e3, name="finmag_validation")
    sim.set_m((1, 0.01, 0.01))
    sim.alpha = 0.014
    sim.gamma = 221017

    H_app_mT = np.array([0.2, 0.2, 10.0])
    H_app_SI = H_app_mT / (1000 * mu0)
    sim.add(Zeeman(tuple(H_app_SI)))
    sim.add(Exchange(1.3e-11))
    sim.add(UniaxialAnisotropy(-1e5, (0, 0, 1)))

    I = 5e-5  # current in A
    J = I / (L * W)  # current density in A/m^2
    theta = 40.0 * pi / 180  # polarisation direction
    phi = pi / 2
    p = (sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta))
    sim.set_stt(current_density=J, polarisation=0.4, thickness=H, direction=p)

    sim.schedule("save_averages", every=5e-12)
    sim.run_until(10e-9)
コード例 #10
0
# converts Tesla to A/m (divides by mu0)
H_app_strength = flux_density_to_field_strength(1e-3)

# Spin-Polarised Current

current_density = 100e10  # in A/m^2
polarisation = 0.76
thickness = 2.5e-9  # in m

theta = math.pi
phi = math.pi / 2
direction = (math.sin(theta) * math.cos(phi), math.sin(theta) * math.sin(phi),
             math.cos(theta))

# Create Simulation

sim = Simulation(mesh, Ms, unit_length, name='disksim')
sim.alpha = alpha
sim.gamma = gamma
sim.set_m((0.01, 0.01, 1.0))
sim.set_stt(current_density, polarisation, thickness, direction)
sim.add(Demag())
sim.add(Zeeman(H_app_strength * H_app_dir))
sim.add(Exchange(A))
sim.add(CubicAnisotropy(u1, u2, K1))
sim.set_tol(reltol=1e-8, abstol=1e-8)  # timestepper tolerances

sim.schedule('save_m', every=10 * ps)
sim.schedule('save_averages', every=100 * ps)
sim.run_until(2000 * ps)