This matching procedure takes advantage of the parametric results that
are accessible with PTC. Namely, parameters occuring in the matching
constrains are obtained as functions (polynomials) of the matching variables.
In other words, each variable is a knob in PTC calculation.
Evaluation of the polynomials is relatively fast comparing to the regular PTC calculation
what makes findining the minimum with the parametrized constraints very fast.
However, the algorithm is not faster in a general case:
- The calculation time dramatically increases with number of parameters and at some point penalty rising from
this overcomes the gain we get from the fast polynomial evaluation.
- A parametric result is an approximation that is valid only around
the nominal parameter values.
The algorithm:
1. Buffer the key commands (ptc_varyknob, constraint, ptc_setswitch, ptc_twiss or ptc_normal, etc)
appearing between
match, useptcknobs=true;
and any of matching actions calls (migrad,lmdif,jacobian, etc)
2. When matching action appears,
a) set "The Current Variables Values" (TCVV) to zero
b) perform THE LOOP, i.e. points 3-17
3. Prepare PTC environment (ptc_createuniverse, ptc_createlayout)
4. Set the user defined knobs (with ptc_knob).
5. Set TCVV using ptc_setfieldcomp command
6. Run a PTC command (twiss or normal)
7. Run a runtime created script that performs a standard matching;
all the user defined knobs are variables of this matching.
8. Evaluate constraints expressions to get the matching function vector (I)
9. Add the matched values to TCVV
10. End PTC session (run ptc_end)
11. If the matched values are not close enough to zeroes then goto 3
12. Prepare PTC environment (ptc_createuniverse, ptc_createlayout)
13. Set TCVV using ptc_setfieldcomp command
( --- please note that knobs are not set in this case -- )
14. Run a PTC command (twiss or normal)
15. Evaluate constraints expressions to get the matching function vector (II)
16. Evaluate a penalty function that compares matching function vectors (I) and (II)
See points 7 and 14
17 If the matching function vectors are not similar to each other
within requested precision then goto 3
18. Print TCVV, which are the matched values.
SYNOPSIS
MATCH, use_ptcknobs=true;
PTC_VARYKNOB:
initial = [s, none] ,
element = [s, none] ,
kn = [i, -1],
ks = [i, -1],
exactmatch = [l, true, true],
trustrange = [r, 0.1],
step = [r, 0.0],
lower = [r, -1.e20],
upper = [r, 1.e20];
END_MATCH;
For the user convenience the limits are specified in the MAD-X units (k1,k2, etc).
This also applies to dipolar field where the user must specify limits of k0=angle/path_lengh.
This guarantees concistency in treatment of normal and skew dipol components.
Important: Note that inside the code skew magnets are represented only by
normal component and tilt, so the nominal skew component is always zero.
Inside PTC tilt can not become a knob, while skew component can.
Remember about this fact when setting the limits of skew components in the matching.
When the final results are exported back to MAD-X, they are converted back to
the "normal" state, so the nominal skew compoment is zero and tilt and
normal component are modified accordingly.
trustrange - defines the range the expansion is trusted