|
| 1 | +# [v3.2.0](https://github.com/pace-neutrons/libpymcr/compare/0.0.1...v3.2.0) |
| 2 | + |
| 3 | +## Initial public beta of PySpinW |
| 4 | + |
| 5 | +This is an initial public beta version of PySpinW released on PyPI. |
| 6 | + |
| 7 | +Please install using: |
| 8 | + |
| 9 | +```bash |
| 10 | +pip install spinw |
| 11 | +``` |
| 12 | + |
| 13 | +This will install a module called `pyspinw` (note the `py` at the start). |
| 14 | + |
| 15 | +You can then run SpinW with: |
| 16 | + |
| 17 | +```python |
| 18 | +import numpy as np |
| 19 | +import matplotlib.pyplot as plt |
| 20 | +from pyspinw import Matlab |
| 21 | +m = Matlab() |
| 22 | +swobj = m.spinw() |
| 23 | +swobj.genlattice('lat_const', [3, 3, 6], 'angled', [90, 90, 120], 'sym', 'P 1'); |
| 24 | +swobj.addatom('r', [0, 0, 0], 'S', 1/2, 'label', 'MCu2') |
| 25 | +swobj.gencoupling('maxDistance', 5) |
| 26 | +swobj.addmatrix('label', 'J1', 'value', 1.00, 'color', 'g') |
| 27 | +swobj.addcoupling('mat', 'J1', 'bond', 1) |
| 28 | +swobj.genmagstr('mode', 'helical', 'k', [-1/3, -1/3, 0], 'n',[0, 0, 1], 'unit', 'lu', 'S', [[1], [0], [0]]) |
| 29 | +spec = swobj.spinwave([[-1/2, 0, 0], [0, 0, 0], [1/2, 1/2, 0], 100], 'hermit', False) |
| 30 | +spec = m.sw_egrid(spec, 'component', 'Sxx+Syy', 'imagChk', False, 'Evect', np.linspace(0, 3, 100)) |
| 31 | +ax = plt.imshow(np.real(np.flipud(spec['swConv'])), aspect='auto', vmax=1) |
| 32 | +plt.show() |
| 33 | +``` |
| 34 | + |
| 35 | +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). |
| 36 | + |
| 37 | + |
| 38 | +# [v0.0.1](https://github.com/spinw/spinw/compare/v3.1.2...0.0.1) |
| 39 | + |
| 40 | +## pySpinW |
| 41 | + |
| 42 | +This is an initial release of pySpinW as a `pip` installable wheel for python >= 3.8 and MATLAB >= R2021a |
| 43 | + |
| 44 | +### Installation |
| 45 | + |
| 46 | +Please install with |
| 47 | + |
| 48 | +```bash |
| 49 | +pip install pyspinw*.whl |
| 50 | +``` |
| 51 | + |
| 52 | +This package can now be used in python if you have a version of MATLAB or MCR available on the machine. |
| 53 | +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 specified. |
| 54 | + |
| 55 | +```python |
| 56 | +from pyspinw import Matlab |
| 57 | +m = Matlab(matlab_version='R2023a', matlab_path='/usr/local/MATLAB/R2023a/') |
| 58 | +``` |
| 59 | + |
| 60 | +### Example |
| 61 | + |
| 62 | +An example would be: |
| 63 | + |
| 64 | +```python |
| 65 | +import numpy as np |
| 66 | +from pyspinw import Matlab |
| 67 | + |
| 68 | +m = Matlab() |
| 69 | + |
| 70 | +# Create a spinw model, in this case a triangular antiferromagnet |
| 71 | +s = m.sw_model('triAF', 1) |
| 72 | + |
| 73 | +# Specify the start and end points of the q grid and the number of points |
| 74 | +q_start = [0, 0, 0] |
| 75 | +q_end = [1, 1, 0] |
| 76 | +pts = 501 |
| 77 | + |
| 78 | +# Calculate the spin wave spectrum |
| 79 | +spec = m.spinwave(s, [q_start, q_end, pts]) |
| 80 | +``` |
| 81 | + |
| 82 | +### Known limitations |
| 83 | + |
| 84 | +At the moment graphics will not work on macOS systems and is disabled. |
0 commit comments