Home > atmatch > atEvaluateConstraints.m

atEvaluateConstraints

PURPOSE ^

This funciton evaluates the contraints defined in Constraints for lattice

SYNOPSIS ^

function Val=atEvaluateConstraints(R,evalfunc,posarray,indinposarray,twissin)

DESCRIPTION ^

 This funciton evaluates the contraints defined in Constraints for lattice
 THERING

 Constraints: structure array struct(...
                     'Fun',@functname(ring,lindata,globaldata),
                     'Min',min,
                     'Max',max,
                     'Weight',w,
                     'RefPoints',refpts);

 lindata is the output of atlinopt at the requested locations
 globdata.fractune=tune fromk atlinopt
 globdata.chromaticity=chrom from atlinopt

 functname must return a row vector of values to be optimized

 min, max and weight must have the same size as the return value of
 functname

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function Val=atEvaluateConstraints(R,evalfunc,posarray,indinposarray,twissin)
0002 % This funciton evaluates the contraints defined in Constraints for lattice
0003 % THERING
0004 %
0005 % Constraints: structure array struct(...
0006 %                     'Fun',@functname(ring,lindata,globaldata),
0007 %                     'Min',min,
0008 %                     'Max',max,
0009 %                     'Weight',w,
0010 %                     'RefPoints',refpts);
0011 %
0012 % lindata is the output of atlinopt at the requested locations
0013 % globdata.fractune=tune fromk atlinopt
0014 % globdata.chromaticity=chrom from atlinopt
0015 %
0016 % functname must return a row vector of values to be optimized
0017 %
0018 % min, max and weight must have the same size as the return value of
0019 % functname
0020 %
0021 
0022 % History of changes
0023 % created 26-8-2012
0024 % updated 28-8-2012 vector res handling.
0025 % updated 28-8-2012 add Weigth field.
0026 % updated 11-10-2012 any number of additonal parameters in cell array format.
0027 %                    if only one parameter still ok.
0028 % updated 11-03-2013 proper use of anonytmous functions introduced.
0029 % updated 21-03-2013 Constraints now is a structure array.
0030 %                    Weigth divides instead of multipling a constraint.
0031 % updated 25-03-2013 Constraints call optimized for linear optics.
0032 %
0033 
0034 if ~isempty(posarray)
0035     if isempty(twissin) % recursive solution
0036         [lindata,t,c]=atlinopt(R,0.0,posarray);
0037         globdata.fractune=t;
0038         globdata.chromaticity=c;
0039     else % open line
0040         [lindata]=twissline(R,0.0,twissin,posarray,'chrom');
0041         dpp=0.0001;
0042         [lindatadpp]=twissline(R,dpp,twissin,posarray,'chrom');
0043         [lindatadpm]=twissline(R,-dpp,twissin,posarray,'chrom');
0044         globdata.fractune=lindata(end).mu/2/pi;
0045         globdata.chromaticity=(lindatadpp(end).mu/2/pi-lindatadpm(end).mu/2/pi)/2/dpp;
0046         
0047     end
0048 else
0049     lindata=[];
0050     globdata=[];
0051 end
0052 
0053 Val=cellfun(@(func,refpts) func(R,lindata(refpts),globdata),...
0054     evalfunc,indinposarray,'UniformOutput',false);
0055 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005