Home > pubtools > create_elems > atidtable_dat.m

atidtable_dat

PURPOSE ^

atidtable(fname, Nslice, filename, Energy, method)

SYNOPSIS ^

function Elem = atidtable_dat(fname, Nslice, filename, Energy, method)

DESCRIPTION ^

 atidtable(fname, Nslice, filename, Energy, method)

 FamName    family name
 Nslice    number of slices (1 means the wiggler is represented by a
           single kick in the center of the device).
 filename    name of file with wiggler tracking tables.
 Energy    Energy of the machine, needed for scaling
 method    name of the function to use for tracking. Use 'WigTablePass'

 The tracking table is described in
 P. Elleaume, "A new approach to the electron beam dynamics in undulators
 and wigglers", EPAC92.

 returns assigned structure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function Elem = atidtable_dat(fname, Nslice, filename, Energy, method)
0002 % atidtable(fname, Nslice, filename, Energy, method)
0003 %
0004 % FamName    family name
0005 % Nslice    number of slices (1 means the wiggler is represented by a
0006 %           single kick in the center of the device).
0007 % filename    name of file with wiggler tracking tables.
0008 % Energy    Energy of the machine, needed for scaling
0009 % method    name of the function to use for tracking. Use 'WigTablePass'
0010 %
0011 % The tracking table is described in
0012 % P. Elleaume, "A new approach to the electron beam dynamics in undulators
0013 % and wigglers", EPAC92.
0014 %
0015 % returns assigned structure
0016 
0017 %---------------------------------------------------------------------------
0018 % Modification Log:
0019 % -----------------
0020 % 13-09-2007:  Created by M. Munoz, based in J. Safranek code.
0021 % 17-11-2008:  Modificated by Z.Martí
0022 %---------------------------------------------------------------------------
0023 
0024 Elem.FamName        = fname;  % add check for identical family names
0025 
0026 Elem.Nslice        = Nslice;
0027 Elem.MaxOrder            = 3;
0028 Elem.NumIntSteps     = 10;
0029 Elem.R1             = diag(ones(6,1));
0030 Elem.R2             = diag(ones(6,1));
0031 Elem.T1             = zeros(1,6);
0032 Elem.T2             = zeros(1,6);
0033 Elem.PassMethod     = method;
0034 
0035 
0036 factor=1/((Energy/0.299792458)^2);
0037 factor1=-1/((Energy/0.299792458));
0038     
0039 % Read the file
0040 D=importdata(filename);
0041 if isfield(D,'Kick1x')
0042     x=(D.x)';
0043     y=(D.y)';
0044     xkick1=factor1*D.Kick1x;
0045     ykick1=factor1*D.Kick1y;
0046     xkick=factor*D.Kick2x;
0047     ykick=factor*D.Kick2y;
0048     L=D.Len;
0049     nn=size(xkick1);
0050     Ny=nn(1);
0051     Nx=nn(2);
0052 %     ElemData.MultiKick= 1;
0053 %     ElemData.nkicks= nn(3);
0054 else
0055     [header_mat, data_mat]=mhdrload_bis(filename);
0056     L=data_mat(:,:,1);
0057     Nx=data_mat(:,:,2);
0058     Ny=data_mat(:,:,3);
0059     A = importdata(filename,' ',10);
0060     x=A.data;
0061     x=x(1,1:Nx);
0062     A = importdata(filename,' ',11);
0063     txkick=A.data;
0064     y=txkick(1:Ny,1);
0065     txkick=txkick(:,2:end);
0066     A=importdata(filename,' ',11+Ny+3);
0067     tykick=A.data;
0068     tykick=tykick(:,2:end);
0069     A=importdata(filename,' ',11+2*Ny+2*3);
0070     if isstruct(A)
0071         txkick1=A.data;
0072         txkick1=txkick1(:,2:end);
0073     else
0074         txkick1=0*txkick;
0075     end
0076     A=importdata(filename,' ',11+3*Ny+3*3);
0077     if isstruct(A)
0078         tykick1=A.data;
0079         tykick1=tykick1(:,2:end);
0080     else
0081         tykick1=0*tykick;
0082     end
0083 
0084     xkick=factor*txkick;
0085     ykick=factor*tykick;
0086     
0087     xkick1=factor1*txkick1;
0088     ykick1=factor1*tykick1;
0089     
0090     % Sort arrays in ascending order (needed for "IdTablePass.c")
0091     [y indy]=sort(y);
0092     [x indx]=sort(x);
0093     x=x';
0094     xkick=xkick(indy,indx);
0095     ykick=ykick(indy,indx);
0096     
0097 end
0098 
0099 Elem.Length= L;
0100 Elem.NumX = Ny;
0101 Elem.NumY = Nx;
0102 Elem.xtable = x;
0103 Elem.ytable = y;
0104 Elem.xkick = xkick;
0105 Elem.ykick = ykick;
0106 Elem.xkick1 = xkick1;
0107 Elem.ykick1 = ykick1;
0108 Elem.PolynomA= [0 0 0 0];     
0109 Elem.PolynomB= [0 0 0 0];

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