Пример #1
0
def apply_field1(mesh):

    sim = Sim(mesh, name='dyn')

    sim.set_tols(rtol=1e-10, atol=1e-10)
    sim.alpha = 0.02
    sim.gamma = 2.211e5
    sim.Ms = 8.0e5

    sim.set_m(np.load('m0.npy'))

    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    demag = Demag()
    sim.add(demag)

    mT = 0.001 / mu0
    print mT

    zeeman = Zeeman([-24.6 * mT, 4.3 * mT, 0], name='H')
    sim.add(zeeman, save_field=True)

    ts = np.linspace(0, 1e-9, 201)
    for t in ts:
        sim.run_until(t)
        print 'sim t=%g' % t
Пример #2
0
def relax_system(mesh):

    sim = Sim(mesh, name='relax')

    sim.set_tols(rtol=1e-6, atol=1e-6)
    sim.alpha = 0.5
    sim.gamma = 2.211e5
    sim.Ms = 8.6e5
    sim.do_precession = False

    sim.set_m(init_m)
    # sim.set_m(np.load('m0.npy'))

    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    dmi = DMI(D=1.3e-3)
    sim.add(dmi)

    anis = UniaxialAnisotropy(-3.25e4, axis=(0, 0, 1))
    sim.add(anis)

    zeeman = Zeeman((0, 0, 6.014576e4))
    sim.add(zeeman, save_field=True)

    sim.relax(dt=1e-13, stopping_dmdt=1e-2, max_steps=5000,
              save_m_steps=None, save_vtk_steps=50)

    np.save('m0.npy', sim.spin)
Пример #3
0
def relax_system(mesh):

    sim = Sim(mesh, name='relax')

    sim.set_tols(rtol=1e-10, atol=1e-10)
    sim.alpha = 0.5
    sim.gamma = 2.211e5
    sim.Ms = 8.0e5
    sim.do_procession = False

    sim.set_m((1, 0.25, 0.1))
    # sim.set_m(np.load('m0.npy'))

    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    demag = Demag()
    sim.add(demag)

    sim.relax(dt=1e-13,
              stopping_dmdt=0.01,
              max_steps=5000,
              save_m_steps=100,
              save_vtk_steps=50)

    np.save('m0.npy', sim.spin)
Пример #4
0
def relax_system(mesh):

    sim = Sim(mesh, name='relax')

    sim.set_tols(rtol=1e-10, atol=1e-14)
    sim.alpha = 0.5
    sim.gamma = 2.211e5
    sim.Ms = spatial_Ms
    sim.do_procession = False

    sim.set_m(init_m)
    # sim.set_m(np.load('m0.npy'))

    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    demag = Demag()
    sim.add(demag)

    mT = 795.7747154594767

    ONE_DEGREE_PER_NS = 17453292.52

    sim.relax(dt=1e-13,
              stopping_dmdt=0.01,
              max_steps=5000,
              save_m_steps=100,
              save_vtk_steps=50)

    np.save('m0.npy', sim.spin)
Пример #5
0
def create_simulation(mesh):

    sim = Sim(mesh)
    sim.Ms = 8.6e5

    sim.set_m((1, 0, 0))
    sim.add(UniformExchange(A=1.3e-11))
    # sim.add(Demag())
    #sim.add(UniaxialAnisotropy(Kx, (1, 0, 0), name='Kx'))
    anis = UniaxialAnisotropy(1e5, axis=(1, 0, 0))
    sim.add(anis)

    return sim
Пример #6
0
def relax_system(mesh):

    # Only relaxation
    sim = Sim(mesh, name='relax')

    # Simulation parameters
    sim.set_tols(rtol=1e-8, atol=1e-10)
    sim.alpha = 0.5
    sim.gamma = 2.211e5
    sim.Ms = 8.6e5
    sim.do_precession = False

    # The initial state passed as a function
    sim.set_m(init_m)
    # sim.set_m(np.load('m0.npy'))

    # Energies
    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    anis = UniaxialAnisotropy(5e4)
    sim.add(anis)

    # dmi = DMI(D=8e-4)
    # sim.add(dmi)

    # mT = 795.7747154594767
    # ONE_DEGREE_PER_NS = 17453292.52

    # Start relaxation and save the state in m0.npy
    sim.relax(dt=1e-14,
              stopping_dmdt=0.00001,
              max_steps=5000,
              save_m_steps=None,
              save_vtk_steps=None)

    np.save('m0.npy', sim.spin)
