The command syntax in FFS is "expression1 [param1..] [;] expression2.."
Example: QF* .1
means the set-value-of-element command unless the symbol QF has been defined. If QF has been defines as a number, such as QF=2.5, the above command line is interpreted as Times[QF,.1] then returns .25 .
Stops SAD immediately.
APP {filename | file-number} switches the output stream to the specified file or the file number. The output is appended to the existing file.
Usage: ATTR element-pattern
prints out the current value, mimumum and maximum values, COUPLEd element and its coefficient for elements which match the element-pattern.
Exits from the current beam line and returns to the original beam line where VISIT command was issued. All information specific to the beam line, such as matching conditions are restored.
Note that BYE does neither SAVE the values of elements of the leaving beam line, nor RESET the values of elements of the returning beam line.
Usage: (1) CALC [[NO]EXPAND]]
(2) CALC matching-function1[-] [matching-function2[-]..]
(1) With no argument or with an option [NO]EXPAND, calculates the optics and the matching-functions using the current values of the components. It prints out the values of the matching-functions specified either by the matching-function-commands or the second usage of CALC, as described below. If an option EXPAND is given(default), it expands the beam line before the calculation. If NOEXPAND is given, it calculates without any expansion. FFS["CAL"] and FFS["GO"] returns the result as a list, whose format is
"{dp, kind, reslist, function-values},"
where
where
(2) With matching-fuction names, sets the matching-functions at the current fit point to be printed out after calculation. If the matching-function is followed by a minus sign, it suppresses the print-out.
Example: CALC BX BY CALC
CHRO prints out the chromaticity of QUAD and SEXT in the entire beam line using the simplest formula:
for QUAD,
for SEXT.
These formula are not valid when there is x-y coupling or vertical dispersion.
CLOSE [INPUT(IN)] closes the current input stream and switches it to the previous input stream.
CLOSE OUTPUT(OUT) suspends the current output and switches it to the previous output stream.
Usage: COUP slave-element master-element coefficient
sets the value of the default-keyword of slave-element to be equal to coefficient times the value of the default-keyword of master-element. COUPLE(COUP) cannot be cascaded. The master-element cannot be COUPLEd to any other element. To reset COUPLE, say COUP slave-element slave-element 1.
Example: COUPLE QFS001 QFS001 1.0 COUPLE QFS002 QFS001 1.0 COUPLE QFS003 QFS001 1.0
Usage: DISP_LAY [keywords] [pattern-string] [region] e.g. DISP B1.1 QF QD (* QFとQDの間にある、B1.1を表示される。)
Displays values of various optical-/geometric-functions at the components given by the pattern-string in the region (see region) in the current beam line.
It has several display modes specified by the keywords. As the default, it displays AX, BX, NX, EX, EPX, AY, BY, NY, EY, EPY, LENG, the length and the value of the default-keyword of the component.
Each line refers to the entrance of each component of the line. The end of the beam line has the name "$$$". The first component can be specified by "^^^".
DISP does not calculate the functions to be displayed, so CALCULATE(CALC) is necessary whenever values of components are updated.
Example: EMITX=...; EMITY=...;DP=...; BEAMSIZE(BEAM) DISP B
DISP .... begin [end]
with begin and end having the form name[.order][{+-}offset] (see components).
Example: DISP ... QF.2-10 QD+5
displays functions starting at 10 elements upstream from the entrance of the second QF through 5 elements downstream from the entrance of the first QD. The region for DISP is kept after once set It is shown in the second part of the prompt when FFSPRMPT is ON, and also seen by the STATUS(STAT) command. The components which match the pattern-string in DISP are only chosen in the current region.
regionのデフォルトはallであるが、一度、regionをセットすると、後まで残るので、その場合は、allを指定すると、resetされる。USE、VISITなど他のビームラインに移っても、resetされる。どのregionが設定されているかはSTATで分かる。
prints out the current machine errors of components which match component- pattern.
Usage: DUMP component-pattern [compnent-pattern1..]
ElementValues is a symbol to assign rules to determine values of keywords of elements or components. This is used to give a dependence between keywords of different elements or components, or determine then by a parameteric expression.
Usage ElementValues = { key[elem] :> expr, ...}
where
Example:
ElementValues =
{ "DX"["QF1"] :> "DX"["QD1"]-0.001,
"DY"["QF2.3"] :> -"DY"["QD1.2"],
"ROTATE"["QF*"] :> f[x] }
Remarks:
executes the character-string-expresssion as FFS commands.
Usage: EXEC character-string-expression
Usage: (1) FIT [component]
(2) FIT component1 component2
sets the current location where the matching condition is applied. The component is given with the form name[.order][{+-}offset] (see components). If component is omitted, the end of the beam line is chosen.
If two components are given, it means a realtive-fitting or zone-fitting. If the fitting condition is not maximum-fitting, the condition means to make values at two components equal (for AX, BX, AY, BY, EX, EPX, EY, EPY, R1, R2, R3, R4, DX, DPX, DY, DPY, PEX, PEPX, PEY, PEPY, CHI1, CHI2, CHI3), or have the specified difference (for NX, NY, LENG, GX, GY, GZ).
If the fitting condition is maximum-fitting, the condition means a zone-fitting (for AX, BX, AY, BY, EX, EPX, EY, EPY, R1, R2, R3, R4, DX, DPX, DY, DPY, PEX, PEPX, PEY, PEPY, CHI1, CHI2, CHI3), which suppress the maximum of the function in the region between component1 and component2, or maximum-fitting for the difference of the function (for NX, NY, LENG, GX, GY, GZ).
The fit region is shown in the first part of the prompt when FFSPRMPT is ON.
Example: (1) FIT QF.2-10
sets the current fit point at 10 components upstream from the entrance of the second QF.
(2) FIT QF QD NX 0.5 BXM 10
sets the two-point fitting between QF and QD, then set the difference of NX between QF and QD to be 0.5, and the maximum of BX to be 10 in the region between QF and QD.
FITP n sets n to the number of off-momentum points in the off-momentum matching. If the fitting condition is on-momentum only, it is not affected.
Usage: (1) FIX element-pattern [keyword] [element-pattern1 [keyword1]..]
removes elements which match element-pattern from the matching variables. The optional keyword specifies the non-default variables. If the keyword is omitted, all keywords are removed.
For the MARK element at the beginning of the beam line, a special form can be used for the FIX command. That is a form I (appending "I" to a matching-function name).
Example: FIX AXI BXI AYI BYI
removes incoming AX, BX, AY, and BY from the matching variables.
Usage: (2) FIX
sets the standard optics for the orbit correction commands.
Usage: FREE element-pattern [keyword] [element-pattern1 [keyword1]..]
specifies elements which match element-pattern as the matching variables. The optional keyword specifies the non-default variables. See default-keyword.
For the MARK element at the beginning of the beam line, a special form can be used for the FREE command. That is a form I (appending "I" to a matching-function name) which means the incoming condition of the matching-function is varied in the matching.
Example: FREE AXI BXI AYI BYI;
changes incoming AX, BX, AY, and BY to find the solution.
Example: FREE BEND K1 Q2;
| type | default-keyword | non-default variable keyword |
| DRIFT | L | - |
| BEND | ANGLE | K1,K0,E1,E2 |
| QUAD | K1 | ROTATE |
| SEXT | K2 | ROTATE |
| OCT | K3 | ROTATE |
| DECA | K4 | ROTATE |
| DODECA | K5 | ROTATE |
| MULT | K1 | K0,K2..K21,SK0,SK1,SK2..SK21,ROTATE,ANGLE |
| MARK | - | AX,BX,EX,EPX,AY,BY,EY,EPY,R1,R2,R3,R4,DX,DPX,DY,DPY,DZ,DDP |
prints out the TopDrawer commands for the geometric plot of the beam line.
Available geometrical-functions are:
| GX | geometrical coordinate xi |
| GY | geometrical coordinate eta |
| GZ | geometrical coordinate zeta |
| CHI1 | geometrical rotation angle chi1 |
| CHI2 | geometrical rotation angle chi2 |
| CHI3 | geometrical rotation angle chi3 |
The geometrical coordinate {xi, eta, zeta} is set by the ORG command. Its default origin is at the entrance of the beam line and the default directions are xi in s-direction, eta in -(x-direction} and zeta in -(y-direction) at the entrance. The set {xi, eta , zeta} forms a right-handed system.
The rotation angle are defined so as to give the local {x, y, s} is writtend as
{x, y, s}_local
= rotate[s, chi3] rotate[x,chi2] rotate[y,-chi1] {x, y, s}_origin,
where rotate[a,b] read " rotate around the new a vector by b right-handedly".
Usage: GO [[NO]EXPAND]
Does matching for fitting conditions given by matching-function-commands with variables specified by FREE.
If an option EXPAND is given (default), it expands the beam line before the calculation. If NOEXPAND is given, it avoids any expansion.
FFS["CAL"] and FFS["GO"] returns the result as a list, whose format is {dp, kind, reslist, function-values},
where
Usage: IF expr1 body1 [ELSEIF expr2 body2 [ELSEIF ..]] [ELSE body3] ENDIF
This is a FORTRAN77 like IF-structure. If the expression expr1 is True(==1) or nonzero, executes commands in body1. If it is False(==0), skip commands until ELSE, ELSEIF or ENDIF appears at the same level of the IF-structure, and executes commands after ELSE or ENDIF, or executes the ELSEIF command. If expr1 is not a real number, an error message is printed and ignores the command line.
IN {filename | file-number} switches the input stream to the specified file or the file-number. The original stream is kept and to be returned by TERMINATE(TERM). The input file is not rewound.
Machine errors can be included as follows.
Usage: cmd [options] error component
| command | keyword affected | applicable types |
| DELX | DX | END QUAD SEXT OCT DECA DODECA SOL CAV |
| DELY | DY | BEND QUAD SEXT OCT DECA DODECA SOL CAV |
| DL | L | DRIFT SOL |
| DTHETA | ROTATE | QUAD SEXT OCT DECA DODECA CAV |
| DTHETA | DROTATE | BEND |
| DK | default-keyword | DRIFT BEND QUAD SEXT OCT DECA DODECA MULT SOL CAV |
| DDK | K0 or DBZ | BEND SOL |
Example:
SeedRandom[11]; DELX R INC 0.1E-3 Q*A; SeedRandom[111]; DTHETA R INC 0.1E-4 B%%%%%A;
Usage: (1) matching-function goal-value [off-momentum-points]
(2) matching-functionM goal-value [off-momentum-points]
(3) matching-functionI incoming-value
(4) matching-functionSCALE scale
Example:
BX 10 3 (beta_x to be 10 at 3 momenta) BX 20 (now beta_x to be 20 at 3 momenta (previous setting)) BX * 5 (now beta_x to be 20 (previous setting) at 5 momenta)
Usage: MATRIX [{SYMPLECTIC(S) | PHYSICAL(P)}] [from to]
prints out the 4 by 5 transfer matrix from from-component to to-component. If SYMPLECTIC(S) is specified (default), the symplectic transfer matrix on {x,px/p0,y,py/p0,dp/p0} where p0 is the nominal momentum at the entrance, is given. Otherwise, in the case of TRPT, the transfer matrix on {x,px/p0(s),y,py/p0(s),dp/p0(s)} is printed out.
If the from- and to- components are omitted, entire beam line is assumed. If to-component is upstream the from-component, it gives the inverse matrix (TRPT) or one-turn-wrapped matrix (RING).
Example: MATRIX S MARK1 Q7
例えば、MATRIXコマンドは、以下のように、
Example2: In[401]:= MATRIX 1 10 Symplectic transfer matrix from IP.1 to $$$ -.982290 -.006002 3.33981E-4 -2.4430E-7 7.8337E-11 5.855696 -.982249 3.34029E-4 1.73638E-7 5.2190E-10 1.40369E-6 -2.5571E-7 -.904844 -1.1543E-4 -1.858E-10 7.76187E-5 8.53083E-5 1576.96169 -.903992 3.47110E-7
ある場所から別の場所へのtransfer matrixを表示します。これを関数値として得るためには、
TransferMatrix[1,10]
Out[407]:= {{.9999950934623387,.03999986939026092,-.0022150757922688117,-8.860206731567784e-05},
{-.00012350960294931125,.9999950597394202,-1.7620057075833354e-06,-.002215076409368412},
{.0022149950604407505,8.860105865371935e-05,.9999950933972983,.039999869847057425},
{-2.307282605538483e06,.0022149943695186627,-.00012265990820026047,.9999950937922504}}
のように関数 TransferMatrix[from, to] を使います。コマンドと関数は別体系なので混同しないようにしてください。
尚
MATRIX;
とだけ記述した際には、リング一周分の行列を得ることができます。
Usage: MEA [end-component] [OUT file plot-spaces]
tracks particles from the entrance to end-component and prints out the statistics ath the end. If end-component is omitted, the componentend used in the last MEASURE(MEA) (default: end of the beam line) is assumed.
If OUT file plot-spaces are attached, it plots phase space disribution on file. The phase-spaces are specified like as X-PX, or X-Y, etc., (up to any numbers).
Parameters for the tracking are specified by special-variables and flags:
The initial transverse distribution is Gaussian.
FFS matches the optical functions for an orbit with finite momentum deviation.
Example:
DP=0.01; sets the range of momentum to DP0-0.01 < dp/p0 < DP0+0.01 .
BX 10 9; sets the goal of betax to 10 m, at 9 points.
in the range above, i.e.,
dp/p0 = {-0.01,-0.0075,-0.005,-0.0025,0,
0.0025,0.005,0.0075,0.01} + DP0 .
GO starts the matching.
As this example, the off-momentum points are chosen with equal separation. If the off-momentum point n is an even number, the chosen points are same as the case of n+1, but the on-momentum point (==DP0) is excluded.
Available optical functions for matching are:
| AX | alpha_X |
| BX | beta_X |
| NX | psi_X, the default scale is 1/(2Pi) |
| AY | alpha_Y |
| BY | beta_Y |
| NY | psi_Y, the default scale is 1/(2Pi) |
| EX | eta_X (dispersion_X) |
| EPX | eta_Px (dispersion_PX) |
| EY | eta_Y (dispersion_Y) |
| EPY | eta_Py (dispersion_PY) |
| R1 | R_1 (see x-y-coupling) |
| R2 | R_2 (see x-y-coupling) |
| R3 | R_3 (see x-y-coupling) |
| R4 | R_4 (see x-y-coupling) |
| DX | dx |
| DPX | dpx |
| DY | dy |
| DPY | dpy |
| DZ | dz |
| DDP | delta=dp/p0 |
| PEX | eta_x (dispersion_x) |
| PEPX | eta_px (dispersion_px) |
| PEY | eta_y (dispersion_y) |
| PEPY | eta_py (dispersion_py) |
| TRX | trace(T_X), only defined at the end of the beam line. |
| TRY | trace(T_Y), only defined at the end of the beam line. |
| LENG | length of the design orbit |
In the above, upper case X, Px, Y, Py represents the x-y decoupled coordinate. EX, EPX, EY, EPY refer the decoupled coordinate, while PEX, PEPX, PEY, PEPY are in the physical coordinate. On the other hand, DX, DPX, DY, DPY refer the physical coordinate.
ORG can change the geometrical-functions. usage:
ORG element_ gx_ gy_ gz_ chi1_ chi2_ chi3_
e.g. org ip 0, 0, 0, 0.011*180/Pi, 0, 0;
where ip is MARK element defined elsewhere.
OUT {filename | file-number} switches the output stream to the specified file or the file-number. The file is written from the beginning.
PRI expression evaluates expression and prints out the result.
Exits FFS and return tos SAD/MAIN level, without saving the values of the elements.
RADINT prints out the radiation integrals involving the x-y coupling for all components of the beam line.
READ {filename | file-number} switches the input stream to the specified file or the file-number. The original stream is kept and to be returned by TERMINATE(TERM). The input file is rewound.
Example:
read "MR080419t"; ! Main Ring Optics read "magmult"; ! Magnet multipole data
REC exchanges the values of FREEd elements with those when the last GO command was issued. FIXed elements are not affected.
Usage: (1) REJ matching-function-pattern [matching-function-pattern1..]
(2) REJ TOTAL
rejects the matching-functions which match matching-function-pattern at the current FIT location. If TOTAL is given, entire matching conditions in all locations.
Usage: REP [n] body UNTIL [expr1]
executes commands in body n times until expr1 gives nonzero. The number n can be any expression which gives a number. If n is omitted, infinity is assumed. If expr1 is omitted, False(==0) is assumed.
Usage: RESET [ALL] [element-pattern]
restores the value of the elements. What are restored are the value of the default keyword of all elements, the values of the non-default keywords which have been changed manually or by the matching. If ALL is given, it resets all keywords. If element-pattern is given, reset is limited to the elements which match the pattern.
REV changes the sign of AX, AY, EPX, EPY, R2, R3, DPX, DPY at the entrance of the beam line.
Usage: SAVE [element-pattern]
saves the values of the elements. What are saved are the value of the default keyword of all elements, the values of the non-default keywords which have been changed manually or by the matching. If ALL is givem it resets all keywords. If element-pattern is given, it is only limited to the elements which match the pattern, otherwise all elements are saved.
SEED n sets n to the seed of the random number generator. The number n should be an odd number. Do not say SEED=n for this purpose.
Usage: element-pattern [keyword] [{MIN | MAX | MINMAX | MAXMIN}] value
sets value to the specified keyword of the elements which match element-pattern. If keyword is omitted, the default-keyword is assumed.
If MIN, MAX, MINMAX, MAXMIN are specified, it sets the limit of the default-keyword. Both MINMAX and MAXMIN means MIN=-Abs[value] and MAX=+Abs[value].
If the keyword is not the default-keyword, it affects both the current and the saved value.
| type | keywords |
| DRIFT | L RADIUS |
| BEND | L ROTATE DROTATE DX DY ANGLE K0 K1 E1 E2 AE1 AE2 F1 FRINGE DISFRIN DISRAD EPS RANKICK |
| QUAD | L ROTATE DX DY K1 F1 F2 FRINGE DISFRIN DISRAD EPS |
| SEXT | L ROTATE DX DY K2 DISFRIN DISRAD |
| OCT | L ROTATE DX DY K3 DISFRIN DISRAD |
| DECA | L ROTATE DX DY K4 DISFRIN DISRAD |
| DODECA | L ROTATE DX DY K5 DISFRIN DISRAD |
| MULT | L DX DY DZ CHI1 CHI2 ROTATE(=CHI3) K0..K21 SK0..SK21 DISFRIN DISRAD EPS VOLT HARM PHI DPHI FREQ RADIUS ANGLE E1 E2 AE1 AE2 DROTATE |
| SOL | BZ DX DY DZ DPX DPY BOUND GEO CHI1 CHI2 CHI3 |
| CAVI | L ROTATE DX DY VOLT V1 V20 V11 V02 FREQ PHI HARM RANVOLT RANPHASE |
| TCAVI | L ROTATE DX DY K0 V1 FREQ PHI HARM RANKICK RANPHASE |
| COORD | DX DY CHI1 CHI2 CHI3 DIR |
| MARK | AX BX AY BY EX EPX EY EPY R1 R2 R3 R4 DX DPX DY DPY DZ DDP EMITX EMITY DP AZ SIGZ GEO OFFSET |
| APERT | DX1 DX2 DY1 DY2 DP |
| type | default-keyword | non-default variable keyword |
| DRIFT | L | - |
| BEND | ANGLE | K1,K0,E1,E2 |
| QUAD | K1 | ROTATE |
| SEXT | K2 | ROTATE |
| OCT | K3 | ROTATE |
| DECA | K4 | ROTATE |
| DODECA | K5 | ROTATE |
| MULT | K1 | K0,K2..K21,SK0,SK1,SK2..SK21,ROTATE,ANGLE |
| MARK | - | AX,BX,EX,EPX,AY,BY,EY,EPY,R1,R2,R3,R4,DX,DPX,DY,DPY,DZ,DDP |
VARYを使ってからFREE/MINMAXを適用すれば,マッチングの場合にも パラメータの範囲の上下限を決めるMAX, MIN, MINMAX, MAXMINを使用することは可能である。
Example: MOMENTUM = 1 GeV; MARK MKS = () MKE = () ; BEND B1 = (L = 0.1 ANGLE = 0.1) ; QUAD Q1 = (L = 0.1) ; DRIFT D1 = (L=0.1) ; LINE TEST = (MKS D1 Q1 D1 B1 D1 MKE) ; ON LOG; ON RAD FLUC COD RFSW RADCOD; FFS USE TEST; INS CALC; FIT BX 1; VARY K1 B1 free B1 K1; B1 K1 MINMAX 0.5 ; VAR GO; TYPE B1 Q1; DISP; STOP; STOP;
SHOW prints out the current matching conditions. FFS["SHOW"] returns the current matching conditions as a list. Each element has a form of "{component1, component2, function, goal-value, number-of-momentums, scale}", which corresponds to the new format of the print-out by SHOW.
Usage: SPLIT component length
splits the component into two pieces at the point where the distance from the entrance is length. The new components have the same name as the original, and the strengths are proportional to the new lengths. Only magnets and cavities can be split. You should CALCULATE(CAL) after SPLIT to get optical parameters after SPLIT. Matching using SPLIT element as a variable may degrades the speed of convergence.
STAT shows the current settings of flags, fit points, special-variables, the region for DISPLAY, seed of the random number generator, and elapsed CPU time, etc.
Exits FFS and returns to SAD/MAIN level, with saving the values of the elements.
Usage: TDR {filename | file_number}
runs TopDrawer (tdr) using the file specified by filename or file_number as the input. It supports both Tek terminal and X-window.
Example: OUT 'a' DRAW bx by & ex ey q* CLOSE OUT TDR 'a'
TDR does not work when SAD is running under EMACS without X-window.
TERM [INPUT(IN)] suspends the current input stream and switches it to the previous input stream.
TERM OUTPUT(OUT) suspends the current output and switches it to the previous output stream.
Usage: TYPE [element-pattern [element-pattern1..]]
prints out the values of elements which match element-pattern in the SAD MAIN input format. Keywords which have zero values are omitted unless it is the default variable. If non element-pattern is given, all elements are printed out.
Usage: REP [n] body UNTIL [expr1]
executes commands in body n times until expr1 gives nonzero. The number n can be any expression which gives a number. If n is omitted, infinity is assumed. If expr1 is omitted, False(==0) is assumed.
Usage: USE [[NO]EXPAND] beam-line
switches the beam line used in FFS to the beam line given by beam-line. beam-line can be an BeamLine object or the name of a beamline defined in MAIN. All information specific to the current beam line, such as matching conditions is lost. If the keyword EXPAND is given (default), the new beam line is expanded, i.e., the values of components are refreshed ot the saved values. If a BeamLine object is used by USE or VISIT, the new beam line becomes a new LINE in the MAIN level, with a name which is created automatically.
VARIABLES displays a list of current matching-variables and their present, previous, saved, minimum, and maximum values together with the COUPLEd master elements and their coefficients.
When executed in the FFS function, it returns the result as a list.
Usage: FFS["VAR"]
returns a list of nvar elements, where nvar is the number of current matching-variables given by the FREE command. Each element has the form "{name, keyword, present, previous, saved, minimum, maximum, coupled-master-element, coupling-coefficient} ",
which corresponds to the output of the VARIABLES(VAR) command.
Usage: VARY keyword element-pattern
changes the default-keyword of the elments which match element-pattern to keyword.
Usage: VISIT [[NO]EXPAND] beam-line
switches the beam line used in FFS to the beam line given by beam-line. beam-line can be an BeamLine object or the name of a beamline defined in MAIN. All information specific to the current beam line, such as matching conditions are reserved, and the previous beam line is restored when BYE command is issued. If the keyword EXPAND is given (default), the new beam line is expanded, i.e., the values of components are refreshed ot the saved values.
If a BeamLine object is used by USE or VISIT, the new beam line becomes a new LINE in the MAIN level, with a name which is created automatically.