与磁力模拟工具spirit一起使用的包
项目描述
spirit-extras
包含一些有用脚本的包,与Spirit Python API(github.com/spirit-code/spirit/
)一起使用。
自旋系统的数据结构
从Spirit状态指针解析数据
from spirit import state
import spirit_extras.data
with state.State("input.cfg") as p_state:
spin_sytem = spirit_extras.data.spin_system_from_p_state()
# Information about the bravais lattice is automatically parsed from the spirit API
print(spin_system)
# The spins can be set
ib, a, b, c = 1, 5, 3, 4
idx = spin_system.idx(ib, a, b, c) # computes the linear index from a bravais tupel
spin_system.spins[idx] = [0,0,-1]
ib, a, b, c = spin_system.tupel(5) # computes the bravais tupel from a linear index
# A shaped view into the spin system is also available
spin_system.shaped().spins[ib,a,b,c] = [0,0,1]
# Slicing syntax works
spin_system.shaped().spins[ib,:,b,c] = [0,1,0]
mask = np.linalg.norm(spin_system.positions - spin_system.center() < 5, radius=1)
spin_sytem.spins[mask] = [1,0,0]
从您自己的缓冲区创建
# Since spirit_extras.Spin_System is needed for many functions in spirit_extras, it can also be created from a spins and positions arrays
spins = [ [1,0,0] for i in range(10) ]
# The default behaviour is to expect an unordered system, meaning some functions will throw an exception
my_spin_system = spirit_extras.data.Spin_System(positions=None, spins=spins) # positions dont _have_ to be specified
try:
my_spin_sytem.shaped() # needs an ordered system
except:
print("Throws :(")
# To create an ordered system pass `unordered=False` and specify `n_cells`
my_spin_system = spirit_extras.data.Spin_System(positions=None, spins=spins, n_cells=[10,1,1], unordered=False)
my_spin_sytem.shaped() # works!
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
spirit-extras-0.0.35.tar.gz (46.0 kB 查看哈希值)
构建分布
spirit_extras-0.0.35-py3-none-any.whl (41.4 kB 查看哈希值)
关闭
spirit-extras-0.0.35.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c8536125a133a2b8f97b6fc1832fe4d40576b35ca276a46c1757b5a44a24f954 |
|
MD5 | 2e7030b15cc34e7e69726a20c8b936e8 |
|
BLAKE2b-256 | 1dba409a1b0bb7f763d2480a5e12d269bccc623afc4afbc228052bfe310b83ba |
关闭
spirit_extras-0.0.35-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9c6b34fba900f87d054a77ba97875ca878f5b7fdcd25c8b81590b5d598caf550 |
|
MD5 | 867bc0398d813be782747738f169f90c |
|
BLAKE2b-256 | 8693ca47a70de09e68a44f4e148693b8616b2759f24aab737118534c743bc226 |