Class Ensemble
- All Implemented Interfaces:
Serializable
- Author:
- CKAllen
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a particle to ensembledeepCopy()
Create a deep copy object of this ensembleMake a deep copy of the ensemble's particle container.int
getCount()
Get size of ensembleiterator()
Iterate through ensembleboolean
Populate the ensemble from a data file.boolean
Populate the ensemble from a data file.static void
Test driver for testing Ensemble class.Get the correlation matrix of the ensemble in homogeneous coordinatesCompute the centroid of the ensembledouble
potentialQuadExpansion
(R3 pt, double q, PhaseMatrix matSigma) Computes the electric potential from a quadrupole multipole expansion.double
potentialSummation
(R3 ptFld) Computes the Coulomb potential of the ensemble at the given field point.void
print
(PrintWriter os) Print out contents of the ensemble.static Ensemble
restoreUrl
(String strUrl) Creates an Ensemble from a file store.double[]
Compute the rms emittances in each phase planeboolean
Save ensemble state to persistent disk file.static void
testPersistence
(PrintWriter osLog) Test the file persistence mechanism.double
Get the total charge of the ensembleGet the total current of the ensemble.
-
Constructor Details
-
Ensemble
public Ensemble()Creates a new instance of Ensemble -
Ensemble
Create a deep copy clone of an ensemble object- Parameters:
ens
- ensemble object to be deep copied
-
-
Method Details
-
restoreUrl
Creates an Ensemble from a file store.- Parameters:
strUrl
- the URL of the file store- Returns:
- new Ensemble instance corresponding to file store
- Throws:
IOException
- unable to read file at URL
-
deepCopy
Create a deep copy object of this ensemble -
add
Add a particle to ensemble -
iterator
Iterate through ensemble -
getCount
public int getCount()Get size of ensemble -
phaseMean
Compute the centroid of the ensemble- Returns:
- homogeneous phase space coordinates of ensemble centroid
-
phaseCovariance
Get the correlation matrix of the ensemble in homogeneous coordinates- Returns:
- the 7x7 correlation matrix of the ensemble distribution
-
rmsEmittances
public double[] rmsEmittances()Compute the rms emittances in each phase plane- Returns:
- three-element array containing (ex,ey,ez)
-
totalCurrent
Get the total current of the ensemble.NOTE: If the momentum components of the particle phases are not the velocities, the return value must be scaled. For example, if the trace space values are used then the returned value must be multiplied by beta*c.
-
totalCharge
public double totalCharge()Get the total charge of the ensemble -
potentialSummation
Computes the Coulomb potential of the ensemble at the given field point.The potentials from every ensemble particle are summed at the field point and no averaging is performed. Thus, vary large potential values may occur if the field point is sufficiently near an ensemble particle.
- Parameters:
ptFld
- field point to evaluate the potential- Returns:
- the coulomb potential in MKS units
-
potentialQuadExpansion
Computes the electric potential from a quadrupole multipole expansion. This approximation is accurate at points outside the distribution, becoming more accurate as the distance increases. Therefore, note that returned potential is inaccurate for field points inside the particle expanse, with a singularity located at the ensemble centroid.Use this method when the ensemble particles all have the same charge, since the covariance matrix is used to compute the moments of the multipole expansion. The covariance matrix is with respect to the phase coordinates and, thus, all particles receive equal weighting.
This method uses the multipoles up to the quadrupole moment, as taken from the covariance matrix. The expansion is taken from the centroid of the distribution, as such the dipole moments are zero at that point. Thus, the result potential field appears to be generated from the centroid as a point particle along with the quadrupole fields due to the cross moments.
This method is intended for determining the potential at many fields points for the same ensemble configuration. To avoid repeated calculations of the covariance matrix (using getSigma()) this matrix should be called once and passed to this method on each invocation with the same ensemble configuration.
- Parameters:
pt
- field point to evaluate the potential- Returns:
- potential from quadrupole expansion of the ensemble
-
load
Populate the ensemble from a data file. Particle objects are loaded from persistent phase space data in file.- Parameters:
strFile
- descriptor of file containing persistent data- Returns:
- true if successfully recovered ensemble from file
-
load
Populate the ensemble from a data file. Particle objects are loaded from persistent phase space data in file.- Parameters:
file
- descriptor of file containing persistent data- Returns:
- true if successfully recovered ensemble from file
-
save
Save ensemble state to persistent disk file. All ensemble particles have phase space coordinates saved.- Parameters:
file
- file containing persistent data- Returns:
- true if successfully saved ensemble to file
-
print
Print out contents of the ensemble. WARING - since typical ensembles contain >10^3 particles this method could absorb a large amount of system resources -
main
Test driver for testing Ensemble class. -
testPersistence
Test the file persistence mechanism.- Parameters:
osLog
- output stream to send logging information
-
deepCopyParticles
Make a deep copy of the ensemble's particle container.- Parameters:
ens
- ensemble whose particles are to be cloned- Returns:
- TreeSet container of cloned particles
-