How to retain D to be traceless

General forum for EasySpin: questions, how to's, etc.
Post Reply
sg_epr
User
Posts: 28
Joined: Sun Apr 03, 2016 1:18 am

How to retain D to be traceless

Post by sg_epr »

Hi,
I am trying to fit a exchanged coupled system using Sys.eeD, Will be thankful if someone can suggest that how can the three components of tensor be varied with their sum to be fixed at 0. Thanks
joscha_nehrkorn
EasySpin Guru
Posts: 32
Joined: Wed Jan 20, 2016 11:35 am

Re: How to retain D to be traceless

Post by joscha_nehrkorn »

You can write your own fit function.

The following function should take care that eeD is traceless (with the additional field eeD12 in Sys):

Code: Select all

function y = pepper_eeD(Sys,Exp,Opt)
if nargin < 3, Opt = struct(); end

if isfield(Sys,'eeD12')
if ~size(Sys.eeD12,2)==2
fprintf('Sys.eeD12 has to be a 2-dimensional vector!\n')
return
end
Sys.eeD = [Sys.eeD12, -Sys.eeD12(:,1)-Sys.eeD12(:,2)];
end
y = pepper(Sys,Exp,Opt);

sg_epr
User
Posts: 28
Joined: Sun Apr 03, 2016 1:18 am

Re: How to retain D to be traceless

Post by sg_epr »

Hi, Thanks for your response, joscha_nehrkorn. I tried many things to tell MATLAB about zero trace of eeD, but could not succeed. Also tried the way as suggested by you, but it comes back with an error message suggesting "Function definitions are not permitted in this context". Would appreciate any further suggestions.
Thanks
joscha_nehrkorn
EasySpin Guru
Posts: 32
Joined: Wed Jan 20, 2016 11:35 am

Re: How to retain D to be traceless

Post by joscha_nehrkorn »

Probably you just copied the function into your script. That cannot work. You have to save the function in a separate .m file in a folder where matlab search for functions (defined in the SetPath options). Then you can called from your script or ask esfit to use it.

Inside of a script it is just the single line:

Code: Select all

Sys.eeD = [Sys.eeD12, -Sys.eeD12(:,1)-Sys.eeD12(:,2)];
you need, after you have defined

Code: Select all

Sys.eeD12
as two dimensional vector. However, you need the function for fitting it.
sg_epr
User
Posts: 28
Joined: Sun Apr 03, 2016 1:18 am

Re: How to retain D to be traceless

Post by sg_epr »

Thanks, joscha_nehrkorn. Finally it worked. I must confess, not a MATLAB guy so took longer to get it right. One more thing, I have an excellent fitting for S = 2 exchanges coupled system with Sys.ee. If I switch to J, dvec and eeD, can I fix g, D, Dstrain Hstrain etc. to previous ones and expect to achieve similar RMSD values by varying three components now. Thanks
joscha_nehrkorn
EasySpin Guru
Posts: 32
Joined: Wed Jan 20, 2016 11:35 am

Re: How to retain D to be traceless

Post by joscha_nehrkorn »

Just a short warning: you will over-parametrize your system!
Assume you have data which you can fit excellently by f(x) = a0 + a1 *x. Would you expect it make sense to fit instead g(x) = a0 + a1 *x+ a2 *x^2 ?

Also: The number you obtain for your fit quality is only useful for this particular fit! If you change the number of parameters, number of data points, what you fit (double-integral, integral, data as is), etc. this number will change, without that your fit change!
rsuarez
Newbie
Posts: 1
Joined: Fri Sep 16, 2016 12:04 pm
Location: spain
Contact:

Re: How to retain D to be traceless

Post by rsuarez »

Thank you very much for the information friends has helped me a lot



Ricardo Suarez Caballero
Director Formativo en IIEMD.com - Marketing Digital
sg_epr
User
Posts: 28
Joined: Sun Apr 03, 2016 1:18 am

Re: How to retain D to be traceless

Post by sg_epr »

Thanks for your suggestion joscha_nehrkorn. But I thought, ee and J(along with dvec & eeeD) are two different representations of the same phenomenon called exchange coupling. If I take your example, two functions f(x) = a0 + a1 *x and g(x) = a0 + a1 *x+ a2 *x^2 may not be true representation of a curve at at a same time but f(x) = a0 + a1 *x and g(x) = a0 + (a5+a3*a4) *x should be fine for the same curve with obviously a4, a5 and a3 being a new set of parameters and a1 being function of them. Though, I will appreciate your views on it.
Another problem which I am facing is of the repeatability of the data. For example if I am fitting a system and during the run one of the parameters touches the limit given with RMSD being say, 0.05 at that point. Now what I would do is stop the run and now make these "best" parameters the "Center" parameters in my code for the next run. If I choose the "start point" to be "Selected parameters" for next run, i expect to start with same RMSD (~0.05) and similar green curve. Unfortunately this does not happen all the time and what I see is a broad hump, no peaks and very high RMSD values, though the center parameters are same. Then the minimization of RMSD starts from the scratch. This problem happens more when I am close to get the desired resemblance with my curve, and then my few days work goes in vain. Will appreciate if you can suggest if I am doing anything wrong here.
joscha_nehrkorn
EasySpin Guru
Posts: 32
Joined: Wed Jan 20, 2016 11:35 am

Re: How to retain D to be traceless

Post by joscha_nehrkorn »

Your example functions are actually more to the point than what I suggested. Sure f(x) and g(x) will give the same result. The point is that a1 = a5+a3*a4, which obviously give non-unique a3, a4, a5 for a given a1. But it is probably the best to try it out. Generate data like your f(x), add maybe a small noise, write two fit functions (f(x) and g(x)) and fit.

You are talking about the GUI, right? Here is what you have to do: After pressing the Stop button, click "Save parameter set", then select the corresponding entry in the "Parameter sets" and then you can use "Selected Parameters" as "start point". I hope this helps!
sg_epr
User
Posts: 28
Joined: Sun Apr 03, 2016 1:18 am

Poor repeatability of fit/RMSD for already optimized paramet

Post by sg_epr »

Generally I use one of the entries in "Parameter Sets" from GUI to start the new cycle of fitting during a run. But, when any of the variable touches the limit of variation during the run, one needs to change the end limits for least square fitting to continue. For this, i close the GUI and retype/repaste the code on Command Window with new limit to the parameter. Now for this new run, if I am using the best parameters of last run as the start point, I expect the starting RMSD to be same as the end point of the last run with similar fit. Though it is not the case, and i get a broad hump with no transitions to start with and my fitting starts from the scratch again. Will appreciate any help in this regard
Post Reply