Skip to content

Commit c3d48a7

Browse files
committed
new spinw property to redefine rlu
- added new spinw property spinw.unit.qmat that transforms any given momentum value - made spinw.validate() a static method - minor changes
1 parent d1a7b1b commit c3d48a7

File tree

13 files changed

+64
-164
lines changed

13 files changed

+64
-164
lines changed

swfiles/+ndbase/spaghetti.m

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
% coo = cell(1,2);
2727
% [coo{:}] = ndgrid(udat.x,udat.y);
2828
% surf(coo{:},udat.sig);
29+
% axscale Scale of the unit on the x-axis. Defines what A^-1 value
30+
% corresponds to unit 1. Default value is 1.
2931
%
3032
% Output:
3133
%
@@ -40,10 +42,10 @@
4042
% clim Limits of the c-axis, row vector with 2 elements.
4143
%
4244

43-
inpForm.fname = {'flip' 'label' 'dashed' 'ylim' 'plot' 'pad'};
44-
inpForm.defval = {[] [] true 'auto' true false};
45-
inpForm.size = {[1 -1] [1 -2] [1 1] [1 -3] [1 1] [1 1]};
46-
inpForm.soft = {true true false false false false};
45+
inpForm.fname = {'flip' 'label' 'dashed' 'ylim' 'plot' 'pad' 'axscale'};
46+
inpForm.defval = {[] [] true 'auto' true false 1 };
47+
inpForm.size = {[1 -1] [1 -2] [1 1] [1 -3] [1 1] [1 1] [1 1] };
48+
inpForm.soft = {true true false false false false false };
4749

4850
param = sw_readparam(inpForm, varargin{:});
4951

@@ -59,6 +61,10 @@
5961
param.flip = logical(param.flip);
6062
end
6163

64+
if isa(dat,'sqw')
65+
dat = d2d(dat);
66+
end
67+
6268
if ~isa(dat,'d2d')
6369
error('spaghetti:WrongDataType','The given data is not d2d type!')
6470
end
@@ -83,8 +89,9 @@
8389
end
8490

8591
ax0 = spags.p{1}(:)*spags.ulen(spags.pax(1));
86-
%ax{1} = ax0-mean(ax0(1:2));
87-
ax{1} = ax0;
92+
% start from 0
93+
ax{1} = ax0-mean(ax0(1:2));
94+
%ax{1} = ax0;
8895
ax{2} = spags.p{2}(:);
8996
dash = zeros(1,nDat-1);
9097

@@ -135,9 +142,15 @@
135142
cLim = [min(sig(:)) max(sig(:))];
136143
end
137144

145+
% scale x-axis for plotting
146+
axscale = 1/param.axscale;
147+
axp = ax;
148+
axp{1} = axp{1}*axscale;
149+
axLim(1:2) = axLim(1:2)*axscale;
150+
138151
% draw the plot
139152
if param.plot
140-
[xx, yy] = ndgrid(ax{:});
153+
[xx, yy] = ndgrid(axp{:});
141154
% pad signal
142155
sigP = sig;
143156
sigP(end+1,:) = nan;
@@ -149,12 +162,12 @@
149162

150163
if param.dashed && nDat>1
151164
xD = [dash(:) dash(:) nan*dash(:)]';
152-
yD = repmat([min(ax{2}) max(ax{2}) nan],[size(xD,2) 1])';
165+
yD = repmat([min(axp{2}) max(axp{2}) nan],[size(xD,2) 1])';
153166
line(xD(:),yD(:),'LineStyle','--','Color','k');
154167
end
155168

156169
if ~isempty(param.label)
157-
hAxis.XTick = [0 dash mean(ax{1}(end-1:end))];
170+
hAxis.XTick = [mean(axp{1}(1:2)) dash mean(axp{1}(end-1:end))];
158171
hAxis.XTickLabel = param.label;
159172
end
160173

@@ -167,6 +180,7 @@
167180
box on
168181
grid off
169182
colormap(cm_viridis(500))
183+
set(gca,'layer','top')
170184
end
171185

172186
udat.x = ax{1};

swfiles/@spinw/addatom.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ function addatom(obj, varargin)
315315

316316
newAtom.color = int32(newAtom.color);
317317
newObj.unit_cell = newAtom;
318-
validate(newObj,'unit_cell');
318+
spinw.validate(newObj,'unit_cell');
319319

