Skip to content

Commit

Permalink
Increase tolerance on eigvals = 0 (for which DSF to be neglected)
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardWaiteSTFC committed Apr 21, 2023
1 parent d72569f commit fadc685
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ function test_AFM_kagome(testCase)
'n',n, 'S', S, 'nExt',[1 1 1]);
testCase.disable_warnings('spinw:spinwave:NonPosDefHamiltonian');
spec_incom = AF33kagome.spinwave(qarg, 'hermit', true);
spec_incom = sw_egrid(spec_incom, 'component','Sxx+Syy+Szz', 'Evect',evec);
spec_incom = sw_egrid(spec_incom, 'component','Sperp', 'Evect',evec);
% use supercell k=0 structure
AF33kagome.genmagstr('mode','helical','unit','lu', 'k', k,...
'n',n, 'S', S, 'nExt', [3,3,1]);

spec_super = AF33kagome.spinwave(qarg, 'hermit', false);
spec_super = sw_egrid(spec_super, 'component','Sxx+Syy+Szz', 'Evect',evec);
spec_super = AF33kagome.spinwave(qarg, 'hermit', true);
spec_super = sw_egrid(spec_super, 'component','Sperp', 'Evect',evec);

testCase.assert_super_and_incom_consistency(AF33kagome, ...
spec_super, ...
Expand Down Expand Up @@ -86,17 +86,16 @@ function test_two_matom_per_unit_cell(testCase)
evec = 0:0.5:5;

% use structural unit cell with incommensurate k
testCase.disable_warnings('spinw:spinwave:NonPosDefHamiltonian', ...
'spinw:magstr:NotExact', ...
testCase.disable_warnings('spinw:magstr:NotExact', ...
'spinw:spinwave:Twokm');
FeCuChain.genmagstr('mode','helical','k', k,...
'S', S, 'nExt',[1 1 1]);
spec_incom = FeCuChain.spinwave(qarg, 'hermit', true);
spec_incom = FeCuChain.spinwave(qarg, 'hermit', false);
spec_incom = sw_egrid(spec_incom, 'component','Sperp', 'Evect',evec);
% use supercell k=0 structure
FeCuChain.genmagstr('mode','helical','k', k,...
'S', S, 'nExt', [2,1,1]);
spec_super = FeCuChain.spinwave(qarg, 'hermit', true);
spec_super = FeCuChain.spinwave(qarg, 'hermit', false);
spec_super = sw_egrid(spec_super, 'component','Sperp', 'Evect',evec);

testCase.assert_super_and_incom_consistency(FeCuChain, ...
Expand Down
5 changes: 3 additions & 2 deletions swfiles/sw_egrid.m
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@
[~, ihkl] = ind2sub(size(ien), 1:numel(ien));
% NaN in ien implies eigvals not in extent of Evect
% also include only nonzero eigenvalues (DSF can blow up at
% zero energy)
ien_valid = abs(real_eigvals(:)) > 1e-10 & ~isnan(ien(:));
% zero energy) tolerance from test using AFM kagome tutorial 8
% systemtest_spinwave_incommensurate_and_supercell_consistency/test_AFM_kagome
ien_valid = abs(real_eigvals(:)) > 1e-7 & ~isnan(ien(:));
sw_conv_idx = [ien(ien_valid), ihkl(ien_valid)']; % index in swConv
% sum intensities and pad energies above max eigval with 0
swConv{ii,tt} = accumarray(sw_conv_idx, DSF{ii,tt}(ien_valid), [nE, nHkl]);
Expand Down

0 comments on commit fadc685

Please sign in to comment.