Different results in version 5

A place to report and discuss potential bugs
Post Reply
yausern
Newbie
Posts: 3
Joined: Tue Sep 01, 2015 3:59 am

Different results in version 5

Post by yausern »

I have some programs that I have been running under version 4.5.5. Since this version is now expired I have upgraded to version 5.
However the results from the same code (with the exception of the new CrystalOrientations syntax) produce different results in the new version.

The code is fairly simple (single absoption spectrum for a given spin system and crystal orientation displayed alongside an experimental measurement).

Code: Select all

clear;
clf;
clc;
Sys.S = 7/2;
Sys.g = 1.992;
b4 = -145.3;
b6 = -0.3;
Sys.B4 = [5./60.*b4 0 0 0 b4/60. 0 0 0 0];          % q = +4,+3,+2,+1,0,-1,-2,-3,-4
Sys.B6 = [0 0 -21./1260.*b6 0 0 0 b6/1260. 0 0 0 0 0 0];          % q = +4,+3,+2,+1,0,-1,-2,-3,-4

Sys.lwpp = 2.3;
Exp.mwFreq = 1.4956; 
Exp.Temperature = 4.2;
Exp.Harmonic = 0;
Exp.nPoints = 1000;
Exp.Range = [0 200];      % in mT

load('./140908_11R_FGd_bz_sweep_4_folder/spec.mat') %Experiment data for comparison
expSpec = 10.^(expSpec/10.);
expSpec = expSpec - max(expSpec);
expSpec = expSpec/abs(min(expSpec))+1;

Opt.Output = 'separate';  % make sure spectra are not added up
theta = 42.25/180*pi;
phi =0;
%Exp.Orientations = [phi ; theta];
Exp.CrystalOrientation = [phi ; theta];
[Field1,Spec1] = pepper(Sys,Exp,Opt);
Field1 = Field1/1000;
Spec1 = -Spec1;
Spec1 = Spec1 - max(Spec1);
Spec1 = Spec1/abs(min(Spec1))+1;
        
plot(expB, expSpec, Field1,Spec1-1);
axis([0 0.1 -1 1.1]);
mytitle = strcat('theta = ', num2str(theta/pi*180), '  phi = ', num2str(phi/pi*180));
title(mytitle);
myfilename = strcat('./matlab_figs/plot_',sprintf('%03d',1),'.png');
print('-dpng', myfilename);

clear Sys Exp;
The result for both versions is shown in the attached image (I set the date back to allow me to run version 4.5.5). Each graph contains the experimental data above the simulated spectra. What could be the problem?

I suspect that it may have something to do with how the crystal orientation is specified. I always found it odd that the documentation specifies that "CrystalOrientations" should contain "one set of three angles per row", but the example file "crystalorientations.m" uses:

Code: Select all

% Generate orientations in a single rotation plane
rotN = [0 1 0];  % rotation axis
[phi,theta] = rotplane(rotN,[0 pi],31);
Exp.CrystalOrientation = [phi; theta];
which generates a matrix of two angles per row. How are the angles supposed to be specified? For my purposes, the second method is preferable and I have made use of it in my programs.
I have also tried sweeping the angles in order to find the spectrum I obtained in 4.5.5 but I have had no success so far.

Thank you in advance
Attachments
plot.png
plot.png (30.13 KiB) Viewed 4306 times
Stefan Stoll
EasySpin Creator
Posts: 1057
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Different results in version 5

Post by Stefan Stoll »

This is indeed inconsistent behavior between 4.5.5 and 5.0.

First of all, if you have a crystal, you always need 3 Euler angles to specify its orientation in the spectrometer. Two of the Euler angles (phi, theta) determine the orientation of the crystal relative to the static field B0 and therefore determine the resonance field. The third Euler angle (chi) co-determines the orientation of the crystal relative to the microwave excitation field B1 and therefore determines the line intensity via the transition dipole moment.

The difference between 4.5.5 and 5.0 lies in what is assumed about the third Euler angle chi if you only give two Euler angles.

In 4.5.5, when you specified only two angles in Exp.Orientations, the program integrated over the third Euler angle (0..pi), essentially giving not a single-crystal spectrum, but a sum spectrum over all crystals with the same orientation relative to B0, but different orientations relative to B1. This is not a realistic situtation, and therefore it is wrong behavior and needed to be changed.

In 5.0, ES sets chi=0 if you give only two angles in Exp.CrystalOrientation. The resulting spectrum is a true single crystal spectrum.

If you want to see the effect of the third angle on the single-crystal spectra, use

Code: Select all

clear

Sys.g = [2 3 4];
Sys.lwpp = 5;

Exp.mwFreq = 9.5;
Exp.Range = [150 350];

phi = rand*2*pi;
theta = rand*pi;

Exp.CrystalOrientation = [phi theta 0];
[x1,y1] = pepper(Sys,Exp);

Exp.CrystalOrientation = [phi theta pi/2];
[x2,y2] = pepper(Sys,Exp);

plot(x1,y1,x2,y2);
The two spectra have the same line positions, but, depending on the spin system, different line intensities. Typically, this effect is not very pronounced. However, your spin system seems to be particularly sensitive to the effect.

Bottomline:
- 4.5.5 Exp.Orientations = [phi theta] gave a partially integrated spectrum that was unrealistic.
- 4.5.5 Exp.Orientations = [phi theta chi] gave a true single-crystal spectrum.
- 5.0 Exp.CrystalOrientation = [phi theta] is interpreted as [phi theta 0].
- 5.0 Exp.CrystalOrientation = [phi theta chi] gives a true single-crystal spectrum.

Probably, the best solution forward for ES is to not automatically supplement the third Euler angle and to always require it as input.

Thanks for pointing out the inconsistencies in the examples. We'll fix them.

Hope this helps.
yausern
Newbie
Posts: 3
Joined: Tue Sep 01, 2015 3:59 am

Re: Different results in version 5

Post by yausern »

Thank you very much for the clarification. This has solved my problem and helped solve a lot of my doubts about how ES treats different crystal orientations.
By pure coincidence, the old behavior corresponds more closely to my experimental conditions than the new behavior. In any case, I can now reproduce either type of spectrum.
Thanks again and best regards
Stefan Stoll
EasySpin Creator
Posts: 1057
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Different results in version 5

Post by Stefan Stoll »

Great!
Post Reply