320320
cField = {'r' 'label' 'S' 'color' 'ox' 'occ' 'b' 'A' 'Z' 'biso'};
321321

@@ -351,7 +351,7 @@ function addatom(obj, varargin)
351351

352352
obj.unit_cell.ff = cat(3,obj.unit_cell.ff,newObj.unit_cell.ff);
353353
end
354-
%validate(obj);
354+
%spinw.validate(obj);
355355

356356
[~,~,rIdx] = unique(obj.unit_cell.r','rows');
357357

swfiles/@spinw/addmatrix.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function addmatrix(obj, varargin)
137137
newJItem.color = int32(newMat.color(:,ii));
138138
newObj.matrix = newJItem;
139139

140-
%validate(newObj,'matrix');
140+
%spinw.validate(newObj,'matrix');
141141

142142
cIdx = find(strcmp(obj.matrix.label,newJItem.label));
143143

@@ -174,6 +174,6 @@ function addmatrix(obj, varargin)
174174
end
175175
end
176176

177-
%validate(obj);
177+
%spinw.validate(obj);
178178

179179
end

swfiles/@spinw/gencoupling.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function gencoupling(obj, varargin)
248248
obj.single_ion.aniso = aniso;
249249
obj.single_ion.g = g;
250250

251-
validate(obj);
251+
spinw.validate(obj);
252252

253253
end
254254

swfiles/@spinw/genmagstr.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,6 @@ function genmagstr(obj, varargin)
451451
mag_str.F = S;
452452

453453
obj.mag_str = mag_str;
454-
validate(obj);
454+
spinw.validate(obj);
455455

456456
end

swfiles/@spinw/optmagstr.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
%obj.mag_str.n = n;
236236
obj.genmagstr('mode','helical','S',M,'k',k,'n',n);
237237

238-
validate(obj);
238+
spinw.validate(obj);
239239

240240
% Create output struct
241241
if nargout > 0

swfiles/@spinw/private/datastruct.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'aniso' 'g' 'field' 'T' '' '' '' '' '' '' '';... % SINGLE_ION
1515
'dl' 'atom1' 'atom2' 'mat_idx' 'idx' 'type' 'sym' 'rdip' 'nsym' '' '';... % COUPLING
1616
'F' 'k' 'nExt' '' '' '' '' '' '' '' '';... % MAG_STR
17-
'kB' 'muB' 'mu0' 'label' 'nformula' '' '' '' '' '' ''}; % UNIT
17+
'kB' 'muB' 'mu0' 'label' 'nformula' 'qmat' '' '' '' '' ''}; % UNIT
1818
Datastruct.sizefield = {...
1919
{1 3} {1 3} {3 4 'nSymOp'} {1 3} {1 'nStr'} {} {} {} {} {} {};...
2020
{3 'nAtom'} {1 'nAtom'} {1 'nAtom'} {3 'nAtom'} {1 'nAtom'} {1 'nAtom'} {2 'nAtom'} {2 11 'nAtom'} {1 'nAtom'} {1 'nAtom'} {1 'nAtom'};...
@@ -23,7 +23,7 @@
2323
{1 'nMagAtom'} {1 'nMagAtom'} {1 3} {1 1} {} {} {} {} {} {} {};...
2424
{3 'nBond'} {1 'nBond'} {1 'nBond'} {3 'nBond'} {1 'nBond'} {3 'nBond'} {3 'nBond'} {1 1} {1 1} {} {};...
2525
{3 'nMagExt' 'nK'} {3 'nK'} {1 3} {} {} {} {} {} {} {} {};...
26-
{1 1} {1 1} {1 1} {1 4} {1 1} {} {} {} {} {} {}};
26+
{1 1} {1 1} {1 1} {1 4} {1 1} {3 3} {} {} {} {} {}};
2727
Datastruct.typefield = {...
2828
'double' 'double' 'double' 'double' 'char' '' '' '' '' '' '' ;...
2929
'double' 'double' 'char' 'integer' 'double' 'double' 'double' 'double' 'integer' 'integer' 'double';...
@@ -32,19 +32,19 @@
3232
'integer' 'integer' 'double' 'double' '' '' '' '' '' '' '' ;...
3333
'integer' 'integer' 'integer' 'integer' 'integer' 'integer' 'integer' 'double' 'integer' '' '' ;...
3434
'double' 'double' 'integer' '' '' '' '' '' '' '' '' ;...
35-
'double' 'double' 'double' 'char' 'integer' '' '' '' '' '' '' };
35+
'double' 'double' 'double' 'char' 'integer' 'double' '' '' '' '' '' };
3636

