当前位置: 首页>>代码示例>>Python>>正文


Python atomistic.Sim类代码示例

本文整理汇总了Python中fidimag.atomistic.Sim的典型用法代码示例。如果您正苦于以下问题:Python Sim类的具体用法?Python Sim怎么用?Python Sim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Sim类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_exch_2d_pbc2d

def test_exch_2d_pbc2d():
    """
    Test the exchange field components in a 2D mesh with PBCs
    The mesh sites:

            3     4     5    -->    (0,1,0)  (1,1,0)  (2,1,0)
     y ^    0     1     2           (0,0,0)  (1,0,0)  (2,0,0)
       |
       x -->

    The expected components are in increasing order along x

    """

    mesh = CuboidMesh(nx=3, ny=2, nz=1, periodicity=(True, True, False))
    print mesh.neighbours
    sim = Sim(mesh)
    exch = UniformExchange(1)
    sim.add(exch)

    sim.set_m(init_m, normalise=False)

    field = exch.compute_field()

    expected_x = np.array([3, 4, 5, 3, 4, 5])
    expected_y = np.array([2, 2, 2, 2, 2, 2])

    # Since the field ordering is now: fx1 fy1 fz1 fx2 ...
    # We extract the x components jumping in steps of 3
    assert np.max(abs(field[::3] - expected_x)) == 0
    # For the y component is similar, now we start at the 1th
    # entry and jump in steps of 3
    assert np.max(abs(field[1::3] - expected_y)) == 0
    # Similar fot he z component
    assert np.max(field[2::3]) == 0
开发者ID:River315,项目名称:fidimag,代码行数:35,代码来源:test_exch.py

示例2: test_exch_1d

def test_exch_1d():
    """
    Test the x component of the exchange field
    in a 1D mesh, with the spin ordering:

    0 1 2 3 4 5

    """
    mesh = CuboidMesh(nx=5, ny=1, nz=1)
    sim = Sim(mesh)
    exch = Exchange(1.0)
    sim.add(exch)

    sim.set_m(init_m, normalise=False)

    field = exch.compute_field()

    assert field[0] == 1
    assert field[1 * 3] == 2
    assert field[2 * 3] == 4
    assert field[3 * 3] == 6
    assert field[4 * 3] == 3

    assert np.max(field[2::3]) == 0
    assert np.max(field[1::3]) == 0
开发者ID:fangohr,项目名称:fidimag,代码行数:25,代码来源:test_exch.py

示例3: test_exch_3d

def test_exch_3d():
    """
    Test the exchange field of the spins in this 3D mesh:

    bottom layer:
    8  9  10  11
    4  5  6   7       x 2
    0  1  2   3

    The assertions are the mx component
    of the: 0, 1, 2, .. 7 spins

    Remember the new new ordering: fx1, fy1, fz1, fx2, ...

    """
    mesh = CuboidMesh(nx=4, ny=3, nz=2)
    sim = Sim(mesh)
    exch = UniformExchange(1)
    sim.add(exch)

    sim.set_m(init_m, normalise=False)

    field = exch.compute_field()
    # print field
    assert field[0] == 1
    assert field[3] == 0 + 1 + 2 + 1
    assert field[6] == 1 + 2 + 3 + 2
    assert field[9] == 2 + 3 + 3

    assert field[4 * 3] == 1
    assert field[5 * 3] == 5
    assert field[6 * 3] == 10
    assert field[7 * 3] == 11
开发者ID:River315,项目名称:fidimag,代码行数:33,代码来源:test_exch.py

示例4: test_sim_init_m_fun

def test_sim_init_m_fun():
    mesh = CuboidMesh(nx=3, ny=4, nz=5)
    sim = Sim(mesh)
    sim.set_m(init_m, normalise=False)
    assert(sim.spin_at(1, 2, 3)[0] == 1)
    assert(sim.spin_at(1, 2, 3)[1] == 2)
    assert(sim.spin_at(1, 2, 3)[2] == 3)
开发者ID:fangohr,项目名称:fidimag,代码行数:7,代码来源:test_llg_atomistic.py

示例5: test_sim_init_m

def test_sim_init_m():
    mesh = CuboidMesh(nx=3, ny=4, nz=5)
    sim = Sim(mesh)
    sim.set_m((0, 1, 0))
    sim.spin.shape = (3, -1)
    spin_y = sim.spin[1]
    assert(spin_y.any() == 1)
开发者ID:fangohr,项目名称:fidimag,代码行数:7,代码来源:test_llg_atomistic.py

示例6: test_exch_energy_1d

def test_exch_energy_1d():
    mesh = CuboidMesh(nx=2, ny=1, nz=1)
    sim = Sim(mesh)
    exch = UniformExchange(1.23)
    sim.add(exch)

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

    energy = exch.compute_energy()
    assert energy == -1.23
开发者ID:River315,项目名称:fidimag,代码行数:10,代码来源:test_exch.py

示例7: test_dynamic

def test_dynamic():

    mesh = CuboidMesh(nx=1, ny=1, nz=1)

    sim = Sim(mesh, name='dyn_spin', driver='llg_stt_cpp')
    # sim.set_options(rtol=1e-10,atol=1e-14)
    sim.driver.gamma = 1.0
    sim.mu_s = 1.0

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

    Kx = Anisotropy(Ku=-0.05, axis=(0, 0, 1), name='Kz')
    sim.add(Kx)

    sim.p = (0,0,1)

    sim.a_J = 0.0052
    sim.alpha = 0.1

    ts = np.linspace(0, 1200, 401)
    for t in ts:
        sim.driver.run_until(t)


    mz = sim.spin[2]
    alpha, K, u = 0.1, 0.05, 0.0052
    print(mz, u/(2*alpha*K))

    #########################################################
    # The system used in this test can be solved analytically, which gives that mz = u/(2*alpha*K),
    # where K represents the easy-plane anisotropy.
    ###
    assert abs(mz - u/(2*alpha*K))/mz< 5e-4
开发者ID:computationalmodelling,项目名称:fidimag,代码行数:33,代码来源:test_stt_slonczewski.py

示例8: test_demag_two_spin_xx

def test_demag_two_spin_xx():
    mesh = CuboidMesh(nx=2, ny=1, nz=1)
    sim = Sim(mesh)

    demag = Demag()
    sim.add(demag)

    sim.set_m((1, 0, 0))
    field = demag.compute_field()
    print field
    assert(field[0] == 2e-7)
    assert(field[3] == 2e-7)
开发者ID:River315,项目名称:fidimag,代码行数:12,代码来源:test_demag.py

示例9: relax_neb

def relax_neb(k, maxst, simname, init_im, interp, save_every=10000):
    """
    Execute a simulation with the NEB function of the FIDIMAG code

    The simulations are made for a specific spring constant 'k' (a float),
    number of images 'init_im', interpolations between images 'interp'
    (an array) and a maximum of 'maxst' steps.
    'simname' is the name of the simulation, to distinguish the
    output files.

    --> vtks and npys are saved in files starting with the 'simname' string

    """

    # Prepare simulation
    sim = Sim(mesh, name=simname)
    sim.gamma = const.gamma

    # magnetisation in units of Bohr's magneton
    sim.mu_s = 2. * const.mu_B

    # Exchange constant in Joules: E = Sum J_{ij} S_i S_j
    J = 12. * const.meV
    exch = UniformExchange(J)
    sim.add(exch)

    # DMI constant in Joules: E = Sum D_{ij} S_i x S_j
    D = 2. * const.meV
    dmi = DMI(D, dmi_type='interfacial')
    sim.add(dmi)

    # Anisotropy along +z axis
    ku = Anisotropy(Ku=0.5 * const.meV,
                    axis=[0, 0, 1],
                    name='ku')
    sim.add(ku)

    # Initial images
    init_images = init_im

    # Number of images between each state specified before (here we need only
    # two, one for the states between the initial and intermediate state
    # and another one for the images between the intermediate and final
    # states). Thus, the number of interpolations must always be
    # equal to 'the number of initial states specified', minus one.
    interpolations = interp

    neb = NEB_Sundials(sim,
                       init_images,
                       interpolations=interpolations,
                       spring=k,
                       name=simname)

    neb.relax(max_steps=maxst,
              save_vtk_steps=save_every,
              save_npy_steps=save_every,
              stopping_dmdt=1e-2)
