Home > lattice > atmakefielderrstruct.m

atmakefielderrstruct

PURPOSE ^

MAKERNDFIELDERRS will create a field error data structure

SYNOPSIS ^

function ferrs = atmakefielderrstruct(ring,class,nval,Bval,Aval,radius,rnd)

DESCRIPTION ^

 MAKERNDFIELDERRS will create a field error data structure

 class is an element class, "Quadrupole", or "Sextupole"

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ferrs = atmakefielderrstruct(ring,class,nval,Bval,Aval,radius,rnd)
0002 % MAKERNDFIELDERRS will create a field error data structure
0003 %
0004 % class is an element class, "Quadrupole", or "Sextupole"
0005 
0006 if isequal(class,'Quadrupole')
0007         elemindex=findcells(ring,'Class','Quadrupole'); 
0008        Nval=2*ones(length(elemindex),1);   
0009 elseif isequal(class,'Sextupole')
0010          elemindex=findcells(ring,'Class','Sextupole');
0011         Nval=3*ones(length(elemindex),1); 
0012 else
0013     error('not a valid element class');
0014 end
0015 
0016 len=length(elemindex);
0017 if(rnd==1)
0018 for j=1:len
0019     Barray(j)=Bval*randn;
0020     Aarray(j)=Aval*randn;
0021 end
0022 else
0023     Barray=Bval*ones(len,1);
0024     Aarray=Aval*ones(len,1);
0025 end
0026 
0027 %e.g. ferr=struct('elemindex',[1 5 6],'nval',[4 4 4],'Nval',[2 2 2],'Bval',[1e-4 -1e-4 3e-4],'Aval',[0 0 0])
0028 
0029 ferrs=struct('elemindex',elemindex,'Nval',Nval,'nval',nval*ones(len,1),'Bval',Barray,'Aval',Aarray,'radius',radius);

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