esfit constraint: multiple component with fixed ratio

General forum for EasySpin: questions, how to's, etc.
Post Reply
gkwchow
Newbie
Posts: 1
Joined: Tue Apr 07, 2015 12:19 pm

esfit constraint: multiple component with fixed ratio

Post by gkwchow »

Hi! I read the post to apply additional constraints when using esfit (viewtopic.php?f=3&t=142&hilit=constrain) for a single spin system and am adapting it to my system. Specifically, I have multiple nitroxides in a mixture (multiple systems) and am trying to pull out concentration changes over time. To that end, I introduce a dummy peak at g = 2.035, weight = 5 as an internal standard and derive relative concentrations by dividing the weight of individual components over that of this internal standard.

Since one of the components (SysX{4}) is tiny compared to others but has a signal at a very different field from the rest of the nitroxides, it can be simulated by only using a small portion of the spectra (call that weight x, SysX{4}.rat) and the internal standard. If not done this way, esfit would try to give it a non-zero concentration to help simulate other parts of the spectrum for some scans.

Then, I try to simulate the whole spectrum with other components. The internal standard is allowed to vary (ie the weight of it is now 5y) but I want to keep the weight of the tiny component to have constant ratio to the internal standard (ie xy).

I have written a custom function garlicX:

Code: Select all

function [x,y] = garlicX(SysX,Exp,SimOpt)
%garlicX Component fixed proportion variation
%   Generates components on a fixed ratio
% SysX
SysX{4}.weight=SysX{4}.rat*SysX{5}.weight;
[x,y]=garlic(SysX,Exp,SimOpt);
end
If I simply call garlicX on an arbitrary system of 4 nitroxides (tiny component SysX{4}) and the dummy internal standard (SysX{5} and Sys_dum), it behaves like garlic while taking into account the ratio coefficient (SysX{4}.rat) and plotting it out.

However, when I tell esfit to call the following,

Code: Select all

esfit('garlicX',epr_spc+5*transpose(garlic(Sys_dum,Exp)),Sys,VaryX,Exp);
I get this:

Code: Select all

SysX = 

         g: 2.0061
      Nucs: '14N,1H'
         A: [34.6404 32.9124]
      lwpp: [0.0384 0.0386]
    weight: 5

Cell contents reference from a non-cell array object.

Error in garlicX (line 5)
SysX{4}.weight=SysX{4}.rat*SysX{5}.weight;
In other words, garlicX functions outside esfit, but when it is used in esfit, it only reads the 1st component. Currently, I am circumventing this by simulating all 5 components first and then the tiny component SysX{4}, but this would introduce (albeit small) error during the first step. My questions are

1. Is this due to how esfit works such that it made garlicX read only the 1st component in SysX?
2. Is there a better algorithm that can solve this problem?

Thanks!
Stefan Stoll
EasySpin Creator
Posts: 1073
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: esfit constraint: multiple component with fixed ratio

Post by Stefan Stoll »

It is possible that esfit does not correctly handle this case. However, I am not able to reproduce this (using ES 5.0.18).

Here is my code:

Code: Select all

clear, clc

Exp.mwFreq = 9.5;
Exp.Range = [300 360];

Sys1.g = 2;
Sys1.lwpp = 1;
Sys2.g = 2.04;
Sys2.lwpp = 0.5;

SysX = {Sys1,Sys2};

[x,y] = garlicX(SysX,Exp);

Vary1.g = 0.01;
Vary2.g = 0.02;
VaryX = {Vary1,Vary2};

esfit('garlicX',y,SysX,VaryX,Exp);
and the custom function garlicX:

Code: Select all

function [x,y] = garlicX(Sys,Exp,Opt)
if nargin<3, Opt = struct; end
[x,y] = garlic(Sys,Exp,Opt);
Does this work on your system? What are the minimal changes to this that reproduce your error?
Post Reply