Output order for resfreqs_matrix and resfreqs_perturb

A place to report and discuss potential bugs

Output order for resfreqs_matrix and resfreqs_perturb

Postby katarkon » Tue May 16, 2017 4:44 am

Surprisingly, the order of line positions calculated by resfreqs_matrix() and resfreqs_perturb() is different. This makes the functions non-interchangeable. It should be better that both functions return equal results.
Here the script illustrating the problem.
Code: Select all
Sys3.g = 2.00552;
Sys3.A = mt2mhz([7.82, 1.89]/10);
Sys3.Nucs = '14N,1H';
Param.Field=344;
Op.PerturbOrder=2;
[pos,int]=resfreqs_matrix(Sys3,Param,Op);
disp(pos');
[pos,int]=resfreqs_perturb(Sys3,Param,Op);
disp(pos');

It returns the follow output:
Code: Select all
>> resfreq_test
    9.6806    9.6587    9.6753    9.6367    9.6534    9.6315

    9.6315    9.6367    9.6534    9.6587    9.6753    9.6806

The line positions are the same, but their order is different.
katarkon
Resident User
 
Posts: 83
Joined: Mon Jan 12, 2015 4:01 am

Re: Output order for resfreqs_matrix and resfreqs_perturb

Postby Stefan Stoll » Thu May 18, 2017 3:36 pm

This is indeed an inconsistency. We will open an issue and investigate it. Thanks for reporting!
Stefan Stoll
EasySpin Creator
 
Posts: 516
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Output order for resfreqs_matrix and resfreqs_perturb

Postby katarkon » Mon Dec 04, 2017 3:20 am

I see the problem is still unsolved in last version (5.2.11). Is any progress in the solving?
I found that the problem has unpleasant effect on the order of output for pepper if Opt.Output='separate' is defined. It is absolutely different for matrix, perturbation or hybrid treatment. Moreover, for last method the order changes absolutely unpredictable with including of some nuclei in Opt.HybridCoreNuclei.
I think the problem is the order of transition selection inside the function resfields. Here the script illustrating the problem
Code: Select all
Sys.g = 2;
Sys.Nucs = '14N,14N';
Sys.lwpp = [0,0.02];
Sys.A = [15; 15]; % MHz
Exp.Range=[340 348];
Exp.mwFreq = 9.65;
[Pos,Amp,Wid,Trans,Grad] = resfields(Sys,Exp);
disp(Trans);
[Pos,Amp,Wid,Trans,Grad] = resfields_perturb(Sys,Exp);
disp(Trans);

The attempt to use the list of transitions was failed.
Code: Select all
Sys.g = 2;
Sys.Nucs = '14N,14N';
Sys.lwpp = [0,0.02];
Sys.A = [15; 15]; % MHz
Exp.Range=[340 348];
Exp.mwFreq = 9.65;
[Pos,Amp,Wid,Trans,Grad] = resfields_perturb(Sys,Exp);
disp(Trans);
Opt.Transitions=Trans;
[Pos,Amp,Wid,Trans,Grad] = resfields(Sys,Exp,Opt);
disp(Trans);

This is completely unexpected. At last, if Opt.Transitions='all' is used the results are more strange.
Code: Select all
Sys.g = 2;
Sys.Nucs = '14N,14N';
Sys.lwpp = [0,0.02];
Sys.A = [15; 15]; % MHz
Exp.Range=[340 348];
Exp.mwFreq = 9.65;
Opt.Transitions='all';
[Pos,Amp,Wid,Trans,Grad] = resfields_perturb(Sys,Exp,Opt);
disp(Trans);
[Pos,Amp,Wid,Trans,Grad] = resfields(Sys,Exp,Opt);
disp(Trans);
[Pos,Amp,Wid,Trans,Grad] = resfields_perturb(Sys,Exp);
disp(Trans);
[Pos,Amp,Wid,Trans,Grad] = resfields(Sys,Exp);
disp(Trans);

UPD. Opt.Transitions='all' affects on the output order of pepper function too. The order of the spectra becomes less unpredictable for matrix and hybrid treatments but just differs from perturbation method.
katarkon
Resident User
 
Posts: 83
Joined: Mon Jan 12, 2015 4:01 am

Re: Output order for resfreqs_matrix and resfreqs_perturb

Postby Stefan Stoll » Mon Dec 04, 2017 1:48 pm

This issue is still unresolved. There is a bug in the level indices in the transition output of resfreqs_perturb and resfields_perturb which needs to be fixed first before the sorting can be addressed.

Concerning the sorting, we will likely not be able to guarantee ordering that is identical between all functions and all options settings, but we will try.
Stefan Stoll
EasySpin Creator
 
Posts: 516
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Output order for resfreqs_matrix and resfreqs_perturb

Postby katarkon » Tue Dec 05, 2017 4:29 am

I suggest that sorting of output of the function pepper according to resonance fields values (e.g. in order of increasing the field) should be enough for temporary solution. A special key, such as Opt.Output = 'sorted', can be used to not violate the compatibility.
Fixing the bug with level indexing is better, of course.
katarkon
Resident User
 
Posts: 83
Joined: Mon Jan 12, 2015 4:01 am


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron