Releases: SpinW/spinw
v4.0.0
New Features
- Add a function to output Mantid MDHistogramWorkspaces (
sw_spec2MDHisto
) - Add Python plotting of magnetic structure using vispy
- Add mex files to compute main loop in
spinwave()
enabling a 2x - 4x speed up depending on system size - Add python wrapper for all Matlab functions so e.g.
sw_plotspec
etc can be called without them.
prefix in pyspinw:q
Improvements
- Replace
spinwavefast()
method with a newfastmode
option in the mainspinwave()
method to reduce confusion - Adds a
neutron_output
option tospinwave()
to compute only the neutron (Sperp
) cross-section and not the full spin-spin correlation tensor, saving memory
Bug Fixes
- Corrects equation for Q-range from
thetaMin
insw_instrument
and addthetaMax
option - Fixes
sw_issymspec
to recognise powder spectra - Fixes a parsing error in the
spinw.fourier
method if no sublat option given. - Fixes several bugs in
sw_plotspec
where it ignores user options in'auto'
mode, and where it inverts user supplied colormaps. - Fixes several bugs in
.fitspec()
for handling twins and where it only outputs the final chi^2 values.
v3.2.0
Initial public beta of PySpinW
This is an initial public beta version of PySpinW released on PyPI.
Please install using:
pip install spinw
This will install a module called pyspinw
(note the py
at the start).
You can then run SpinW with:
import numpy as np
import matplotlib.pyplot as plt
from pyspinw import Matlab
m = Matlab()
swobj = m.spinw()
swobj.genlattice('lat_const', [3, 3, 6], 'angled', [90, 90, 120], 'sym', 'P 1');
swobj.addatom('r', [0, 0, 0], 'S', 1/2, 'label', 'MCu2')
swobj.gencoupling('maxDistance', 5)
swobj.addmatrix('label', 'J1', 'value', 1.00, 'color', 'g')
swobj.addcoupling('mat', 'J1', 'bond', 1)
swobj.genmagstr('mode', 'helical', 'k', [-1/3, -1/3, 0], 'n',[0, 0, 1], 'unit', 'lu', 'S', [[1], [0], [0]])
spec = swobj.spinwave([[-1/2, 0, 0], [0, 0, 0], [1/2, 1/2, 0], 100], 'hermit', False)
spec = m.sw_egrid(spec, 'component', 'Sxx+Syy', 'imagChk', False, 'Evect', np.linspace(0, 3, 100))
ax = plt.imshow(np.real(np.flipud(spec['swConv'])), aspect='auto', vmax=1)
plt.show()
On Windows and Linux systems, as long as you're running PySpinW locally, Matlab plotting commands like m.plot(swobj)
will work. This is not the case on MacOS (a known bug) and on remote systems (e.g. via JupyterHub).
pySpinW
pySpinW
This is an itial release of pySpinW as a pip
installable wheel for python >= 3.7 and MATLAB >= R2021a
Installation
Please install with
pip install pyspinw*.whl
This package can now be used in python if you have a version of MATLAB or MCR available on the machine.
The package will try to automatically detect your installation, however if it is in a non-standard location, the path and version will have to be especified.
m = Matlab(matlab_version='R2023a', matlab_path='/usr/local/MATLAB/R2023a/')
Example
An example would be:
import numpy as np
from pyspinw import Matlab
m = Matlab()
# Create a spinw model, in this case a triangular antiferromagnet
s = m.sw_model('triAF', 1)
# Specify the start and end points of the q grid and the number of points
q_start = [0, 0, 0]
q_end = [1, 1, 0]
pts = 501
# Calculate the spin wave spectrum
spec = m.spinwave(s, [q_start, q_end, pts])
Known limitations
At the moment graphics will not work on macOS systems and is disabled.
Last 3.1 Version
SpinW will be moving to SpinW4 in the future. This is the last stable build before the new version is released (Though there will be hot fixes if required.)
SpinW 3.1
Introducing SpinW 3.1.
There have been a lot of bug and compatibility fixes including:
- Better Horace integration by @mducle
- Faster mex calculation on pre R2017b systems @mducle
- Fixed errors while plotting structures and dispersion
- Fixed multi g-tensor calculations
- Fixed updating
- Better testing
- Minor text fixes
Standard installation procedure is required, help can be found at:
http://www.spinw.org/installation/
Please check out the new website and update your links as the old site will be closing down
http://www.spinw.org
SpinW 3.1 Pre-release
This is a pre-release of SpinW 3.1. Download spinw3_R1520.zip and after unpacking add it to the Matlab® search path.
MATLAB® is copyright of the Mathworks.
pySpinW 3.0
Use these executables to call SpinW from Python without MATLAB® license. Some functionality of the original code might be missing.
To use these files you will need to do the following (MacOs, Linux):
install Python 3
install zeroMQ (MacOS use brew install zmq
, Linux check its website for instructions)
add the Python package transplant pip3 install git+https://github.com/bastibe/transplant.git
install Matlab Runtime R2017a from here: https://www.mathworks.com/products/compiler/mcr.html
To use these files in Windows do the following:
install Anaconda (for Python 3 from here: https://www.continuum.io/downloads)
install zeroMQ (binary from here: http://zeromq.org/intro:get-the-software)
add the Python package transplant in Anaconda Command Line pip install git+https://github.com/bastibe/transplant.git
install Matlab Runtime R2016b from here: https://www.mathworks.com/products/compiler/mcr.html
Now in Python you can call the pySpinW executable:
from transplant import Matlab
m = Matlab(executable='full path to pyspinw.sh')
m.disp('Hello World')
tri = m.sw_model('triAF',1.)
tri.plot()
m.waitforgui()
The waitforgui()
function enables interaction with MATLAB® figures. If you have problems or question check first the GitHub page of Transplant or submit an issue here.
MATLAB® is copyright of the Mathworks.