public interface HasNumericState
DataBuffer
.Modifier and Type | Method and Description |
---|---|
default void |
advanceState(double t0,
double t1)
If
requiresAdvance() and hasState() both return true , then this method is called each time step by the system integrator
to update this component's state. |
default int |
getAuxVarDerivative(double[] buf,
int idx)
If this component has auxiliary variables, returns the current values of
their derivatives in
buf , starting at the location idx . |
default int |
getAuxVarState(double[] buf,
int idx)
If this component has auxiliary variables, returns their values in
buf , starting at the location idx . |
void |
getState(DataBuffer data)
Saves state information for this component by adding data to the
supplied DataBuffer.
|
default int |
getStateVersion()
Returns a version number for this component's state.
|
boolean |
hasState()
Returns
true if this component currently holds state. |
default int |
numAuxVars()
Returns the number of auxiliary variables associated with this
component, or 0 if there are no auxiliary variables.
|
default boolean |
requiresAdvance()
Returns
true if the state of this component must be
updated each time step using advanceState(double, double) . |
default int |
setAuxVarState(double[] buf,
int idx)
If this component has auxiliary variables, sets them from the values in
buf , starting at the location idx . |
void |
setState(DataBuffer data)
Restores the state for this component by reading from the supplied
data buffer, starting at the current buffer offsets.
|
boolean hasState()
true
if this component currently holds state. This
allows the presence of state to depend on the component's configuration.true
if this component holds statevoid getState(DataBuffer data)
data
- buffer for storing the state values.void setState(DataBuffer data)
data
- buffer containing the state informationdefault int getStateVersion()
default boolean requiresAdvance()
true
if the state of this component must be
updated each time step using advanceState(double, double)
.true
if advanceState
must be calleddefault void advanceState(double t0, double t1)
requiresAdvance()
and hasState()
both return true
, then this method is called each time step by the system integrator
to update this component's state. For single step integrators, the method
is called once at the start of the integration, with t0
and
t1
set to the step's start and end times. For multi-step
integrators (such as Runge Kutta), the method is called for each
sub-step, with t0
and t1
set to the sub-step's time
bounds. Multi-step integrators will also use getState(maspack.util.DataBuffer)
and
setState(maspack.util.DataBuffer)
to save and restore state as required.t0
- beginning time associated with the time step or sub-stept1
- end time associated with the time step or sub-stepdefault int numAuxVars()
If hasState()
returns true
and the component has
auxiliary variables, the variables are updated each time step by the
system integrator using explcit integration of the form
w += h dwdtwhere
h
is a time increment, w
is a vector of variables
accessed using getAuxVarState(double[], int)
and setAuxVarState(double[], int)
, and
dwdt
is a time derivative obtained using getAuxVarDerivative(double[], int)
. For single step integrators, this will be done
once at the start of the integration, with h
set to the time step
size. For multi-step integrators (such as Runge Kutta), this will be done
at the start of each sub-step, with h
set to the sub-step size.
If present, auxiliary variables are also assumed to be contained
within the state accessed using getState(maspack.util.DataBuffer)
and setState(maspack.util.DataBuffer)
.
default int getAuxVarState(double[] buf, int idx)
buf
, starting at the location idx
. See numAuxVars()
for
a description of auxiliary variables. The method returns idx +
num
, where num
is the number of variables.buf
- returns the variable valuesidx
- starting point within buf
idx
plus the number of variablesdefault int setAuxVarState(double[] buf, int idx)
buf
, starting at the location idx
. See numAuxVars()
for a description of auxiliary variables. The method
returns idx + num
, where num
is the number of variables.buf
- contains the new variable valuesidx
- starting point within buf
idx
plus the number of variablesdefault int getAuxVarDerivative(double[] buf, int idx)
buf
, starting at the location idx
.
See numAuxVars()
for a description of auxiliary variables. The
method returns idx + num
, where num
is the number of
variables.buf
- returns the variable derivative valuesidx
- starting point within buf
idx
plus the number of variables