Welcome to SAD/FFS & SADScript

SAD/FFS SADScript Version: 1.1.6.7k64, Updated: 6/2/2019
 Please use browser's search to find out an item.

 The FFS commands are shown in uppercases. The minimum abbreviated form of each command is
 enclosed
in (). Each command can be shorten down to that. The optional arguments for the commands a
re usually
shown in [].
 The notation ===> reads "equivalent to" below.

SAD Back to SAD Home Page

SAD/FFS Examples


 
   ABORT
   APPEND(APP)
   ATTRIBUTE(ATTR)
   beam-line
      beam-line-functions
         BeamLine
         BeamLineName
         ExtractBeamLine
         PrintBeamLine
         WriteBeamLine
      orientation-of-an-element
   BYE
   character-string
      FromCharacterCode
      StringFill
      StringJoin
      StringLength
      StringMatchQ
      StringPart
      StringPosition
      StringReplace
      StringTrim
      Symbol
      ToCharacterCode
      ToExpression
      ToString
   command-syntax
   components
   constants
   CALCULATE(CAL)
   CHROMATICITY(CHRO)
   CLOSE(CLO)
   COUPLE(COUP)
   data-structure
      Extract
      Head
      Length
      List
      Part
   defining-functions
   dynamics
      independent-variable
      Lagrangean
      Hamiltonian
      remarks-on-dynamics
      x-y-coupling
      extended-Twiss-parameters
         definitions
   DISPLAY(DISP)
      ACCELERATION(A)
      ALL
      BEAM(B)
      DUMPOPTICS(D)
      GEOMETRY(G)
      OGEOMETRY(OG)
      ORBIT(O)
      pattern-string
      PHYSICAL(P)
      region
      RMATRIX(R)
      Z
   DRAW
      Draw$Option
   DUMP
   elements
      APERT
      BEND
         AE1
         AE2
         ANGLE
         DISFRIN
         DISRAD
         DROTATE
         DX
         DY
         E1
         E2
         F1
         FB1
         FB2
         FRINGE
         K0
         K1
         L
         ROTATE
         transformation:BEND
      CAVI
         DISFRIN
         DPHI
         DVOLT
         DX
         DY
         FREQ
         HARM
         L
         PHI
         ROTATE
         V02
         V1
         V11
         VOLT
      COORD
      default-keyword
      DECA
         DISFRIN
         DISRAD
         DX
         DY
         K4
         L
         ROTATE
         transformation:THIN
      DODECA
         DISFRIN
         DISRAD
         DX
         DY
         K5
         L
         ROTATE
         transformation:THIN
      DRIFT
         L
         RADIUS
         transformation:DRIFT
      keywords
      MARK
         OFFSET
      MULT
         AE1
         AE2
         ANGLE
         DISFRIN
         DISRAD
         DPHI
         DVOLT
         E1
         E2
         F1
         F2
         FB1
         FB2
         FREQ
         FRINGE
         HARM
         K0
         K1
         K10
         K11
         K12
         K13
         K14
         K15
         K16
         K17
         K18
         K19
         K2
         K20
         K21
         K3
         K4
         K5
         K6
         K7
         K8
         K9
         L
         misalignments
         multipole_with_nonzero_ANGLE
         PHI
         RADIUS
         SK0
         SK1
         SK10
         SK11
         SK12
         SK13
         SK14
         SK15
         SK16
         SK17
         SK18
         SK19
         SK2
         SK20
         SK21
         SK3
         SK4
         SK5
         SK6
         SK7
         SK8
         SK9
         VOLT
      OCT
         DISFRIN
         DISRAD
         DX
         DY
         K3
         L
         ROTATE
         transformation:THIN
      QUAD
         DISFRIN
         DISRAD
         DX
         DY
         F1
         F2
         FRINGE
         K1
         L
         ROTATE
         transformation:QUAD
      SEXT
         DISFRIN
         DISRAD
         DX
         DY
         K2
         L
         ROTATE
         transformation:THIN
      SOL
         BOUND
         BZ
         DISFRIN
         DPX
         DPY
         DX
         DY
         F1
         GEO
   expression
      (-)
      (/)
      AddTo(+=)
      Alternatives(|)
      And(&&)
      Apply (@@)
      CompoundExpression(;)
      Decrement(--)
      DivideBy(/=)
      Dot(.)
      Equal(==)
      Function(&)
      Greater(>)
      GreaterEqual(>= or =>)
      Increment(++)
      Less(<)
      LessEqual(<= or =<)
      List({})
      Map (/@)
      MapAll(//@)
      Member(@)
      MessageName(::)
      Not(~)
      Or(||)
      Part([[]])
      PatternTest(?)
      Plus(+)
      Power(^)
      Repeated(..)
      RepeatedNull(...)
      ReplaceAll(/.)
      ReplaceRepeated(//.)
      Rule(->)
      RuleDelayed(:>)
      SameQ(===)
      Sequence([])
      Set(=)
      SetDelayed(:=)
      StringJoin (//)
      SubtractFrom(-=)
      TagSet(/:)
      Times(*)
      TimesBy(*=)
      Unequal(<>)
      UnsameQ(<=>)
      Unset(=.)
   ELSE
   ELSEIF
   EMITTANCE(EMIT)
   END
   ENDIF
   EXECUTE(EXEC)
   EXPAND
   flags
      ABSW
      BIPOL
      CALC4D
      CALC6D
      CELL
      CMPLOT
      COD
      CODPLOT
      CONV
      CONVCASE
      DAMPONLY
      DAPERT
      DIFFRES
      ECHO
      EMIOUT
      FFSPRMPT
      FIXSEED
      FLUC
      GAUSS
      GEOCAL
      GEOFIX
      HALFRES
      IDEAL
      INS
      INTRA
      INTRES
      JITTER
      LOG
      LWAKE
      MOVESEED
      PHOTONS
      POL
      PRSVCASE
      PSPAC
      QUIET
      RAD
      RADCOD
      RADLIGHT
      RADPOL
      RADTAPER
      REAL
      RELW
      RFSW
      RING
      SELFCOD
      SORG
      SPAC
      STABLE
      SUMRES
      TRPT
      TWAKE
      UNIFORM
      UNIPOL
      UNSTABLE
      WSPAC
   functions
      Data-Manipulation
         Fit
         FitEmit
         FitGaussian
         NIntegrate
         PolynomialFit
         Spline
      DownhillSimplex
      functional-operations
         Apply
         Cases
         DeleteCases
         Difference
         FixedPoint
         FixedPointList
         level-spec
         Map
         MapThread
         Position
         Scan
         ScanThread
         SelectCases
         SwitchCases
         Thread
      FFS-dedicated-functions
         AccelerateParticles
         BeamMatrix
         DynamicApertureSurvey
         Element
            key-strings:Element
         Emittance
         ExternalMap
         FFS
         FFS$SHOW
         FitValue
         FitWeight
         GeoBase
         LINE
            key-strings:LINE
         OptimizeOptics
         OrbitGeo
         RadiationField
         RadiationSpectrum
         SetElement
         SurvivedParticles
         SymplecticJ
         SynchroBetaEmittance
         TouschekLifetime
         TrackParticles
         Twiss
         VariableRange
         VariableWeight
         WakeFunction
      Graphics
         BeamPlot
         ColumnPlot
         FitPlot
         GeometryPlot
         HistoPlot
         ListContourPlot
         ListDensityPlot
         ListPlot
         OpticsPlot
         Plot
      Input/Output
         $FORM
         $Input
         $Output
         Close
         OpenAppend
         OpenRead
         OpenWrite
         PageWidth
         Print
         Read
         ReadString
         StandardForm
         StringToStream
         Write
         WriteString
      Multiprocessing
         Fork
         OpenShared
         Shared
         SharedSize
      Object-oriented-programing
         Class
      Random-number-functions
         Random
         GaussRandom
         ParabolaRandom
         SeedRandom
         ListRandom
      System-interface
         System
         TemporaryName
      Utilities
         DateString
         MemoryCheck
         TimeUsed
         Timing
         TracePrint
   FIT
   FITPOINTS(FITP)
   FIX
   FREE
      default-keyword
   geometric-functions
   GEO
   GO
   IF
   INPUT(IN)
   machine-error-commands
   matching-function-commands
   multi-turn-tracking
   MATRIX(MAT)
   MEASURE(MEA)
   off-momentum-matching
   optical-functions
   ORG
   OUTPUT(OUT)
   pattern
      MatchQ
   physical-constants
   PRINT(PRI)
   QUIT
   RADINT
   READ
   RECOVER(REC)
   REJECT(REJ)
   REPEAT(REP)
   RESET
   REVERSE(REV)
   set-value-of-element
      keywords
      default-keyword
   special-variables
      $Line
      CASE
      CHARGE
      CONVERGENCE
      DAPWIDTH
      DP
      DP0
      DTSYNCH
      EFFRFFREQ
      EFFVC
      EFFVCRATIO
      ElementValues
      EMITX
      EMITXE
      EMITY
      EMITYE
      EMITZ
      EMITZE
      ExponentOfResidual
      FFS$NumericalDerivative
      FitFunction
      FSHIFT
      GCUT
      InitialOrbits
      LOSSAMPL
      LOSSDZ
      MatchingAmplitude
      MatchingResidual
      MASS
      MINCOUP
      MOMENTUM
      NBUNCH
      NetResidual
      NP
      NPARA
      OffMomentumWeight
      OMEGA0
      OpticsEpilog
      OpticsProlog
      PBUNCH
      PhotonList
      PHICAV
      SIGE
      SIGZ
      SpeedOfLight
      StabilityLevel
      STACKSIZ
      TITLE
   SAVE
   SEED
   SHOW
   SPLIT
   STATUS(STAT)
   STOP
   TERMINATE(TERM)
   TYPE(T)
   UNTIL
   USE
   VARIABLES(VAR)
   VARY
   VISIT
   wildcards


ABORT

Terminates SAD immediately.
See also:
 STOP QUIT SAVE USE VISIT BYE

APPEND(APP)

APP {filename | file-number} switches the output stream to the specified file or the 
file number.
The output is appended to the existing file.
See also:
 TERMINATE(TERM) CLOSE(CLO) INPUT(IN) READ OUTPUT(OUT) END

ATTRIBUTE(ATTR)

Usage: ATTR element-pattern

prints out the current value, minimum and maximum values, COUPLEd element and its coeffici
ent for
elements which match the element-pattern.
See also:
 COUPLE(COUP) set-value-of-element wildcards

beam-line

 A beam line is defined in the MAIN level by LINE command as:

   LINE a = ( [n1*][-]l1 [ [n2*]l2 ...] ) [b = ( ... )];

where l1, l2 are either an element or a line. n1, n2 are positive integers to repeat the s
ame element.
An optional negative sign in fromt of element means the negative orientation of the elemen
t of the
line. A negative orientation of a line is inherited by its elements.
 The first element of a beam line must be a MARK element, if it is used by FFS, USE, VISIT
.
 Please do not confuse the LINE command in the MAIN level with the LINE function in FFS.
 A beam line can be accessed within FFS via beam-line-functions as shown below.
See also:
 elements orientation-of-an-element USE VISIT

BYE

Exits from the current beam line and returns to the original beam line where VISIT co
mmand 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 RE
SET the
values of elements of the returning beam line.
See also:
 VISIT USE SAVE RESET STOP QUIT ABORT

character-string

 A character-string is expressed by enclosing in "". Special characters are expressed
 using \:

\n     new line
\r     carriage return
\t     tab
\"     double quote
\      backslash
\nnn   a character whose octal code is nnn.

 If a character-string is written over multiple lines, \ must be placed at the end of each
 line.
 The length of a character-string is limited to 2^31-1.

command-syntax

The command syntax in FFS is

     expression1 [param1..] [;] expression2..

(1)  The input is first evaluated as an expression. If the expression returns a Symbol wit
h the same
     name as the expression itself, it is interpreted as an FFS command, otherwise the ret
urned value
     is printed out unless it is Null.
(2)  Each command takes succeeding its parameters if necessary. A command with indefinite 
number
     of parameters can be terminated by semicolon. Most commands terminate itself at the e
nd of line.
(3)  A line can be continued to the next line if a backslash is placed at the end of the l
ine.
(4)  An expression continues to the next line if it is not closed in the line.
(5)  An exclamation mark comments out the rest of the line.

Example: A command line

          QF* .1

means the set-value-of-element command as unless the symbol QF has been defined otherwise.
 If QF
has been defines as a number, such as QF=2.5, the above command line is interpreted as Tim
es[QF,.1]
then returns .25 .
See also:
 expression functions

components

Components are the objects which consist the beam line. A component simulates an indi
vidual magnet,
drift space, or rf-cavity. The parameters of a component is specified the values in the co
rresponding
element with the same name as the component, which simulates a power supply. Many componen
ts can
be attached to the same element. Parameters of each component may deviate from the corresp
onding
element if machine errors are given.
   A component is specified with the form name[.order][{+-}offset], where name is the name
 of the
component. The number order means the order-th component which belongs to name element, co
unted from
the beginning of the line starting from 1. Offset is a positive or negative number to spec
ify the
downstream or upstream components from the given component. If order is omitted, the first
 element
is assumed, and if offset is omitted, zero is assumed.
   The end of line is specified by $$$. The first component can be specified by ^^^.

See also:
 elements

constants

There are pre-defined special symbols for constants in FFS:

symbol         value
True           1
False          0
Infinity       INF
INF            INF
NaN            NaN
Pi             ArcSin[1]*2
E              Exp[1]
I              Complex[0,1]
Degree         Pi/180
GoldenRatio    (1+Sqrt[5])/2
EulerGamma     0.57721566490153286061
See also:
 special-variables physical-constants flags expression

CALCULATE(CAL)

Usage: (1) CAL [[NO]EXPAND]]
       (2) CAL 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-funct
ions specified
either by the matching-function-commands or the second usage of CAL, as described below. I
f 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 li
st, whose
format is

   {dp, kind, reslist, function-values},

where

dp:       a list contains dp/p0 .
kind:     a list of kind of the orbit (usually 0, but 1 to 6 for the finite amplitude matc
hing, see
          MatchingAmplitude).
reslist:  a list of {residual, xstab, ystab}, where
       residual: matching residual,
       xstab:    True when the matrix is stable in X,
       ystab:    True when the matrix is stable in Y, for each orbit.

Above are lists with length nf (== number of orbits).

function-values: a list of length nc (== number of calculated items). Each element has the
 form:

       {component1, component2, function, list-of-values},

       where

       component1, component2: fit locations (see FIT).
       function: name of the function (see matching-function-commands).
       list-of-values: list of the value of the function for each orbit Length nf.
       The central orbit comes at the Floor[(n+1)/2]-th element.

(2) With matching-function 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.
\nExample:
CALC BX BY CAL
See also:
 GO DISPLAY(DISP) COUPLE(COUP) ATTRIBUTE(ATTR) SHOW FIT matching-function-commands EXPAND
 CONV CONVERGENCE MatchingResidual FFS

CHROMATICITY(CHRO)

CHRO prints out the chromaticity of QUAD and SEXT in the entire beam line using the s
implest formula:


    xi_{x,y}=Integrate[-(K1/L) beta_{x,y}(s) ds] for QUAD,
     xi_{x,y}=Integrate[-(K2/L) eta_x (s) beta_{x,y}(s) ds] for SEXT.

These formula are not valid when there is x-y coupling or vertical dispersion.

CLOSE(CLO)

   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 str
eam.
See also:
 TERMINATE(TERM) INPUT(IN) READ OUTPUT(OUT) APPEND(APP) END

COUPLE(COUP)

   Usage: COUP slave-element master-element coefficient

sets the value of the default-keyword of slave-element to be equal to coefficient times th
e value
of the default-keyword of master-element. COUPLE(COUP) cannot be cascaded. The master-elem
ent cannot
be COUPLEd to any other element. To reset COUPLE, say COUP slave-element slave-element 1.
 Consider ElementValues to define universal coupling for any keywords.
See also:
 ATTRIBUTE(ATTR) FREE ElementValues

data-structure

All data and "programs" in SAD Script are expressed either by an atom or a list-struc
ture:

   head[body1 [,body2...]]

where head and body1... are atom or list-structure. Defined atoms are:
Real     a real number
Symbol   a symbol
String   a character-string
Pattern  a pattern structure for argument matching

Currently the lengths of a list-structure, a character-string, and the name of a symbol ar
e limited
to 2^31-1. A real number has an accuracy of 8 bytes.
See also:
 character-string pattern

defining-functions

 A function is defined by one of the following forms:

f[pat1 [,pat2...]] (:)= body;
f[pat1 [,pat2...]] ^(:)= body;
g//:f[pat1 [,pat2...]] (:)= body;

where pat1 [,pat2...] are patterns (including expressions).
 If UpSet(^=) or UpSetDelayed (^:=) is used, the definition is associated with the symbol 
in the
first level of l.h.s.
 If TagSet(//:) is used, the definition is associated with the symbol on the left of //: .


 The patters can be an expression including constants. The definition with constant argume
nts can
be accessed faster than searching a list, in general, so they are suitable for a data base
. Definitions
with constant arguments have higher priorities than with patterns.
See also:
 UpSet UpSetDelayed TagSet(/:) pattern

dynamics



DISPLAY(DISP)

Usage: DISP_LAY [keywords] [pattern-string] [region]

Displays values of various optical-/geometric-functions at the components given by the pat
tern-string
in the region (see region) in the current beam line. It has several display modes specifie
d 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 speci
fied by
"^^^".
   DISP does not calculate the functions to be displayed, so CALCULATE(CALC) is necessary 
whenever
values of components are updated.
See also:
 TYPE(T) optical-functions geometric-functions

DRAW

Usage: DRAW [begin end] fun1 [fun2..] [& fun11 [fun12..]] [element-pattern]

draws a plot of optical functions in multi columns. It calls OpticsPlot internally. Availa
ble functions
are all matching-functions (except LENG, TRX, TRY, GX, GY, GZ, CHI1, CHI2, CHI3) and addit
ional functions.
If functions are separated by ampersand (&), these are plotted in a separated window.
  If begin- and end-components are specified, the plot region is limited between them. If 
the end-component
comes earlier than the begin-components, it wraps the plot around the beam line.
  If the optional element-pattern is given, it draws the beam-line lattice with the labels
 for elements
which match element-pattern. If LAT is specified for element-pattern, the lattice is drawn
 without
label.
 A character string assigned to TITLE is shown as the FrameLabel on the top of the plot.

 Example:
   TITLE="FCCee_t_202_nosol_16_ipac.sad";
   Draw$Option={Thickness->2};
   DRAW BX BY & EX EY Q*;



See also:
 OpticsPlot special-variables TITLE matching-function-commands OUTPUT(OUT) TERMINATE(TERM)
 GEO DISPLAY(DISP) wildcards

DUMP

Usage: DUMP component-pattern [component-pattern1..]

prints out the current machine errors of components which match component-pattern.
See also:
 machine-error-commands components wildcards

elements

An element in FFS represents an object which has a unique name and several keywords w
ith values.
This simulates a power supply of a magnet. An element has one or more components, which co
rrespond
to individual magnets in a beam line. Each component may have different values from the va
lues of
the corresponding element. This simulates the machine error which varies magnet to magnet
   The value of an element can be saved to or recovered from the element-save-buffer by SA
VE or RESET
commands. Different beam lines can share the same element, and their values can be differe
nt to each
other, but they have the common element-save-buffer. Therefore the value of an element can
 be transferred
between beam lines by SAVE and RESET command through the element-save-buffer.
   An element is created only in SAD MAIN level. In the definition, if a keyword is omitte
d, the
previous definition is unchanged. All keywords have the default value zero. In FFS, it is 
only possible
to change their values.
See also:
 TYPE(T) set-value-of-element Element

expression

An expression in FFS consists of a symbol, constants, and operators.

>>> A symbol is a characters of any length starting with an alphabet or $.
>>> There are two kinds of constants, real number and character-string.
    real number is a number in fortran-line format.
    character-string is a set of characters surrounded by "" or ''.
    special-characters can be specified with backslash.
>>> Available operators are (in the order of the priority):
    #,##,
    ?,
    ::,
    @,
    [],
    ++, --,
    /@, //@, @@,
    .,
    ^,
    *, /,
    +, -,
    ==, <>, >, <, >=, =>, <=, =<, 
    ===, <=>, 
    ~, 
    &&,
    ||,
    .., ...,
    |,
    :,
    ->, :>,
    /., //.,
    +=, -=, *=, /=,
    &,
    //,
    /:,
    =, :=, ^=, ^:=, =.
    ;,
    {}
An operator with higher priority is operated first. An expression enclosed in () is evalua
ted first.
Most mathematical operations are threaded into a list, i.e., {a,b} + {c,d} gives {a + b,c 
+ d}, etc.

  Each operators can be used as a function using its name. For example, Plus[x,y] gives th
e same
result as x + y.
See also:
 constants functions command-syntax character-string

ELSE

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, ex
ecutes
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 comman
d line.
See also:
 If ELSEIF ENDIF

ELSEIF

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, ex
ecutes
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 comman
d line.
See also:
 IF ELSE ENDIF

EMITTANCE(EMIT)

Usage: (1) EMIT
       (2) EMIT dp

(1) EMIT calculates the closed orbit, the normal coordinate, and the equilibrium emittance
 assuming the current beam line is a positron ring. One of EMITTANCE(EMIT), the Emittance[
] function, or the EMIT command in the MAIN level are necessary to be done in prior to mul
ti-turn tracking. See multi-turn-tracking.

(2) EMIT dp, where dp is |df_rf/f_rf|/(alpha_p == momentum compaction), does EMIT for five
 rf frequencies:



then prints out a table of the dependences of various quantities on the frequency shift.

   The results of EMITTANCE(EMIT) are affected by flags COD, RADCOD, RFSW, INTRA, WSPAC, E
MIOUT,
CODPLOT and special-variables MOMENTUM, CHARGE, FSHIFT, MINCOUP, PBUNCH. The flag TRPT or 
RING affects
only Emittance[], as EMITTANCE(EMIT) automatically set RING.
   EMITTANCE(EMIT) returns the equilibrium emittances in variables EMITX, EMITY, EMITZ, an
d the equilibrium
bunch length in SIGZ, the relative momentum spread in SIGE, and the longitudinal equilibri
um position
DTSYNCH. 

   The map used in EMIT is slightly different from that used in the tracking. For instance
, the edge
angle of a bend is approximated by a thin quad. If the edge angle is large and the curvatu
re is small,
EMIT may give a wrong answer. This will be corrected in near future.
See also:
 multi-turn-tracking extended-Twiss-parameters COD RADCOD RFSW INTRA EMIOUT WSPAC CODPLOT
 TRPT MOMENTUM CHARGE FSHIFT MINCOUP PBUNCH EMITX EMITY EMITZ SIGE SIGZ DTSYNCH
 Emittance

END

Closes the current output-stream and set the output stream to the standard output(6).
 It also suspends
all the input streams and switches to the standard input(5). Since this command affects al
l input
and output streams, you may consider to use TERMINATE(TERM) or CLOSE(CLO) to suspend or cl
ose them
selectively.
See also:
 TERMINATE(TERM) CLOSE(CLO) INPUT(IN) READ OUTPUT(OUT) APPEND(APP)

ENDIF

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, ex
ecutes
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 comman
d line.
See also:
 IF ELSE ELSEIF

EXECUTE(EXEC)

Usage: EXEC character-string-expression

executes the character-string-expression as FFS commands.
See also:
 expression FFS ToExpression

EXPAND

 EXPAND distributes all variable keys to each corresponding components. Individual de
viations (machine
errors) are cleared.
See also:
 GO CALCULATE(CAL) EMITTANCE(EMIT)

flags

Usage: [NO]flag

turns the flag on. If NO is prepended to flag, the flag is turned off. Some flags have ant
onym which
works in the opposite way. Flags can be accessed in the function-syntax with the form ?fla
g, which
returns True (=1) when the flag is on, or False (=0) otherwise. Some flags can be accessed
 by the
ON/OFF commands at the MAIN level.
 Status of all flags are displayed by the STATUS(STAT) command.
See also:
 STATUS(STAT) PatternTest(?)

functions

FFS functions:

Constants:
   Degree GoldenRatio I INF* Infinity NaN* Pi SpeedOfLight
Elementary-functions:
   ArcCos ArcCosh ArcSin ArcSinh ArcTan ArcTanh Cos Cosh Exp Log Sin Sinh
   Sqrt Tan Tanh
Special-functions:
   BesselI BesselJ BesselK BesselY BesselJZero Erf Erfc Factorial 
   Gamma LogGamma LogGamma1 GammaRegularized GammaRegularizedQ*
   GammaRegularizedP* GaussianCoulomb* GaussianCoulombU*
   GaussianCoulombFitted* LegendreP*
Numerical-functions:
   Abs Ceiling Floor Max Min MinMax* Mod Negative NonNegative Positive
   Round Sign FractionalPart
Matrix-operations:
   Det Eigensystem IdentityMatrix Inner LinearSolve Outer SingularValues*
   Transpose
Random-number:
   GaussRandom* Random* SeedRandom
Complex:
   Arg Complex ComplexQ Conjugate Im Re
Rational:
   Rational FromRational ContinuedFraction FromContinuedFraction SmallPrime
   Numerator Denominator
Fourier-Transformation:
   Fourier InverseFourier
Data-Manipulation:
   FindRoot Fit* NIntegrate* PolynomialFit* Spline*
Calculus:
   D NIntegrate
Minimization:
   DownhillSimplex*
List-manipulations:
   Append Complement Delete Depth Difference* Dimensions Drop Extract Flatten
   FlattenAt HeldPart Insert Intersection Join Length Part Partition Prepend
   Product Range ReplacePart Rest Reverse RotateLeft RotateRight Select 
   Sort Sum Take Table Union
Character-strings:
   FromCharacterCode CharacterPosition Characters DigitQ LetterQ StringDrop
   StringFill* StringInsert StringLength StringPosition StringTrim*
   Symbol SymbolName ToCharacterCode ToLowerCase ToUpperCase ToExpression
Functional-Operations:
   Apply Cases Count DeleteCases Identity FixedPoint* FixedPointList*
   Fold Function Level Map MapAll MapAt MapIndexed MapThread Nest Position
   Replace Scan ScanThread* SelectCases* SwitchCases* Thread
Object-oriented programing and context:
   Begin BeginPackage Class* End EndPackage
Flow-Control:
   Break Catch Check Continue Do For Goto If Label Return Switch Throw Which
   While
Tests:
   AtomQ ComplexQ DirectoryQ* EvenQ FileQ* MatchQ MatrixQ MemberQ NearlySameQ* 
   Negative NonNegative NumberQ OddQ Order Positive RealQ StringQ* VectorQ
   BoundQ* FBoundQ*
Input/Output:
   Close Flush* Get OpenRead OpenWrite OpenAppend Print Put Read ReadString SeekFile*
   Short* StringToStream Write WriteString
File System:
   CopyDirectory CopyFile CreateDirectory DeleteDirectory DeleteFile
   DirectoryName FileByteCount FileDate FileNames FileType
   RenameDirectory RenameFile SetFileDate ToFileName
Scoping:
   Block Module With*
Attributes:
   Attributes* Clear Evaluate Head Hold Literal Protect ReleaseHold
   SetAttributes* Unevaluated Unprotect
GUI Widget:
   Window* PanedWindow* Frame* LabelFrame* Canvas* TextLabel* TextMessage*
   Button* CheckButton* RadioButton* Menu* OptionMenu* MenuButton*
   Entry* SpinBox* ListBox* ScrollBar* Scale* TextEditor*
Graphics:
   BeamPlot* ColumnPlot* HistoPlot* ListContourPlot ListDensityPlot 
   ListPlot Plot Show FitPlot* GeometryPlot* OpticsPlot* TkPhotoPutBlock*
System Interface:
   Directory Environment GetEnv* GetGID* GetPID* GetUID* ProcessStatus* 
   SetDirectory SetEnv* System* TemporaryName* MkSecureTemp* RealPath*
Multiprocessing:
   BiPipe* Fork* OpenShared* Shared* Wait*
Utilities:
   Date DateString* Definition* FromDate* ToDate ToDateString* Pause
   MemoryCheck* Message Off On Sleep TimeUsed Timing TracePrint

Functions listed above work basically in the same way as Mathematica's 
except those marked by *.

FFS-dedicated-functions:
   BeamMatrix CalculateOptics DynamicApertureSurvey Element Emittance FFS
   FitValue FitWeight GeoBase LINE OptimizeOptics OrbitGeo RadiationField
   RadiationSpectrum SymplecticJ SetElement TrackParticles Twiss VariableRange
   SynchroBetaEmittance TouschekLifetime WakeFunction

Beam-line-functions:
   BeamLine BeamLineName ExtractBeamLine PrintBeamLine WriteBeamLine
See also:
 expression constants physical-constants beam-line-functions

FIT

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 be
am line
is chosen.
   If two components are given, it means a relative-fitting or zone-fitting. If the fittin
g 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 functi
on in the
region between component1 and component2, or maximum-fitting for the difference of the fun
ction (for
NX,  NY, LENG, GX, GY, GZ). The fit region is shown in the first part of the prompt when F
FSPRMPT
is ON.

Examples: (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.
See also:
 matching-function-commands components SHOW GO CALCULATE(CAL)

FITPOINTS(FITP)

Usage: 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.
See also:
 matching-function-commands

FIX

Usage: (1) FIX element-pattern [keyword] [element-pattern1 [keyword1]..]

removes elements which match element-pattern from the matching variables. The optional key
word 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.
See also:
 FREE FIT SHOW GO CALCULATE(CAL) wildcards elements

FREE

Usage: FREE element-pattern [keyword] [element-pattern1 [keyword1]..]

specifies elements which match element-pattern as the matching variables. The optional key
word 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.
See also:
 FIX FIT SHOW GO CALCULATE(CAL) wildcards elements

geometric-functions

Available geometric-functions are:

GX      geometrical coordinate xi
GY      geometrical coordinate eta
GZ      geometrical coordinate zeta
CHI1    geometrical rotation angle ch1_1
CHI2    geometrical rotation angle ch1_2
CHI3    geometrical rotation angle ch1_3

The geometrical coordinate {xi, eta, zeta} is set by the ORG command, and its default orig
in 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-hand sys
tem.
   The rotation angles are defined so as to give the local {x,y,s} is written

    {x, y, s}_local
   = rotate[s, chi3] rotate[x, chi2] rotate[y, -chi1]{x, y, s}_origin,

where rotate[a, b] reads "rotate around the new-a vector by b right-handedly".
See also:
 optical-functions matching-function-commands DISPLAY(DISP) GEOCAL GEOFIX

GEO

prints out the TopDrawer commands for the geometric plot of the beam line.
See also:
 DISPLAY(DISP)

GO

Usage: GO [[NO]EXPAND]

Does matching for fitting conditions given by matching-function-commands with variables sp
ecified
by FREE.

If an option EXPAND is given (default), it expands the beam line before the calculation. I
f 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

dp:       a list contains dp/p0 .
kind:     a list of kind of the orbit (usually 0, but 1 to 6 for the finite amplitude matc
hing, see
          MatchingAmplitude).
reslist:  a list of {residual, xstab, ystab}, where
       residual: matching residual,
       xstab:    True when the matrix is stable in X,
       ystab:    True when the matrix is stable in Y, for each orbit.

Above are lists with length nf (== number of orbits).

function-values: a list of length nc (== number of calculated items). Each element has the
 form:

       {component1, component2, function, list-of-values},

       where

       component1, component2: fit locations (see FIT).
       function: name of the function (see matching-function-commands).
       list-of-values: list of the value of the function for each orbit Length nf.
       The central orbit comes at the Floor[(n+1)/2]-th element.
See also:
 FIT SHOW matching-function-commands off-momentum-matching FREE FIX VARIABLES(VAR) COUPLE(COUP)
 ATTRIBUTE(ATTR) CALCULATE(CAL) VARY SHOW CONV CONVERGENCE MatchingResidual MatchingAmplitude
 FitFunction FFS OptimizeOptics

IF

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, ex
ecutes
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 comman
d line.
See also:
 ELSE ELSEIF ENDIF expression command-syntax If

INPUT(IN)

IN {filename | file-number} switches the input stream to the specified file or the fi
le-number. The
original stream is kept and to be returned by TERMINATE(TERM). The input file is not rewou
nd.
See also:
 TERMINATE(TERM) CLOSE(CLO) READ OUTPUT(OUT) APPEND(APP) END

machine-error-commands

Usage: machine-error-command [options] amount component-pattern ..

where machine-error-command is one of

command    keyword affected     applicable types
DELX       DX                   BEND 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

   amount is the amount of the error,
   component-pattern is the pattern to specify the components to be applied.

   Options are

RANDOM(R)        Set amount*GaussRandom[] to the keyword.
UNIFORM(U)       Set the specified amount to the keyword without random number.
INCOHERENT(INC)  GaussRandom[] is called for each component. Default.
COHERENT(C)      GaussRandom[] is called once for each component-pattern.
PUT(P)           Set the error to the keyword. Default.
ADD(A)           Add the error to the keyword.
See also:
 components wildcards keywords default-keyword DUMP SEED

matching-function-commands

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

(1) sets the matching condition for matching-function at the current fitting point or regi
on with
the goal-value and the off-momentum-points (see off-momentum-matching).
   If off-momentum-points is omitted, the previous value for this matching-function at thi
s fitting-point
is assumed. If the previous value is not defined, 1 is assumed. If -1 is given for off-mom
entum-points,
the matching-function is rejected from the matching (see REJECT(REJ)).
   If "*" is given for goal-value, the previous value is used if exists.

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)

(2) If the letter "M" is appended to matching-function, it means the maximum-fitting for t
he function.
The maximum of either the value (for positive-definite functions) or the absolute value (f
or bipolar
functions) are to be limited in the matching.

(3) If the letter "I" is appended to matching-function, it specifies the value of the inco
ming beam.

(4)
If SCALE is appended to matching-function, it sets the scale of the input/output of the fu
nction
to scale. This scale is used in the matching-function commands, DISPLAY(DISP), SHOW, etc.
(5) If the current fit location is at a MARK, @ for the goal value refers the save value a
t the MARK.
@- refers -(save value). These are useful to match between two beam lines.

   Available matching-functions are:
optical-functions (see optical-functions):
AX BX NX AY BY NY EX EPX EY EPY R1 R2 R3 R4 DETR DX DPX DY DPY DZ DDP PEX PEPX PEY PEPY TR
X TRY LENG
geometric-functions
(see geometric-functions):
GX GY GZ CHI1 CHI2 CHI3
See also:
 FIT GO SHOW MARK optical-functions geometric-functions off-momentum-matching x-y-coupling
 REJECT(REJ) special-variables DP functions FitValue MatchingAmplitude

multi-turn-tracking

The multi-turn tracking can be done by the TRACK command of the MAIN level, the TRACK
 command in
FFS, or the DynamicApertureSurvey[] function in FFS. The latter only perform the DAPERT mo
de.

   The multi-turn tracking uses the closed orbit, normal coordinate, and the equilibrium e
mittances.
Therefore One of EMITTANCE(EMIT), the Emittance[] function, or the EMIT command in the MAI
N level
are necessary to be done once in prior to the multi-turn-tracking. The values of EMITX, EM
ITY, EMITZ,
SIGE can be changed between EMITs and the multi-turn-tracking.
See also:
 EMITTANCE(EMIT) RFSW RAD FLUC RADCOD SPAC WSPAC special-variables

MATRIX(MAT)

Usage: MATRIX [{SYMPLECTIC(S) | PHYSICAL(P)}] [from to]

prints out the 4 by 5 (w/CALC4D) or 6 by 6 (w/CALC6D) transfer matrix from from-component 
to to-component.
If SYMPLECTIC(S) is specified (default), the symplectic transfer matrix on {x,px/p0,y,py/p
0,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).
See also:
 DISPLAY(DISP) TRPT RING CALC4D CALC6D TransferMatrix

MEASURE(MEA)

Usage: MEA [end-component] [OUT file plot-spaces]

tracks particles from the entrance to end-component and prints out the statistics at the e
nd. If
end-component is omitted, the component end 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 distribution on file. The ph
ase-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:

seed for the random-number generator:
     SeedRandom[seed_Real] or SeedRandom[{seeds__Real}]

special-variables (can be set with =):
     NP        number of particles 
     EMITX     horizontal emittance
     EMITY     vertical emittance
     DP        relative momentum spread
     DP0       relative momentum offset dp/p0
     GCUT      cut-off value of the Gaussian tail
flags:
     GAUSS/UNIFORM    Gaussian/uniform(default) momentum distribution
     JITTER/NOJITTER  off(default)/on nullifying the incoming centroid offset
     RFSW/NORFSW      switch on(default)/off the rf-cavities
     RAD/NORAD        synchrotron radiation on/off
     RADCOD/NORADCOD  off/on compensation of energy loss due to radiation
     FIXSEED/MOVESEED keep(default)/unkeep the initial random-number seed

   The initial transverse distribution is Gaussian.
See also:
 special-variables TrackParticles SeedRandom RESULTOFTRACKING

off-momentum-matching

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-mome
ntum point
n is an even number, the chosen points are same as the case of n+1, but the on-momentum po
int (==DP0)
is excluded.
See also:
 matching-function-commands DP DP0

optical-functions

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)
DETR  R_1*R_4 - R_2*R_3 (see x-y-coupling)
DX    dx
DPX   dpx
DY    dy
DPY   dpy
DZ    dz
DDP   delta=dp/p0
AZ    alpha_Z
BZ    beta_Z
NZ    psi_Z, the default scale is 1/(2Pi)
ZX    zeta_X  (z-dispersion_X)
ZPX   zeta_Px (z-dispersion_PX)
ZY    zeta_Y  (z-dispersion_Y)
ZPY   zeta_Py (z-dispersion_PY)
PEX   eta_x   (dispersion_x)
PEPX  eta_px  (dispersion_px)
PEY   eta_y   (dispersion_y)
PEPY  eta_yy  (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 th
e other
hand,  DX, DPX, DY, DPY refer the physical coordinate.
See also:
 geometric-functions x-y-coupling matching-function-commands GO CALCULATE(CAL) DISPLAY(DISP)
 SHOW

ORG

Usage: ORG location, dgx, dgy, dgz, dchi1, dchi2, dch3

sets the origin of the geometrical coordinate relative to the location with a relative shi
ft (dgx,
dgy, dgz) and rotation (dchi1, dchi2, dchi3).

OUTPUT(OUT)

OUT {filename | file-number} switches the output stream to the specified file or the 
file-number.
The file is written from the beginning.
See also:
 TERMINATE(TERM) CLOSE(CLO) INPUT(IN) READ APPEND(APP) END

pattern

 Pattern is a special expression for mathing arguments in function definitions and ru
les with several
forms:

_           matches any single argument.
__          matches a sequence of 1 or more arguments.
___         matches a sequence of 0 or more arguments.
x_          matches any single argument, which is names x.
x__         matches a sequence of 1 or more arguments, which is named x.
x___        matches a sequence of 0 or more arguments, which is named x.
x:pattern   a pattern which is named x.
pattern:v   a pattern which has a default value v when matching is failed.
pattern..   a non-null sequence of arguments each of which matches pattern.
pattern...  a sequence, which can be null, of arguments each of which matches pattern.
expression  matches expression.
See also:
 MatchQ defining-functions rules

physical-constants

Physical constants available in FFS are:

SpeedOfLight           299792458
FineStructureConstant  alpha
ElectronCharge         e in Coulomb
ElectronMass           m_e in eV
ElectronRadius         classical radius of electron, in m
ElectronGminus2        electron g-2
ProtonMass             m_p in eV
ProtonRadius           classical radius of Proton, in m
SIMu0                  4 Pi 10^{-7}
SIEpsilon0             1/SIMu0/SpeedOfLight^2
BoltzmannConstant      k_B in J/K
See also:
 constants expression special-variables

PRINT(PRI)

PRI expression evaluates expression and prints out the result.
See also:
 expression Print

QUIT

Exits FFS and return to SAD/MAIN level, without saving the values of the elements.

See also:
 STOP SAVE ABORT USE VISIT BYE

RADINT

RADINT prints out the radiation integrals involving the x-coupling for all components
 of the beam
line.

READ

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 rewou
nd.
See also:
 TERMINATE(TERM) CLOSE(CLO) INPUT(IN) OUTPUT(OUT) APPEND(APP) END

RECOVER(REC)

REC exchanges the values of FREEd elements with those when the last GO command was is
sued. FIXed
elements are not affected.
See also:
 GO FREE FIX RESET SAVE

REJECT(REJ)

Usage: (1) REJ matching-function-pattern [matching-function-pattern1..]
       (2) REJ TOTAL
       (3) REJ TOTALFIT

rejects the matching-functions which match matching-function-pattern at the current FIT lo
cation.
If TOTAL or TOTALFIT is given, the entire matching conditions in all locations are rejecte
d, then
output parameters by CALCULATE are reset when TOTAL is given.
See also:
 matching-function-commands FIT wildcards

REPEAT(REP)

Usage: REP [n] body UNTIL [expr1]

executes commands in body n times until expr1 gives nonzero. The number n can be any expre
ssion which
gives a number. If n is omitted, infinity is assumed. If expr1 is omitted, False(==0) is a
ssumed.
See also:
 UNTIL

RESET

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 th
e matching.
If ALL is given, it resets all keywords. If element-pattern is given, reset is limited to 
the elements
which match the pattern.
See also:
 SAVE USE VISIT wildcards RECOVER(REC)

REVERSE(REV)

REV changes the sign of AX, AY, EPX, EPY, R2, R3, DPX, DPY at the
entrance of the beam line.
See also:
 matching-function-commands

set-value-of-element

Usage: element-pattern [keyword] [{MIN | MAX | MINMAX | MAXMIN}] value

sets value to the specified keyword of the elements which match element-pattern. If keywor
d is omitted,
the default-keyword is assumed. keyword can be a wildcard to apply all matching keywords.
   If MIN, MAX, MINMAX, MAXMIN are specified, it sets the limit of the default-keyword. Bo
th 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 va
lue.
See also:
 ATTRIBUTES(ATTR) SAVE elements default-keyword wildcards Element

special-variables

There are several variables which have special rolls in FFS. Some of them are also ac
cessible in
the MAIN level.
See also:
 constants expression flags

SAVE

Usage: SAVE [element-pattern]

saves the values of the elements. What are saved are the value of the default keyword of a
ll 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, it is only limited to the el
ements
which match the pattern, otherwise all elements are saved.
See also:
 RESET USE VISIT BYE STOP QUIT wildcards

SEED

The SEED command is obsolete. Use SeedRandom[] function instead of SEED.
See also:
 MEASURE(MEA) machine-errors FIXSEED MOVESEED SeedRandom

SHOW

SHOW prints out the current matching conditions.

   FFS["SHOW"] or FFS$SHOW[] returns the current matching conditions as a list. Each eleme
nt has
a form of

{component1, component2, function, goal-value, number-of-momentums, scale},

which corresponds to the format of the print-out by SHOW.
See also:
 matching-function-commands FIT FFS FFS$SHOW

SPLIT

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 degrade the
 speed
of convergence.

STATUS(STAT)

STAT shows the current settings of flags, fit points, 
special-variables, the region for DISPLAY, seed of the random number generator, and elapse
d CPU time,
etc.
See also:
 special-variables flags

STOP

Exits FFS and returns to SAD/MAIN level, with saving the values of the elements.

See also:
 QUIT SAVE ABORT USE VISIT BYE

TERMINATE(TERM)

   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 stre
am.
See also:
 CLOSE(CLO) INPUT(IN) READ OUTPUT(OUT) APPEND(APP) END

TYPE(T)

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-patte
rn is given,
all elements are printed out.
See also:
 DISPLAY(DISP) VARIABLES(VAR) elements

UNTIL

Usage: REP [n] body UNTIL [expr1]

executes commands in body n times until expr1 gives nonzero. The number n can be any expre
ssion which
gives a number. If n is omitted, infinity is assumed. If expr1 is omitted, False(==0) is a
ssumed.
See also:
 REPEAT(REP) expression command-syntax functions Do

USE

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 a
n BeamLine
object or the name of a beam line 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 bea
m line
is expanded, i.e., the values of components are refreshed to 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.
See also:
 VISIT BYE EXPAND BeamLine BeamLineName

VARIABLES(VAR)

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 gi
ven by
the FREE command. Each element has the form

  {name, keyword, present, previous, saved, minimum, maximum, coupled-master-element, coup
ling-coefficient}
,

which corresponds to the output of the VARIABLES(VAR) command.
See also:
 FREE COUPLE(COUP) FFS

VARY

Usage: VARY keyword element-pattern

changes the default-keyword of the elements which match element-pattern to keyword.

See also:
 FREE elements wildcards

VISIT

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 a
n BeamLine
object or the name of a beam line 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 to the saved values.
   If a BeamLine object is used by USE or VISIT, the new beam line becomes a new LINE in t
he MAIN
level, with a name which is created automatically.
See also:
 USE BYE EXPAND BeamLine BeamLineName

wildcards

   Many commands and functions accept the wildcards as a specification for the name o
f elements or
components. The valid wildcards are:

       *         matches any zero or more characters.
       %         matches one character.
       {..}      matches any character enclosed.
       {^..}     matches any character not enclosed.
       ..|..     alternative pattern.
See also:
 elements components DISPLAY(DISP) TYPE(T) SAVE RESET FREE FIX machine-errors ATTRIBUTE(ATTR) REJECT(REJ)
 CALCULATE(CAL) functions Element LINE Twiss