EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH
Introduction
It is possible to match user defined expressions with the USE_MACRO keyword.
The general input structure for a match command is the following:
MATCH,USE_MACRO;
... VARY statements ...
USE_MACRO, NAME=macro1;
or
macro1: MACRO={ ... madx statements};
CONSTRAINT, expr= "lhs1 < | = | > rhs1";
CONSTRAINT, expr= "lhs2 < | = | > rhs2";
... CONSTRAINT statements ...
MACRO 2 definition
... CONSTRAINT statements ...
MACRO n definition
... CONSTRAINT statements ...
... METHODS statements ...
ENDMATCH;
The algorithm for evaluating the penalty function is the following:
- execute the first macro,
- evaluate and compute the difference between the lhs and the rhs the first set of expressions,
- in case of other macros, evaluates in order the macro and the expressions
- the set of differences are minimized by the selected method using the variables defined in the VARY statements.
Initiating the Matching Module with USE_MACRO
With:
MATCH,USE_MACRO;
the 'match' command can be used for matching any expression which can be
defined through expression. It requires a slightly different syntax.
VARY statements
In the USE_MACRO mode the vary statement follows the same rules of the other modes explained in the section Define Variable Parameter
Macro definitions
The macro to be used in the matching routine can be defined in two ways:
-
using USE_MACRO statement:
USE_MACRO, NAME=macro1;
defining a new macro on the fly using the usual syntax for macros.
After a macro definition is necessary to define a set of constraints exclusively with the following syntax:
CONSTRAINT, expr= "lhs = rhs";
or
CONSTRAINT, expr= "lhs < rhs";
or
CONSTRAINT, expr= "lhs > rhs";
where "lhs" and "rhs" are well defined MadX expressions.
Other set of macro and constraints can be defined afterwards.
Examples
The following example the USE_MACRO mode can emulate a matching script which uses the normal syntax.
Normal syntax:
MATCH,SEQUENCE=LHCB1,LHCB2;
VARY, NAME=KSF.B1, STEP=0.00001;
VARY, NAME=KSD.B1, STEP=0.00001;
VARY, NAME=KSF.B2, STEP=0.00001;
VARY, NAME=KSD.B2, STEP=0.00001;
GLOBAL,SEQUENCE=LHCB1,DQ1=QPRIME;
GLOBAL,SEQUENCE=LHCB1,DQ2=QPRIME;
GLOBAL,SEQUENCE=LHCB2,DQ1=QPRIME;
GLOBAL,SEQUENCE=LHCB2,DQ2=QPRIME;
LMDIF, CALLS=10, TOLERANCE=1.0E-21;
ENDMATCH;
USE_MACRO syntax:
MATCH,USE_MACRO;
VARY, NAME=KSF.B1, STEP=0.00001;
VARY, NAME=KSD.B1, STEP=0.00001;
VARY, NAME=KSF.B2, STEP=0.00001;
VARY, NAME=KSD.B2, STEP=0.00001;
M1: MACRO={ TWISS,SEQUENCE=LHCB1; };
CONSTRAINT, EXPR= "TABLE(SUMM,DQ1)=QPRIME";
CONSTRAINT, EXPR= "TABLE(SUMM,DQ2)=QPRIME";
M2: MACRO={ TWISS,SEQUENCE=LHCB2; };
CONSTRAINT, EXPR= "TABLE(SUMM,DQ1)=QPRIME";
CONSTRAINT, EXPR= "TABLE(SUMM,DQ2)=QPRIME";
LMDIF, CALLS=10, TOLERANCE=1.0E-21;
ENDMATCH;
Oliver Brüning,
October, 2003;
Riccardo de Maria, February, 2006.