I want to generate n spin systems, all of which are variants of a basic system according to a predefined trigonometric function. The fit is carried out on two external parameters that generate the actual parameters of each individual spin system.
My code is:
Code: Select all
cm=100*clight/1e6; % Conversion constant from cm-1 to MHz
J=-30; % Isotropic exchange in cm-1 according to the -2JSiSj formalism (external parameter)
r=0.01; % Coefficient (external parameter)
gxy=2; gz=2;
n=12; %Number of variations of the phi angle <--This is the number of the individual spin systems that will be generated
% Angles to be used as constants
theta1=0;
theta2=-2*pi/3;
theta3=2*pi/3;
%Experimental for curry
[T,chiSI] = textread('data_easyspin_chiSI.dat','%f %f');
Exp.Field = 1000; Exp.Temperature = T; chiSI = n*chiSI; <-- The calculated curves are added up. The experimental curve needs to be multiplied by [i]n[/i] to be brought up to the calculated curve.
%Define a dummy system containing the J and r parameters as variables
SysA.r = r;
SysA.J = J;
% Create n systems Sys(1), Sys(2),...Sys(n)
for i=1:n
phi(i)=((i-1)/n)*2*pi;
%The trigonometric function:
a12(i)=r*(cos(phi(i)-theta1));
a13(i)=r*(cos(phi(i)-theta2));
a23(i)=r*(cos(phi(i)-theta3));
J12(i)=-2*cm*J*(1+a12(i));
J13(i)=-2*cm*J*(1+a13(i));
J23(i)=-2*cm*J*(1+a23(i));
Sys(i).S=[5/2 5/2 5/2];
Sys(i).g=[gxy gz; gxy gz; gxy gz];
Sys(i).weight=1/n;
Sys(i).ee = [J12(i) J13(i) J23(i)];
end
VaryA.r = [0.01];
VaryA.J = [5];
for i=1:n
Vary(i).ee = [0 0 0];
Vary(i).g = [0 0; 0 0; 0 0];
end
FitOpt.OutArg = [2 2]; % to fit the magnetic susceptibility chizz (second output)
FitOpt.Method = 'simplex fcn';
FitOpt.Scaling = 'none';
esfit('curry',chiSI,{SysA,Sys(1),Sys(2),Sys(3),Sys(4),Sys(5),Sys(6),Sys(7),Sys(8),Sys(9),Sys(10),Sys(11),Sys(12)},{VaryA,Vary(1),Vary(2),Vary(3),Vary(4),Vary(5),Vary(6),Vary(7),Vary(8),Vary(9),Vary(10),Vary(11),Vary(12)},Exp,[],FitOpt);
What am I missing?
Thanks in advance!