Page 1 of 1

Multi components with curry

Posted: Wed Jun 23, 2021 6:01 am
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!

Re: Multi components with curry

Posted: Wed Jun 23, 2021 12:58 pm
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.


Re: Multi components with curry

Posted: Mon Jul 12, 2021 12:15 am
by EmilLarsen

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


Re: Multi components with curry

Posted: Tue Jul 13, 2021 4:19 am
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.


Re: Multi components with curry

Posted: Tue Jul 13, 2021 5:51 am
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.


Re: Multi components with curry

Posted: Tue Jul 13, 2021 7:53 am
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