本文整理汇总了Python中fidimag.atomistic.Sim.relax方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.relax方法的具体用法?Python Sim.relax怎么用?Python Sim.relax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fidimag.atomistic.Sim
的用法示例。
在下文中一共展示了Sim.relax方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh):
sim=Sim(mesh,name='relax')
sim.set_options(rtol=1e-12,atol=1e-14)
sim.do_precession = False
sim.alpha = 0.5
sim.gamma = 1.0
sim.mu_s = 1.0
sim.set_m(init_m)
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
D = 0.18
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman([0,0e-3,2e-2],name='H')
sim.add(zeeman)
sim.relax(dt=2.0, stopping_dmdt=1e-8, max_steps=10000, save_m_steps=None, save_vtk_steps=100)
np.save('m0.npy',sim.spin)
示例2: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh):
# Only relaxation
sim = Sim(mesh, name='relax')
# Simulation parameters
sim.driver.set_tols(rtol=1e-8, atol=1e-10)
sim.alpha = 0.5
sim.driver.gamma = 2.211e5 / mu0
sim.mu_s = 1e-27 / mu0
sim.driver.do_precession = False
# The initial state passed as a function
sim.set_m(init_m)
# sim.set_m(np.load('m0.npy'))
# Energies
exch = UniformExchange(J=2e-20)
sim.add(exch)
anis = Anisotropy(0.01*2e-20, axis=(0, 0, 1))
sim.add(anis)
# dmi = DMI(D=8e-4)
# sim.add(dmi)
# Start relaxation and save the state in m0.npy
sim.relax(dt=1e-14, stopping_dmdt=1e4, max_steps=5000,
save_m_steps=None, save_vtk_steps=None)
np.save('m0.npy', sim.spin)
示例3: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh):
sim = Sim(mesh, name='relax')
sim.set_default_options(gamma=const.gamma)
sim.driver.alpha = 0.5
sim.mu_s = const.mu_s_1
sim.set_m(init_m)
J = 50.0 * const.k_B
exch = UniformExchange(J)
sim.add(exch)
D = 0.5 * J
dmi = DMI(D)
sim.add(dmi)
Hz = 0.2 * J / const.mu_s_1
zeeman = Zeeman([0, 0, Hz])
sim.add(zeeman)
ONE_DEGREE_PER_NS = 17453292.52
sim.relax(dt=1e-13, stopping_dmdt=0.01 * ONE_DEGREE_PER_NS,
max_steps=1000, save_m_steps=100, save_vtk_steps=50)
np.save('m0.npy', sim.spin)
示例4: test_skx_num
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def test_skx_num():
mesh = CuboidMesh(nx=120, ny=120, nz=1, periodicity=(True, True, False))
sim = Sim(mesh, name='skx_num')
sim.set_tols(rtol=1e-6, atol=1e-6)
sim.alpha = 1.0
sim.gamma = 1.0
sim.mu_s = 1.0
sim.set_m(init_m)
sim.do_procession = False
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
D = 0.09
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman([0, 0, 5e-3])
sim.add(zeeman)
sim.relax(dt=2.0, stopping_dmdt=1e-2, max_steps=1000,
save_m_steps=None, save_vtk_steps=None)
skn = sim.skyrmion_number()
print 'skx_number', skn
assert skn > -1 and skn < -0.99
示例5: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh):
sim = Sim(mesh, name='relax')
# sim.set_options(rtol=1e-10,atol=1e-14)
sim.alpha = 1.0
sim.gamma = 1.0
sim.mu_s = 1.0
sim.set_m(init_m)
# sim.set_m(random_m)
# sim.set_m(np.load('m_10000.npy'))
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
D = 0.09
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman([0, 0, 3.75e-3])
sim.add(zeeman)
sim.relax(dt=2.0, stopping_dmdt=1e-6, max_steps=1000,
save_m_steps=100, save_vtk_steps=50)
np.save('m0.npy', sim.spin)
示例6: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh, Hy=0):
sim = Sim(mesh, name="relax")
sim.set_options(rtol=1e-10, atol=1e-12)
sim.alpha = 0.5
sim.gamma = 1.0
sim.mu_s = 1.0
sim.do_precession = False
sim.set_m(init_m)
# sim.set_m(random_m)
# sim.set_m(np.load('m_10000.npy'))
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
D = 0.18
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman([0, Hy, 2e-2], name="H")
sim.add(zeeman)
sim.relax(dt=2.0, stopping_dmdt=1e-8, max_steps=10000, save_m_steps=100, save_vtk_steps=50)
np.save("m0.npy", sim.spin)
示例7: relax_system_stage1
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system_stage1():
mesh = CuboidMesh(nx=140 , ny=140, nz=1)
sim = Sim(mesh, name='relax', driver='llg')
#sim.set_options(dt=1e-14, gamma=const.gamma, k_B=const.k_B)
sim.alpha = 0.5
sim.do_precession = False
sim.gamma = const.gamma
sim.mu_s = spatial_mu
sim.set_m(init_m)
J = 50 * const.k_B
exch = UniformExchange(J)
sim.add(exch)
D = 0.27 * J
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman(spatial_H)
sim.add(zeeman)
sim.relax(dt=1e-14, stopping_dmdt=1e10, max_steps=1000,
save_m_steps=100, save_vtk_steps=10)
np.save('skx.npy', sim.spin)
plot_m(mesh, 'skx.npy', comp='z')
示例8: test_skx_num_atomistic
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def test_skx_num_atomistic():
"""
Test the *finite spin chirality* or skyrmion number for
a discrete spins simulation in a two dimensional lattice
The expression is (PRL 108, 017601 (2012)) :
Q = S_i \dot ( S_{i+1} X S_{j+1} )
+ S_i \dot ( S_{i-1} X S_{j-1} )
which measures the chirality taking two triangles of spins
per lattice site i:
S_{i} , S_{i + x} , S_{i + y} and
S_{i} , S_{i - x} , S_{i - y}
The area of the two triangles cover a unit cell, thus the sum
cover the whole area of the atomic lattice
This test generate a skyrmion pointing down with unrealistic
paremeters.
"""
mesh = CuboidMesh(nx=120, ny=120, nz=1,
periodicity=(True, True, False))
sim = Sim(mesh, name='skx_num')
sim.set_tols(rtol=1e-6, atol=1e-6)
sim.alpha = 1.0
sim.gamma = 1.0
sim.mu_s = 1.0
sim.set_m(lambda pos: init_m(pos, 60, 60, 20))
sim.do_precession = False
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
D = 0.09
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman([0, 0, 5e-3])
sim.add(zeeman)
sim.relax(dt=2.0, stopping_dmdt=1e-2, max_steps=1000,
save_m_steps=None, save_vtk_steps=None)
skn = sim.skyrmion_number()
print('skx_number', skn)
assert skn > -1 and skn < -0.99
示例9: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system():
# 1D chain of 50 spins with a lattice constant of 0.27 A
mesh = CuboidMesh(nx=nx,
dx=dx,
unit_length=1e-9,
# pbc='1d'
)
# Initiate the simulation. PBCs are specified in the mesh
sim = Sim(mesh, name=sim_name)
sim.gamma = const.gamma
# magnetisation in units of Bohr's magneton
sim.mu_s = 2. * const.mu_B
# sim.set_options(gamma=const.gamma, k_B=const.k_B)
# Initial magnetisation profile
sim.set_m((0, 0, 1))
# 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)
# Faster convergence
sim.alpha = 0.5
sim.do_precession = False
sim.relax(dt=1e-13, stopping_dmdt=0.05,
max_steps=700,
save_m_steps=1000, save_vtk_steps=1000)
# Save the last relaxed state
np.save(sim_name + '.npy', sim.spin)
示例10: test_dw_dmi_atomistic
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def test_dw_dmi_atomistic(do_plot=False):
mesh = CuboidMesh(nx=300, ny=1, nz=1)
sim = Sim(mesh, name='relax')
sim.set_default_options(gamma=const.gamma)
sim.alpha = 0.5
sim.mu_s = const.mu_s_1
sim.do_procession = False
sim.set_m(m_init_dw)
J = 50.0 * const.k_B
exch = UniformExchange(J)
sim.add(exch)
D = 0.01 * J
dmi = DMI(D)
sim.add(dmi)
K = 0.005 * J
anis = Anisotropy(K, axis=[1,0,0])
sim.add(anis)
ONE_DEGREE_PER_NS = 17453292.52
sim.relax(dt=1e-13, stopping_dmdt=0.01 * ONE_DEGREE_PER_NS,
max_steps=1000, save_m_steps=100, save_vtk_steps=50)
np.save('m0.npy', sim.spin)
xs = np.array([p[0] for p in mesh.coordinates]) - 150
mx, my, mz = analytical(xs, A=J/2.0, D=-D, K=K)
mxyz = sim.spin.copy()
mxyz = mxyz.reshape(-1, 3).T
assert max(abs(mxyz[0, :] - mx)) < 0.001
assert max(abs(mxyz[1, :] - my)) < 0.001
assert max(abs(mxyz[2, :] - mz)) < 0.0006
if do_plot:
save_plot(xs, mxyz, mx, my, mz)
示例11: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh):
sim = Sim(mesh, name='relax')
# sim.set_options(rtol=1e-10,atol=1e-14)
sim.alpha = 1.0
sim.gamma = 1.0
sim.mu_s = 1.0
sim.set_m(init_m)
# sim.set_m(random_m)
# sim.set_m(np.load('m_10000.npy'))
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
Kx = Anisotropy(Ku=0.005, axis=(1, 0, 0), name='Kx')
sim.add(Kx)
sim.relax(dt=2.0, stopping_dmdt=1e-6, max_steps=1000,
save_m_steps=100, save_vtk_steps=50)
np.save('m0.npy', sim.spin)
示例12: relax_system
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def relax_system(mesh):
sim = Sim(mesh, name='relax')
sim.set_default_options(gamma=constant.gamma)
sim.driver.alpha = 0.5
sim.mu_s = constant.mu_s_1
sim.do_precession = False
sim.set_m(m_init_dw)
J = 50.0 * constant.k_B
exch = UniformExchange(J)
sim.add(exch)
D = 0.1 * J
dmi = DMI(D, dmi_type = 'interfacial')
sim.add(dmi)
K = 0.02 * J
anis = Anisotropy(K, axis=[0,0,1])
sim.add(anis)
ONE_DEGREE_PER_NS = 17453292.52
sim.relax(dt=1e-13, stopping_dmdt=0.01 * ONE_DEGREE_PER_NS,
max_steps=1000, save_m_steps=100, save_vtk_steps=50)
np.save('m0.npy', sim.spin)
xs = np.array([p[0] for p in mesh.pos]) - 150
mx, my, mz = analytical(xs, A=J/2.0, D=-D, K=K)
mxyz = sim.spin.copy()
mxyz.shape = (3, -1)
save_plot(xs, mxyz, mx, my, mz)
示例13: test_skx_num_atomistic
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [as 别名]
def test_skx_num_atomistic():
"""
Test the *finite spin chirality* or skyrmion number for
a discrete spins simulation in a two dimensional lattice
The expression is (PRL 108, 017601 (2012)) :
Q = S_i \dot ( S_{i+1} X S_{j+1} )
+ S_i \dot ( S_{i-1} X S_{j-1} )
which measures the chirality taking two triangles of spins
per lattice site i:
S_{i} , S_{i + x} , S_{i + y} and
S_{i} , S_{i - x} , S_{i - y}
The area of the two triangles cover a unit cell, thus the sum
cover the whole area of the atomic lattice
We also test the Berg and Luscher definition for a topological
charge (see the hexagonal mesh test for details) in a
square lattice.
This test generate a skyrmion pointing down with unrealistic
paremeters.
"""
mesh = CuboidMesh(nx=120, ny=120, nz=1,
periodicity=(True, True, False))
sim = Sim(mesh, name='skx_num')
sim.driver.set_tols(rtol=1e-6, atol=1e-6)
sim.driver.alpha = 1.0
sim.driver.gamma = 1.0
sim.mu_s = 1.0
sim.set_m(lambda pos: init_m(pos, 60, 60, 20))
sim.do_precession = False
J = 1.0
exch = UniformExchange(J)
sim.add(exch)
D = 0.09
dmi = DMI(D)
sim.add(dmi)
zeeman = Zeeman([0, 0, 5e-3])
sim.add(zeeman)
sim.relax(dt=2.0, stopping_dmdt=1e-2, max_steps=1000,
save_m_steps=None, save_vtk_steps=None)
skn = sim.skyrmion_number()
print('skx_number', skn)
skn_BL = sim.skyrmion_number(method='BergLuscher')
print('skx_number_BergLuscher', skn_BL)
# Test the finite chirality method
assert skn > -1 and skn < -0.99
# Test the Berg-Luscher method
assert np.abs(skn_BL - (-1)) < 1e-4 and np.sign(skn_BL) < 0
# Test guiding center
Rx, Ry = compute_RxRy(mesh, sim.spin)
print('Rx=%g, Ry=%g'%(Rx, Ry))
assert Rx<60 and Rx>58
assert Ry<60 and Ry>58
示例14: test_skx_num_atomistic_hexagonal
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import relax [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