Page 1 of 1

Absolute weights in the absence of auto-scaling

Posted: Mon Jun 02, 2025 11:39 pm
by katarkon

I see that esfit() with EasySpin's built-in functions like garlic with the FitOpt.AutoScale = 'none' ignores defined Sys.weight and return it ad a weighted value at the range 0..1. My custom simulation functions work fine.


Re: Absolute weights in the absence of auto-scaling

Posted: Tue Jun 03, 2025 11:01 am
by Stefan Stoll

Thanks. Can you please provide an example script that we use to troubleshoot?


Re: Absolute weights in the absence of auto-scaling

Posted: Tue Jun 03, 2025 10:03 pm
by katarkon

Yes, of course. The spectrum is attached.
clear;
[x, y, par] = eprload('AnthTCNE_new\AntTCNE_DMCHA_lod_PBN_1day\AntTCNE_DMCHA_lod_PBN_1day_005.xml');
y=y';
Exp.Range=[min(x) max(x)];
x=10*x;
Exp.mwFreq=par.MwFreq;
Exp.nPoints=numel(x);

Sys.Nucs = '14N,1H';
Sys.n = [1 1];
Sys.A=mt2mhz([14.38 2.21]/10); %in G, 1mT=10G
Sys.g=2.00915;
Sys.lw=[0.06 0.025]; %Gauss Lorentz
Sys.weight=10;

Sys1.Nucs = '14N,14N,14N,1H';
Sys1.n = [1 1 1 1];
Sys1.A=mt2mhz([1.27 1.40 1.11 3.35]/10); %in G, 1mT=10G
Sys1.g=2.00574;
Sys1.lw=[0.048 0.065]; %Gauss Lorentz
Sys1.weight=10;

Opt.Method = 'exact';

FitOpt.Method = 'simplex fcn';
FitOpt.AutoScale = 'none';
FitOpt.BaseLine = 2;

Vary.A=0.021*Sys.A;
Vary.g=0.001;
Vary.lw=0.995*Sys.lw;
Vary.weight=0.99999*Sys.weight;

Vary1.A=0.21*Sys.A;
Vary1.g=0.001;
Vary1.lw=0.995*Sys.lw;
Vary1.weight=0.99999*Sys1.weight;

%esfit(y,@garlic,{Sys,Exp,Opt},{Vary},FitOpt); %garlic iso, pepper aniso
esfit(y,@garlic,{{Sys,Sys1},Exp,Opt},{{Vary,Vary1}},FitOpt);
%esfit(y,@garlic,{Sys1,Exp,Opt},{Vary1},FitOpt);


Re: Absolute weights in the absence of auto-scaling

Posted: Thu Jun 05, 2025 11:35 am
by Stefan Stoll

Thanks. This looks like a case where the initial values for Sys.weight are too far from the minimum. The simulated spectrum is about 410 times more intense than the experimental spectrum, so without autoscale initial values for Sys.weight need to be on the order of 0.05 or so to have a good chance that the optimization algorithm is able to find the minimum.

This works for me:

Code: Select all

clc, clear

[B, spcexp, par] = eprload('AntTCNE_DMCHA_lod_PBN_1day_005.xml');
spcexp = spcexp.';

Exp.mwFreq = par.MwFreq;
Exp.Range = [min(B) max(B)];
Exp.nPoints = numel(B);

SysA.Nucs = '14N,1H';
SysA.n = [1 1];
SysA.A = [40.228 6.187];
SysA.g = 2.00901;
SysA.lw = [0.060 0.0279];
SysA.weight = 10;

SysB.Nucs = '14N,14N,14N,1H';
SysB.n = [1 1 1 1];
SysB.A = [3.639 3.980 3.062 9.273];
SysB.g = 2.00564;
SysB.lw = [0.0517 0.0694]; %Gauss Lorentz
SysB.weight = 10;

spcsim0 = garlic({SysA,SysB},Exp);
fprintf('Intensity of sim. spectrum: %e\n',max(spcsim0));
fprintf('Intensity of exp. spectrum: %e\n',max(spcexp));

Opt.Method = 'exact';

FitOpt.Method = 'simplex fcn';
FitOpt.AutoScale = 'none';
FitOpt.BaseLine = 2;

% Set start values
SysA.weight = 0.05;
SysB.weight = 0.05;

varyA.A = 0.021*SysA.A;
varyA.g = 0.001;
varyA.lw = 0.995*SysA.lw;
varyA.weight = 0.99999999*SysA.weight;

varyB.A = 0.21*SysB.A;
varyB.g = 0.001;
varyB.lw = 0.995*SysB.lw;
varyB.weight = 0.99999999*SysB.weight;

esfit(spcexp,@garlic,{{SysA,SysB},Exp,Opt},{{varyA,varyB}},FitOpt);