Fitting of magnetic susceptibility data

General forum for EasySpin: questions, how to's, etc.
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

Thanks for the suggestion.

I have tried some variations of your suggestion and I get different errors (I always invoke my function with FitOpt.OutArg = [2 1];)

1. My first try is

Code: Select all

function [x,y] = constrainJg_isosceles_xT(Sys1,Exp,Opt);
fullSys = etc...
T = 0;
[x,y] = curry(fullSys,Exp,Opt);
x = x.*T;
return
This starts the fit but I get a chi*T = 0 horizontal line and a non-varying rmsd.

2. Then, I supposed I needed to initialize T from non-zero value.
-when I initialise T with T = Exp.Temperature; I get
Error using .*
Matrix dimensions must agree.
Error in constrainJg_isosceles_xT (line 11)
x = x.*T;
-when I try to read the values in from the data file:

Code: Select all

function [x,y] = constrainJg_isosceles_xT(Sys1,Exp,Opt);
fullSys = etc...
[T,chiSI] = textread('data_easyspin_chiSI.dat','%f %f');
[x,y] = curry(fullSys,Exp,Opt);
x = x.*T;
return
I get the same error.

-when I try

Code: Select all

function [x,y] = constrainJg_isosceles_xT(Sys1,Exp,Opt);
fullSys = etc...
[T,chiSI] = textread('data_easyspin_chiSI.dat','%f %f');
[x,y] = curry(fullSys,Exp,Opt);
x = chiSI.*T;
return
I get:
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Is that towards the right direction?
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

OK, got it:
I needed to invoke my custom function with FitOpt.OutArg = [2 2]; so that I would still get chi, and then in my custom function do a bit of flip-flopping the y array to multiply it with T and then bring it back to its [1 x n] form:

Code: Select all

function [x,y] = constrainJg_isosceles_xT(Sys1,Exp,Opt);
fullSys = etc
...
T = Exp.Temperature;
[x,y] = curry(fullSys,Exp,Opt);
y = y.';
y = y.*T;
y = y.';
That did the trick!
Stefan Stoll
EasySpin Creator
Posts: 1057
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

Great!
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

And just a final (I think) question:

From what I understand, at the moment curry cannot calculate multi-component systems like pepper can (e.g. an antiferromagnetic system and its paramagnetic impurity).

Is there a way to do so, or is that planned for a next version?
Stefan Stoll
EasySpin Creator
Posts: 1057
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

You are right, this features is currently not implemented for curry. We will add it to our to-do list.
aldamen
Newbie
Posts: 5
Joined: Tue May 10, 2016 2:08 pm

Re: Fitting of magnetic susceptibility data

Post by aldamen »

I carried out the following code based on your input with a moderate modification.
The code is for tetrameric manganese with
J1 for MnIII-MnIII
J2 for MnII-MnIII
0 for MnII-MnII
2 for g
and external data

the code is :

Code: Select all

clear all;
close all;

cm=2.99793e4; % Conversion constant from cm-1 to MHz (~ 100*clight/1e6)
path = 'C:\Users\AlDamen\Desktop\easyspin-5.0.22\Fitting';
cd(path);
format long;
[T,chi] = textread('data_easyspin.dat','%f %f');

J1 = -22;
J2 = 1;
g = 2;
Sys1.S=[5/2 5/2 2 2];
Sys1.g=[g; g; g; g; g];
Sys1.ee = -2*cm*[J1 J2 J2 J2 J2];
Vary1.ee = [2]*cm
Vary1.g = [0.01 0.01];
Exp.Field = 1000; Exp.Temperature = T;
FitOpt.OutArg = [2 2];   % to fit the magnetic susceptibility chizz (second output)
FitOpt.nKnots = 31;
esfit('constrainJg',chi,Sys1,Vary1,Exp,[],FitOpt);


the output error is

Code: Select all

