Interface DiscreteGenerator<TShared, TInternal>

Interface defining the functionality of a discrete time model, which can be used by DiscreteSystem to initialise and update particles. Generators are stateless and are always provided with all state and other parameters required to update the particle in each method.

interface DiscreteGenerator<TShared, TInternal> {
    initial(
        time: number,
        shared: TShared,
        internal: TInternal,
        stateNext: number[],
        random: Random,
    ): void;
    internal(shared: TShared): TInternal;
    packingState(shared: TShared): Packer;
    update(
        time: number,
        dt: number,
        state: number[],
        shared: TShared,
        internal: TInternal,
        stateNext: number[],
        random: Random,
    ): void;
    updateShared(shared: TShared, newShared: TShared): void;
}

Type Parameters

  • TShared

    Values which are shared between all particles in a group and are not mutated by them - the model parameter values for that group

  • TInternal

    Internal state values which can be mutated by generators, used to improve efficiency of the system by e.g. caching calculation results for use by other particles.

Hierarchy (View Summary)

Methods

  • Sets the initial state of a particle.

    Parameters

    • time: number

      The current time at which to initialise particle state

    • shared: TShared

      The shared parameter values used by the particle's group

    • internal: TInternal

      The internal state used by the particle's group

    • stateNext: number[]

      The array of values which should be updated by the generator with initial particle state values

    • random: Random

      A random number generator which may be used by the generator to initialise values

    Returns void

  • Updates the state of a particle from its previous state.

    Parameters

    • time: number

      The new time to which the particle state should be updated.

    • dt: number

      The time step from the current time to the new time

    • state: number[]

      The current state of the particle

    • shared: TShared

      The shared parameter values used by the particle's group

    • internal: TInternal

      The internal state used by the particle's group

    • stateNext: number[]

      The array of values which should be updated by the generator with new particle state values

    • random: Random

      A random number generator which may be used by the generator to update values

    Returns void

  • Updates values in a system parameter set from a new parameter set. A generator may do custom updating of some values.

    Parameters

    • shared: TShared

      The shared parameter set to update

    • newShared: TShared

      The parameter set to update from

    Returns void