本文整理汇总了Python中fidimag.atomistic.Sim.get_interaction方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.get_interaction方法的具体用法?Python Sim.get_interaction怎么用?Python Sim.get_interaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fidimag.atomistic.Sim
的用法示例。
在下文中一共展示了Sim.get_interaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cuboid_demags_2D
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import get_interaction [as 别名]
def test_cuboid_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 = CuboidMesh(a, a, a, N, N, 1, unit_length=1e-9)
mu_s = 2 * const.mu_B
# Centre
xc = (mesh.Lx * 0.5)
yc = (mesh.Ly * 0.5)
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()
# 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_2Dvortex(pos, (xc, yc)))
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
示例2: test_cuboid_demags_1Dchain
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import get_interaction [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
示例3: test_hexagonal_demags_1Dchain
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import get_interaction [as 别名]
def test_hexagonal_demags_1Dchain():
"""
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 = 12
a = 0.4
mesh = HexagonalMesh(a * 0.5, N, 1,
unit_length=1e-9,
alignment='square')
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()
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_dw(pos, N, a))
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
示例4: test_skx_num_atomistic_hexagonal
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import get_interaction [as 别名]
def test_skx_num_atomistic_hexagonal():
"""
Test the topological charge or skyrmion number for a discrete spins
simulation in a two dimensional hexagonal lattice, using Berg and Luscher
definition in [Nucl Phys B 190, 412 (1981)] and simplified in [PRB 93,
174403 (2016)], which maps a triangulated lattice (using triangles of
neighbouring spins) area into a unit sphere.
The areas of two triangles per lattice site cover a unit cell, thus the sum
cover the whole area of the atomic lattice
This test generates a skyrmion pointing down and two skyrmions pointing up
in a PdFe sample using magnetic parameters from: PRL 114, 177203 (2015)
"""
mesh = HexagonalMesh(0.2715, 41, 41, periodicity=(True, True))
sim = Sim(mesh, name='skx_number_hexagonal')
sim.driver.set_tols(rtol=1e-6, atol=1e-6)
sim.driver.alpha = 1.0
sim.driver.gamma = 1.0
sim.mu_s = 3 * const.mu_B
sim.set_m(lambda pos: init_m(pos, 16.1, 10, 2))
sim.driver.do_precession = False
J = 5.881 * const.meV
exch = UniformExchange(J)
sim.add(exch)
D = 1.557 * const.meV
dmi = DMI(D, dmi_type='interfacial')
sim.add(dmi)
sim.add(Anisotropy(0.406 * const.meV, axis=[0, 0, 1]))
zeeman = Zeeman([0, 0, 2.5])
sim.add(zeeman)
sim.relax(dt=1e-13, stopping_dmdt=1e-2, max_steps=2000,
save_m_steps=None, save_vtk_steps=100)
skn_single = sim.skyrmion_number(method='BergLuscher')
print('skx_number_hexagonal', skn_single)
# Now we generate two skyrmions pointing up
sim.driver.reset_integrator()
sim.set_m(lambda pos: init_m_multiple_sks(pos, 1,
sk_pos=[(9, 6), (18, 12)]
)
)
sim.get_interaction('Zeeman').update_field([0, 0, -2.5])
sim.relax(dt=1e-13, stopping_dmdt=1e-2, max_steps=2000,
save_m_steps=None, save_vtk_steps=None)
skn_two = sim.skyrmion_number(method='BergLuscher')
print('skx_number_hexagonal_two', skn_two)
# Check that we get a right sk number
assert np.abs(skn_single - (-1)) < 1e-4 and np.sign(skn_single) < 0
assert np.abs(skn_two - (2)) < 1e-4 and np.sign(skn_two) > 0