wecopttool.core.WEC

class WEC[source]

A wave energy converter (WEC) object for performing simulations using the pseudo-spectral solution method.

To create the WEC use one of the initialization methods:

Note

Direct initialization of a wecopttool.WEC object as WEC(f1, nfreq, forces, ...) using wecopttool.WEC.__init__() is discouraged. Instead use one of the other initialization methods listed in the See Also section.

To solve the pseudo-spectral problem use wecopttool.WEC.solve().

__init__(f1, nfreq, forces, constraints=None, inertia_matrix=None, ndof=None, inertia_in_forces=False, dof_names=None)[source]

Create a WEC object directly from its inertia matrix and list of forces.

The wecopttool.WEC class describes a WEC’s equation of motion as \(ma=Σf\) where the inertia_matrix matrix specifies the inertia \(m\), and the forces dictionary specifies the different forces to be summed. The forces can be linear or nonlinear. If inertia_in_forces is True the equation of motion is \(Σf=0\), which is included to allow for initialization using an intrinsic impedance through the WEC.from_impedance initialization function.

Note

Direct initialization of a wecopttool.WEC object as WEC(f1, nfreq, forces, ...) is discouraged. Instead use one of the other initialization methods listed in the See Also section.

Parameters:
  • f1 (float) – Fundamental frequency f1 [\(Hz\)].

  • nfreq (int) – Number of frequencies (not including zero frequency), i.e., freqs = [0, f1, 2*f1, ..., nfreq*f1].

  • forces (Mapping[str, StateFunction]) – Dictionary with entries {'force_name': fun}, where fun has a signature def fun(wec, x_wec, x_opt, waves):, and returns forces in the time-domain of size (2*nfreq+1, ndof).

  • constraints (Iterable[Mapping] | None) – List of constraints, see documentation for scipy.optimize.minimize() for description and options of constraints dictionaries. If None: empty list [].

  • inertia_matrix (ndarray | None) – Inertia matrix of size (ndof, ndof). Not used if inertia_in_forces is True.

  • ndof (int | None) – Number of degrees of freedom. Must be specified if inertia_in_forces is True, else not used.

  • inertia_in_forces (bool | None) – Set to True if inertial “forces” are included in the forces argument. This scenario is rare. If using an intrinsic impedance, consider initializing with wecoptool.core.WEC.from_impedance() instead.

  • dof_names (Iterable[str] | None) – Names of the different degrees of freedom (e.g. 'Heave'). If None the names ['DOF_0', ..., 'DOF_N'] are used.

Raises:
  • ValueError – If inertia_in_forces is True but ndof is not specified.

  • ValueError – If inertia_in_forces is False but inertia_matrix is not specified.

  • ValueError – If inertia_matrix does not have the correct size ((ndof, ndof)).

  • ValueError – If dof_names does not have the correct size (ndof).

Return type:

None

See also

from_bem

Initialize a wecopttool.WEC object from BEM results.

from_floating_body

Initialize a wecopttool.WEC object from a capytaine.bodies.bodies.FloatingBody object.

from_impedance

Initialize a wecopttool.WEC object from an intrinsic impedance array and excitation coefficients.

Attributes

WEC.constraints

List of constraints.

WEC.derivative2_mat

Matrix to create Fourier coefficients of the second derivative of some quantity.

WEC.derivative_mat

Matrix to create Fourier coefficients of the derivative of some quantity.

WEC.dof_names

Names of the different degrees of freedom.

WEC.dt

Time spacing [s].

WEC.f1

Fundamental frequency f1 [\(Hz\)].

WEC.forces

Dictionary of forces.

WEC.frequency

Frequency vector [\(Hz\)].

WEC.inertia

Function representing the inertial term \(ma\) in the WEC's dynamics equation.

WEC.inertia_in_forces

Whether inertial "forces" are included in the forces dictionary.

WEC.inertia_matrix

Inertia (mass) matrix.

WEC.ncomponents

Number of Fourier components (2*nfreq) for each degree of freedom.

WEC.ndof

Number of degrees of freedom.

WEC.nfreq

Number of frequencies, not including the zero-frequency.

WEC.nstate_wec

Length of the WEC dynamics state vector consisting of the Fourier coefficient of the position of each degree of freedom.

WEC.nt

Number of timesteps.

WEC.omega

Radial frequency vector [rad/s].

WEC.period

Period vector [s].

WEC.tf

Final time (repeat period) [s].

WEC.time

Time vector [s], size '(2*nfreq, ndof)', not containing the end time 'tf'.

WEC.time_mat

Matrix to create time-series from Fourier coefficients.

WEC.w1

Fundamental radial frequency [rad/s].

Methods

decompose_state

Split the state vector into the WEC dynamics state and the optimization (control) state.

dofmat_to_vec

Flatten a matrix to a vector.

fd_to_td

Convert a frequency-domain array to time-domain.

from_bem

Create a WEC object from linear hydrodynamic coefficients obtained using the boundary element method (BEM) code Capytaine.

from_floating_body

Create a WEC object from a Capytaine FloatingBody (:py:class:capytaine.bodies.bodies.FloatingBody).

from_impedance

Create a WEC object from the intrinsic impedance and excitation coefficients.

post_process

Post-process the results from wecopttool.WEC.solve().

residual

Return the residual of the dynamic equation (r = m⋅a-Σf).

solve

Simulate WEC dynamics using a pseudo-spectral solution method and returns the raw results dictionary produced by scipy.optimize.minimize().

td_to_fd

Convert a time-domain array to frequency-domain.

time_mat_nsubsteps

Create a time matrix similar to wecopttool.WEC.time_mat() but with finer time-domain discretization.

time_nsubsteps

Create a time vector with finer discretization.

vec_to_dofmat

Convert a vector to a matrix with one column per degree of freedom.