Multi components with curry

General forum for EasySpin: questions, how to's, etc.
Post Reply
EmilLarsen
Newbie
Posts: 3
Joined: Thu May 20, 2021 4:03 am

Multi components with curry

Post by EmilLarsen »

Hi, I have been working with the curry function for some time now and I wondered if an expansion of the function to handle multiple components is in the pipeline? I am in need of fitting some data with multiple spin structures.

  • love the software!
thanasis
Local Expert
Posts: 260
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Multi components with curry

Post by thanasis »

This can be solved quite flexibly with an auxiliary function that calculates several components and returns the total susceptibility to be fitted by esfit.

EmilLarsen
Newbie
Posts: 3
Joined: Thu May 20, 2021 4:03 am

Re: Multi components with curry

Post by EmilLarsen »

For a guy who is not a master of the MatLab languages how would that look like? :)

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

Re: Multi components with curry

Post by thanasis »

You can get an idea about:
Custom functions here.
Fitting magnetic data here (though it refers to the v. 5 of ES and you will need to adjust some syntax for v.6).
Multicomponent fitting and visualization here.

EmilLarsen
Newbie
Posts: 3
Joined: Thu May 20, 2021 4:03 am

Re: Multi components with curry

Post by EmilLarsen »

Thank you for the feedback. However, it still seems to me that pepper copes with multiple Sys components and curry does not, like pepper({Sys1, Sys2},Exp,Opt) is something pepper understands and curry does not. Maybe I just don't understand how to bypass this.

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

Re: Multi components with curry

Post by thanasis »

Yes, hence the use of the custom function.

In the custom function, you define an arbitrary number of systems using parameters and experimental conditions you enter in your script. You then calculate the contributions of each system by calling curry separately for each of them.
You then add them up and the total susceptibility is exported as y.
That y is fitted by esfit.

In the main script:

Code: Select all

Sys.S1 = 1/2;
Sys.g1 = [g1xy g1z]
Sys.weight1 = w1;
...
Sys.S2 = 1;
Sys.g2 = [g2xy g2z]
Sys.weight2 = w2;
...
esfit(@mufunc,Sys,Vary,Exp,Opt,FitOpt);

And:

Code: Select all

function y = mufunc(Sys,Exp,Opt)
fullSys1.S = Sys.S1
fullSys1.g = Sys.g1
fullSys1.J = ..

fullSys2.S = Sys.S1
fullSys2.g = Sys.g2
fullSys2.J = ..

etc

sus1 = curry(fullSys1,Exp,Opt)
sus2 = curry(fullSys2,Exp,Opt)
y = Sys.weight1 * sus1 + Sys.weight2 * sus2
return
Post Reply