tsdev / spinw Goto Github PK
View Code? Open in Web Editor NEWSpinW Matlab library for spin wave calculation
Home Page: www.psi.ch/spinw
License: GNU General Public License v3.0
SpinW Matlab library for spin wave calculation
Home Page: www.psi.ch/spinw
License: GNU General Public License v3.0
There seems to be problems sometimes when plotting octahedra. I have a fairly complicated example with 40 atoms in the unit cell (the space group I've used is P 21/n which isn't standard, so I've opted to omit symmetry for plotting in spinw for now and just put all atoms in by hand).
I am trying to plot octahedra around the Ca1 atoms, but for some reason this doesn't work. I've managed to plot a single one the way I want it in red. The code is below:
Thanks.
close all
clear
r= [ 0.7566 0.5206 0.8821
0.7434 0.0206 0.6179
0.2434 0.4794 0.1179
0.2566 0.9794 0.3821
0.7628 0.4920 0.3785
0.7372 0.9920 0.1215
0.2372 0.5080 0.6215
0.2628 0.0080 0.8785
0.5114 0.9905 0.7577
0.9886 0.4905 0.7423
0.4886 0.0095 0.2423
0.0114 0.5095 0.2577
0 0 0
0.5000 0.5000 0.5000
0 0 0.5000
0.5000 0.5000 0
0.7779 0.9315 0.9480
0.7221 0.4315 0.5520
0.2221 0.0685 0.0520
0.2779 0.5685 0.4480
0.7673 0.0357 0.3937
0.7327 0.5357 0.1063
0.2327 0.9643 0.6062
0.2673 0.4643 0.8938
0.5274 0.2257 0.6140
0.9726 0.7257 0.8860
0.4726 0.7743 0.3860
0.0274 0.2743 0.1140
0.5283 0.3369 0.1477
0.9717 0.8369 0.3523
0.4717 0.6631 0.8523
0.0283 0.1631 0.6477
0.5849 0.7011 0.6594
0.9151 0.2011 0.8406
0.4151 0.2989 0.3406
0.0849 0.7989 0.1594
0.4971 0.7954 0.0813
0.0029 0.2954 0.4187
0.5029 0.2046 0.9187
0.9971 0.7046 0.5813];
idx= [1 1 1 1 2 2 2 2 3 3 3 3 4 4 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11];
colors={'k' 'k' 'b' 'gold' 'gold' 'r' 'r' 'r' 'r' 'r' 'r'};
% atomName={'Pb1' 'Pb2' 'Ca1' 'Os1' 'Os2' 'O11' 'O12' 'O21' 'O22' 'O31' 'O32'};
atomName={'Pb1' 'Pb2' 'Ca1' 'Os1' 'Os2' 'O' 'O' 'O' 'O' 'O' 'O'};
S=[0 0 0 0.6063 0.6063 0 0 0 0 0 0];
Pb=spinw;
Pb.genlattice('lat_const',[10.0826 5.6881 11.8366],'angled',[90 125.32 90]);
for k=1:length(idx)
Pb.addatom('r',r(k,:),'S',S(idx(k)),'label',atomName{idx(k)},'color',colors{idx(k)});
end
plot(Pb,'range',[0 1; -0.4 1; 0 1])
% swplot.plotchem('atom1','Ca','atom2','O','limit',[0 2.1],'color','blue','replace',0);
swplot.plotchem('atom1','Ca','atom2','O','limit',6,'color','blue','replace',0);
r=Pb.atom.r;
R=[r(:,31)+[0 -1 0]' r(:,17)+[0 -1 0]' r(:,39)+[0 0 0]' r(:,23)+[0 -1 0]' r(:,33)+[0 -1 0]' r(:,25)+[0 0 0]']';
swplot.plot('type','polyhedron','position',permute(R,[2 3 1]),'color','red','alpha',0.5)
Save the hystory of all commands into sw object. Create function to expport the
commands in .m file. Take iFit as example.
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:54
Hi Sandor
It seems in a monoclinic structure that clicking and the a, b and c icons don't actually make one look down that axis. Instead, it seems that we look down the a*, b* and c* axes.
Cheers
Henrik
Hello again - I'm finding the ground state of a spin 1/2 BCC lattice. I think its working, the simulation converges and if I plot just my unit cell, it is ferromagnetic for J1, or J1 and J2, < 0, and antiferromagnetic for the opposite case.
The problem is, if I plot an extended unit cell, there are spins on the outer edges that are facing a different direction from the ones in the unit cell, so that the cell periodic image looks frustrated. Have you encountered this?
Import crystal structure from .cif file in the constructor of the sw object:
Example:
Cryst = sw('cryst.cif')
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:52
Improve help, take example from http://code.google.com/p/mtex/
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:57
Hi,
I've emailed about this several times. In the manual, it says that the dispersions provided by Hermit = 0/false are wrong. Setting hermit = 0 is the only way I can generate results for my system. Can you please explain to me in what way it is wrong, and if the results could be considered correct or approximate in any context?
thanks.
Hello, I am trying to write a function that can allow me to visualize each magnon branches, such as the flatband mode in a kagome ferromagnets.
My plan is to use the V matrix stored in the spectrum structure, however, I could not find enough information about this V matrix from SpinW website.
Could someone help explain the meaning of this matrix?
Cheers.
Include magnetic form factor in spin wave calculation.
NOte:
- can be hard, because it is a matrix in general case (different magnetic atoms
in the unit cell)
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:50
Dear Sandor,
In order to specify DM interaction one needs to provide D-vector and a bond index. SpinW spreads it out on all equivalent bonds taking into account symmetry of the crystal. In general, the D-vector will be pointed in the different directions on the different equivalent bonds.
My problem is that I know a D-vector only for a bond between particular pair of atoms.
Is there any way to define D-vector not for a bond index but for a bond between particular pair of atoms and then spread it out using crystal symmetry?
{system: MacOS Sierra 10.12.6}
Hi Sandor
After installing pyspinw and trying your sample script I get the following:
Last login: Fri Aug 11 11:31:29 on ttys000
[rosss-imac:~] rossstewart% python3
Python 3.6.2 (default, Jul 17 2017, 16:44:45)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> spinw='/Applications/pyspinw.app/pyspinw.sh'
>>> from transplant import Matlab
>>> from transplant import MatlabStruct
>>> import numpy as np
>>> m=Matlab(spinw)
SpinW process is running...
>>> tri = m.sw_model('triAF',1.)
Preparing 'triAF' model ...
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/site-packages/transplant/transplant_master.py", line 124, in reader
print(line.decode(), end='')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 41: invalid continuation byte
>>>
Cheers
Ross
Hi Sandor!
This is probably the smallest, most insignificant thing I will ever report, and I feel petty just for typing it, but I thought I might as well :)
in sw_neutron line 148 the warning says
warning('sw_neutron:ScatteringPlaneProblem','The normal to the scattering plane is not perpendiculat to Q!');
It should be perpendicular, not perpendiculat
I am preparing the code for plotting orbitals (orbital-dev branch). It would be a great help if some of you could give a few tips how you would like to use it.
Coordinate system
The most difficult part of the user interface is, that the user needs to define an xyz coordinate system on the atom to show the orbitals. The main question is what would be the easiest/most reasonable way to do it. I have 2 ideas:
Symmetry transformations
After the user defined the orientation of the orbital on a selected atom, the orbital orientation will be transformed to all symmetry equivalent atoms. This could be switched off if the user requests (the system has lower symmetry than the given space group).
I am also curious any other new ideas!
Example script plotting d_xy (works with orbital-dev branch):
R = [0 0 0;1 0 0;1 1 0;0 1 0]';
T = sw_rotmatd([0 0 1],90);
T = cat(3,T,T^2,T^3,T^4);
swplot.plot('type','orbital','qLabel','d_xy','position',R,'T',T,'scale',0.03,'nPatch',100,'color',{'red' 'green'});
And the result:
http://pasteboard.co/D8UAtHj5S.png
Is it possible, or is it planned, to support calculation of critical (Curie/Néel) temperatures using SpinW?
Graphical interface like vTAS:
http://www.ill.eu/?id=2048
- angle between reflections
- intensities of certain peaks
- scattering plane
- ub matrix refinement???? maybeee
Also export spectra for vTAS.
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 9:10
It would be neat to be able to plot the xyz coordinate systems and the a^, b^ and c^* coordinate systems when using the plot() command.
Calculate error bar on fitted parameters in functions:
- sw.fitspec
- sw.fitmagstr
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:53
Improve exporting figures:
- enable to combine raster/vector plot (raster image, vector axis)
- .eps/.pdf recommended
- .svg?
- see exportfig: http://www.mathworks.com/matlabcentral/fileexchange/727
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:59
{mac OS 10.12.6, pyspinw}
Hi
I can see structures within spinw objects ok. For example:
from transplant import Matlab
from transplant import MatlabStruct
m=Matlab('/Applications/pyspinw.app/pyspinw.sh')
gto=m.spinw()
Flist = MatlabStruct(gto.mag_str)['F']
What I haven't figured out yet is how to write to the spinw object structures directly. (I would like to - in this case - manually change some of the spins in the 'F' array)
Cheers
Ross
Calculate magnetic and nuclear scattering structure factor.
- for neutron and X-ray
- simulate powder spectra
- simulate single crystal diffraction planes
- simulate Laue pattern
Basically copy features of Carine Crystallography!
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 9:15
sw_freemem at the moment checks for OS version.
isunix and ismac have the same command, where isunix command should be:
[~, memStr] = unix('free -b | grep ''-''');
[mem_used, mem_free] = strtok(memStr(20:end));
mem = str2double(mem_free);
Original issue reported on code.google.com by [email protected]
on 14 Oct 2013 at 9:11
The new swpref
class uses the built-in functions mustBeInteger
, mustBeNonNegative
, mustBeGreaterThan
and mustBeLessThan
which were introduced in Matlab 2017a.
Is Matlab 2017 or newer now a requirement?
Hi, I hope this is the appropriate place to ask questions about SpinW, please refer me to the appropriate venue if not!
Has SpinW been tested with Octave? Are there any plans for support? Asking because we have limited Matlab licenses available, and would be nice to be able to run core SpinW features (even if not, say, symbolic calculations) using free software.
Change spinw.addg
and spinw.addaniso
to accept string options similarly to spinw.addcoupling
. Also fix the bug in spinw.addg
to enable specify atoms where g-tesor is assigned. Currently errors out when non-magnetic atoms are also present in the structure.
See this paper:
http://iopscience.iop.org/0305-4470/37/48/005/
Presently, powder average is calculated using Monte-Carlo, however a constant
density grid on the unit sphere might be faster.
Original issue reported on code.google.com by [email protected]
on 10 May 2013 at 9:06
I would like to be able to change the default xyz coordinate system from the current standard of x||a, y in the ab plane and z perpendicular. For instance, in my system it is natural to have x || (10-1), y in the ac plane and z||b.
I have been figuring out how to use this program over the past couple of days. I can't get the 'addcoupling' function to work for my system in pyspinw 3.0.0. Specifically, I'm trying to generate an antiferromagnetic coupling between 16 atoms using addmatrix and gencoupling.
here is my code for generating the negative J coupling (is it correct?):
H_sys.addmatrix('value',-np.eye(3),'label','J1')
Here is my code for generating the coupling:
H_sys.addcoupling('J1',1)
Thank you.
I think
hMax2 = sum(obj.basisvector,2);
can be replaced with
hMax2 = abs(sum(obj.basisvector,2));
to solve this problem.
Hi Sandor
I am looking into have different anisotropies on different ions, but get an error message when I try to plot the structure. The error is this:
Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
Error in swplot.plotion (line 303)
posc = bsxfun(@plus,posc,repmat(pos,[1 3]));
Error in spinw/plot (line 263)
hFigure = plotFun{ii}(selArg{:});
Below is a small example creating this error. The code seems to run correctly apart from this; it creates a figure with anisotropy only on the correct ions.
Cheers,
Henrik
CuO = spinw;
CuO.fileid(0)
CuO.genlattice('lat_const',[4.684 3.423 5.129],'angled',[90 99.54 90])
CuO.addatom('r', [1/4 1/4 0],'S', 1/2,'label','Cu1','color','blue')
CuO.addatom('r', [3/4 3/4 0],'S', 1/2,'label','Cu2','color','blue')
CuO.addatom('r', [3/4 1/4 1/2],'S', 1/2,'label','Cu3','color','blue')
CuO.addatom('r', [1/4 3/4 1/2],'S', 1/2,'label','Cu4','color','blue')
CuO.gencoupling
S0=[0 -1 0;
0 -1 0;
0 -1 0;
0 1 0;].';
CuO.genmagstr('mode','helical','k',[1/2 0 -1/2],'n',[0 0 1],'unitS','lu','S',S0,'nExt',[2 1 2]);
D_matrix=diag([0 -0.15 0]);
CuO.addmatrix('value',D_matrix,'label','D','color','r')
% CuO.addaniso('D')
% CuO.addaniso('D',[1 2 ])
CuO.addaniso('D',{'Cu1','Cu2'})
plot(CuO)
Fix missing stuff:
- extra subwindow to rotate crystal by fixed angle, see CrystalMaker, Carine
crystallography etc
- (window) to calculate distances, angles, etc.
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 9:05
Restrict the magnetic Hamiltonian (exchange matrix and anisotropy matrix) based
on the space group.
- find the allowed matrix elements
- transform the matrix to every simmetry equivalent couplings using the
symmetry operators
- for example: Dzyaloshinskii-Moriya interaction
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:48
Hi Sandor
It seems that when an atom is right at the edge of the unit cell, plotchem will plot the bonds from that atom to where they are supposed to be outside the unit cell, even if this goes outside of the desired plot range. An example is given below
Cheers,
Henrik
clear
CuO = spinw;
CuO.fileid(0)
CuO.genlattice('lat_const',[4.684 3.423 5.129],'angled',[90 99.54 90],'sym','C 2/c')
CuO.addatom('r', [1/4 1/4 0],'S', 1/2,'label','Cu','color','blue')
CuO.gencoupling
CuO.addatom('r', [0 0.416 1/4],'S', 0,'label','O','color','red')
CuO.plot('range',[2 1 2],'cellMode','inside')
swplot.plotchem('atom1','Cu','atom2','O','limit',4,'range',[2 1 2],'mode','bond')
Is there an easy way to plot one (or more) Q vectors along with the unit cell?
It seems like tutorial for symbolic calculations Tutorial_17 is obsolete now.
There is a minor error in plotting:
Error using sprintf
Function is not defined for 'sym' inputs.
Error in swplot.tooltipstring (line 125)
string = [string 'Heisenberg exchange' newline 'Value:' newline sprintf('%7.3f ',M(1,1)) ' ' unitE];
Error in swplot.tooltipcallback (line 43)
string = swplot.tooltipstring(sObject,swobj);
Error in swplot.tooltip>@(obj,hit)swplot.tooltipcallback(obj,hit,hFigure,h) (line 113)
set(unique([obj(:).handle]),'ButtonDownFcn',@(obj,hit)swplot.tooltipcallback(obj,hit,hFigure,h));
Error while evaluating Patch ButtonDownFcn
And I wasn't able to go further than generating magnetic structure:
Error using spinw/genmagstr (line 357)
Wrong number of input spins!
I'm using the latest SpinW version:
>> sw_version()
This version of SpinW is not released yet!
MATLAB version: 8.4.0.150421 (R2014b), Symbolic Math Toolbox installed
Sum up intensities of degenerate modes for plotting the intensity of selected
spin wave mode.
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 9:13
Include space group operations:
- determination of Wyckoff positions
- point group symmetry of any point inside the crystal
- rewrite symmetry operators as permutation matrix
- take functions from CrysFML
- ...
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 9:17
Check this article:
http://www.myoutsourcedbrain.com/2009/07/produce-print-quality-figures-from.html
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:23
Create a function which returns version information
function varargout = sw_version()
build = 'SpinW release 2.0beta';
name = 'SpinW';
version = 2.0;
build_data = '01.01.2013';
contact = '[email protected]';
licence = 'Needs to be filled in....'
if nargout ~= 1
disp(build)
else
varargout{1}.name = name;
varargout{1}.version = version;
varargout{1}.build_data = build_date;
varargout{1}.contact = contact;
varargout{1}.licence = licence;
end
Original issue reported on code.google.com by [email protected]
on 14 Oct 2013 at 9:19
The function sw_instrument
has code which computes the kinematic limits of the detectors. Unfortunately it assumes that the detectors span the range of scatterings [thetaMin, 180-thetaMin]
and allows only a single argument for this computation thetaMin
.
In fact, it is not physically feasible for most spectrometers to cover up to 180 degrees scattering angle. Thus a thetaMax
parameter should be allowed and the expressions in the code modified. In practice most instruments cover around 120-130 degrees in scattering angle, and some cover an even more restricted range of around 60 degrees.
@tsdev Hi, Dr. Toth
I am trying to use the 'type' option to add biquadratic exahange in my model (bcc lattice) :
LaSrCrO4.addcoupling('mat','Biq','bond',
4, 'type', 'biquadratic');
I assume this add a Q*(Si * Sj)^2 type term to the Hamiltonian. However the spinwave calculated by SpinW is a little different from my analytic calculations. And I found that if the defination of biqudratic is 0.5Q(Si * Sj)^2 , these two results fit perfectly.
I read your tutorial document "tutorial28.m". This document also compared the results of analystic calculation and SpinW on fcc lattice.
fcc.addmatrix('label','B','value',-0.5*Q/S^3*2)
fcc.addcoupling('mat','B','bond',1,'type','biquadratic')
According to the paper ''PHYSICAL REVIEW B 85, 054409 (2012)'' mentioned in "tutorial28.m", their Hamiltonian is:
In this example, we also have to add another factor 2 in SpinW to get consistent results.
So I want to confirm that when we use command
fcc.addcoupling('mat','B','bond',1,'type','biquadratic')
we actually add 0.5Q(Si * Sj)^2 instead of Q*(Si * Sj)^2 to Hamiltonian?
JingZhou
To include crystallographic twinning the following are necessary:
- new field in sw object: twin
subfields:
weight Volume ratio of the twins, dimensions [1 nTwin]
rot Rotation matrix for every twin, dimensions [3 3 nTwin]
- change spinwave function to include twins:
it has to rotate Q and Sab
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 11:26
Hi Sandor
I get the following error message after updating to the latest version:
Error using swpref.pref (line 86)
The requested SpinW preference does not exists!
Error in swpref.getpref (line 33)
rPref = swpref.pref(prefName,'get',varargin{:});
Error in spinw/spinwave (line 175)
useMex = swpref.getpref('usemex',[]);
Error in CuO_AFM (line 403)
CuOSpec = CuO.spinwave({ Gamma, X, N, Gamma, M, X, 200},'hermit',false);
I assume it's related to me running SpinW on Linux. If needed, I can provide a minimal example of the bug, but it's probably something general. I tried bug hunting a bit, but it's not easy.. What I know is that in getpref, the input variables when it fails are
prefName =
usemex
varargin =
cell
{[]}
Cheers,
Henrik
Provide test functions:
- check that every function runs without error
- check spin wave functions with numerical results
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:57
Improve the sw_plotspec function to plot constant Q spectra (single Q scan in
triple axis spectrometer).
- modes convoluted with energy resolution and intensity
Original issue reported on code.google.com by [email protected]
on 24 Apr 2013 at 8:51
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.