Skip to main content

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


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.29.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

spirit_extras-0.0.29-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

Details for the file spirit-extras-0.0.29.tar.gz.

File metadata

  • Download URL: spirit-extras-0.0.29.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for spirit-extras-0.0.29.tar.gz
Algorithm Hash digest
SHA256 b78da294d114ddb84144b76abb20c492130c6b2b6288fde9437aae101df5552f
MD5 ccd9044df3920ccf7b89056e87b107de
BLAKE2b-256 aaee278088db65a32001307a97599334d7cf63bb3060b2778d9f5d86a4729f40

See more details on using hashes here.

File details

Details for the file spirit_extras-0.0.29-py3-none-any.whl.

File metadata

File hashes

Hashes for spirit_extras-0.0.29-py3-none-any.whl
Algorithm Hash digest
SHA256 7ff4da50dac33157385bf14bee503ccea776b6a0c647d39e0f568d5b87c1b1e0
MD5 1b2a53faf48420e44f1baff58e2f8c73
BLAKE2b-256 4fdd6e6f655e2dda36f4aa0a407657506b314486cb0b61dc60de0027b4b27b85

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page