Home > at > atdemos > elementpassdemo.m

elementpassdemo

PURPOSE ^

ELEMENTPASSDEMO self-running tutorial

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

ELEMENTPASSDEMO self-running tutorial
 1. Phase-Space tracking variables
 2. Tracking through individual elements
 3. Method - Element consistencyclear all

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %ELEMENTPASSDEMO self-running tutorial
0002 % 1. Phase-Space tracking variables
0003 % 2. Tracking through individual elements
0004 % 3. Method - Element consistencyclear all
0005 clc
0006 echo on
0007 % The term 'tracking' in Accelerator Physics refers to numerical simulation
0008 % of particle motion in phase-space as it passes through an accelerator
0009 %
0010 % MATLAB Accelerator Toolbox uses 6-by-1 column vectors to represent
0011 %  Individual particles in phase space with components [x px y py delta ct]'
0012 %  For example:
0013 R = [0.01 0 0.01 0 0 0]'
0014 
0015 % 6-by-N matrixes are used to represent groups of N particles
0016 %
0017 RRR = [R 2*R 3*R]
0018 
0019 pause % Press any key to continue
0020 clc
0021 % In Accelerator Toolbox tracking is built upon an open-ended
0022 % collection of functions that track particles through
0023 % individual accelerator elements
0024 %
0025 % Examle: Load spear2 lattice
0026 spear2
0027 %
0028 % Second element in spear2 lattice is a drift space
0029 SOMEDRIFT = THERING{2}
0030 whos SOMEDRIFT
0031 % SOMEDRIFT is a MATLAB structure
0032 % Now use function DRIFTPASS to track through SOMEDRIFT
0033 pause % Press any key to continue
0034 clc
0035 driftpass(SOMEDRIFT,R)
0036 %
0037 % DRIFTPASS and other tracking functions in accelerator Toolbox
0038 % accept matrix input to simultaneously track many particles
0039 %
0040 driftpass(SOMEDRIFT,RRR)  
0041 % Obviously in a drift space particle momentums don't change
0042 %
0043 % Try this
0044 DriftPass(SOMEDRIFT,[0 0.01 0 0.02 0 0]'),
0045 
0046 pause % Press any key to continue
0047 clc
0048 % Accelerator Toolbox provides an open endeed collection
0049 % of functions that track through elements using various
0050 % field models.
0051 %
0052 % For example with a more interesting element QUADRUPOLE
0053 % the user can  use different methods
0054 % implemented as different pass-functions:
0055 
0056 SOMEQUAD = THERING{5};
0057 % ______________________________________________________
0058 QuadLinearPass(SOMEQUAD,R)
0059 % ______________________________________________________
0060 StrMPoleSymplectic4Pass(SOMEQUAD,R)
0061 % ______________________________________________________
0062 StrMPoleSymplectic4RadPass(SOMEQUAD,R)
0063 
0064 pause % Press any key to continue
0065 clc
0066 % The choice of a proper model depends on
0067 %
0068 % 1. The problem
0069 %
0070 % 2. Speed-accuracy trade-off
0071 %      For example:
0072 %      StrMPoleSymplectic4Pass (4-th order integrator)
0073 %      is slower but more accurate
0074 %      than StrMPoleSymplectic2Pass (2-nd order integrator)
0075 % 3. Physical considerations
0076 %      For example:
0077 %      DRIFTPASS assumes a field-free region which is
0078 %      NOT a good model for a quadrupole magnet
0079 % 4. Element-Method consistency
0080 %      Element data gets passed to a pass-function as the first argument
0081 %      Pass-function attempts to use the field with specific name:
0082 %      For example:
0083 %      QUADLINEARPASS needs fields 'Length' and 'K' ...
0084 %      If the element is a drift it does not have 'K' field
0085 %      If in the above examples we tried QUADLINEARPASS(SOMEDRIFT,R)
0086 %      MATLAB would ungracefully stop excecution
0087 %      !!! This feature puts responsibility for consistency between
0088 %      Pass-functions used and elements ON THE USER. Small price to
0089 %      pay for flexibility !!!
0090 %
0091 pause % Press any key to continue
0092 clc
0093 % Available and extensively tested methods in Accelerator Toolbox 1.0
0094 %
0095 % AperturePass
0096 % BendLinearPass
0097 % BndMPoleSymplectic4Pass
0098 % BndMPoleSymplectic4RadPass
0099 % DriftPass
0100 % IdentityPass
0101 % QuadLinearPass
0102 % StrMPoleSymplectic4Pass
0103 % StrMPoleSymplectic4RadPass
0104 % ThinCavityPass
0105 % ThinCorrectorPass
0106 %
0107 % The names were ment to be long and self-explanatory and end with 'Pass'
0108 %
0109 % Calling syntax is allways for all element pass-functions is the same
0110 %
0111 % These files are originally written in C and converted to MATLAB mex-functions
0112 % They are located (together with source codes and some with help files)
0113 % in ..\simulator\element
0114                         
0115 pause % Press any key to finish
0116 clc
0117 
0118 echo off
0119 clc

Generated on Mon 21-May-2007 15:26:45 by m2html © 2003