Unexpected separate output of exchange() function
Unexpected separate output of exchange() function
It should be expected that separate output of the function returns a set of the spectra with single line for each. But exchange() function in slow rate limit returns some spectra with several lines. Is any way to rid it out?
- Attachments
-
- 1.png (3.19 KiB) Viewed 6819 times
-
- EasySpin Creator
- Posts: 1127
- Joined: Mon Jul 21, 2014 10:11 pm
- Location: University of Washington
Re: Unexpected separate output of exchange() function
Looking at the code of
You will have to modify this to store the spectra separately not only for each line (
It might be necessary to adjust some other spots in the code as well.
exchange
, it can be seen that each spectrum is the sum over all the sites of a particular line:
Code: Select all
for iLine=1:nLines
spc_ = 0;
for iSite=1:nSites
% Calculation of spc_
end
if separateOutput
spc(iLine,:) = spc_;
else
spc = spc + spc_;
end
end
iLine
) but also for each site (iSite
). Something along the lines of the following should work:Code: Select all
% code within Opt.Method = 2 branch of switch statement
idx = 1;
for iLine=1:nLines
for iSite=1:nSites
% Calculation of spc_
if separateOutput
spc(idx,:) = spc_;
idx = idx + 1;
else
spc = spc + spc_;
end
end
end
Re: Unexpected separate output of exchange() function
Yes, this idea should be working, although there are some problems with such 'hyperseparated' output.
Firstly, some zero spectra are generated. Surprisingly, in the case of fast exchange a pair of zero spectrum and line spectrum is generated instead of expected pair of equal spectra. Of course, the zero spectra may be easily detected and discarded
However Opt.reduce parameter should be 0 for fast exchange and 1 for slow one to get the predictable results. More sadly, the removing of the duplicates works only for two-site mutual exchange (although its algorythm looks adoptable for more general cases).
Secondly, if nuclei with I>1/2 are used, the order of the spectra becomes unpredictable. I propose that the 'brute force' code will be working:
Firstly, some zero spectra are generated. Surprisingly, in the case of fast exchange a pair of zero spectrum and line spectrum is generated instead of expected pair of equal spectra. Of course, the zero spectra may be easily detected and discarded

Secondly, if nuclei with I>1/2 are used, the order of the spectra becomes unpredictable. I propose that the 'brute force' code will be working:
Code: Select all
idx = 1;
for iLine=1:nLines
for iSite=1:nSites
% Calculation of spc_
if separateOutput
spc(idx,:) = spc_;
[~,B0] = max(spc_); %approximate resonance position
spc(idx,nPoints+1)=B0; %indexing the spectra by resonance position
idx = idx + 1;
else
spc = spc + spc_;
end
end
if separateOutput
spc=sortrows(spc,nPoints+1); %sorting
spc(:,nPoints+1)=[]; %removing indexes
end
end
- Attachments
-
- two 14N nuclei, slow exchange, reducing on
- 3.png (3.63 KiB) Viewed 6808 times
-
- slow exchange, reducing off
- 2.png (3.41 KiB) Viewed 6808 times
-
- fast exchange, reducing on
- 1_.png (3.11 KiB) Viewed 6808 times