开发者ID:fangohr,项目名称:fidimag,代码行数:57,代码来源:neb_helicoid-fm.py

示例10: test_sim_pin

def test_sim_pin():
    mesh = CuboidMesh(nx=3, ny=2, nz=1)
    sim = Sim(mesh)
    sim.set_m((0, 0.8, 0.6))
    sim.alpha = 0.1
    sim.gamma = 1.0
    sim.pins = pin_fun

    anis = Anisotropy(Ku=1.0, axis=[0, 0, 1], name='Dx')
    sim.add(anis)

    sim.run_until(1.0)
    assert sim.spin[0] == 0
    assert sim.spin[2] != 0
开发者ID:fangohr,项目名称:fidimag,代码行数:14,代码来源:test_llg_atomistic.py

示例11: test_exch_1d_pbc

def test_exch_1d_pbc():
    mesh = CuboidMesh(nx=5, ny=1, nz=1, periodicity=(True, False, False))
    sim = Sim(mesh)
    exch = UniformExchange(1)
    sim.add(exch)

    sim.set_m(init_m, normalise=False)

    field = exch.compute_field()
    assert field[0] == 1 + 4
    assert field[3] == 2
    assert field[6] == 4
    assert field[9] == 6
    assert field[12] == 3 + 0
    assert np.max(field[2::3]) == 0
    assert np.max(field[1::3]) == 0
开发者ID:River315,项目名称:fidimag,代码行数:16,代码来源:test_exch.py

示例12: test_exch_2d

def test_exch_2d():
    mesh = CuboidMesh(nx=5, ny=2, nz=1)
    sim = Sim(mesh)
    exch = UniformExchange(1)
    sim.add(exch)

    sim.set_m(init_m, normalise=False)

    field = exch.compute_field()

    assert np.max(field[2::3]) == 0

    assert field[0] == 1
    assert field[3] == 2 + 1
    assert field[6] == 1 + 2 + 3
    assert field[9] == 2 + 3 + 4
    assert field[12] == 3 + 4
开发者ID:River315,项目名称:fidimag,代码行数:17,代码来源:test_exch.py

示例13: test_dmi_1d

def test_dmi_1d():

    mesh = CuboidMesh(nx=2, ny=1, nz=1)

    sim = Sim(mesh)
    sim.set_m((1, 0, 0))

    dmi = DMI(D=1)
    sim.add(dmi)

    field = dmi.compute_field()

    expected = np.array([0, 0, 0, 0, 0, 0])

    assert (field == expected).all()

    energy = dmi.compute_energy()
    assert energy == 0
开发者ID:River315,项目名称:fidimag,代码行数:18,代码来源:test_dmi.py

示例14: test_dmi_1d_field

def test_dmi_1d_field():

    mesh = CuboidMesh(nx=2, ny=1, nz=1)

    sim = Sim(mesh)
    sim.set_m(init_m)

    dmi = DMI(D=1.23)
    sim.add(dmi)

    field = dmi.compute_field()

    expected = np.array([0, -1, 0, 0, 0, -1]) * 1.23

    assert np.allclose(field, expected)

    energy = dmi.compute_energy()

    assert energy == 1.23
开发者ID:River315,项目名称:fidimag,代码行数:19,代码来源:test_dmi.py

示例15: test_exch_1d_spatial

def test_exch_1d_spatial():
    """
    Test the x component of the exchange field
    in a 1D mesh, with the spin ordering:

    0 1 2 3 4 5

    """
    mesh = CuboidMesh(nx=12, ny=1, nz=1)
    sim = Sim(mesh)
    exch = Exchange(spatial_J)
    sim.add(exch)

    sim.set_m(init_m, normalise=False)

    field = exch.compute_field()

    assert exch._J[3,3] == -1.0
    assert exch._J[5,1] == 0.3
    assert exch._J[6,0] == 0.3
    assert exch._J[8,5] == 1.0
开发者ID:fangohr,项目名称:fidimag,代码行数:21,代码来源:test_exch.py


注:本文中的fidimag.atomistic.Sim类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。