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.

(1)minxJ(x)s.t.r(x)=0cineq(x)0ceq(x)=0

For the linear case, which is the default formulation in WecOptTool, the WEC dynamics can be expressed, in residual form, as

(2)r=(M+ma)x¨kx(t)Bx˙(t)Ctx˙(t)+fext+fexc=0.

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.

(3)x=[xpos,xext]T

Here, xposRm(2n+1), where m is the number of body modes of motion and n is the number of frequency components. Similarly, xextRp(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 ωRn should span the relevant frequencies of the device operation, and also super harmonics to capture nonlinearities.

(4)xpos=[xpos,1,xpos,2,,xpos,m]T

For each mode, xpos has 2n+1 elements (xpos,kR2n+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 xpos describing the k-th mode would be.

(5)xpos,k=[x¯pos,k,ak,1,bk,1,,ak,n,bk,n]T

The external state vector (xext) can have an analogous composition. The mean components in xext can be used to capture, for example, pretension in a tether.

The corresponding time vector for the chosen frequency array

f=[0,f1,2f2,,nf1]T

is given by

t=[0,Δt,2Δt,,(2n1)Δt]T,

where Δt=tf/(2n) and the repeat period is tf=2nΔ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

x=[X0,(X1),(X1),,(Xn),(Xn)]T

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=[X0,X1,,Xn]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.