Attempted to access CenterFieldValue(1,2); index out of bounds because size(CenterFieldValue)=[5,1].

Error in esfit>getParamList (line 976)



Error in esfit (line 349)



Error in code (line 21)
esfit('constrainJg',chi,Sys1,Vary1,Exp,[],FitOpt);
 
>> 
Any help!!!
Stefan Stoll
EasySpin Creator
Posts: 1057
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

Please post your data and your custom simulation function so we can try to reproduce the error.
aldamen
Newbie
Posts: 5
Joined: Tue May 10, 2016 2:08 pm

Re: Fitting of magnetic susceptibility data

Post by aldamen »

Code: Select all

clear all;
close all;

cm=2.99793e4; % Conversion constant from cm-1 to MHz (~ 100*clight/1e6)
path = 'C:\Users\AlDamen\Desktop\easyspin-5.0.22\Fitting';
cd(path);
format long;
[T,chi] = textread('data_easyspin.dat','%f %f');

J1 = -22;
J2 = 1;
g = 2;
Sys1.S=[5/2 5/2 2 2];
Sys1.g=[g; g; g; g];
Sys1.ee = -2*cm*[J1 J2 J2 J2 J2];
Vary1.ee = [0.1 0.1]*cm % [x] x is the fitting variable +x i.e. J=-22, -22+nx
Vary1.g = [0.01];
Exp.Field = 1000; Exp.Temperature = T;
FitOpt.OutArg = [1 1];   % to fit the magnetic susceptibility chizz (second output)
FitOpt.Method = 'simplex fcn';
FitOpt.Scaling = 'none'
esfit('constrainJg',chi,Sys1,Vary1,Exp,[],FitOpt);

constainJg.m

Code: Select all

function y = constrainJg(Sys1,Exp,Opt)
fullSys = Sys1;
fullSys.g = [Sys1.g;Sys1.g;Sys1.g;Sys1.g];
fullSys.ee = [Sys1.ee; Sys1.ee; Sys1.ee; Sys1.ee; Sys1.ee];
[x,y] = curry(fullSys,Exp,Opt);
return


the data

Code: Select all

300	0.0340698
290.16	0.034941963
279.36	0.036019724
269.52	0.037099028
259.49	0.038191106
249.49	0.039391639
239.54	0.040671829
229.53	0.042068836
219.52	0.043577123
209.54	0.045264532
199.54	0.047156009
189.54	0.049260103
179.58	0.051572725
169.62	0.054241009
159.64	0.057141255
149.66	0.060468462
139.78	0.06420289
130.15	0.068160507
119.96	0.073397216
110.04	0.079102508
100.06	0.086008095
94.905	0.089974606
90.071	0.094079004
85.074	0.09895632
80.076	0.104435536
75.072	0.110600357
70.115	0.117042716
65.109	0.125301264
60.078	0.134752488
55.08	0.145612564
50.07	0.158673857
45.035	0.174634173
40.009	0.194480492
34.997	0.219791411
29.998	0.253107207
24.978	0.301346385
22.994	0.322953379
21.002	0.350758499
19.001	0.384026104
17.001	0.424274454
15.001	0.473919072
13.004	0.535879729
10.996	0.618935977
10.018	0.668053504
9.5016	0.698012966
9.0015	0.729067378
8.502	0.76287697
8.0022	0.799772563
7.5023	0.840367621
7.0036	0.885381804
6.5038	0.935529998
6.0046	0.991250042
5.5035	1.055475606
5.0009	1.124485593
4.5028	1.208876699
4.0005	1.308833896
3.5009	1.425741952
3.0032	1.57225293
2.505	1.758978044
2.0105	2.018090027
1.8465	2.148762524
I corrected the error, but still the data is not acceptable,

J must be fit to be -44 and 1 respectively
and g=1.99

Also, another question, how can I add the intermolecular term

zJ
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

Your definition of your data ('%f %f') is two floating-point columns with one space between them.

