Skip to content

Commit

Permalink
Add test for norm explicitly true/false
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccafair committed Aug 17, 2022
1 parent aac29ed commit e8afe01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions +sw_tests/+unit_tests/unittest_spinw_genmagstr.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
{'epsilon', complex(1)}, ...
{'phid', i}};
rotate_phi_inputs = {{'phi', pi/4}, {'phid', 45}, {'phi', pi/4, 'phid', 90}};
input_norm_output_F = {
% norm_bool, mag_str.F
{true, [2; 0; -2i]}, ...
{false, [1; 0; -1i]}
};
end
methods (TestMethodSetup)
function setup_chain_model(testCase)
Expand Down Expand Up @@ -202,6 +207,18 @@ function test_helical_any_S_parallel_to_n_warns(testCase)
'F', [-sqrt(9/8)*1i; sqrt(9/8); sqrt(9/8)]);
testCase.verify_obj(expected_mag_str, swobj_tri.mag_str);
end
function test_helical_S2_norm(testCase, input_norm_output_F)
swobj = spinw();
swobj.genlattice('lat_const', [3 8 8], 'angled', [90 90 90]);
swobj.addatom('r', [0 0 0], 'S', 2);
k = [1/3 0 0];
swobj.genmagstr('mode', 'helical', 'S', [1; 0; 0], 'k', k, ...
'n', [0 1 0], 'norm', input_norm_output_F{1});
expected_mag_str = testCase.default_mag_str;
expected_mag_str.k = k';
expected_mag_str.F = input_norm_output_F{2};
testCase.verify_obj(expected_mag_str, swobj.mag_str);
end
function test_direct_fm_chain(testCase)
swobj = copy(testCase.swobj);
swobj.genmagstr('mode', 'direct', 'k', [0 0 0], ...
Expand Down
2 changes: 1 addition & 1 deletion swfiles/@spinw/genmagstr.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function genmagstr(obj, varargin)
error('spinw:genmagstr:WrongMode','Wrong param.mode value!');
else
input_arg_names = varargin(1:2:end);
input_arg_names(ismember(input_arg_names, "mode")) = [];
input_arg_names(ismember(input_arg_names, ["mode" "norm"])) = [];
unused_args = setdiff(input_arg_names, mode_args.(param.mode));
if ~isempty(unused_args)
warning('spinw:genmagstr:UnusedInput', ...
Expand Down

0 comments on commit e8afe01

Please sign in to comment.