java.lang.Object
simpa.acc.api.match.Matcher
Class for optics or initial conditon matching. It does the
matching by minimizing the difference between the target and
the actual value by varying the the scaling factors of the given list of
elements or the initial beam parameters until the RMS residual goes below the
given relative error value.
- Author:
- lbojtar
-
Constructor Summary
ConstructorsConstructorDescriptionMatcher
(org.apache.commons.math3.optim.BaseOptimizer<?> optimizer, List<org.apache.commons.math3.optim.OptimizationData> optimizationData, Sequence sequence, List<MatchingVariable> variables, List<MatchingTarget> params) Constructor for the class to do optics or initial condition matching. -
Method Summary
Modifier and TypeMethodDescriptionmatchLine
(Sequence sequence, EllipseBeam beam0, EllipseBeam beam1, double stepSize, double diskRadius, boolean backward) Does the optics matching procedure with the given parameters for a transfer line.void
matchLine
(Sequence sequence, TwissParameters inTwissParameters, Beam beam, double stepSize, double diskRadius, boolean backward) Does the initial beam parameter matching procedure with the given parameters for a transfer line.Does the matching procedure with the given parameters for a ring.void
writeOptics
(String file) Writes the optics to a file.
-
Constructor Details
-
Matcher
public Matcher(org.apache.commons.math3.optim.BaseOptimizer<?> optimizer, List<org.apache.commons.math3.optim.OptimizationData> optimizationData, Sequence sequence, List<MatchingVariable> variables, List<MatchingTarget> params) Constructor for the class to do optics or initial condition matching.- Parameters:
optimizer
- An implementation of the optimizer.optimizationData
- An array of optimization data. The actual implementations in the array depends on the type of the optimizer.sequence
- A sequence. The magnetic and electric fields of the elements in the sequence are calculated according to the scaling map of the sequence. All the scalings not present in the list of variables will be determined from the sequence scaling map. The sequence scalings also present in list of variables has no effect, those will be varied and their initial values are taken from theMatchingVariable.getInitialGuess()
field.variables
- A list of variables to be optimized during the matching.params
- A list of target optics values to be obtained during the matching. The number of target values must be the same as the number of variables.
-
-
Method Details
-
matchLine
public void matchLine(Sequence sequence, TwissParameters inTwissParameters, Beam beam, double stepSize, double diskRadius, boolean backward) Does the initial beam parameter matching procedure with the given parameters for a transfer line. The result of the matching is the latest values of the matching variables.- Parameters:
sequence
- The sequence to be matched.inTwissParameters
- The initial Twiss parameters of the beam.beam
- The beam to be matched. During the optimization process the beam will be deep copied and the initial conditions will be set according to the matching variables.stepSize
- Step size for the tracking.diskRadius
- The radius of the observer disk. Should be big enough to cover the aperture, but should not intersect the sequence twice.backward
- If true the matching procedure will use backward tracking.
-
matchLine
public Map<String,Double> matchLine(Sequence sequence, EllipseBeam beam0, EllipseBeam beam1, double stepSize, double diskRadius, boolean backward) Does the optics matching procedure with the given parameters for a transfer line.- Parameters:
sequence
- The sequence to be matched.beam0
- An ellipse beam with the nominal momentum for optics parameter matching.beam1
- An ellipse beam with some momentum deviation for optics parameter matching. The momentum deviation is needed to calculate the dispersion.stepSize
- Step size for the tracking.diskRadius
- The radius of the observer disk. Should be big enough to cover the aperture, but should not intersect the sequence twice.backward
- If true the matching procedure will use backward tracking. This is useful when the optics parameters are known at the end of the transfer line. One example is when matching a line to the beam coming from a source and the end of the line there is a ring with known Twiss parameters.- Returns:
- A deep copy of the scalings map of the sequence with the matched scalings.
-
matchRing
public Map<String,Double> matchRing(Sequence sequence, Particle p0, Particle p1, double stepSize, double diskRadius) Does the matching procedure with the given parameters for a ring.- Parameters:
sequence
- The sequence to be matched.p0
- A particle with the nominal momentum.p1
- A particle with some momentum deviation. The momentum deviation is needed to calculate the dispersion.stepSize
- Step size for the tracking.diskRadius
- The radius of the observer disk. Should be big enough to cover the aperture, but should not intersect the sequence twice.- Returns:
- A deep copy of the scalings map of the sequence with the matched scalings.
-
writeOptics
Writes the optics to a file. Typically called after the matching.- Parameters:
file
- File name where the optics will be written.
-
getVariables
-