However, you actual data have three spaces. Maybe first try correcting that.

As for zJ, you could easily calculate it by doing the relevant algebra on your calculated curve (e.g. BestSpc) once the calculation is done, but to treat is as a fitting variable, I believe you should write a custom function (see answer to my previous question at viewtopic.php?f=3&t=299).
aldamen
Newbie
Posts: 5
Joined: Tue May 10, 2016 2:08 pm

Re: Fitting of magnetic susceptibility data

Post by aldamen »

I want to resume again the case,
two coupling constant J1 and J2 and one g to fit a Chi vs T curve.

the code is

Code: Select all

clear all;
close all;

cm=2.99793e4; % Conversion constant from cm-1 to MHz (~ 100*clight/1e6)
path = 'C:\Users\AlDamen\Desktop\easyspin-5.0.22\Fitting';
cd(path);
format long;
[T,chi] = textread('data_easyspin.dat','%f %f');

J1 = 22*cm;
J2 = -1*cm;
g = 2;
Sys1.S=[2 2 5/2 5/2];
Sys1.g=[g; g; g; g];
Sys1.ee = -2*cm*[J1 J2 J2 J2 J2 0];
Vary1.ee = [1.0 0.1]*cm % [x] x is the fitting variable +x i.e. J=-22, -22+nx
Vary1.g = [0.01];

Exp.Field = 1000; Exp.Temperature = T;
FitOpt.OutArg = [1 1];   % to fit the magnetic susceptibility chizz (second output)
FitOpt.Method = 'simplex fcn';
FitOpt.Scaling = 'none'
esfit('constrainJg',chi,Sys1,Vary1,Exp,[],FitOpt);
the function as found in this forum

Code: Select all

function y = constrainJg(Sys1,Exp,Opt)
fullSys = Sys1;
fullSys.g = [Sys1.g];
fullSys.ee = [Sys1.ee];
[x,y] = curry(fullSys,Exp,Opt);
return
the data corrected to be one space

Code: Select all

300.00 0.0340698
290.16 0.034941963
279.36 0.036019724
269.52 0.037099028
259.49 0.038191106
249.49 0.039391639
239.54 0.040671829
229.53 0.042068836
219.52 0.043577123
209.54 0.045264532
199.54 0.047156009
189.54 0.049260103
179.58 0.051572725
169.62 0.054241009
159.64 0.057141255
149.66 0.060468462
139.78 0.06420289
130.15 0.068160507
119.96 0.073397216
110.04 0.079102508
100.06 0.086008095
94.905 0.089974606
90.071 0.094079004
85.074 0.09895632
80.076 0.104435536
75.072 0.110600357
70.115 0.117042716
65.109 0.125301264
60.078 0.134752488
55.080 0.145612564
50.070 0.158673857
45.035 0.174634173
40.009 0.194480492
34.997 0.219791411
29.998 0.253107207
24.978 0.301346385
22.994 0.322953379
21.002 0.350758499
19.001 0.384026104
17.001 0.424274454
15.001 0.473919072
13.004 0.535879729
10.996 0.618935977
10.018 0.668053504
9.502 0.698012966
9.002 0.729067378
8.502 0.76287697
8.002 0.799772563
7.502 0.840367621
7.003 0.885381804
6.503 0.935529998
6.504 0.935529998
6.005 0.991250042
5.504 1.055475606
5.001 1.124485593
4.503 1.208876699
4.001 1.308833896
3.501 1.425741952
3.003 1.57225293
2.505 1.758978044
2.011 2.018090027
1.847 2.148762524
the result is the following
fit
fit
fit.png (30.46 KiB) Viewed 3357 times
My questions ;
FitOpt.OutArg = [1 1]; this is correct to fit J1 J2 g for these data using input Chi vs T
why the fitting is not ok,
is it a problem of units or there is another problem

thank you
Post Reply