Пример #7
0
def excite_system(mesh):

    # Specify the stt dynamics in the simulation
    sim = Sim(mesh, name='dyn', driver='llg_stt')

    sim.set_tols(rtol=1e-12, atol=1e-14)
    sim.alpha = 0.05
    sim.gamma = 2.211e5
    sim.Ms = 8.6e5

    # sim.set_m(init_m)
    sim.set_m(np.load('m0.npy'))

    # Energies
    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    anis = UniaxialAnisotropy(5e4)
    sim.add(anis)

    # dmi = DMI(D=8e-4)
    # sim.add(dmi)

    # Set the current in the x direction, in A / m
    # beta is the parameter in the STT torque
    sim.jx = -1e12
    sim.beta = 1

    # The simulation will run for 5 ns and save
    # 500 snapshots of the system in the process
    ts = np.linspace(0, 5e-9, 501)

    for t in ts:
        print 'time', t
        sim.run_until(t)
        sim.save_vtk()
        sim.save_m()
Пример #8
0
def excite_system(mesh):

    sim = Sim(mesh, name='dyn')

    sim.set_tols(rtol=1e-10, atol=1e-14)
    sim.alpha = 0.01
    sim.gamma = 2.211e5
    sim.Ms = spatial_Ms

    # sim.set_m(init_m)
    sim.set_m(np.load('m0.npy'))

    A = 1.3e-11
    exch = UniformExchange(A=A)
    sim.add(exch)

    demag = Demag()
    sim.add(demag)

    mT = 795.7747154594767
    sigma = 0.08e-9

    def gaussian_fun(t):

        return np.exp(-0.5 * (t / sigma)**2)

    zeeman = TimeZeeman((80 * mT, 0, 0), time_fun=gaussian_fun, name='hx')
    #zeeman = Zeeman((100*mT,0,0), name='hx')
    sim.add(zeeman, save_field=True)

    ts = np.linspace(0, 1e-9, 501)

    for t in ts:
        print 'time', t
        print 'length:', sim.spin_length()[0:200]
        sim.run_until(t)
        sim.save_vtk()
Пример #9
0
def test_prb88_184422():
    mu0 = 4 * np.pi * 1e-7

    Ms = 8.6e5
    A = 16e-12
    D = 3.6e-3
    K = 510e3

    mesh = CuboidMesh(nx=100, dx=1, unit_length=1e-9)

    sim = Sim(mesh)

    sim.driver.set_tols(rtol=1e-10, atol=1e-14)

    sim.driver.alpha = 0.5
    sim.driver.gamma = 2.211e5
    sim.Ms = Ms
    sim.do_precession = False

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

    sim.add(UniformExchange(A=A))
    sim.add(DMI(-D, type='interfacial'))
    sim.add(UniaxialAnisotropy(K, axis=(0, 0, 1)))

    sim.relax(dt=1e-13,
              stopping_dmdt=0.01,
              max_steps=5000,
              save_m_steps=None,
              save_vtk_steps=50)

    m = sim.spin

    mx, my, mz = np.split(m, 3)

    x_array = np.linspace(-49.5, 49.5, 100)

    #plt.plot(x_array, mx)
    #plt.plot(x_array, my)
    #plt.plot(x_array, mz)

    mesh = df.IntervalMesh(100, -50, 50)

    Delta = np.sqrt(A / K)
    xi = 2 * A / D

    Delta_s = Delta * 1e9

    V = df.FunctionSpace(mesh, "Lagrange", 1)
    u = df.TrialFunction(V)
    v = df.TestFunction(V)
    u_ = df.Function(V)
    F = -df.inner(df.nabla_grad(u), df.nabla_grad(v)) * df.dx - \
        (0.5 / Delta_s**2) * df.sin(2 * u) * v * df.dx
    F = df.action(F, u_)

    J = df.derivative(F, u_, u)

    # the boundary condition is from equation (8)
    theta0 = np.arcsin(Delta / xi)
    ss = 'x[0]<0? %g: %g ' % (-theta0, theta0)

    u0 = df.Expression(ss)

    def u0_boundary(x, on_boundary):
        return on_boundary

    bc = df.DirichletBC(V, u0, u0_boundary)

    problem = df.NonlinearVariationalProblem(F, u_, bcs=bc, J=J)
    solver = df.NonlinearVariationalSolver(problem)
    solver.solve()

    u_array = u_.vector().array()

    mx_df = []
    for x in x_array:
        mx_df.append(u_(x))

    #plt.plot(x_array, mx_df)

    assert abs(np.max(mx - mx_df)) < 0.05