public final class NumericalPropagator extends Object implements IThreadAware, IDisposable
A propagator which can advance the state from initial conditions by either taking individual
integration steps or by propagating over a given time span. Note that a given instance of a
propagator is NOT thread safe. So if there is a need to propagate a given state in different
threads, make sure to clone the propagator for another thread using CopyForAnotherThread.copy(T)
.
A NumericalPropagator
is created by configuring a NumericalPropagatorDefinition
and then calling NumericalPropagatorDefinition.createPropagator()
.
Modifier and Type | Method and Description |
---|---|
void |
addExceptionDuringPropagation(EventHandler<ExceptionDuringPropagationEventArgs> value)
Gets the instance of the event handler which will be triggered after
the propagator throws an exception.
|
void |
addStepTaken(EventHandler<PropagationEventArgs> value)
Gets the instance of the event handler which will be triggered after
every time the propagator takes an integration step.
|
Object |
clone(CopyContext context)
Clones this object using the specified context.
|
void |
dispose()
Releases any resources associated with this instance.
|
PropagationStateConverter |
getConverter()
Gets an instance of a converter which can convert the overall raw output
into the output corresponding to a particular
PropagationStateElement
or AuxiliaryStateElement based on a string identifier and output type. |
double[] |
getCurrentState()
Gets a copy of the raw state at the end of the last step taken.
|
double |
getCurrentStepSize()
Gets the current step size in seconds that the integrator will take when advancing to the next time.
|
JulianDate |
getCurrentTime()
Gets the time at the end of the last step taken.
|
boolean |
getIncludeIntegratorInformationInOutput()
Gets a value indicating whether the
NumericalIntegrationInformation produced by the
integrator will be stored in the output produced by this propagator when it creates a
NumericalPropagationStateHistory . |
JulianDate |
getInitialEpoch()
Gets the time at which the
InitialState (get ) is defined. |
double[] |
getInitialState()
Gets a copy of the raw initial state used to start propagation.
|
boolean |
getIsThreadSafe()
Gets a value indicating whether the methods on this instance are safe to call from
multiple threads simultaneously.
|
double |
getPreviousStepSize()
|
IntegrationSense |
getPropagationDirection()
Gets the direction of propagation with regard to time,
either increasing or decreasing.
|
StepSizeInformation |
getStepSizeInformation()
Gets information about the last step that was taken by the integrator.
|
double[] |
propagate(Duration propagationTime)
|
NumericalPropagationStateHistory |
propagate(Duration propagationTime,
int outputSparsity)
|
NumericalPropagationStateHistory |
propagate(Duration propagationTime,
int outputSparsity,
ITrackCalculationProgress tracker)
|
double[] |
propagate(Duration propagationTime,
ITrackCalculationProgress tracker)
|
StoppableNumericalPropagatorResults |
propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions,
IntegrationSense direction,
boolean initializeStoppingCondition,
int outputSparsity,
ITrackCalculationProgress progressTracker)
Propagates until one of the
conditions are tripped. |
StoppableNumericalPropagatorResults |
propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions,
IntegrationSense direction,
boolean initializeStoppingCondition,
ITrackCalculationProgress progressTracker)
Propagates until one of the
conditions are tripped. |
StoppableNumericalPropagatorResults |
propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions,
IntegrationSense direction,
ITrackCalculationProgress progressTracker)
Propagates until one of the
conditions are tripped. |
StoppableNumericalPropagatorResults |
propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions,
ITrackCalculationProgress progressTracker)
Propagates forward until one of the
conditions are tripped. |
void |
removeExceptionDuringPropagation(EventHandler<ExceptionDuringPropagationEventArgs> value)
Gets the instance of the event handler which will be triggered after
the propagator throws an exception.
|
void |
removeStepTaken(EventHandler<PropagationEventArgs> value)
Gets the instance of the event handler which will be triggered after
every time the propagator takes an integration step.
|
void |
reset()
Resets the propagation back to the initial conditions.
|
void |
reset(JulianDate newEpoch,
double[] newInitialState)
Resets the propagation to a new set of initial conditions at the epoch time.
|
PropagationEventIndication |
restep(double stepSize)
|
PropagationEventIndication |
takeStep()
Advance the state from the
CurrentState (get ) by taking a single integration step. |
PropagationEventIndication |
takeStep(double maxStepSize)
Advance the state from the
CurrentState (get ) by taking a single integration step bounded by a maximum. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public final Object clone(CopyContext context)
This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext
as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T)
to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T)
to copy any reference fields.
A typical implementation of ICloneWithContext
:
public static class MyClass implements ICloneWithContext {
public MyClass(MyClass existingInstance, CopyContext context) {
context.addObjectMapping(existingInstance, this);
someReference = context.updateReference(existingInstance.someReference);
}
@Override
public final Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
}
In general, all fields that are reference types should be copied with a call to
CopyContext.updateReference(T)
. There are a couple of exceptions:
If one of these exceptions applies, the CopyContext
should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T)
to update the reference. If CopyContext.updateReference(T)
returns
the original object, indicating that the context does not have a replacement registered,
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.
alwaysCopy = context.updateReference(existingInstance.alwaysCopy);
if (existingInstance.alwaysCopy != null && alwaysCopy == existingInstance.alwaysCopy) {
alwaysCopy = (AlwaysCopy) existingInstance.alwaysCopy.clone(context);
}
If you are implementing an evaluator (a class that implements IEvaluator
), the
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
method shares some responsibilities with the
copy context constructor. Code duplication can be avoided by doing the following:
CopyContext.updateReference(T)
. You should still call CopyContext.updateReference(T)
on any references to
non-evaluators.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as the last line in the constructor and pass it the
same CopyContext
passed to the constructor.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as normal. See the reference documentation for
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
for more information on implementing that method.
public MyClass(MyClass existingInstance, CopyContext context) {
super(existingInstance, context);
someReference = context.updateReference(existingInstance.someReference);
evaluatorReference = existingInstance.evaluatorReference;
updateEvaluatorReferences(context);
}
@Override
public void updateEvaluatorReferences(CopyContext context) {
evaluatorReference = context.updateReference(evaluatorReference);
}
@Override
public Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
private IEvaluator evaluatorReference;
clone
in interface ICloneWithContext
context
- The context to use to perform the copy.public final void dispose()
dispose
in interface IDisposable
public final boolean getIsThreadSafe()
If this property is true
, all methods and properties are guaranteed to be thread safe.
Conceptually, an object that returns true
for this method acts as if there is a lock
protecting each method and property such that only one thread at a time can be inside any method or
property in the class. In reality, such locks are generally not used and are in fact discouraged. However,
the user must not experience any exceptions or inconsistent behavior that would not be experienced if such
locks were used.
If this property is false
, the behavior when using this class from multiple threads
simultaneously is undefined and may include inconsistent results and exceptions. Clients wishing to use
multiple threads should call CopyForAnotherThread.copy(T)
to get a separate instance of the
object for each thread.
getIsThreadSafe
in interface IThreadAware
@Nonnull public final JulianDate getCurrentTime()
@Nonnull public final double[] getCurrentState()
PropagationStateConverter.convertState(java.lang.String, double[])
method on the
Converter
(get
) property.@Nonnull public final JulianDate getInitialEpoch()
InitialState
(get
) is defined.public final double[] getInitialState()
PropagationStateConverter.convertState(java.lang.String, double[])
method on the
Converter
(get
) property.@Nonnull public final StepSizeInformation getStepSizeInformation()
public final double getCurrentStepSize()
public final double getPreviousStepSize()
public final boolean getIncludeIntegratorInformationInOutput()
NumericalIntegrationInformation
produced by the
integrator will be stored in the output produced by this propagator when it creates a
NumericalPropagationStateHistory
.@Nonnull public final IntegrationSense getPropagationDirection()
@Nonnull public final PropagationStateConverter getConverter()
PropagationStateElement
or AuxiliaryStateElement
based on a string identifier and output type.
This is also the object to use when producing ephemeris data to create
interpolated Point
or
Vector
objects.public final void addStepTaken(EventHandler<PropagationEventArgs> value)
public final void removeStepTaken(EventHandler<PropagationEventArgs> value)
public final void addExceptionDuringPropagation(EventHandler<ExceptionDuringPropagationEventArgs> value)
NumericalPropagationException
that wraps the underlying exception.public final void removeExceptionDuringPropagation(EventHandler<ExceptionDuringPropagationEventArgs> value)
NumericalPropagationException
that wraps the underlying exception.public final void reset()
public final void reset(@Nonnull JulianDate newEpoch, double[] newInitialState)
newEpoch
- The new epoch corresponding to the initial state.newInitialState
- The new initial state corresponding to the propagation epoch.
Use the PropagationStateConverter.adjustState(java.lang.String, double[], agi.foundation.Motion1<T>)
method on the
Converter
(get
) property to easily create a new initial state vector.public final double[] propagate(@Nonnull Duration propagationTime)
CurrentTime
(get
) and CurrentState
(get
).
The direction of propagation is determined by the sign of the Duration
specified.propagationTime
- The (positive or negative) total time, measured from
the CurrentTime
(get
), over which to propagate.
A negative duration will indicate that the propagator should propagate backwards
in time.propagationTime
away from the Epoch
(get
/ set
) on the state, and if IncludeIntegratorInformationInOutput
(get
)
is true it also contains the combined integration information over the propagation and
the average step size. Use PropagationStateConverter.convertState(java.lang.String, double[])
to process this raw state
into a useful form.public final double[] propagate(@Nonnull Duration propagationTime, ITrackCalculationProgress tracker)
CurrentTime
(get
) and CurrentState
(get
).
The direction of propagation is determined by the sign of the Duration
specified.propagationTime
- The (positive or negative) total time, measured from
the CurrentTime
(get
), over which to propagate.
A negative duration will indicate that the propagator should propagate backwards
in time.tracker
- A progress tracker which will report the progress of the propagation
from 0 percent to 100 percent.propagationTime
away from the Epoch
(get
/ set
) on the state, and if IncludeIntegratorInformationInOutput
(get
)
is true it also contains the combined integration information over the propagation and
the average step size. Use PropagationStateConverter.convertState(java.lang.String, double[])
to process this raw state
into a useful form.public final NumericalPropagationStateHistory propagate(@Nonnull Duration propagationTime, int outputSparsity)
CurrentTime
(get
) and CurrentState
(get
).
The direction of propagation is determined by the sign of the Duration
specified.propagationTime
- The (positive or negative) total time, measured from
the CurrentTime
(get
), over which to propagate.
A negative duration will indicate that the propagator should propagate backwards
in time.outputSparsity
- The interval at which to produce output samples.
By default this should be set to one, meaning that output will be saved in the state history
for every integration step. If a thinner (but less accurate) ephemeris is desired you can set this
to a higher number. Two means that output is saved every other integration step, etc, etc.IncludeIntegratorInformationInOutput
(get
) is true it also contains the combined
integration information over the propagation and the average step size.public final NumericalPropagationStateHistory propagate(@Nonnull Duration propagationTime, int outputSparsity, ITrackCalculationProgress tracker)
CurrentTime
(get
) and CurrentState
(get
).
The direction of propagation is determined by the sign of the Duration
specified.propagationTime
- The (positive or negative) total time, measured from
the CurrentTime
(get
), over which to propagate.
A negative duration will indicate that the propagator should propagate backwards
in time.outputSparsity
- The interval at which to produce output samples.
By default this should be set to one, meaning that output will be saved in the state history
for every integration step. If a thinner (but less accurate) ephemeris is desired you can set this
to a higher number. Two means that output is saved every other integration step, etc, etc.tracker
- A progress tracker which will report the progress of the propagation
from 0 percent to 100 percent.IncludeIntegratorInformationInOutput
(get
) is true it also contains the combined
integration information over the propagation and the average step size.@Nonnull public final PropagationEventIndication takeStep()
@Nonnull public final PropagationEventIndication takeStep(double maxStepSize)
CurrentState
(get
) by taking a single integration step bounded by a maximum.
CurrentState
(get
) and CurrentTime
(get
) will be updated to reflect the new values.maxStepSize
- The maximum step size the integrator can take while advancing the state.
The sign of this maximum step size will determine (set) the PropagationDirection
(get
).
If positive, it will be IntegrationSense.INCREASING
and if negative it will be
IntegrationSense.DECREASING
from the CurrentTime
(get
).StepTaken
(add
/ remove
) event handler.@Nonnull public final PropagationEventIndication restep(double stepSize)
CurrentState
(get
), reintegrate the last step that was taken by the integrator
by the given step size to produce a new CurrentState
(get
) and CurrentTime
(get
).stepSize
- The exact size of the step to take since the last time, which will replace
PreviousStepSize
(get
). The sign of the step will determine (set) the PropagationDirection
(get
).
If the sign is positive, time will be IntegrationSense.INCREASING
and if negative it will be
IntegrationSense.DECREASING
from the CurrentTime
(get
).StepTaken
(add
/ remove
) event handler.public final StoppableNumericalPropagatorResults propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions, ITrackCalculationProgress progressTracker)
conditions
are tripped. This will propagate
IntegrationSense.INCREASING
by default.conditions
- The conditions to stop on.progressTracker
- An optional progress tracker
.
How long the segment will take to propagate generally is not known ahead of time, so the reported
progress completed is set to -1. But you can cancel propagation with the tracker.public final StoppableNumericalPropagatorResults propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions, @Nonnull IntegrationSense direction, ITrackCalculationProgress progressTracker)
conditions
are tripped.conditions
- The conditions to stop on.direction
- The direction to search for an event.progressTracker
- An optional progress tracker
.
How long the segment will take to propagate generally is not known ahead of time, so the reported
progress completed is set to -1. But you can cancel propagation with the tracker.public final StoppableNumericalPropagatorResults propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions, @Nonnull IntegrationSense direction, boolean initializeStoppingCondition, ITrackCalculationProgress progressTracker)
conditions
are tripped.conditions
- The conditions to stop on.direction
- The direction to search for an event.progressTracker
- An optional progress tracker
.
How long the segment will take to propagate generally is not known ahead of time, so the reported
progress completed is set to -1. But you can cancel propagation with the tracker.initializeStoppingCondition
- Indicates if the conditions
should be
initialized
. Set this to false
if
the conditions
have been initialized prior to this method being called.public final StoppableNumericalPropagatorResults propagateUntilStop(Iterable<? extends StoppingConditionEvaluator> conditions, @Nonnull IntegrationSense direction, boolean initializeStoppingCondition, int outputSparsity, ITrackCalculationProgress progressTracker)
conditions
are tripped.conditions
- The conditions to stop on.direction
- The direction to search for an event.progressTracker
- An optional progress tracker
.
How long the segment will take to propagate generally is not known ahead of time, so the reported
progress completed is set to -1. But you can cancel propagation with the tracker.outputSparsity
- The interval at which to produce output samples.
By default this should be set to one, meaning that output will be saved in the state history
for every integration step. If a coarser (but less accurate) ephemeris is desired you can set this
to a higher number. Two means that output is saved every other integration step, etc, etc.initializeStoppingCondition
- Indicates if the conditions
should be
initialized
. Set this to false
if
the conditions
have been initialized prior to this method being called.