Class Twiss

java.lang.Object
xal.tools.beam.Twiss
All Implemented Interfaces:
Serializable

public class Twiss extends Object implements Serializable

Convenience class for dealing with Courant-Snyder (or Twiss) parameters. These parameters represent an ellipse in phase space given by

    γx2 + 2αxx' + βx'2 = ε

where α, β, γ, and ε are the Courant-Snyder parameters and (x,x') are coordinates on the horizontal phase plane. (There are analogous equations for the other phase planes.) Recall that the Courant-Snyder parameters are not independent but related by the fact

    βγ - α2 = 1

Since:
Nov 12, 2002
Version:
Sep 25, 2014
Author:
Christopher K. Allen
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration of the Courant-Snyder parameters used.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new, uninitialized, instance of Twiss
    Twiss(double dblAlpha, double dblBeta, double dblEmitt)
    Creates a new instance of Twiss initialized to the given Twiss parameters.
    Twiss(Twiss twiss)
    Copy constructor: creates a deep copy of the argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    Compute and return the eigenvalues of the Twiss matrix.
    R2[]
    Compute and return the eigenvectors of the Twiss matrix.
    double
    Compute the phase space ellipse's rotation from upright.
    double[]
    Computes and returns the semi-axes of the phase space ellipse represented by the Twiss parameters.
    double[][]
    Return the correlation matrix associated with these Twiss parameters.
    static Twiss
    createFromCovarianceMatrix(double[][] arrCov)
    Create a new set of Twiss parameters from the given covariance matrix.
    static Twiss
    createFromEquivalentBeam(double dblEnvRad, double dblEnvSlp, double dblEmit)
    Creates a new Twiss object given the parameters of the equivalent uniform beam.
    static Twiss
    createFromMoments(double dblMmtSigX, double dblMmtCov, double dblMmtSigXp)
    Creates a new Twiss object initialized by the given set of central, second-order moments of the beam in whatever phase plane.
    double
    Return the alpha Twiss parameter
    double
    Return the beta Twiss parameter
    double
    Return the beam emittance
    double
    Return the envelope radius extent
    double
    Return the envelope slope
    double
    Return the gamma Twiss parameter
    void
    Print out contents of the Twiss object.
    void
    setEnvelope(double dblEnvRad, double dblEnvSlp, double dblEmitt)
    Set the values of the Twiss parameters from the corresponding phase space envelope values.
    void
    setTwiss(double dblAlpha, double dblBeta, double dblEmitt)
    Sets the values of the Twiss parameters directly.
    Get the Twiss parameters as a string
    double[][]
    Return the Twiss matrix associated with these Twiss parameters.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Twiss

      public Twiss()
      Creates a new, uninitialized, instance of Twiss
    • Twiss

      public Twiss(Twiss twiss)
      Copy constructor: creates a deep copy of the argument.
      Parameters:
      twiss - twiss object to be copied.
    • Twiss

      public Twiss(double dblAlpha, double dblBeta, double dblEmitt)
      Creates a new instance of Twiss initialized to the given Twiss parameters.
      Parameters:
      dblAlpha - coefficient of 2*x*x'
      dblBeta - coefficient of x'^2
      dblEmitt - magnitude^2 of the ellipse (beam emittance)
  • Method Details

    • createFromMoments

      public static Twiss createFromMoments(double dblMmtSigX, double dblMmtCov, double dblMmtSigXp)
      Creates a new Twiss object initialized by the given set of central, second-order moments of the beam in whatever phase plane. Note that the RMS emittance ε is given by [<x2><x'2> - <xx'>2]1/2For example, in the horizontal phase plane the parameters are given as
      Parameters:
      dblMmtSigX - the second moment <x2>
      dblMmtCov - the second moment <xx'>
      dblMmtSigXp - the second moment <x'2>
      Returns:
      the Courant-Snyder parameters (α=-<xx'>/ε, β=<x2>/ε, ε)
      Since:
      Aug 29, 2012
    • createFromCovarianceMatrix

      public static Twiss createFromCovarianceMatrix(double[][] arrCov)

      Create a new set of Twiss parameters from the given covariance matrix. The covariance matrix is simply the second-order moments packaged up as a symmetric matrix. The form of this matrix σ is

           σ ≅ | <x2> <xx'> |
               | <xx'> <x'2> |
       
      Parameters:
      arrCov - symmetric matrix array of second-order moments
      Returns:
      Courant-Snyder parameters corresponding to the given covariance matrix
      Since:
      Aug 29, 2012
    • createFromEquivalentBeam

      public static Twiss createFromEquivalentBeam(double dblEnvRad, double dblEnvSlp, double dblEmit)

      Creates a new Twiss object given the parameters of the equivalent uniform beam. This is the uniform beam that has the same second-moments as the beam under study. Because of the uniform charge distribution it can be modeled as a KV (Kapchinsky-Vladimirsky) beam having a distinct envelope size (radius) and a distinct envelope slope (this value is related to the divergence angle).

      NOTE

      · We do not scale the emittance! It is common practice to multiply the RMS emittance by 4 for 2D beams and other values for 3D beams with various distributions. We assume the same second moments which yield the same RMS emittance. Specially, the emittance of the returned object IS THE RMS EMITTANCE.

      Parameters:
      dblEnvRad - envelope size X of the uniform beam
      dblEnvSlp - slope divergence angle X' of the uniform beam
      dblEmit - emittance of the beam - This value is not scaled!
      Returns:
      Courant-Snyder parameters corresponding to the given equivalent uniform beam parameters
      Since:
      Aug 29, 2012
    • setTwiss

      public void setTwiss(double dblAlpha, double dblBeta, double dblEmitt)
      Sets the values of the Twiss parameters directly.
      Parameters:
      dblAlpha - alpha parameter (phase plane coupling)
      dblBeta - beta parameter (the envelope magnitude)
      dblEmitt - beam emittance (phase space area)
    • setEnvelope

      public void setEnvelope(double dblEnvRad, double dblEnvSlp, double dblEmitt)
      Set the values of the Twiss parameters from the corresponding phase space envelope values.
      Parameters:
      dblEnvRad - envelope radius
      dblEnvSlp - envelope slope
      dblEmitt - beam emittance
    • getAlpha

      public double getAlpha()
      Return the alpha Twiss parameter
    • getBeta

      public double getBeta()
      Return the beta Twiss parameter
    • getGamma

      public double getGamma()
      Return the gamma Twiss parameter
    • getEmittance

      public double getEmittance()
      Return the beam emittance
    • getEnvelopeRadius

      public double getEnvelopeRadius()
      Return the envelope radius extent
    • getEnvelopeSlope

      public double getEnvelopeSlope()
      Return the envelope slope
    • twissMatrix

      public double[][] twissMatrix()
        Return the Twiss matrix associated with these Twiss parameters.
        This matrix has the form
      
            S = | gamma  alpha |
                | alpha  beta  |
      
        so that the equation of the phase space ellipse is given by
      
            (x,x')*S*(x,x') = emittance
       
      Returns:
      2x2 Twiss matrix
    • correlationMatrix

      public double[][] correlationMatrix()
      Return the correlation matrix associated with these Twiss parameters.
      Returns:
      2x2 phase space correlation matrix
    • computeRotation

      public double computeRotation()
      Compute the phase space ellipse's rotation from upright.
      Returns:
      phase space rotation (radians)
    • computeSemiAxes

      public double[] computeSemiAxes()
        Computes and returns the semi-axes of the phase space ellipse
        represented by the Twiss parameters.
      
        NOTE:
        Since the ellipse may be rotated these values do not necessarily
        correspond to any particular values of x, and x' in the phase plane.
       
      Returns:
      two-dimension array of semi-axes (a,b)
    • computeEigenvalues

      public double[] computeEigenvalues()
        Compute and return the eigenvalues of the Twiss matrix.  This matrix has
        the form
      
                | gamma  alpha |
                | alpha  beta  |
      
       
      Returns:
      eigenvalues of the above matrix
    • computeEigenvectors

      public R2[] computeEigenvectors()
        Compute and return the eigenvectors of the Twiss matrix.  This matrix has
        the form
      
                | gamma  alpha |
                | alpha  beta  |
      
       
      Returns:
      two-element array of eigenvectors of the above matrix
    • printOn

      public void printOn(PrintWriter pw)
      Print out contents of the Twiss object.
      Parameters:
      pw - PrintWriter object to receive contents
    • toString

      public String toString()
      Get the Twiss parameters as a string
      Overrides:
      toString in class Object