esfit ignores some variables

General forum for EasySpin: questions, how to's, etc.
Locked
mkbowman
Newbie
Posts: 1
Joined: Mon Aug 11, 2014 6:53 am

esfit ignores some variables

Post by mkbowman »

We have been fitting some solution EPR spectra to determine natural abundance C-13 hyperfine couplings using esfit. The fitting went fine until seeral months ago. Since that time, we have consistently had a fitting problem with esfit on this problem. All other sitations where we use esfit seem to work fine. Unfortunately, we can’t remember whether it started to appear with a new version of EasySpin, MatLab or Linux. But it has been there for the last few updates.

The problem is that esfit will not vary some or all of the C-13 couplings when Simplex or Levenburg-Marquardt algorithms are chosen. I have attached a set of files showing this. One is the experimental spectrum which has several pairs of C-13 natural abundance hyperfine lines and one main large line with only C-12 in it. There is also a script for fitting it which we simplified to one C-13 (a bad model) in order to illustrate the problem with minimal number of variables. When we run this script (or the original with 5 C-13 splittings) LM or Simplex varies only the g and LW parameters and doesn’t vary the A. Even if we set g and lw as constant, the fitting starts as if it were setting things up, but doesn’t vary the A.

Fitting works fine with particle swarm, everything gets optimized, but slowly.

One thought is that the problem has something to do with natural abundance in the spectral simulation, perhaps it gets derivatives only using the C-12 spectrum. Another thought is that the natural abundance C-13 is so small that it makes no contribution to the derivatives or Jacobian because of roundoff or truncation so the Jacobian doesn’t have its full dimensionality. But those shouldn’t apply to Simplex fits. This is the only fitting of isotropic spectra that we do, everything else is pulsed or powder (and works). I hope there is a clue here.

Is this happening to anyone else?
Attachments
easyspin test.rar
You need to change the path to the datafile.
(204.64 KiB) Downloaded 589 times
Morgan Bye
EasySpin Guru
Posts: 18
Joined: Thu Jul 24, 2014 9:44 am
Location: BC Cancer, Canada
Contact:

Re: esfit ignores some variables

Post by Morgan Bye »

Ok, so I've played around with your code a little bit for the last 15 minutes over coffee and offer some suggestions:

I don't know how Stefan has changed easyfit, but if you go back to ES versions from the start of Jan '13 you can try with the old versions when it did not have the GUI - just play around with licenses to get around the time bomb.

Anyway, actual useful suggestions:

1) In the GUI change "Target" from "data as is" to "derivative" or "Fourier transfrom"
- you're looking for a subtle difference on a strong signal, so trying to fit in 1st derivative will never work

2) I'd personally use fitting method "Genetic algorithm", I personally have found it to be a more intelligent searching of parameters

3) Natural abundance of carbon just doesnt cut it. The central line of the trityl is so strong it overpowers everything else in the fitting. To get around this you need to set the 13C levels artificially high and let the algorithm work them down. In my case, I adjusted the spin system to look like this:

Code: Select all

Sys.g= 2.0031;
Sys.lwpp = [0.05536 0.0016151];
Sys.Nucs = '(12,13)C';     
Sys.Abund = [0.95 0.05];
Sys.A= [32.1305];
This way, the fitting algorithm "finds" the 13C and keeps it in the refinement, rather than jumping straight to the assumption of 100 % 12C.

Obviously, to make this work requires the addition of another variable:

Code: Select all

vary.Abund = [0.05 0.05];
Stefan Stoll
EasySpin Creator
Posts: 1108
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: esfit ignores some variables

Post by Stefan Stoll »

I think I have located the origin of this behavior. Both the LM and the simplex algorithm depend on simulating spectra with slightly different parameters to determine local derivatives in the parameter space (Jacobian for LM, a small simplex for the simplex algorithm). The local derivatives then guide the searches in these two algorithms.

For the C13 hyperfine coupling in the given script, the derivatives are zero, even though in principle they shouldn't. The search range for the hf coupling is quite small,and both algorithms use very small steps within this search range to calculate local derivatives.

Now here's the source of the trouble: Using garlic, you ca identical spectra for slightly different hf couplings. That results in a zero derivative, and consequently the algorithms get stuck. Here's an illustration

Code: Select all

clear, clc

Exp.mwFreq = 9.445196;
Exp.Range = [334.88 338.88];
Exp.nPoints = 2048;
Exp.ModAmp = 0.04;

Sys.g= 2.0031;
Sys.lwpp = [0.05536 0.0016151];
Sys.Nucs = '13C';

Sys.A = 32.13;
[Field,Spec1g] = garlic(Sys,Exp);
Sys.A = 32.16;
[Field,Spec2g] = garlic(Sys,Exp);

plot(Field,Spec1g,Field,Spec2g);
max(abs(Spec2g-Spec1g))
garlic constructs a stick spectrum first by binning lines into the 2048-point spectral array, and then convoluting it with the linewidth. Clearly, the two hf lines end up in the same bins for the two hf values.

Since pepper uses a more sophisticated method for spectrum construction (interpolative copy from a lineshape template), I suggest using pepper instead of garlic.
Locked