Class Probe<S extends ProbeState<S>>
- Direct Known Subclasses:
BunchProbe
,DiagnosticProbe
,ParticleProbe
,TransferMapProbe
Provides a base class implementation of the IProbe interface that is useful for most standard probe types. This class provides most of the functionality necessary for the implementation of the IProbe interface, except a definition and implementation of a probe "state". Thus, it is up to base classes to provide and implement the particular aspect of a beam the probe represents.
- Author:
- Christopher K. Allen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
element tag for comment datastatic final String
element tag for probe dataprotected S
current state of the probe - defines the probeprotected static final String
attribute tag for comment textprotected static final String
attribute tag for the time stampprotected Trajectory<S>
Current probe trajHistprotected static final String
attribute tag for probe type nameFields inherited from interface xal.model.IProbe
LIGHT_SPEED, PERMITTIVITY, UNIT_CHARGE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyState
(S state) Apply the contents of ProbeState to update my current state.This method returns a clone of the current state of this probe.copy()
Creates a deep copy of the probeabstract S
Creates a new, blankProbeState
of the appropriate species.abstract S
Captures the probe's state in a ProbeState of the appropriate species.abstract Trajectory<S>
Require concrete implementations to override this method to create aTrajectory
object of the appropriate species.protected void
This is a convenience function for derived classes when implementing their deepCopy() method.Return the algorithm defining the probes dynamics.Return the archiving interface for this object.double
getBeta()
Returns the probe velocity normalized to the speed of light.Returns the comment string associated with the probeReturns the id of the current lattice element that the probe is visiting.Get the type identifier string of the modeling element where this probe currently exists.Returns the identifier of the hardware modeled by the element associated with this state.Returns the current state object maintained by this probe.double
getGamma()
Returns the relativistic parameter corresponding to the probe velocity.Returns the initial state of this probe.double
Return the kinetic energy of the probe.double
Returns the longitudinal phase of this probe with respect to the RF phase.double
Returns the momentumdouble
Returns the current beam-line position of the probedouble
Returns the charge of probe's particle speciesreturns the species namedouble
Returns the rest energy of particle speciesdouble
getTime()
Return the time elapsed since the probe began propagation.Returns the time stamp of the probe.Get the state history of the probe.void
Initializes the probe, resetting state as necessary.protected void
initializeFrom
(Probe<S> probe) Deprecated.This method is only called from child class overrides which are never called themselves.void
load
(DataAdaptor daptSource) Load the contents of a probe from an data archive represented by aDataAdaptor
interface.ProbeState<?>
lookupLastStateFor
(String strElemTypeId) Looks up the last probe state created by a modeling element of the given identifier.static Probe<?>
newProbeInitializedFrom
(Probe<?> probeInit) Clone factory method.void
Deprecated.This method is called in several places I don't think it ever is implemented to do anything.static Probe<?>
readFrom
(DataAdaptor container) Read the contents of the suppliedDataAdaptor
and return an instance of the appropriate Probe species.protected abstract S
readStateFrom
(DataAdaptor container) Read the contents of the suppliedDataAdaptor
and return an instance of the appropriate Trajectory species.void
reset()
Resets the probe to the saved initial state, if there is one and clears the trajHist.void
save
(DataAdaptor daSink) Save the contents of a probe to a data archive represented by aDataAdaptor
interface.boolean
setAlgorithm
(IAlgorithm ifcAlg) Set the algorithm defining the probes dynamics through elementsvoid
setComment
(String strComment) Provide a user comment associated with the probevoid
Set the current lattice element id.void
setCurrentElementTypeId
(String strTypeId) Sets the type identifier string of the modeling element where this probe currently exists.void
setCurrentHardwareId
(String strSmfId) Sets the identifier of the hardware modeled by the current element.void
setKineticEnergy
(double w) Set the current kinetic energy of the probe.void
setLongitudinalPhase
(double dblPhsLng) Set the longitudinal phase of this probe with respect to the RF phase.void
setPosition
(double s) Set the current position of the probe along the beamline.void
setSpeciesCharge
(double q) Set the charge of the particle species in the beamvoid
setSpeciesName
(String name) Set the species namevoid
setSpeciesRestEnergy
(double eR) Set the rest energy of a single particle in the beamvoid
setTime
(double dblTime) Set the current time since the probe began propagatingvoid
setTimestamp
(Date dateStamp) Sets a time stamp for the probe.void
setTracking
(boolean bolTrack) Set particle trajHist tracking for probes.void
update()
Save the probe state into trajHist.
-
Field Details
-
PROBE_LABEL
element tag for probe data- See Also:
-
TYPE_LABEL
attribute tag for probe type name- See Also:
-
TIME_LABEL
attribute tag for the time stamp- See Also:
-
COMMENT_LABEL
element tag for comment data- See Also:
-
TEXT_LABEL
attribute tag for comment text- See Also:
-
stateCurrent
current state of the probe - defines the probe -
trajHist
Current probe trajHist
-
-
Constructor Details
-
Probe
protected Probe()Creates a new instance of Probe. Since Probe is an abstract base only derived classes may call constructor. -
Probe
Creates a new instance of Probe. Since Probe is an abstract base only derived classes may call constructor.- Parameters:
ifcAlg
- default dynamics algorithm for probe
-
Probe
Copy constructor for Probe. This constructor does a deep copy of the Probe base attributes by calling member support method deepCopyProbeBase().- Parameters:
probe
- Probe object to be cloned
-
-
Method Details
-
readFrom
Read the contents of the suppliedDataAdaptor
and return an instance of the appropriate Probe species.- Parameters:
container
-DataAdaptor
to read a Probe from- Returns:
- a Probe for the contents of the DataAdaptor
- Throws:
DataFormatException
- error encountered reading the DataAdaptor
-
newProbeInitializedFrom
Clone factory method. Creates a new
Probe
object, of the appropriate type, initialized to the argumentProbe
.NOTE:
There is now a reset() method that is preferable to this one. It clears the probe trajHist and restores the initial state saved in the initialize() method, without creating a new probe instance.
- Parameters:
probeInit
-Probe
object containing initial data- Returns:
- new
Probe
object initialized to argument
-
createTrajectory
Require concrete implementations to override this method to create aTrajectory
object of the appropriate species.- Returns:
- a
Trajectory
of the appropriate species for this probe type
-
createProbeState
Captures the probe's state in a ProbeState of the appropriate species. -
createEmptyProbeState
Creates a new, blankProbeState
of the appropriate species.- Returns:
- a new, blank
ProbeState
- Since:
- Jul 1, 2014
-
readStateFrom
Read the contents of the suppliedDataAdaptor
and return an instance of the appropriate Trajectory species.- Parameters:
container
-DataAdaptor
to read a Trajectory from- Returns:
- a ProbeState for the contents of the DataAdaptor
- Throws:
DataFormatException
- error encountered reading the DataAdaptor
-
copy
Creates a deep copy of the probe -
setComment
Provide a user comment associated with the probe- Parameters:
strComment
- user comment string
-
setTimestamp
Sets a time stamp for the probe.- Parameters:
dateStamp
- time stamp for probe
-
setSpeciesName
Set the species name- Parameters:
name
- the species name
-
setAlgorithm
Set the algorithm defining the probes dynamics through elements- Parameters:
ifcAlg
- object exposing the IAlgorithm interface
-
setTracking
public void setTracking(boolean bolTrack) Set particle trajHist tracking for probes.- Parameters:
bolTrack
- turn tracking on or off
-
initializeFrom
Deprecated.This method is only called from child class overrides which are never called themselves.Initialize this probe from the one specified.- Parameters:
probe
- the probe from which to initialize this one
-
cloneCurrentProbeState
This method returns a clone of the current state of this probe. That is, theProbeState
object is a representation of this probe at the moment this method was called.- Returns:
- a deep copy of the current state of this probe
- Since:
- Jun 26, 2014
-
applyState
Apply the contents of ProbeState to update my current state. Subclass implementations should call super.applyState to ensure superclass state is applied.- Parameters:
state
-ProbeState
object containing new probe state data
-
reset
public void reset()Resets the probe to the saved initial state, if there is one and clears the trajHist.
CKA NOTES:
These notes concern the refactoring of the probe component in order to tighten the typing.
· The new behavior should be the same as before, only the implementation differs. The current state is set to a clone of the (previously saved) initial state. · The trajectory is cleared. -
getComment
Returns the comment string associated with the probe- Returns:
- comment string
-
getTimestamp
Returns the time stamp of the probe.- Returns:
- time stamp
-
getMomentum
public double getMomentum()Returns the momentum- Returns:
- particle momentum
-
getCurrentState
Returns the current state object maintained by this probe. The state object contains all the defining state information at the current simulation trajectory location.- Returns:
- the current state of this probe
- Since:
- Nov 18, 2014
-
getInitialState
Returns the initial state of this probe. This is the state with which the probe begins the simulation. Whenever the
command is called the current state of the simulation is set to this state.reset()
- Returns:
- the current starting state for this probe
- Since:
- Dec 29, 2015, Christopher K. Allen
-
getTrajectory
Get the state history of the probe.- Specified by:
getTrajectory
in interfaceIProbe
- Returns:
- Trajectory object of the proper sub-type for the probe type
-
getLongitinalPhase
public double getLongitinalPhase()Returns the longitudinal phase of this probe with respect to the RF phase. Typically used to account for phase delay/advance in cavities incurred due to finite propagation time. For example
φ ≜ φ0 - Δφ
where Δφ = 2πfΔt is the phase delay due to elapsed time Δt, f is the cavity resonant frequency, and φ0 is the operating phase of the cavity (w.r.t. the synchronous particle).- Specified by:
getLongitinalPhase
in interfaceIProbe
- Returns:
- the probe phase φ with respect to the machine RF frequency
- Since:
- Nov 17, 2014
-
getSpeciesName
returns the species name- Specified by:
getSpeciesName
in interfaceIProbe
- Returns:
- species name
-
getSpeciesCharge
public double getSpeciesCharge()Returns the charge of probe's particle species- Specified by:
getSpeciesCharge
in interfaceIProbe
- Returns:
- particle species charge (Coulombs)
-
getSpeciesRestEnergy
public double getSpeciesRestEnergy()Returns the rest energy of particle species- Specified by:
getSpeciesRestEnergy
in interfaceIProbe
- Returns:
- particle species rest energy (electron-volts)
-
getCurrentElement
Returns the id of the current lattice element that the probe is visiting.- Specified by:
getCurrentElement
in interfaceIProbe
- Returns:
- id of current lattice element
-
getCurrentElementTypeId
Description copied from interface:IProbe
Get the type identifier string of the modeling element where this probe currently exists. Note that all modeling elements have a static string identifier defined in their class definition.- Specified by:
getCurrentElementTypeId
in interfaceIProbe
- Since:
- Dec 16, 2014 by Christopher K. Allen
- See Also:
-
getCurrentHardwareId
Returns the identifier of the hardware modeled by the element associated with this state.- Specified by:
getCurrentHardwareId
in interfaceIProbe
- Returns:
- hardware ID of the associated modeling element
- Since:
- Sep 3, 2014
- See Also:
-
getPosition
public double getPosition()Returns the current beam-line position of the probe- Specified by:
getPosition
in interfaceIProbe
- Returns:
- probe position (meters)
-
getTime
public double getTime()Return the time elapsed since the probe began propagation. -
getKineticEnergy
public double getKineticEnergy()Return the kinetic energy of the probe. Depending upon the probe type, this could be the actual kinetic energy of a single constituent particle, the average kinetic energy of an ensemble, the design energy, etc.- Specified by:
getKineticEnergy
in interfaceIProbe
- Returns:
- probe kinetic energy (electron-volts)
-
getBeta
public double getBeta()Returns the probe velocity normalized to the speed of light. -
getGamma
public double getGamma()Returns the relativistic parameter corresponding to the probe velocity. The relativistic factor is given by the formulae
γ = (W/mc2) + 1 = [1/(1-β2)]1/2 -
lookupLastStateFor
Description copied from interface:IProbe
Looks up the last probe state created by a modeling element of the given identifier. The history of the probe (i.e., aTrajectory
object is searched for the last state with the modeling type ID equal to the given value.- Specified by:
lookupLastStateFor
in interfaceIProbe
- Parameters:
strElemTypeId
- modeling element type identification string- Returns:
- the last state created by such a modeling element
- Since:
- Dec 17, 2014 by Christopher K. Allen
- See Also:
-
setCurrentElement
Set the current lattice element id.- Specified by:
setCurrentElement
in interfaceIProbe
- Parameters:
id
- element id of current lattice element
-
setCurrentElementTypeId
Description copied from interface:IProbe
Sets the type identifier string of the modeling element where this probe currently exists. Note that all modeling elements have a static string identifier defined in their class definition.- Specified by:
setCurrentElementTypeId
in interfaceIProbe
- Parameters:
strTypeId
- static identifier string of the modeling element class- Since:
- Dec 16, 2014 by Christopher K. Allen
- See Also:
-
setCurrentHardwareId
Sets the identifier of the hardware modeled by the current element.- Specified by:
setCurrentHardwareId
in interfaceIProbe
- Parameters:
strSmfId
- hardware ID of the current modeling element- Since:
- Sep 3, 2014
- See Also:
-
setPosition
public void setPosition(double s) Set the current position of the probe along the beamline.- Specified by:
setPosition
in interfaceIProbe
- Parameters:
s
- new probe position (meters)- See Also:
-
setTime
public void setTime(double dblTime) Set the current time since the probe began propagating -
setLongitudinalPhase
public void setLongitudinalPhase(double dblPhsLng) Set the longitudinal phase of this probe with respect to the RF phase. Typically used to account for phase delay/advance in cavities incurred due to finite propagation time. For example
φ ≜ φ0 - Δφ
where Δφ = 2πfΔt is the phase delay due to elapsed time Δt, f is the cavity resonant frequency, and φ0 is the operating phase of the cavity (w.r.t. the synchronous particle).- Specified by:
setLongitudinalPhase
in interfaceIProbe
- Parameters:
dblPhsLng
- the phase delay Δφ incurred from probe propagate between RF cavities- Since:
- Nov 17, 2014
-
setKineticEnergy
public void setKineticEnergy(double w) Set the current kinetic energy of the probe.- Specified by:
setKineticEnergy
in interfaceIProbe
- Parameters:
w
- new probe kinetic energy (electron-volts)- See Also:
-
setSpeciesCharge
public void setSpeciesCharge(double q) Set the charge of the particle species in the beam- Specified by:
setSpeciesCharge
in interfaceIProbe
- Parameters:
q
- species particle charge in units of positive electron charge- See Also:
-
setSpeciesRestEnergy
public void setSpeciesRestEnergy(double eR) Set the rest energy of a single particle in the beam- Specified by:
setSpeciesRestEnergy
in interfaceIProbe
- Parameters:
eR
- particle rest energy (electron-volts)- See Also:
-
initialize
public void initialize()Initializes the probe, resetting state as necessary.
CKA NOTES:
These notes concern the refactoring of the probe component in order to tighten the typing.
· In order to make this method compatible with the previous behavior it must set the saved "initial state" to the current probe state. The previous incarnation assigned the new initial state by calling thecreateProbeState()
method to which created a new probe state representing the current state of the probe.
· The trajectory is cleared, that is, there is no longer any history in the probe
· Thus, initialize() is really a poor choice, since all that is done is
- The initial state is reset to the current state
- The trajectory is cleared- Specified by:
initialize
in interfaceIProbe
-
update
Save the probe state into trajHist.- Specified by:
update
in interfaceIProbe
- Throws:
ModelException
- an error occurred while trying to update the probe
-
performPostProcessing
Deprecated.This method is called in several places I don't think it ever is implemented to do anything.Subclasses should override this method to perform any required post processing upon completion of algorithm processing. This method implementation does nothing.- Specified by:
performPostProcessing
in interfaceIProbe
-
getAlgorithm
Return the algorithm defining the probes dynamics.- Specified by:
getAlgorithm
in interfaceIProbe
- Returns:
- interface to probe dynamics
-
getArchive
Return the archiving interface for this object.- Specified by:
getArchive
in interfaceIProbe
- See Also:
-
load
Load the contents of a probe from an data archive represented by aDataAdaptor
interface.- Specified by:
load
in interfaceIArchive
- Parameters:
daptSource
- data archive containing probe info- Throws:
DataFormatException
- bad probe type, missing child data node, or bad number format
-
save
Save the contents of a probe to a data archive represented by aDataAdaptor
interface. -
deepCopy
This is a convenience function for derived classes when implementing their deepCopy() method. This functions deep copies all attributes in the Probe base class. The derived classes need only then deep copy all attributes particular to their type (e.g., state, etc.).- Parameters:
probe
- probe object whose Probe base is to be deep copied into this
-