本文整理汇总了Python中fidimag.micro.Sim.compute_energy方法的典型用法代码示例。如果您正苦于以下问题:Python Sim.compute_energy方法的具体用法?Python Sim.compute_energy怎么用?Python Sim.compute_energy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fidimag.micro.Sim
的用法示例。
在下文中一共展示了Sim.compute_energy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mode
# 需要导入模块: from fidimag.micro import Sim [as 别名]
# 或者: from fidimag.micro.Sim import compute_energy [as 别名]
cbar.set_label(r'$m_z$', rotation=270, labelpad=10, fontsize=16)
# Interactive mode (this needs so set up a proper backend
# when importing matplotlib for the first time)
plt.ion()
# Set False to avoid the execution of the following code
plt.show(False)
# ---------------------------------------------------------------------
# Now run the simulation printing the energy
for time in times:
if not run_from_ipython():
print 'Time: ', time, ' s'
print 'Total energy: ', sim.compute_energy(), ' J'
print '\n'
sim.run_until(time)
# Update the vector data for the plot (the spins do not move
# so we don't need to update the coordinates) and redraw
m = np.copy(sim.spin)
# reshape rows, transpose and filter according to top layer
m = m.reshape(3, -1).T[top_z]
quiv.set_UVC(m[:, 0], m[:, 1], m[:, 2])
# Update title
ttime.set_text('Time: {:.4f} ns'.format(time * 1e9))
tenergy.set_text('Energy: {:.6e} ns'.format(sim.compute_energy()))
# fig.show()