3737
uLabel = {char(197) 'meV' 'T' 'K'};
3838

3939
Datastruct.defval = {...
40-
pi/2*ones(1,3) [3 3 3] zeros(3,4,0) zeros(1,3) 'P 0' [] [] [] [] [] [];...
41-
zeros(3,0) zeros(1,0) cell(1,0) int32(zeros(3,0)) zeros(1,0) zeros(1,0) zeros(2,0) zeros(2,11,0) int32(zeros(1,0)) int32(zeros(1,0)) zeros(1,0);...
42-
1 eye(3) [] [] [] [] [] [] [] [] [];...
43-
zeros(3,3,0) int32(zeros(3,0)) cell(1,0) [] [] [] [] [] [] [] [];...
44-
int32(zeros(1,0)) int32(zeros(1,0)) [0 0 0] 0 [] [] [] [] [] [] [];...
40+
pi/2*ones(1,3) [3 3 3] zeros(3,4,0) zeros(1,3) 'P 0' [] [] [] [] [] [];...
41+
zeros(3,0) zeros(1,0) cell(1,0) int32(zeros(3,0)) zeros(1,0) zeros(1,0) zeros(2,0) zeros(2,11,0) int32(zeros(1,0)) int32(zeros(1,0)) zeros(1,0);...
42+
1 eye(3) [] [] [] [] [] [] [] [] [];...
43+
zeros(3,3,0) int32(zeros(3,0)) cell(1,0) [] [] [] [] [] [] [] [];...
44+
int32(zeros(1,0)) int32(zeros(1,0)) [0 0 0] 0 [] [] [] [] [] [] [];...
4545
int32(zeros(3,0)) int32(zeros(1,0)) int32(zeros(1,0)) int32(zeros(3,0)) int32(zeros(1,0)) int32(zeros(3,0)) int32(zeros(3,0)) 0 int32(0) [] [];...
46-
zeros(3,0,0) zeros(3,0) int32([1 1 1]) [] [] [] [] [] [] [] [];...
47-
0.086173324 0.057883818066 201.335431 uLabel int32(0) [] [] [] [] [] []};
46+
zeros(3,0,0) zeros(3,0) int32([1 1 1]) [] [] [] [] [] [] [] [];...
47+
0.086173324 0.057883818066 201.335431 uLabel int32(0) eye(3) [] [] [] [] []};
4848
% 0.086173324 Boltzmann constant: k_B [meV/K]
4949
% 0.057883818066 Bohr magneton: mu_B [meV/T]
5050
% 1.602176565e-19 electron charge: e [C]

swfiles/@spinw/private/validate.m

Lines changed: 0 additions & 133 deletions
This file was deleted.

swfiles/@spinw/spinw.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
% kB Boltzmann constant, default is 0.0862 [meV/K]
257257
% muB Bohr magneton, default is 0.0579 [meV/T]
258258
% mu0 vacuum permeability, 201.335431 [T^2*Angstrom^3/meV]
259+
% qmat transformation matrix that converts the given q-values
259260
unit
260261
% Stores the cache, it should be only used to check consistency of the code.
261262
% The stored values should not be changed by the user in any case!
@@ -280,6 +281,11 @@
280281
ver = sw_version;
281282
end
282283

284+
methods (Static)
285+
% static methods
286+
validate(varargin)
287+
end
288+
283289
methods
284290
function obj = spinw(varargin)
285291
% SPINW constructor
@@ -330,7 +336,7 @@
330336
objS.lattice.angle = objS.lattice.angle';
331337
end
332338

333-
validate(objS);
339+
spinw.validate(objS);
334340
fNames = fieldnames(objS);
335341
for ii = 1:length(fNames)
336342
obj.(fNames{ii}) = objS.(fNames{ii});

swfiles/@spinw/spinwave.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@
255255
% whether the structure is incommensurate
256256
incomm = any(abs(km-round(km)) > param.tol);
257257

258+
% Transform the momentum values to the new lattice coordinate system
259+
hkl = obj.unit.qmat*hkl;
260+
258261
% Calculates momentum transfer in A^-1 units.
259262
hklA = 2*pi*(hkl'/obj.basisvector)';
260263

0 commit comments

Comments
 (0)