ForcedOscillator1D¶
- class component_model.analytic.ForcedOscillator1D(k: float, c: float, m: float = 1.0, a: float = 0.0, wf: float = 0.1, x0: float | None = None, dx0: float | None = None, d0: float = 0.0)¶
Bases:
objectCalculate the expected (analytic) position and speed of a harmonic oscillator in one dimension with the given parameter settings.
i.e. the solution to the differential equation:
m* d2x + c* dx + k* x = a* sin(wf*t+d0) , with x(0)=x0 and dx(0)=dx0
Used for verification purposes, but made available within code base to be available for other packages.
- Parameters:
k (float) – harmonic oscillator parameters
c (float) – harmonic oscillator parameters
m (float) – harmonic oscillator parameters
a (float) – sinusoidal force parameters (amplitude and angular frequency). Assume F(t) = a*sin(wf*t)
wf (float) – sinusoidal force parameters (amplitude and angular frequency). Assume F(t) = a*sin(wf*t)
x0 (float) – start values for harmonic oscillator (force has fixed start values). Assume x0=dx0=0.0 for forced oscillation and x0=0, dx0=1 for non-forced if None.
dx0 (float) – start values for harmonic oscillator (force has fixed start values). Assume x0=dx0=0.0 for forced oscillation and x0=0, dx0=1 for non-forced if None.
d0 (float) – optional additional phase of force. E.g. d0=np.pi/2 leads to a cos(wf*t) force
- __init__(k: float, c: float, m: float = 1.0, a: float = 0.0, wf: float = 0.1, x0: float | None = None, dx0: float | None = None, d0: float = 0.0)¶
Methods
__init__(k, c[, m, a, wf, x0, dx0, d0])calc(t)Calculate position x and speed v of oscillator for time(s) t.
coefficients([x0, dx0, a, wf, d0])Calculate integration parameters (C1 and C2/phi, and A, d) such that start position x0 and velocity dx0 and a, wf and d0 are as specified.
period()- calc(t: float | ndarray)¶
Calculate position x and speed v of oscillator for time(s) t. Change of any of .x0, .dx0, .a, .wf, .d0 requires running .coefficients() beforehand.
- coefficients(x0: float | None = None, dx0: float | None = None, a: float | None = None, wf: float | None = None, d0: float | None = None)¶
Calculate integration parameters (C1 and C2/phi, and A, d) such that start position x0 and velocity dx0 and a, wf and d0 are as specified.
Default values x0, dx0: (0.0, 1.0) or (1.0, 0.0) if not forced. (0.0, 0.0) if forced. Default values a, wf, d0: the stored value self.* Note: d0=0.0 results into a sine function as force while e.g. d0=pi/2 results into a cosine force.
- period()¶