SpinW / spinw

SpinW Matlab library for spin wave calculation
http://www.spinw.org
GNU General Public License v3.0
37 stars 15 forks source link

Add unit tests optmagsteep #108

Closed RichardWaiteSTFC closed 2 years ago

RichardWaiteSTFC commented 2 years ago

Added tests unit tests for optmagsteep. Please note that

github-actions[bot] commented 2 years ago

Unit Test Results

       4 files  ±  0       76 suites  +4   7m 30s :stopwatch: + 1m 37s    438 tests +18     438 :heavy_check_mark: +18  0 :zzz: ±0  0 :x: ±0  1 296 runs  +64  1 296 :heavy_check_mark: +64  0 :zzz: ±0  0 :x: ±0 

Results for commit 03e5d1b0. ± Comparison against base commit 37e2ac7f.

:recycle: This comment has been updated with latest results.

codecov-commenter commented 2 years ago

Codecov Report

Merging #108 (a224627) into master (4d02dbd) will increase coverage by 9.12%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #108      +/-   ##
==========================================
+ Coverage   27.16%   36.28%   +9.12%     
==========================================
  Files         235      235              
  Lines       15740    15744       +4     
==========================================
+ Hits         4276     5713    +1437     
+ Misses      11464    10031    -1433     
Impacted Files Coverage Δ
swfiles/@spinw/optmagsteep.m 97.86% <100.00%> (+14.80%) :arrow_up:
swfiles/@spinw/intmatrix.m 76.42% <0.00%> (+1.42%) :arrow_up:
swfiles/sw_atomdata.m 74.00% <0.00%> (+2.00%) :arrow_up:
external/eigorth.m 82.85% <0.00%> (+2.85%) :arrow_up:
swfiles/@spinw/magstr.m 95.23% <0.00%> (+4.76%) :arrow_up:
swfiles/+swplot/color.m 76.92% <0.00%> (+5.76%) :arrow_up:
swfiles/+swplot/mouse.m 20.87% <0.00%> (+20.87%) :arrow_up:
swfiles/+swplot/delete.m 34.54% <0.00%> (+34.54%) :arrow_up:
swfiles/+swplot/tooltip.m 50.00% <0.00%> (+50.00%) :arrow_up:
... and 24 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

RichardWaiteSTFC commented 2 years ago

@mducle I have been trying to figure out how to distinguish free and per boundary conditions - I think in my toy example with NN and next NN coupling the result is the same because when per boundary conditions are removed it identifies that spins are coupled to themselves and the interactions in extend unit cells are removed anyway (as they are in free boundary conditions).

testCase.swobj = spinw();
testCase.swobj.genlattice('lat_const', [2 3 6])
testCase.swobj.addatom('r',[0; 0; 0],'S',1)
testCase.swobj.addmatrix('label', 'A', ...
                         'value', diag([0 0 -0.1])) % c easy
testCase.swobj.addmatrix('label', 'J1', 'value', 1)
testCase.swobj.addmatrix('label', 'J2', 'value', 5)
testCase.swobj.gencoupling();
testCase.swobj.addcoupling('mat', 'J1', 'bond', 1); % NN along a
testCase.swobj.addcoupling('mat', 'J2', 'bond', 4); % Next NN along a
testCase.swobj.addaniso('A');
testCase.swobj.table('bond',1:4)
% idx    subidx         dl               dr          length      matom1      idx1      matom2      idx2                    matrix                
%     ___    ______    _____________    _____________    ______    __________    ____    __________    ____    ______________________________________
% 
%      1       1       1     0     0    1     0     0        2     {'atom_1'}     1      {'atom_1'}     1      {'J1'    }    {0×0 char}    {0×0 char}
%      2       1       0     1     0    0     1     0        3     {'atom_1'}     1      {'atom_1'}     1      {0×0 char}    {0×0 char}    {0×0 char}
%      3       1       1    -1     0    1    -1     0    3.606     {'atom_1'}     1      {'atom_1'}     1      {0×0 char}    {0×0 char}    {0×0 char}
%      3       2       1     1     0    1     1     0    3.606     {'atom_1'}     1      {'atom_1'}     1      {0×0 char}    {0×0 char}    {0×0 char}
%      4       1       2     0     0    2     0     0        4     {'atom_1'}     1      {'atom_1'}     1      {'J2'    }    {0×0 char}    {0×0 char}

% free
testCase.swobj.genmagstr('mode', 'helical', 'S', [0; 0; 1], ...
                                     'k',[1,0,0], 'n', [0,1,0]); % FM
out = testCase.swobj.optmagsteep('nExt', [2,1,1], ...
    'boundary', {'free', 'free', 'free'});
out.e(end) % 3.9
testCase.swobj.magstr.S % [0 0; 0 0; -1 1]

% per
testCase.swobj.genmagstr('mode', 'helical', 'S', [0; 0; 1], ...
                                     'k',[1,0,0], 'n', [0,1,0]); % FM
out = testCase.swobj.optmagsteep('nExt', [2,1,1], ...
    'boundary', {'per', 'per', 'per'}); % self-coupling - interactions removed
out.e(end) % 3.9
testCase.swobj.magstr.S % [0 0; 0 0; -1 1]

I can get round this by extending the unit cell which removes the self-coupling warning and I do get a different structure, but it looks a bit dodgy for free and it thinks they have the same energy whatever I put in for J2...). Here is the structure fro nExt=[6,1,1] image