java.lang.Object
simpa.acc.api.utils.OpticsCalculator
This class calculates the optical functions from trajectory files generated
during two particles or beams. It calculates the intersections of the
trajectories with
ObserverDisk
along the orbit, then at each orbit
point fits an ellipse to the PhaseSpaceCoordinates
.- Author:
- lbojtar
-
Constructor Summary
ConstructorsConstructorDescriptionOpticsCalculator
(ReferenceOrbit refOrbit) Constructor with the reference obit . -
Method Summary
Modifier and TypeMethodDescriptioncalculateOpticsFunctions
(String trajectoryFile1, String trajectoryFile2, double dpop, double maxAperture, boolean backward) Calculates the optical functions from two trajectory files in a transfer line or a ring.calculateRingOptics
(List<TrajectoryData> trajectoryData1, List<TrajectoryData> trajectoryData2, double dpop, double maxAperture, boolean backward) Calculates the optical functions from two trajectory data lists in a ring.calculateTLineOptics
(Map<String, List<TrajectoryData>> trajectoryMap1, Map<String, List<TrajectoryData>> trajectoryMap2, double dpop, double maxAperture, boolean backward) Calculates the optical functions from two trajectory data maps in a transfer line.boolean
void
setPartialOpticsAllowed
(boolean partialOpticsAllowed) Set if the optics calculation is allowed to be partial.void
setTurns
(int turns) Set the number of turns for the tracking of the particles used for optics calculation.trackInLineAndCalculate
(boolean writeTrajectoryFile, EllipseBeam b0, EllipseBeam b1, PotentialProvider pp, double stepsize, double diskradius, boolean backward) Tracks the two beams in a transfer line, then calculates the optical functions from two beam trajectory files.trackInRingAndCalculate
(Particle p0, Particle p1, PotentialProvider pp, double stepsize, double diskradius, boolean writeTrajectoryFile) Tracks the two particles in a ring given as parameters, then calculates the optical functions from two trajectory files.
-
Constructor Details
-
OpticsCalculator
Constructor with the reference obit .- Parameters:
refOrbit
- The reference orbit.
-
-
Method Details
-
trackInRingAndCalculate
public Optics trackInRingAndCalculate(Particle p0, Particle p1, PotentialProvider pp, double stepsize, double diskradius, boolean writeTrajectoryFile) throws IOException, OpticsCalculationException Tracks the two particles in a ring given as parameters, then calculates the optical functions from two trajectory files. The first particle should have the nominal energy and the second have some dp/p deviation, for example 1E-3. This momentum deviation is used for calculating the dispersion.- Parameters:
p0
- Particle with nominal momentum.p1
- Particle with with some momentum deviation.pp
- A potential provider object.stepsize
- Step size for the tracking.diskradius
- The disk radius for the observers.writeTrajectoryFile
- If true, two trajectory files will be written to the disk and the optics will be calculated from these files. It is useful for debugging if something goes wrong. When false tha trajectory data stored internally and the optics calculated from that data without writing it to the disk. This should be the case when doing matching, for example.- Returns:
- The calculated optics.
- Throws:
IOException
OpticsCalculationException
-
trackInLineAndCalculate
public Optics trackInLineAndCalculate(boolean writeTrajectoryFile, EllipseBeam b0, EllipseBeam b1, PotentialProvider pp, double stepsize, double diskradius, boolean backward) throws IOException, OpticsCalculationException Tracks the two beams in a transfer line, then calculates the optical functions from two beam trajectory files. It is highly recommended to generate the beams with theEllipseBeamSampler
. A Gaussian beam would make the Ellipse fitting more inefficient. The first beam should have the nominal energy and the second have some dp/p deviation. This momentum deviation is used for calculating the dispersion.- Parameters:
writeTrajectoryFile
- If true, two trajectory files will be written to the disk and the optics will be calculated from these files. It is useful for debugging if something goes wrong. When false, the trajectory data stored internally and the optics calculated from that data without writing it to the disk. This should be the case when doing matching, for example.b0
- Beam with nominal momentum.b1
- Beam with with some momentum deviation.pp
- A potential provider object.stepsize
- Step size for the tracking.diskradius
- The disk radius for the observers.backward
- If true, the optics will be calculated by tracking backward. Useful when the Twiss parameters are known at the end of a transfer line.- Returns:
- The calculated optics.
- Throws:
IOException
OpticsCalculationException
-
setTurns
public void setTurns(int turns) Set the number of turns for the tracking of the particles used for optics calculation.- Parameters:
turns
- Number of turns for the tracking.
-
calculateOpticsFunctions
public Optics calculateOpticsFunctions(String trajectoryFile1, String trajectoryFile2, double dpop, double maxAperture, boolean backward) throws IOException, OpticsCalculationException Calculates the optical functions from two trajectory files in a transfer line or a ring. The first tracking file should belong to the nominal energy and the second with a dp/p deviation as given in the dpop parameter. The trajectory file names must conform to theFileNamingConventions
, so the method can decide from the file name it belongs to a single particle in a ring or a beam in a transfer line.- Parameters:
trajectoryFile1
- File containing a trajectory at least 6 machine turns in case of a ring or 6 particles in case of a transfer line, otherwise the ellipse fit will fail. This data is used for dispersion calculation. The tracking producing this trajectory must have been made with the nominal energy.trajectoryFile2
- File containing a trajectory at least 6 machine turns in case of a ring or 6 particles in case of a transfer line, otherwise the ellipse fit will fail. This data is used for dispersion calculation. The tracking producing this trajectory must have been made with some non zero dp/p.dpop
- Dp/p of the particle used for the second tracking.maxAperture
- Maximum aperture of the machine. To calculate the optics this class places disks along the orbit and calculate the intersections with the trajectory. The disk diameter should be big enough to cover the aperture, but should not be too big to intersect more than once the orbit of the machine.backward
- Must be set true when the trajectory files belong to tracking backward.- Returns:
- An optics object containing the Twiss parameters at each orbit point.
- Throws:
IOException
OpticsCalculationException
-
calculateRingOptics
public Optics calculateRingOptics(List<TrajectoryData> trajectoryData1, List<TrajectoryData> trajectoryData2, double dpop, double maxAperture, boolean backward) throws IOException, OpticsCalculationException Calculates the optical functions from two trajectory data lists in a ring. The first tracking data should belong to the nominal momentum and the second with a dp/p deviation as given in the dpop parameter.- Parameters:
trajectoryData1
- The trajectory data obtained from a single particle tracking in a ring with the nominal momentum.trajectoryData2
- The trajectory data obtained from a single particle tracking in a ring with the dp/p momntum deviation.dpop
- Dp/p of the particle used for the second tracking.maxAperture
- Maximum aperture of the machine. To calculate the optics this class places disks along the orbit and calculate the intersections with the trajectory. The disk diameter should be big enough to cover the aperture, but should not be too big to intersect more than once the orbit of the machine.backward
- Must be set true when the trajectory files belong to tracking backward.- Returns:
- An optics object containing the Twiss parameters at each orbit point.
- Throws:
IOException
OpticsCalculationException
-
calculateTLineOptics
public Optics calculateTLineOptics(Map<String, List<TrajectoryData>> trajectoryMap1, Map<String, throws IOException, OpticsCalculationExceptionList<TrajectoryData>> trajectoryMap2, double dpop, double maxAperture, boolean backward) Calculates the optical functions from two trajectory data maps in a transfer line. The first tracking data should belong to the nominal momentum and the second with a dp/p deviation as given in the dpop parameter.- Parameters:
trajectoryMap1
- The trajectory data obtained from a beam tracking in a transfer line with the nominal momentum.trajectoryMap2
- The trajectory data obtained from a beam tracking in a ring with the dp/p momntum deviation.dpop
- Dp/p of the particle used for the second tracking.maxAperture
- Maximum aperture of the machine. To calculate the optics this class places disks along the orbit and calculate the intersections with the trajectory. The disk diameter should be big enough to cover the aperture, but should not be too big to intersect more than once the orbit of the machine.backward
- Must be set true when the trajectory files belong to tracking backward.- Returns:
- An optics object containing the Twiss parameters at each orbit point.
- Throws:
IOException
OpticsCalculationException
-
isPartialOpticsAllowed
public boolean isPartialOpticsAllowed()- Returns:
- True if the optics calculation is allowed to be partial. That can happen when there are losses before the end of a transfer line. If false, an OpticsCalculationException is thrown when an error occurs during the optics calculation.
-
setPartialOpticsAllowed
public void setPartialOpticsAllowed(boolean partialOpticsAllowed) Set if the optics calculation is allowed to be partial.- Parameters:
partialOpticsAllowed
- Setting this true allows the optics calculation in a transfer line to be partial. That can happen when there are losses before the end of a transfer line. If false, an OpticsCalculationException is thrown when there is particle loss or an error occurs during the optics calculation.
-