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


Python Sim.compute_energy方法代码示例

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


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

示例1: test_hexagonal_demags_2D

# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import compute_energy [as 别名]
def test_hexagonal_demags_2D():
    """
    Comparison of the FFT approach for hexagonal meshes, named
    DemagHexagonal, where it is used a system with the double number
    of nodes along the x direction (i.e. a mesh with twice the number
    of nodes of the original mesh), against the full calculation
    of the Demag field
    """
    # Number of atoms
    N = 15
    a = 0.4
    mesh = HexagonalMesh(a * 0.5, N, N,
                         unit_length=1e-9,
                         alignment='square')

    # Centre
    xc = (mesh.Lx * 0.5)
    yc = (mesh.Ly * 0.5)

    mu_s = 2 * const.mu_B

    sim = Sim(mesh)
    sim.mu_s = mu_s

    sim.set_m(lambda pos: m_init_2Dvortex(pos, (xc, yc)))
    # Brute force demag calculation
    sim.add(DemagFull())

    sim.get_interaction('demag_full').compute_field()
    sim.get_interaction('demag_full').field
    demag_full_energy = sim.compute_energy() / const.meV

    # Demag using the FFT approach and a larger mesh
    sim2 = Sim(mesh)
    sim2.mu_s = mu_s

    sim2.set_m(lambda pos: m_init_2Dvortex(pos, (xc, yc)))

    sim2.add(DemagHexagonal())
    sim2.get_interaction('demag_hex').compute_field()
    sim2.compute_energy()

    demag_2fft_energy = sim2.compute_energy() / const.meV

    # We compare both energies scaled in meV
    assert (demag_full_energy - demag_2fft_energy) < 1e-10
开发者ID:River315,项目名称:fidimag,代码行数:48,代码来源:test_demag_libraries.py

示例2: test_cuboid_demags_1Dchain

# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import compute_energy [as 别名]
def test_cuboid_demags_1Dchain():
    """
    Test a brute force calculation of the demagnetising field, called
    DemagFull, based on the sum of the dipolar contributions of the whole
    system for every lattice site, against the default FFT approach for the
    demag field. We compute the energies scaled in meV.
    This test is performed in a cuboid mesh to assure that the DemagFull
    library is calculating the same than the default demag function
    """
    N = 12
    a = 0.4
    mesh = CuboidMesh(a, a, a, N, 1, 1, unit_length=1e-9)
    mu_s = 2 * const.mu_B

    sim = Sim(mesh)
    sim.mu_s = mu_s

    sim.set_m(lambda pos: m_init_dw(pos, N, a))
    # Brute force demag calculation
    sim.add(DemagFull())

    sim.get_interaction('demag_full').compute_field()
    # print sim.get_interaction('demag_full').field
    demag_full_energy = sim.compute_energy() / const.meV

    # Demag using the FFT approach
    sim2 = Sim(mesh)
    sim2.mu_s = mu_s

    sim2.set_m(lambda pos: m_init_dw(pos, N, a))

    sim2.add(Demag())
    sim2.get_interaction('demag').compute_field()
    sim2.compute_energy()

    demag_fft_energy = sim2.compute_energy() / const.meV

    # We compare both energies scaled in meV
    assert (demag_full_energy - demag_fft_energy) < 1e-10
开发者ID:River315,项目名称:fidimag,代码行数:41,代码来源:test_demag_libraries.py


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