Page 1 of 1

Tie selected variables to a common value

Posted: Wed Feb 17, 2016 4:26 am
by thanasis
This is relevant to the more general post "Tie several variables to a common value", but in this case I would like to fix together only some of the total variables (i.e. considering a not so symmetric system).

E.g., following up from the special case of the model described in "Fitting of magnetic susceptibility data", I would like to tie together two J values and let the third one evolve independently:

Code: Select all

cm=100*clight/1e6;
Ja = -20;
Jb = -22;
gxy = 2;
gz = 2;
Sys1.S=[5/2 5/2 5/2];
Sys1.g=[gxy gz; gxy gz; gxy gz];
Sys1.ee = -2*cm*[Ja Ja Jb];
In that post I had successfully tied all three J's and g's together, but when the problem becomes less symmetrical I cannot simply invoke a fullSys.ee = [Sys1.ee; Sys1.ee; Sys1.ee]; declaration in my constrainJg external function to tie the J's together.

Is that possible to do?

Thanks in advance!

Re: Tie selected variables to a common value

Posted: Thu Feb 18, 2016 3:28 pm
by Stefan Stoll
Define a Sys.Ja and a Sys.Jb, and then in your custom function set fullSys.ee = [Sys.Ja Sys.Ja Sys.Jb].

Re: Tie selected variables to a common value

Posted: Tue Apr 12, 2016 2:32 am
by thanasis
Thanks for the suggestion!

What worked is:

Code: Select all

Ja = -20.6;
Jb = -27.1;
gxy = 2;
gz = 2;

Sys1.S=[5/2 5/2 5/2];
Sys1.g=[gxy gz; gxy gz; gxy gz];
Sys1.Ja = -2*cm*Ja;
Sys1.Jb = -2*cm*Jb;

Vary1.Ja = 10*cm;
Vary1.Jb = 10*cm;
Vary1.g = [0 0];

Exp.Field = 1000; Exp.Temperature = T;

% Fitting arguments
FitOpt.OutArg = [2 2];   % to fit the magnetic susceptibility chizz (second output)
FitOpt.Method = 'simplex fcn';
FitOpt.Scaling = 'none';
esfit('constrainJg_isosceles',chiSI,Sys1,Vary1,Exp,[],FitOpt);
using the constrain function:

Code: Select all

function [x,y] = constrainJg_isosceles(Sys1,Exp,Opt);
fullSys = Sys1;
fullSys.g = [Sys1.g];
fullSys.ee = [Sys1.Ja Sys1.Ja Sys1.Jb];
[x,y] = curry(fullSys,Exp,Opt);
return
That seems to have done the trick!

Re: Tie selected variables to a common value

Posted: Thu Apr 14, 2016 4:55 pm
by Stefan Stoll
Great!