Implementation
As described in the Theory & Practice page, WecOptTool operates by solving a constrained optimization problem, in which an equality constraint (\(r(x) = 0\)) is used to enforce the dynamics of the system.
For the linear case, which is the default formulation in WecOptTool, the WEC dynamics can be expressed, in residual form, as
The decision variable, \(x\), includes states of the body motion as well as other external states, e.g., related to controllers, PTO systems, mooring systems, etc.
Here, \(x_{pos} \in \mathbb{R}^{m(2n + 1)}\), where \(m\) is the number of body modes of motion and \(n\) is the number of frequency components. Similarly, \(x_{ext} \in \mathbb{R}^{p(2n+1)}\), where \(p\) is the number of external states. Body modes could include multiple degrees-of-freedom for a single body (e.g., heave, surge, and pitch) and/or degrees-of-freedom from multiple bodies (e.g., heave modes from each body in a large array of bodies). The frequency vector \(\omega \in \mathbb{R}^n\) should span the relevant frequencies of the device operation, and also super harmonics to capture nonlinearities.
For each mode, \(x_{pos}\) has \(2n + 1\) elements (\(x_{pos,k} \in \mathbb{R}^{2n + 1}\)). There are \(2n\) elements because each frequency is described by two components: one each corresponding to the cosine and sine amplitudes. The additional element in the first position is used to capture a mean (“DC”) displacement. Thus, the portion of \(x_{pos}\) describing the \(k\)-th mode would be.
The external state vector (\(x_{ext}\)) can have an analogous composition. The mean components in \(x_{ext}\) can be used to capture, for example, pretension in a tether.
The corresponding time vector for the chosen frequency array
is given by
where \(\Delta t = t_f/(2n)\) and the repeat period is \(t_f=2n\Delta t\). Since the pseudo-spectral method results in continuous in time solutions, the resulting dynamic time-series can be evaluated with additional substeps in the time vector.
The code deals with the same dynamic system in different representations and there is a need to convert between them. In general, a state \(x\) is represented as the mean (DC) component followed by the real and imaginary components of the Fourier coefficients as
In the time-domain, \(x(t)\), this is given as \(Mx\), where \(M\) is the time matrix.
Similarly, the state of its derivative is given as \(Dx\), where \(D\) is the derivative matrix.
Alternatively, we sometimes need to represent the state as a complex vector \(x=[X_0, X_1, \dots, X_n]^T\).
Finally, sometimes we need to relate the state \(x\) to another state \(y\) (e.g. a force component) via an impedance matrix \(Z\) as \(y = Zx\).
The matrices \(M\), \(D\), and different matrices \(Z\), and relevant functions are constructed internally in wecopttool
.