Weighting of simulations

General forum for EasySpin: questions, how to's, etc.
Post Reply
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Weighting of simulations

Post by AMullen »

Hi,

I'm trying to simulate and fit two systems to several spectra, showing progression of weighting/majority contributions of one system to the other. However, this has been difficult to make sense of in regards to the Sys.weight variable. For a comparison, I have done the weighting progression manually (i.e. simulate each of the systems, multiply one by 0.9 and the other by 0.1 and add together, then 0.8 & 0.2, 0.7 & 0.3 etc.). A figure of this is attached.

When I take one of the spectra, and try to fit it with a Sys1 and Sys2 (relevant segment of code attached below) and it works but I get a 'best fit' of about 75 'weight' for Sys1, and 25 for Sys2 (only varying weight and line width). A screen shot of the fitting window is also attached. However, you can see from my manual weighting figure the spectrum looks very much like the purple line, which was a 10% Sys1 to 90% Sys2 simulation.

Am I misunderstanding how the Sys.weight function works?

Thanks,
Anna

Code: Select all

Sys1.g = 2.00473;
Sys1.Nucs = 'B,1H,14N,1H';
Sys1.n = [1 18 6 9];
Sys1.A = [8.3 1.5 1.2 2.8]*2.804;
Sys1.lwpp = [0.3];
Sys1.weight = 75;
Vary1.lwpp = [0.15];
Vary1.weight = 10;

Sys2.g = 2.0064;
Sys2.Nucs = '14N';
Sys2.n = [1];
Sys2.A = [13.3]*2.804;
Sys2.lwpp = [0.2];
Sys2.weight = 25;
Vary2.lwpp = [0.15];
Vary2.weight = 10;

Exp.mwFreq = 9.485481;
Exp.CenterSweep = [338 10];
Exp.nPoints = 2048;

esfit('garlic',y2,{Sys1,Sys2},{Vary1,Vary2},Exp,[]);
Attachments
Figure of manually weighted simulations
Figure of manually weighted simulations
Screen Shot 2018-02-21 at 17.24.19.png (205.67 KiB) Viewed 2726 times
Screen shot of fitting window
Screen shot of fitting window
Screen Shot 2018-02-21 at 17.08.20.png (83.15 KiB) Viewed 2727 times
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: Weighting of simulations

Post by Matt Krzyaniak »

One thing you should be careful with, the weighting corresponds to effectively the area under the curve. So if you're increasing the linewidth, the relative amplitude of your spectrum may decrease, even though you didn't touch the weighting. So it'd probably be best to keep the linewidth fixed if you're trying to extract meaningful weights across a series.

In addition if you're going to be fitting the weights of two spectra, it's best to keep one fixed as they are correlated, for example you multiply them both by ten they will show the same relative difference. So fix one weight to 1 and let the other vary around it.
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Re: Weighting of simulations

Post by AMullen »

Thanks for the advice and explanation. I've now tried setting the Sys2 weight fixed at 1 (and kept line widths fixed too), with Sys1 varying around it, and vice versa; it still goes towards a heavier relative weighting on Sys1 than Sys2. This doesn't make sense to me when I look at the features of the spectrum.

I have tried with another spectrum, where the contributions of Sys1:Sys2 appear more even (i.e. around 70:30 or 60:40) based on my figure. However, this fitting is also dominated by the Sys1 contribution (~98:2). Could the fitting be exaggerating the contributions of the broader/less well-resolved system?
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: Weighting of simulations

Post by Matt Krzyaniak »

if you're just concerned about the ratio of two spectra, you could just calculate the spectra individually and apply simple linear regression to obtain the best fit.

something like:

Code: Select all

Sys1.g = 2.00473;
Sys1.Nucs = 'B,1H,14N,1H';
Sys1.n = [1 18 6 9];
Sys1.A = [8.3 1.5 1.2 2.8]*2.804;
Sys1.lwpp = [0.3];

Sys2.g = 2.0064;
Sys2.Nucs = '14N';
Sys2.n = [1];
Sys2.A = [13.3]*2.804;
Sys2.lwpp = [0.2];


Exp.mwFreq = 9.485481;
Exp.CenterSweep = [338 10];
Exp.nPoints = 2048;

[x1,y1] = garlic(Sys1,Exp);

[x2,y2] = garlic(Sys2,Exp);

fit = [y1; y2];
a = expspec*fit'/(fit*fit');
fit = a*fit;
You can do something similar and simultaneously fit all of your spectra, just expand expspec from a vector into a matrix of your data, assuming the frequency is the same.
AMullen
User
Posts: 14
Joined: Mon Nov 16, 2015 8:58 am

Re: Weighting of simulations

Post by AMullen »

It turns out the weightings I was getting previously were indeed correct (or at least approximately right), but I hadn't taken into account the actual spectral width/area under the curve (as you mentioned) of the contributions when doing the manual calculations. The values I got out from the linear regression you suggested were 3:1, in agreement with the weightings of ~75:25 from the esfit function.

Thank you for your time/effort in helping me resolve this!
Post Reply