state

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(dst State)

Abs takes absolute value of elements in X variables and stores the result in dst.

func Add

func Add(dst, s State)

Add adds, element-wise the X variables of state s and dst and stores result in dst. It panics if the slice argument lengths do not match.

func AddConst

func AddConst(c float64, dst State)

AddConst adds the scalar c to all of the values in dst.

func AddScaled

func AddScaled(dst State, alpha float64, s State)

AddScaled performs dst = dst + alpha * s. It panics if the slice argument lengths do not match.

func Div

func Div(dst, s State)

Div performs element-wise division dst / s and stores the value in dst. It panics if the argument lengths do not match.

func Jacobian

func Jacobian(dst *mat.Dense, d Diffs, s State, settings *fd.JacobianSettings) *mat.Dense

Jacobian approximates jacobian matrix for Diffs system

func Max

func Max(s State) float64

Max returns the maximum value of s

func Min

func Min(s State) float64

Min returns the minimum value of s

func Mul

func Mul(dst, s State)

Mul performs element-wise multiplication between dst and s and stores the value in dst. It panics if the argument lengths do not match.

func Norm

func Norm(s State, L float64) float64

Norm returns the L norm of state s, defined as (sum_{i=1}^N s[i]^L)^{1/L}

Special cases: L = math.Inf(1) gives the maximum absolute value. Does not correctly compute the zero norm (use Count)

func Scale

func Scale(c float64, dst State)

Scale multiplies every element in dst by the scalar c.

func Sub

func Sub(dst, s State)

Sub subtracts, element-wise, the elements of s from dst. It panics if the argument lengths do not match.

Types

type Diff

type Diff func(State) float64

Diff represents a single non-linear differential equation of the Simulation's system of differential equation. Specifically, it represents an X variable change.

type Diffs

type Diffs []Diff

Diffs represents a coupled non-linear algebraic system

type Input

type Input func(State) float64

Input represents a time-varying or table look-up variable/coefficient of the Simulation's system of differential equations. Inputs can be used to model non-autonomous system of differential equations. Input functions are called after solver algorithm finishes on the resulting state.

type State

type State struct {
	// contains filtered or unexported fields
}

State describes a discrete simulation configuration.

Contains X and U vectors for a step instance (i.e. point in time) Can access step variable with Time() method.

func AddScaledTo

func AddScaledTo(dst, y State, alpha float64, s State) State

AddScaledTo performs elementwise dst = y + alpha * s, where alpha is a scalar, and dst, y and s are all slices. It panics if the slice argument lengths do not match.

func AddTo

func AddTo(dst, s, t State) State

AddTo adds, element-wise, the elements of s and t and stores the result in dst. Returns dst. It panics if the slice argument lengths do not match.

func DivTo

func DivTo(dst, s, t State) State

DivTo performs element-wise division s / t and stores the value in dst. Returns modified dst. It panics if the argument lengths do not match.

func MulTo

func MulTo(dst, s, t State) State

MulTo performs element-wise multiplication between s and t and stores the value in dst. It panics if the argument lengths do not match.

func New

func New() State

New creates empty state

func NewFromXMap

func NewFromXMap(xm map[Symbol]float64) State

NewFromXMap Creates state from a X var symbol to value map

func ScaleTo

func ScaleTo(dst State, c float64, s State) State

ScaleTo multiplies the elements in s by c and stores the result in dst. It panics if the slice argument lengths do not match.

func SubTo

func SubTo(dst, s, t State) State

SubTo subtracts, element-wise, the elements of t from s and stores the result in dst. It panics if the argument lengths do not match.

func (State) Clone

func (s State) Clone() State

Clone creates a duplicate of a State.

func (State) CloneBlank

func (s State) CloneBlank(t float64) State

CloneBlank creates a duplicate of state at time `t` with all X vector set to zero value

func (State) ConsistencyU

func (s State) ConsistencyU(question []Symbol) []float64

ConsistencyU can be used to determine if Symbols are present in U and if a symbol is missing.

It takes a vector of Symbols and returns a vector of zero floats

If a symbol is not present in U then an IEEE 754 “not-a-number” value will correspond to it.

func (State) ConsistencyX

func (s State) ConsistencyX(question []Symbol) []float64

ConsistencyX can be used to determine if Symbols are present in X and if a symbol is missing.

It takes a vector of Symbols and returns a vector of zero floats

If a symbol is not present in X then an IEEE 754 “not-a-number” value will correspond to it.

func (State) Len

func (s State) Len() int

Len returns amount of X variables in state

func (*State) SetAllX

func (s *State) SetAllX(new []float64)

SetAllX replace all ordered X values with new ones

func (*State) SetTime

func (s *State) SetTime(t float64)

SetTime set domain variable (default time)

func (State) Time

func (s State) Time() float64

Time get State step variable (default time)

func (State) U

func (s State) U(sym Symbol) float64

U get a State input.

If state input does not exist then U panics

func (*State) UEqual

func (s *State) UEqual(sym Symbol, val float64)

UEqual Set a State Input (U) Symbol to a value.

If Symbol does not exist then it is created

func (*State) USet

func (s *State) USet(sym Symbol, val float64)

USet sets an existing State Symbol to a value.

If Symbol does not exist then USet panics

func (State) USymbols

func (s State) USymbols() []Symbol

USymbols returns ordered input Symbol slice

func (State) UVector

func (s State) UVector() []float64

UVector returns copy of state U vector

func (State) X

func (s State) X(sym Symbol) float64

X get a State variable.

If state variable does not exist then X panics

func (*State) XEqual

func (s *State) XEqual(sym Symbol, val float64)

XEqual Set a State Symbol to a value.

If Symbol does not exist then it is created

func (*State) XSet

func (s *State) XSet(sym Symbol, val float64)

XSet set an existing State Symbol to a value

If Symbol does not exist then XSet panics

func (State) XSymbols

func (s State) XSymbols() []Symbol

XSymbols returns ordered state Symbol slice

func (State) XVector

func (s State) XVector() []float64

XVector returns copy of state X vector

type Symbol

type Symbol string

Symbol is used to reference a simulation variable.

It should be unique for each simulation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL