Home > atdemos > tracking > trackingdemo.m

trackingdemo

PURPOSE ^

TRACKINGDEMO self-running tutorial

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

TRACKINGDEMO self-running tutorial
 1. Phase-Space tracking variables
 2. Tracking through individual elements
 3. Method - Element consistency

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %TRACKINGDEMO self-running tutorial
0002 % 1. Phase-Space tracking variables
0003 % 2. Tracking through individual elements
0004 % 3. Method - Element consistency
0005 clear all
0006 clc
0007 echo on
0008 % The term 'tracking' in Accelerator Physics refers to numerical simulation
0009 % of particle motion in phase-space as it passes through an accelerator
0010 %
0011 % MATLAB Accelerator Toolbox uses 6-by-1 column vectors to represent
0012 %  Individual particles in phase space with components [x px y py delta ct]'
0013 %  For example:
0014 R = [0.01 0 0.01 0 0 0]'
0015 
0016 % and 6-by-N matrixes to simultaneously track groups of N particles
0017 %
0018 RRR = [R 2*R 3*R]
0019 
0020 pause % Press any key to continue
0021 clc
0022 % In Accelerator Toolbox tracking is built upon
0023 % a collection of functions that track particles through
0024 % individual accelerator elements
0025 %
0026 % Example: Load the spear2 lattice
0027 spear2
0028 %
0029 % Second element in spear2 lattice is a drift space
0030 SOMEDRIFT = THERING{2}
0031 whos SOMEDRIFT
0032 % D is a MATLAB structure
0033 % Now use function DRIFTPASS to track through SOMEDRIFT
0034 pause % Press any key to continue
0035 clc
0036 DriftPass(SOMEDRIFT,R)
0037 % or simultaneously for 3 particles
0038 DriftPass(SOMEDRIFT,R)  
0039 % Obviously in a drift space particle momentums don't change
0040 %
0041 % Try this
0042 DriftPass(SOMEDRIFT,[0 0.01 0 0.02 0 0]'),
0043 
0044 pause % Press any key to continue
0045 clc
0046 % Accelerator Toolbox provides an open ended collection
0047 % of functions that track through elements using various
0048 % field models.
0049 %
0050 % For example with a more interesting element QUADRUPOLE
0051 % the user can  use different models
0052 % implemented in as different pass-methds:
0053 
0054 SOMEQUAD = THERING{5};
0055 % ______________________________________________________
0056 QuadLinearPass(SOMEQUAD,R)
0057 % ______________________________________________________
0058 StrMPoleSymplectic4Pass(SOMEQUAD,R)
0059 % ______________________________________________________
0060 StrMPoleSymplectic4RadPass(SOMEQUAD,R)
0061 % ______________________________________________________
0062 % even
0063 DriftPass(SOMEQUAD,R)
0064 
0065 pause % Press any key to continue
0066 clc
0067 % The choice of a proper model depends on
0068 %
0069 % 1. The problem
0070 %
0071 % 2. Speed-Accuracy trade-off
0072 %      StrMPoleSymplectic4Pass is slower but more accurate
0073 %      than StrMPoleSymplectic2Pass.
0074 % 3. Physical considerations
0075 %      DriftPass assumes a field-free region which is
0076 %      NOT a good model for a quadrupole magnet
0077 % 4. Element-Method consistency
0078 %      Element data gets passed to a pass-function as the first argument
0079 %      Pass-function attempts to use the field with specific name:
0080 %      For example QUADLINEARPASS needs 'Length', 'K',
0081 %      If the element is a drift it does not have 'K'
0082 %      If in the above examples we tried QUADLINEARPASS(SOMEDRIFT,R)
0083 %      MATLAB would ungracefully stop execution
0084 %      !!! This feature puts responsibility for consistency between
0085 %      Pass-functions used and elements ON THE USER. Small price to
0086 %      pay for flexibility !!!
0087 
0088 
0089 
0090 pause % Press any key to finish
0091 echo off
0092 clc

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