Fitting of magnetic susceptibility data

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

Re: Fitting of magnetic susceptibility data

Post by thanasis »

And it works!

Thanks a lot, I'll be tuned in for the bug fix.
thanasis
Local Expert
Posts: 245
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

I have successfully ran a few fits to my data and have a couple of issues (version 5.0.18). I will post them under this thread, as I think it is more convenient for future reference.

1. Horizontal scaling
I had observed some "weird" appearance of my experimental data and I now know why.
It seems that the fitting window arranges the experimental points equidistantly between the two horizontal edges of the plot and not on their absolute x-positions. This is a valid approach for EPR spectra, where the B-field is scanned in equidistant steps, but in the case of SQUID data, where we may use different T-steps at different T-regimes, it produces those "bumps" (better visible in the mueff vs T data).
EasySpin Least-Squares Fitting.png
EasySpin Least-Squares Fitting.png (83.92 KiB) Viewed 5430 times
The issue is mostly aesthetic artistic, but I just make a note of it for the record.

2. Magnetic moment
As seen in the image above, I get a weird artifact in the mueff calculation. I use an ascii data file with the T, mueff values and the crucial points of my script are:

Code: Select all

[T,mueff] = textread('data_easyspin_mueff.dat','%f %f');
...
FitOpt.OutArg = [1 1];
FitOpt.nKnots = 101;
esfit('constrainJg',mueff,Sys1,Vary1,Exp,[],FitOpt);
Since mueff = 2.828*sqrt(chi*T), this low-T increase should not appear. Is there an error in my script?
(I have thought of fitting directly the chi*T vs T data, but from the documentation I understand that easyspin doesn't provide the relevant option)

3. Convergence (data form & vertical scaling)
Finally, I found that the convergence is heavily dependent on the data form (chi vs mueff) and scaling method.
In my experience, depending on the type of magnetic behaviour, it actually is preferable to fit one type of data over another (e.g. chi vs T for weakly AF and chi*T vs T for FM or paramagnetic materials). However, in the present case the best-fit values vary very widely, and are heavily dependent on the starting values.
I don't know if a have invoked 100% correctly the chi and mueff calculations, but I have noticed that the scaling method affects the results. Since this is not a spectroscopic technique, where applying an absorption scaling and a baseline correction is a valid approach, I believe that there should be no scaling (or baseline correction for that matter). However, the fitting window offers 6 scaling methods from which to choose, without a "no scaling" option.
Is there something I am missing?
Stefan Stoll
EasySpin Creator
Posts: 1073
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

The new version 5.0.19 has now the Temperature bug fixed. It also provides a no-scaling option for esfit.
thanasis
Local Expert
Posts: 245
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

Thanks for the update!

Things are now working fine.

I just have a question (or feature request): for some systems it is numerically more useful to fit the chi*T vs T instead of the chi vs T data (the form of the curve is more revealing of the magnetic behavior and it is easier to obtain a meaningful convergence, as e.g. for paramagnetic and ferromagnetic systems).

I know that without any arguments curry also plots chi*T vs T simulations (among others). However, when it comes to fitting, I understand that it can calculate mu and chi. Could it also also fit chi*T vs T data, either out of the box, or through a custom-made function?

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

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

You can always use a custom function to achieve this. We look into making curry capable of returning chi*T directly.
thanasis
Local Expert
Posts: 245
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

Thanks, that sounds great!
thanasis
Local Expert
Posts: 245
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

Trying to better understand custom simulation functions, I previously got around to making a custom function that fixes two J's together and keeps the third distinct ("Tie selected variables to a common value"), giving an isosceles magnetic model.

Now I am trying to fit the chi*T product instead of the magnetic susceptibility, chi.

First, I instruct ES to read the (chi, T) file and translate the data to chi*T:

Code: Select all

[T,chiSI] = textread('data_easyspin_chiSI.dat','%f %f');
chiSIT=chiSI.*T
Exp.Temperature = T;
Then I define my spin system as before and invoke my custom function, telling it to fit chi*T data:

Code: Select all

esfit('constrainJg_isosceles_xT',chiSIT,Sys1,Vary1,Exp,[],FitOpt);
Indeed, when I execute, I get the chi*T vs T plot.

However, my problems are mostly in the custom function inputs and outputs, and how to instruct ES what to calculate. Since the documentation on the subject is relatively sparse for non-experts like me, I have tried to define the 2nd output (y) as chi*T in my custom function:

Code: Select all

chiSI = 0;
T = 0;
chiSIT = chiSI.*T;
y = chiSIT;
But to no avail; ES still seems to calculate chi.

Then, thinking that I should make the space for a new output (i.e. chi*T), I tried my function with [x,y,z] = and defined z = chiSIT;. This threw the following error:

Code: Select all

Undefined function or variable "chizzT_SI".
Error in curry (line 305)
Error in constrainJg_isosceles_xT (line 8)
[x,y,z] = curry(fullSys,Exp,Opt);
Error in esfit>assess (line 808)
Error in esfit_simplex (line 77)
Error in esfit>runFitting (line 660) 
Error while evaluating UIControl Callback
Does that mean that there is the possibility to calculate chi*T directly from ES?

Could you please suggest how to go about better understanding the way output arguments are defined?
Stefan Stoll
EasySpin Creator
Posts: 1073
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

Have you tried to return chi*T as the first output argument of your custom function?
thanasis
Local Expert
Posts: 245
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Fitting of magnetic susceptibility data

Post by thanasis »

Assuming I have correctly understood how to do that, I tried changing the custom function to:

Code: Select all

function [x,y] = constrainJg_isosceles_xT(Sys1,Exp,Opt);
fullSys = Sys1;
fullSys.g = [Sys1.g];
fullSys.ee = [Sys1.Ja Sys1.Ja Sys1.Jb];
chiSI = 0;
T = 0;
chiSIT = chiSI.*T;
x = chiSIT;
[x,y] = curry(fullSys,Exp,Opt);
return
and invoke it using FitOpt.OutArg = [2 1];.
However, I still get what I suppose is the magnetic moment.
Stefan Stoll
EasySpin Creator
Posts: 1073
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Fitting of magnetic susceptibility data

Post by Stefan Stoll »

In your function, as you have it right now, you are returning what you get from curry, which is not chi*T. To get chi*T, you need to call curry before you calculate chiSIT.
Post Reply