I just started to work with easyspin a few days ago but I recognized some strange effect using esfit with pepper. I try to fit a spectrum at 4 Kelvin with two Fe-states by using esfit. After that, I take the results of esfit and simulate each Fe-state on its own with pepper to get the single effect of each state. Finally, I take the sum of the simulations which should be equal to the result bestspc of esfit. Surprisingly it is not. Even if I would try to rescale the simulations, I wouldn't receive the bestspc result. I attached a plot which shows my problem.
Code: Select all
%load spectrum data
[fieldFn4K intensityFn4K] = textread('4K.txt','%f %f %*f %*f %*f',...
'headerlines',1);
%basecorr
[intensityFn4K Bline32] = basecorr(intensityFn4K,1,1);
%Scaling
intensityFn4K = intensityFn4K/(max(intensityFn4K)-min(intensityFn4K));
%convert field from Gauß to mT
fieldFn4K = fieldFn4K/10;
%specify starting values
%first component
g1 = [2.22 2.43 2.07];
D1 = [3.037*10^5 0.679*10^5] ;
lwpp1 = 9.71;
weight1 = 0.7557;
Sys1 = struct('S',3/2, 'g', g1, 'lwpp', lwpp1, 'weight', weight1,'D',D1);
Sys1 = nucspinadd(Sys1, 'Fe',0);
%second component
g2 = [1.993 1.98 1.99];
D2 = [1.0066*10^5 (1/3)*1.0066*10^5];
lwpp2 = 7.3;
weight2 = 3.08;
Sys2 = struct('S',5/2, 'g', g2, 'lwpp', lwpp2, 'weight', weight2,'D',D2);
Sys2 = nucspinadd(Sys2, 'Fe',0);
%specify the variables to fit
Vary1 = struct('g',[0.2 0.2 0.2],'lwpp',2,'D',[2*10^5 0.1914*2*10^5], 'weight', 0.5);
Vary2 = struct('g',[0.2 0.2 0.2],'lwpp',0, 'D', [0 0], 'weight', 0.5);
%specify experimental setup
Exp = struct('mwFreq', 9.4, 'Range', [min(fieldFn4K) max(fieldFn4K)], 'nPoints', length(fieldFn4K), 'Temperature', 4);
%options for esfit
FitOpt.Scaling = 'maxabs';
FitOpt.Method = 'simplex fcn';
FitOpt.maxTime = 10;
%start fitting
[BestSys BestSpc] = esfit('pepper', intensityFn4K, {Sys1, Sys2},...
{Vary1, Vary2}, Exp, [], FitOpt);
%define new values for simuation
g1 = BestSys{1,1}.g;
lwpp1 = BestSys{1,1}.lwpp;
weight1 = BestSys{1,1}.weight;
D1 = BestSys{1,1}.D;
Sys1 = struct('S',1/2, 'g', g1, 'lwpp', lwpp1, 'weight', weight1,'D',D1);
Sys1 = nucspinadd(Sys1, 'Fe',0);
%simulation for first comp.
[xSim1 ySim1] = pepper(Sys1,Exp);
g2 = BestSys{1,2}.g;
lwpp2 = BestSys{1,2}.lwpp;
weight2 = BestSys{1,2}.weight;
D2 = BestSys{1,2}.D;
Sys2 = struct('S',5/2, 'g', g2, 'lwpp', lwpp2, 'weight', weight2,'D',D2);
Sys2 = nucspinadd(Sys2, 'Fe',0);
[xSim2 ySim2] = pepper(Sys2,Exp);
overlay = ySim1+ySim2;
scalingFactor = overlay/(max(overlay)-min(overlay));
ySim1 = ySim1 * scalingFactor;
ySim2 = ySim2 * scalingFactor;
overlay = overlay * scalingFactor;