Simultaneous susceptibility-magnetisation fit
Posted: Tue Sep 19, 2017 2:55 am
I am trying out the new features in curry, regarding simultaneous fits to magnetic susceptibility (chi vs T) and magnetisation (M vs H) data.
I have started out from the example curry_fit.m (http://easyspin.org/easyspin/examples/f ... urry_fit.m), and have simplified it a little.
The objective is to take the data from two ascii files, sus.dat and mag.dat, each containing the experimental points as [T, B, chi] and [T, B, mag], respectively and fit them simultaneously.
If I understand correctly, the
In the following, the chi vs T data are under just one magnetic field, and the M vs H data are under three temperatures.
However, after I get the plot, I get the error:
Thanks in advance!
I have started out from the example curry_fit.m (http://easyspin.org/easyspin/examples/f ... urry_fit.m), and have simplified it a little.
The objective is to take the data from two ascii files, sus.dat and mag.dat, each containing the experimental points as [T, B, chi] and [T, B, mag], respectively and fit them simultaneously.
If I understand correctly, the
fitdata = [ChiTData(:); MvsBData(:)];
line takes the two datasets, combines them into a single column and uses that column as argument for curry
. It is not clear to me if they must be in the same units, or whether ES can tell from the previous code where each dataset stops and the next begins.In the following, the chi vs T data are under just one magnetic field, and the M vs H data are under three temperatures.
Code: Select all
% Combined fit of magnetic susceptibility and magnetic moment for an S = 2
% system
clear all
close all
cm=100*clight/1e6; % Conversion constant from cm-1 to MHz
% Import susceptibility data in cgs units: T (in K), B (in Gauss), x (in cm3 mol-1)
[Tchi,Bchi,chi] = textread('sus.dat','%f %f %f');
chiSI = chi*4*pi*1e-6; % Convert chi from cgs to SI
BchimT = Bchi/10; % Convert B from G to mT
chiT = Tchi.*chi; % chiT in cgs
chiSIT = Tchi.*chiSI; % chiT in SI
% Import magnetisation data: T (in K), B (in Gauss), M (in NA*muB)
[Tmag,Bmag,muzz] = textread('mag.dat','%f %f %f');
BmagmT = Bmag/10; % Convert from G to mT
% Temperatures and fields for magnetic susceptibilty:
Exp.chiTemperature = Tchi';
Exp.chiField = 1000;
% Temperatures and fields for magnetisation
Exp.mTemperature = [2,3,5];
Exp.mField = BmagmT';
OptData.Output = 'ChiTCGs MvsB';
figure(1)
subplot(2,1,1)
plot(Exp.chiTemperature,chiT,'+')
title('\chi T for S = 2');
subplot(2,1,2)
plot(Exp.mField,muzz,'+')
title('M(B)for S = 2');
ylim([0 3])
% The spin system
Sys1.S = 4;
Sys1.g = [2.1];
Sys1.D = [8 1]*cm;
Sys1.TIP = 300e-6*(4*pi*1e-6);
% Fitting variables
Vary1.g = [0.1];
Vary1.D = [1 0.2]*cm;
Vary1.TIP = 100e-6*(4*pi*1e-6);
% combine all data in 1-row array
fitdata = [chiSI; muzz];
% set output to ChiT and MvsB in 1-coloumn array
Opt.Output = 'ChiTCGs MvsB OneColoumn';
FitOpt.Scaling = 'none';
[bestsys,bestspc] = esfit('curry',fitdata,Sys1,Vary1,Exp,Opt,FitOpt);
[ChiTSim,MvsBSim] = curry(bestsys,Exp,Opt);
figure(3)
subplot(2,1,1)
plot(Exp.chiTemperature,ChiTData,'+', Exp.chiTemperature,ChiTSim)
title(['\chi T for S = 2 fitted with D = ', ...
num2str(bestsys.D(1)/cm,'%2.1f'), ' cm^{-1}, E = ',num2str(bestsys.D(2)/cm,'%2.1f'), ' cm^{-1} and g = ', num2str(bestsys.g,'%1.2f')]);
subplot(2,1,2)
plot(Exp.mField,MvsBData,'+',Exp.mField,MvsBSim)
title(['M(B) for S = 2 fitted with D = ', ...
num2str(bestsys.D(1)/cm,'%2.1f'), ' cm^{-1}, E = ',num2str(bestsys.D(2)/cm,'%2.1f'), ' cm^{-1} and g = ', num2str(bestsys.g,'%1.2f')]);
ylim([0 3])
In the next two posts I will upload the data files (.dat attachments are not allowed).Error using &
Matrix dimensions must agree.
Error in rescale (line 94)
Error in esfit>assess (line 839)
Error in esfit_simplex (line 77)
Error in esfit>runFitting (line 677)
Error in esfit (line 552)
Error in Fe_fit_xT_new (line 57)
[bestsys,bestspc] = esfit('curry',fitdata,Sys1,Vary1,Exp,Opt,FitOpt);
Thanks in advance!