Description Usage Arguments Value Examples
generate.2order
returns a data frame containing the time (supplied as input) and a simulated signal generated as a solution to a second order
differential equation with constant coefficients that are provided as inputs:
\frac{d^2y}{dt} + 2ξω_{n}\frac{dy}{dt} + ω_{n}^2 y = ω_{n}^2 k*u(t)
Where: y(t) is the signal, \frac{dy}{dt} its derivative and \frac{d^2y}{dt} its second derivative
ω_{n} = \frac{2π}{T} -where T is the period of the oscillation- is the system's natural frequency, the frequency with which the system would vibrate if there were no damping. The term ω_{n}^2 represents thus the ratio between the attraction to the equilibrium and the inertia. If we considered the example of a mass attached to a spring, this term would represent the ratio of the spring constant and the object's mass.
ξ is the damping ratio. It represents the friction that damps the oscillation of the system (slows the rate of change of the variable). The term 2ξω_n thus represents the respective contribution of the inertia, the friction and the attraction to the equilibrium. The value of ξ determines the shape of the system time response, which can be: ξ<0 Unstable, oscillations of increasing magnitude ξ=0 Undamped, oscillating 0<ξ<1 Underdamped or simply "damped": the oscillations are damped by an exponential of damping rate ξω_{n} ξ=1 Critically damped ξ>1 Over-damped, no oscillations in the return to equilibrium
k is the gain
u(t) is an external excitation perturbing the dynamics
The excitation is also provided as input and it can be null (then the solution will be a damped linear oscillator when the initial condition is different from 0)
1 2 3 4 5 6 7 8 9 10 11 | generate.2order(
time = 0:100,
excitation = NULL,
y0 = 0,
v0 = 0,
t0 = NULL,
xi = 0.1,
period = 10,
k = 1,
yeq = 0
)
|
time |
is a vector containing the time values corresponding to the excitation signal. |
excitation |
Is a vector containing the values of the excitation signal. |
y0 |
is the initial condition for the variable y(t=t0), (0, by default), it is a scalar. |
v0 |
is the initial condition for the derivative dy(t=t0), (0, by default), it is a scalar. |
t0 |
is the time corresponding to the initial condition y0 and v0. Default is the minimum value of the time vector. |
xi |
is the damping factor. A negative value will produce divergence from equilibrium. |
period |
is the period T of the oscillation, T = \frac{2*π}{ω_{n}} as mentioned |
k |
Default is 1. It represents the proportionality between the stationary increase of signal and the excitation increase that caused it. Only relevant if the excitation is non null. |
yeq |
is the signal equilibrium value, i.e. the stationary value reached when the excitation term is 0. |
Returns a data.table containing four elements:
t is a vector containing the corresponding time values
y is a vector containing the values calculated with deSolve so that y is a solution to a second order differential equation with constant coefficients (provided as input) evaluated at the time points given by t
dy is a vector containing the values of the derivative calculated at the same time points
exc is the excitation vector
1 2 | generate.2order(time=0:249,excitation=c(rep(0,10),rep(1,240)),period=10)
generate.2order(y0=10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.