Package to be used with the magnetism simulation tool spirit
Project description
spirit-extras
Package with some useful scripts, to be used together with the Spirit python API (github.com/spirit-code/spirit/
).
Data structure for spin systems
Parse data from a Spirit state pointer
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]
Create from your own buffers
# 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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spirit-extras-0.0.33.tar.gz
(45.9 kB
view details)
Built Distribution
File details
Details for the file spirit-extras-0.0.33.tar.gz
.
File metadata
- Download URL: spirit-extras-0.0.33.tar.gz
- Upload date:
- Size: 45.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f0221f17615b578760e09cb841fa9aada607160775241250ab4240210b02ef |
|
MD5 | eb53b55acd037aff0aab6340ac934183 |
|
BLAKE2b-256 | 356e5d488d1fbf7989615dea5674ef369998a01f71c6ac28ab9d8a7393a5a4bb |
File details
Details for the file spirit_extras-0.0.33-py3-none-any.whl
.
File metadata
- Download URL: spirit_extras-0.0.33-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f46a5d13a7cf98d4d792ca812b1a3c27c2dd55a21bc8533d3d96c3326e54a476 |
|
MD5 | be808cf8bc35e0f3ba49a3b98c1ecded |
|
BLAKE2b-256 | bd2eaf3a44b6630a4944fe29a4d8632cde2b499162d2311046a482919b058732 |