wecopttool.core

Core functionality for solving the pseudo-spectral problem for WEC.

Contains:

  • The WEC class

  • Functions for basic functionality

Note

All contents of this module are imported into WecOpTool and can be called directly as wecopttool.<function> instead of wecopttool.core.<function>.

Classes

WEC

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

Functions

ncomponents

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

frequency

Construct equally spaced frequency array.

time

Assemble the time vector with nsubsteps subdivisions.

time_mat

Assemble the time matrix that converts the state to a time-series.

derivative_mat

Assemble the derivative matrix that converts the state vector of a response to the state vector of its derivative.

derivative2_mat

Assemble the second derivative matrix that converts the state vector of a response to the state vector of its second derivative.

mimo_transfer_mat

Create a block matrix of the MIMO transfer function.

vec_to_dofmat

Convert a vector back to a matrix with one column per DOF.

dofmat_to_vec

Flatten a matrix that has one column per DOF.

real_to_complex

Convert from two real amplitudes to one complex amplitude per frequency.

complex_to_real

Convert from one complex amplitude to two real amplitudes per frequency.

fd_to_td

Convert a complex array of Fourier coefficients to a real array of time-domain responses.

td_to_fd

Convert a real array of time-domain responses to a complex array of Fourier coefficients.

read_netcdf

Read a NetCDF file with possibly complex entries as a xarray.Dataset.

write_netcdf

Save an xarray.Dataset with possibly complex entries as a NetCDF file.

check_radiation_damping

Ensure that the linear hydrodynamics (friction + radiation damping) have positive damping.

check_impedance

Ensure that the real part of the impedance (resistive) is positive.

force_from_rao_transfer_function

Create a force function from its position transfer matrix.

force_from_impedance

Create a force function from its impedance.

force_from_waves

Create a force function from waves excitation coefficients.

inertia

Create the inertia "force" from the inertia matrix.

standard_forces

Create functions for linear hydrodynamic forces.

run_bem

Run Capytaine for a range of frequencies and wave directions.

change_bem_convention

Change the convention from \(-iωt\) to \(+iωt\).

add_linear_friction

Add linear friction to BEM data.

wave_excitation

Calculate the complex, frequency-domain, excitation force due to waves.

hydrodynamic_impedance

Calculate hydrodynamic intrinsic impedance.

atleast_2d

Ensure an array is at least 2D, otherwise add trailing dimensions to make it 2D.

degrees_to_radians

Convert a 1D array of angles in degrees to radians in the range \([-π, π)\) and optionally sort them.

subset_close

Check if the first set set_a is contained, to some tolerance, in the second set set_b.

scale_dofs

Create a scaling vector based on a different scale for each DOF.

decompose_state

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

frequency_parameters

Return the fundamental frequency and the number of frequencies in a frequency array.

time_results

Create a xarray.DataArray of time-domain results from xarray.DataArray of frequency-domain results.

set_fb_centers

Sets default properties if not provided by the user: - center_of_mass is set to the geometric centroid - rotation_center is set to the center of mass