public class SimResultsAdaptor extends java.lang.Object implements ISimulationResults.ISimLocResults<ProbeState<?>>, ISimulationResults.ISimEnvResults<ProbeState<?>>
This class allows the developer to dynamically choose which calculation engine
applies to which simulation results type. This is done by first registering
the calculation engine (i.e., CalculationsOnBeams
,
CalculationsOnRings
, etc.) using the method
while providing
the type of registerCalcEngine(Class, ISimulationResults)
ProbeState
derived simulation data and the previously
instantiated calculation engine.
Currently, either or both of the interfacesISimulationResults.ISimLocResults
and
ISimulationResults.ISimEnvResults
are recognized by the adaptor and the
adaptor exposes both interfaces itself. When registering the adaptor checks if
the calculation engine exposes each of the above interfaces then registers it as
a provider of that calculation output. Any calls to
supersedes any previous
registrations.
registerCalcEngine(Class, ISimulationResults)
When an exposed method of either of the supported interfaces is called upon this
adaptor, it first looks at the type of ProbeState
it was given
then retrieves the calculation engine registered to that type. It then
delegates the method call to that simulation engine and returns the result.
ISimulationResults.ISimEnvResults<S>, ISimulationResults.ISimLocResults<S>
Constructor and Description |
---|
SimResultsAdaptor()
Constructor for SimResultsAdaptor.
|
Modifier and Type | Method and Description |
---|---|
R3 |
computeBetatronPhase(ProbeState<?> state)
Get the betatron phase values at the given state location for
all three phase planes.
|
PhaseVector |
computeChromAberration(ProbeState<?> state)
Compute and return the aberration at the given state location
due to energy spread.
|
PhaseVector |
computeChromDispersion(ProbeState<?> state)
Calculates the fixed point (closed orbit) in transverse phase space
at the given state Sn location sn in the presence of dispersion.
|
PhaseVector |
computeCoordinatePosition(ProbeState<?> state)
Returns homogeneous phase space coordinates of something involving the simulation
data.
|
PhaseVector |
computeFixedOrbit(ProbeState<?> state)
Computes the fixed orbit about which betatron oscillations occur.
|
Twiss[] |
computeTwissParameters(ProbeState<?> state)
Returns the array of twiss objects for this state for all three planes at the
location of the given simulation state.
|
<I extends ISimulationResults> |
registerCalcEngine(java.lang.Class<? extends ProbeState<?>> clsType,
I iCalcEngine)
Register the location calculation engine for the given probe data type.
|
public SimResultsAdaptor()
public <I extends ISimulationResults> void registerCalcEngine(java.lang.Class<? extends ProbeState<?>> clsType, I iCalcEngine) throws java.lang.IllegalArgumentException
clsType
- class type of the simulation trajectory statesiCalcEngine
- interface of computation engine for processing the datajava.lang.IllegalArgumentException
- unknown calculation engine typepublic PhaseVector computeCoordinatePosition(ProbeState<?> state) throws java.lang.IllegalArgumentException
ISimulationResults.ISimLocResults
Returns homogeneous phase space coordinates of something involving the simulation data. The interpretation is highly dependent upon the context of the data. That is, this quantity is open for interpretation; we can be referring to the position of the design trajectory, an offset, or the location of the beam centroid, whatever "beam" means in the context. The units are meters and radians.
computeCoordinatePosition
in interface ISimulationResults.ISimLocResults<ProbeState<?>>
state
- simulation state where parameters are computedjava.lang.IllegalArgumentException
xal.tools.beam.calc.ISimulationResults.ISimLocResults#computeCoordinatePosition(xal.model.probe.traj.ProbeState)
public PhaseVector computeFixedOrbit(ProbeState<?> state)
ISimulationResults.ISimLocResults
Computes the fixed orbit about which betatron oscillations occur. This
value is well-defined for rings but could be ambiguous for beam envelope
simulation, especially with regard to method
. The returned
value for some given simulation types are provided below.
#computeCoordinatePosition(ProbeState)
In general the idea is that the returned coordinate z in phase space P6 ≅ R6 × {1} is invariant under some map φ : P6 → P6 representing the dynamics of the system.
computeFixedOrbit()
presented by the trajectory classes for particles, beam envelopes, etc. (This method
has been deprecated and discontinued.) The methods
responded differently depending upon whether the structure producing the simulation
data was from a ring or a linear transport/accelerator structure. This behavior
has now changed, the method produces different results for different simulation
types (e.g., particle, transfer map, envelope, etc.) rather than different simulation
structures.
When the underlying data is produced by a transfer map this method should return the fixed orbit position at the given state. When the underlying data is produced by a particle then the returned value should be the position of the particle at the given state location (for its given initial position). When the underlying data is from a beam envelope then this method should return the centroid location of the beam bunch (for its given initial condition).
You must specify the simulation processing engine for each data type to
use a SimResultsAdaptor
. To reproduce the behavior of the past
Trajectory#computeFixedOrbit(ProbeState)
specify a
simulation data processor for ring
lattices and a CalculationsOnMachines
simulation processor
for linear lattices. This configuration is accommodated in the class
CalculationsOnBeams
exposing this interface.
SimpleSimResultsAdaptor
computeFixedOrbit
in interface ISimulationResults.ISimLocResults<ProbeState<?>>
state
- simulation state where parameters are computedxal.tools.beam.calc.ISimulationResults.ISimLocResults#computeFixedOrbit(xal.model.probe.traj.ProbeState)
public PhaseVector computeChromAberration(ProbeState<?> state)
ISimulationResults.ISimLocResults
computeChromAberration
in interface ISimulationResults.ISimLocResults<ProbeState<?>>
state
- simulation state where parameters are computedxal.tools.beam.calc.ISimulationResults.ISimLocResults#computeChromAberration(xal.model.probe.traj.ProbeState)
public Twiss[] computeTwissParameters(ProbeState<?> state)
ISimulationResults.ISimEnvResults
computeTwissParameters
in interface ISimulationResults.ISimEnvResults<ProbeState<?>>
state
- simulation state where Twiss parameters are computedxal.tools.beam.calc.ISimulationResults.ISimEnvResults#computeTwissParameters(xal.model.probe.traj.ProbeState)
public R3 computeBetatronPhase(ProbeState<?> state)
ISimulationResults.ISimEnvResults
computeBetatronPhase
in interface ISimulationResults.ISimEnvResults<ProbeState<?>>
state
- simulation state where parameters are computedxal.tools.beam.calc.ISimulationResults.ISimEnvResults#computeBetatronPhase(xal.model.probe.traj.ProbeState)
public PhaseVector computeChromDispersion(ProbeState<?> state)
ISimulationResults.ISimEnvResults
Calculates the fixed point (closed orbit) in transverse phase space at the given state Sn location sn in the presence of dispersion.
Let the full-turn map a the state location be denoted Φn (or the transfer
matrix from entrance to location sn for a linac).
The transverse plane dispersion vector Δ is defined
Δt ≡ -(1/γ2)[dx/dz', dx'/dz', dy/dz', dy'/dz']T .
It can be identified as the first 4 entries of the 6th
column in the transfer matrix Φn. The above vector
quantifies the change in the transverse particle phase
coordinate position versus the change in particle momentum.
The factor -(1/γ2) is needed to convert from longitudinal divergence
angle z' used by XAL to momentum δp ≡ Δp/p used in
the dispersion definition. Specifically,
δp ≡ Δp/p = γ2z'
As such, the above vector can be better described
Δt ≡ [Δx/δp, Δx'/δp, Δy/δp, Δy'/δp]T
explicitly describing the change in transverse phase coordinate for fractional
change in momentum δp.
Since we are only concerned with transverse phase space coordinates, we restrict ourselves to the 4×4 upper diagonal block of Φn, which we denote take Tn. That is, Tn = π ⋅ Φn where π : R6×6 → R4×4 is the projection operator.
This method finds that point zt ≡
(xt, x't, yt, y't)
in transvse phase space that is invariant under the action of the ring for a given momentum spread
δp. That is, the particle ends up
in the same location each revolution. With a finite momentum spread of δp > 0
we require this require that
Tnzt + δpΔt = zt ,
which can be written
zt = δp(Tn - I)-1Δt ,
where I is the identity matrix. Dividing both sides by δp yields the final
result
z0 ≡ zt/δp = (Tn - I)-1Δt ,
which is the returned value of this method. It is normalized by
δp so that we can compute the closed orbit for any given momentum spread.
computeChromDispersion
in interface ISimulationResults.ISimEnvResults<ProbeState<?>>
state
- we are calculating the dispersion at this state locationxal.tools.beam.calc.ISimulationResults.ISimEnvResults#computeChromDispersion(xal.model.probe.traj.ProbeState)