本文整理汇总了Python中fidimag.atomistic.Sim.compute_average方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.compute_average方法的具体用法?Python Sim.compute_average怎么用?Python Sim.compute_average使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fidimag.atomistic.Sim
的用法示例。
在下文中一共展示了Sim.compute_average方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sim_spins
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import compute_average [as 别名]
def test_sim_spins(do_plot=False):
mesh = CuboidMesh(nx=10, ny=5, nz=1)
sim = Sim(mesh, name='10spin')
alpha = 0.1
gamma = 2.21e5
sim.alpha = alpha
sim.gamma = gamma
sim.mu_s = 1.0
sim.set_m((1, 0, 0))
print(sim.spin)
H0 = 1e5
sim.add(Zeeman((0, 0, H0)))
ts = np.linspace(0, 1e-9, 101)
mx = []
my = []
mz = []
real_ts = []
for t in ts:
sim.run_until(t)
real_ts.append(sim.t)
#print sim.t, abs(sim.spin_length()[0] - 1)
av = sim.compute_average()
mx.append(av[0])
my.append(av[1])
mz.append(av[2])
#sim.save_vtk()
mz = np.array(mz)
# print mz
a_mx, a_my, a_mz = single_spin(alpha, gamma, H0, ts)
print(sim.stat())
if do_plot:
plot(real_ts, mx, my, mz, a_mx, a_my, a_mz, name='spins.pdf', title='integrating spins')
print(("Max Deviation = {0}".format(
np.max(np.abs(mz - a_mz)))))
assert np.max(np.abs(mz - a_mz)) < 5e-7
示例2: test_m_average
# 需要导入模块: from fidimag.atomistic import Sim [as 别名]
# 或者: from fidimag.atomistic.Sim import compute_average [as 别名]
def test_m_average():
mesh = CuboidMesh(nx=3, ny=4, nz=5)
sim = Sim(mesh)
sim.set_m((0, 0, 1))
a = sim.compute_average()
assert a[2] == 1.0