Documentation ¶
Overview ¶
Package dbf implements a database of f(t,{x}) functions (e.g. time-space functions). The functions in this package are accompanied by derivatives w.r.t t and gradients w.r.t {x}. For instance: g(t,{x}) = df/dt, h(t,{x}) = dg/dt, and grad = df/d{x}
Index ¶
- Variables
- func CheckDerivT(tst *testing.T, o T, t0, tf float64, xcte []float64, np int, tskip []float64, ...)
- func CheckDerivX(tst *testing.T, o T, tcte float64, xmin, xmax []float64, np int, ...)
- func PlotT(o T, dirout, fnkey string, t0, tf float64, xcte []float64, np int)
- func PlotX(o T, dirout, fnkey string, tcte float64, xmin, xmax []float64, np int)
- type Add
- type Cdist
- type Cos
- type Cte
- type CutSin
- type Exc1
- type Exc2
- type Halo
- type Lin
- type Mul
- type P
- type Params
- func (o *Params) CheckAndGetValues(names []string) (values []float64)
- func (o *Params) CheckAndSetVariables(names []string, variables []*float64)
- func (o *Params) CheckLimits()
- func (o *Params) Connect(V *float64, name, caller string) (errorMessage string)
- func (o *Params) ConnectSet(V []*float64, names []string, caller string) (errorMessage string)
- func (o *Params) ConnectSetOpt(V []*float64, names []string, optional []bool, caller string) (errorMessage string)
- func (o *Params) Find(name string) *P
- func (o *Params) GetBool(name string) bool
- func (o *Params) GetBoolOrDefault(name string, defaultValue bool) bool
- func (o *Params) GetIntOrDefault(name string, defaultInt int) int
- func (o *Params) GetValue(name string) float64
- func (o *Params) GetValueOrDefault(name string, defaultValue float64) float64
- func (o *Params) GetValues(names []string) (values []float64, found []bool)
- func (o *Params) SetBool(name string, value float64)
- func (o *Params) SetValue(name string, value float64)
- func (o Params) String() (l string)
- type Pts
- type Pulse
- type RefDecGen
- type RefDecSp1
- type RefIncRL1
- type Rmp
- type Sin
- type Srmps
- type T
- type Xpoly1
- type Xpoly2
Constants ¶
This section is empty.
Variables ¶
var One = Cte{1}
One implements an specialisation of Cte function that always returns one
Functions ¶
func CheckDerivT ¶
func CheckDerivT(tst *testing.T, o T, t0, tf float64, xcte []float64, np int, tskip []float64, sktol, dtol, dtol2 float64, ver bool)
CheckDerivT checks derivatives w.r.t to t for fixed coordinates x
func CheckDerivX ¶
func CheckDerivX(tst *testing.T, o T, tcte float64, xmin, xmax []float64, np int, xskip [][]float64, sktol, dtol float64, ver bool)
CheckDerivX checks derivatives w.r.t to x for fixed t
Types ¶
type Add ¶
Add implements the addition of two other functions.
F(t, x) := A*Fa(t,x) + B*Fb(t,x)
type Cdist ¶
type Cdist struct {
// contains filtered or unexported fields
}
Cdist implements the distance from point to a circle (2D) or a sphere (3D) where the circle/sphere is implicitly defined by means of F(x) = 0.
where F(x) = sqrt((x-xc) dot (x-xc)) - r with r being the radius and xc the coordinates of the centre. Thus F > 0 is outside and F < 0 is inside the circle/sphere
type Cos ¶
type Cos struct { // parameters A float64 B float64 C float64 // contains filtered or unexported fields }
Cos implements y(t) = a * cos(b*t) + c Input:
b/pi -- is a flag that says that b is in fact b divided by π thus, the code will multiply b by π internally
type Cte ¶
type Cte struct {
C float64
}
Cte implements a constant function
var Zero Cte
Zero implements an specialisation of Cte function that always returns zero
type CutSin ¶
type CutSin struct { // parameters A float64 B float64 C float64 // contains filtered or unexported fields }
CutSin implements a sine function such as:
if find["cps"]: # means cut_positive is True if y < 0: y(t) = a * sin(b*t) + c else: y(t) = 0 else: # means cut_positive is False so cut negative values if y > 0: y(t) = a * sin(b*t) + c else: y(t) = 0
Input:
b/pi -- is a flag that says that b is in fact b divided by π thus, the code will multiply b by π internally
type Exc1 ¶
type Exc1 struct {
A, B float64
}
Exc1 implements excitation #1 y(t) = a * (1 - cos(b*π*t)) / 2
type Exc2 ¶
Exc2 implements excitation # 2: y(t) = if t < ta a*sin(b*π*t), else 0
type Halo ¶
type Halo struct {
// contains filtered or unexported fields
}
Halo implements the equation of a circle in 2D or a sphere in 3D by means of the following implicit form F(x) = 0
where F(x) = (x-xc) dot (x-xc) - r^2 with r being the radius and xc the coordinates of the centre. Thus F > 0 is outside and F < 0 is inside the circle/sphere
type Lin ¶
Lin implements a linear function w.r.t t
y = m * (t - ts)
type Mul ¶
type Mul struct {
Fa, Fb T
}
Mul implements the multiplication of two other functions.
F(t, x) := fa(t,x) * fb(t,x)
type P ¶
type P struct { // input N string `json:"n"` // name of parameter V float64 `json:"v"` // value of parameter Min float64 `json:"min"` // min value Max float64 `json:"max"` // max value S float64 `json:"s"` // standard deviation D string `json:"d"` // probability distribution type U string `json:"u"` // unit (not verified) Adj int `json:"adj"` // adjustable: unique ID (greater than zero) Dep int `json:"dep"` // depends on "adj" Extra string `json:"extra"` // extra data Inact bool `json:"inact"` // parameter is inactive in optimisation SetDef bool `json:"setdef"` // tells model to use a default value // auxiliary Fcn T // a function y=f(t,x) Other *P // dependency: connected parameter // contains filtered or unexported fields }
P holds numeric parameters defined by a name N and a value V.
P is convenient to store the range of allowed values in Min and Max, and other information such as standard deviation S, probability distribution type D, among others.
Dependent variables may be connected to P using Connect so when Set is called, the dependendt variable is updated as well.
Other parameters can be linked to this one via the Other data member and Fcn may be useful to compute y=f(t,x)
type Params ¶
type Params []*P
Params holds many parameters
A set of Params can be initialized as follows: var params Params params = []*P{ {N: "klx", V: 1.0}, {N: "kly", V: 2.0}, {N: "klz", V: 3.0}, } Alternatively, see NewParams function
func NewParams ¶ added in v1.1.0
func NewParams(pp ...interface{}) (o Params)
NewParams returns a set of parameters
This is an alternative to initializing Params by setting slice items A set of Params can be initialized as follows: params := NewParams( &P{N: "P1", V: 1}, &P{N: "P2", V: 2}, &P{N: "P3", V: 3}, ) Alternatively, you may set slice components directly (see Params definition)
func (*Params) CheckAndGetValues ¶
CheckAndGetValues check min/max limits and return values. Will panic if values are outside corresponding min/max range. Will also panic if a parameter name is not found.
func (*Params) CheckAndSetVariables ¶ added in v1.1.0
CheckAndSetVariables get parameter values and check limits defined in Min and Max Will panic if values are outside corresponding Min/Max range. Will also panic if a parameter name is not found.
func (*Params) CheckLimits ¶
func (o *Params) CheckLimits()
CheckLimits check limits of variables given in Min/Max Will panic if values are outside corresponding Min/Max range.
func (*Params) ConnectSet ¶
ConnectSet connects set of parameters
func (*Params) ConnectSetOpt ¶ added in v1.0.1
func (o *Params) ConnectSetOpt(V []*float64, names []string, optional []bool, caller string) (errorMessage string)
ConnectSetOpt connects set of parameters with some being optional
func (*Params) GetBool ¶ added in v1.1.0
GetBool reads Boolean parameter or Panic Returns true if P[name] > 0; otherwise returns false Will panic if name does not exist in parameters set
func (*Params) GetBoolOrDefault ¶ added in v1.1.0
GetBoolOrDefault reads Boolean parameter or returns default value Returns true if P[name] > 0; otherwise returns false Will return defaultValue if name does not exist in parameters set
func (*Params) GetIntOrDefault ¶ added in v1.1.0
GetIntOrDefault reads parameter or returns default value Will return defaultInt if name does not exist in parameters set
func (*Params) GetValue ¶ added in v1.1.0
GetValue reads parameter or Panic Will panic if name does not exist in parameters set
func (*Params) GetValueOrDefault ¶ added in v1.1.0
GetValueOrDefault reads parameter or returns default value Will return defaultValue if name does not exist in parameters set
func (*Params) SetBool ¶ added in v1.1.0
SetBool sets Boolean parameter or Panic Sets +1==true if value > 0; otherwise sets -1==false Will panic if name does not exist in parameters set
type Pts ¶
type Pts struct {
// contains filtered or unexported fields
}
Pts is a function based on a linear interpolation over a set of points
type Pulse ¶
Pulse implements a ramp function
type RefDecGen ¶
type RefDecGen struct {
A, B float64 // lambda function coeficients
// contains filtered or unexported fields
}
RefDecGen implements the reference decreasing model (general)
[1] Pedroso DM, Sheng D, Zhao J. The concept of reference curves for constitutive modelling in soil mechanics, Computers and Geotechnics, 36, 1-2, http://dx.doi.org/10.1016/j.compgeo.2008.01.009
type RefDecSp1 ¶
type RefDecSp1 struct {
// contains filtered or unexported fields
}
RefDecSp1 implements a specialisation of the reference decreasing model
[1] Pedroso DM, Sheng D, Zhao J. The concept of reference curves for constitutive modelling in soil mechanics, Computers and Geotechnics, 36, 1-2, http://dx.doi.org/10.1016/j.compgeo.2008.01.009 y ^ | ya o | \ | | \ | ------------+-------------------------> x | yb o--._ -\-------- λ0 = 0 | `. | \\ | . | \ | \--- | \ | λ1 | \| | \ | |
type RefIncRL1 ¶
type RefIncRL1 struct {
// contains filtered or unexported fields
}
RefIncRL1 implements a specialisation of the reference increasing model Reference concept model: dydx growth but solved from right to left with right-most initial point @ x,y=1,1 with (0 <= x <= 1) Flipped model is also available if λ1 < λ0 ( b == 1 )
type Sin ¶
type Sin struct { // parameters A float64 B float64 C float64 // contains filtered or unexported fields }
Sin implements y(t) = a * sin(b*t) + c Input:
b/pi -- is a flag that says that b is in fact b divided by π thus, the code will multiply b by π internally
type Srmps ¶
Srmps implements the increasing or decreasing smooth-ramp-smooth function
type T ¶
type T interface { Init(prms Params) // initialise function parameters F(t float64, x []float64) float64 // y = F(t, x) G(t float64, x []float64) float64 // ∂y/∂t_cteX = G(t, x) H(t float64, x []float64) float64 // ∂²y/∂t²_cteX = H(t, x) Grad(v []float64, t float64, x []float64) // ∇F = ∂y/∂x = Grad(t, x) }
T defines the interface for t-x functions; i.e. f(t, {x})
type Xpoly1 ¶
type Xpoly1 struct {
// contains filtered or unexported fields
}
Xpoly1 implements F(x) as a 1st order polynomial with the components x[i]
functions: F(x) = a0 x0 + a1 x1 + a2 x2 or, if '2D = true': F(x) = a0 x0 + a1 x1
type Xpoly2 ¶
type Xpoly2 struct {
// contains filtered or unexported fields
}
Xpoly2 implements F(x) as a 2nd order polynomial with the components x[i]
functions: F(x) = a0 x0 + a1 x1 + a2 x2 + b0 x0² + b1 x1² + b2 x2² + c01 x0 x1 + c12 x1 x2 + c20 x2 x0 or, if '2D = true': F(x) = a0 x0 + a1 x1 + b0 x0² + b1 x1² + c01 x0 x1