OpenFAST
Wind turbine multiphysics simulator
Functions/Subroutines | Variables
waves2 Module Reference

Waves2 module. More...

Functions/Subroutines

subroutine, public waves2_init (InitInp, u, p, x, xd, z, OtherState, y, misc, Interval, InitOut, ErrStat, ErrMsg)
 This routine is called at the start of the simulation to perform initialization steps. More...
 
subroutine, public waves2_end (u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg)
 This routine is called at the end of the simulation. More...
 
subroutine, public waves2_updatestates (t, n, Inputs, InputTimes, p, x, xd, z, OtherState, m, ErrStat, ErrMsg)
 Loose coupling routine for solving constraint states, integrating continuous states, and updating discrete states. More...
 
subroutine, public waves2_calcoutput (Time, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg)
 Routine for computing outputs, used in both loose and tight coupling. More...
 
subroutine, public waves2_calccontstatederiv (Time, u, p, x, xd, z, OtherState, m, dxdt, ErrStat, ErrMsg)
 This routine is required for the FAST framework, but is not actually needed for this module. More...
 
subroutine, public waves2_updatediscstate (Time, n, u, p, x, xd, z, OtherState, m, ErrStat, ErrMsg)
 This routine is required for the FAST framework, but is not actually needed for this module. More...
 
subroutine, public waves2_calcconstrstateresidual (Time, u, p, x, xd, z, OtherState, m, z_residual, ErrStat, ErrMsg)
 This routine is required for the FAST framework, but is not actually needed for this module. More...
 

Variables

type(progdesc), parameter waves2_progdesc = ProgDesc( 'Waves2', '', '' )
 This holds the name of the program, version info, and date. More...
 
real(dbki), parameter, private onepluseps = 1.0 + EPSILON(OnePlusEps)
 

Detailed Description

Waves2 module.

This module calculates the second order wave forces on a structure. This module is used with HydroDyn in FAST.

This software is written in the FAST modular framework.

Function/Subroutine Documentation

◆ waves2_calcconstrstateresidual()

subroutine, public waves2::waves2_calcconstrstateresidual ( real(dbki), intent(in)  Time,
type(waves2_inputtype), intent(in)  u,
type(waves2_parametertype), intent(in)  p,
type(waves2_continuousstatetype), intent(in)  x,
type(waves2_discretestatetype), intent(in)  xd,
type(waves2_constraintstatetype), intent(in)  z,
type(waves2_otherstatetype), intent(in)  OtherState,
type(waves2_miscvartype), intent(inout)  m,
type(waves2_constraintstatetype), intent(out)  z_residual,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

This routine is required for the FAST framework, but is not actually needed for this module.

In the framework, this is a tight coupling routine for solving for the residual of the constraint state equations So, this routine will simply issue a warning and return.

Note
A few values will be set so that compilers are happy, but nothing of value is done.
Parameters
[in]timeCurrent simulation time in seconds
[in]uInputs at Time
[in]pParameters
[in]xContinuous states at Time
[in]xdDiscrete states at Time
[in]zConstraint states at Time (possibly a guess)
[in]otherstateOther states at Time
[in,out]mMisc/optimization variables
[out]z_residualResidual of the constraint state equations using the input values described above
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

◆ waves2_calccontstatederiv()

subroutine, public waves2::waves2_calccontstatederiv ( real(dbki), intent(in)  Time,
type(waves2_inputtype), intent(in)  u,
type(waves2_parametertype), intent(in)  p,
type(waves2_continuousstatetype), intent(in)  x,
type(waves2_discretestatetype), intent(in)  xd,
type(waves2_constraintstatetype), intent(in)  z,
type(waves2_otherstatetype), intent(in)  OtherState,
type(waves2_miscvartype), intent(inout)  m,
type(waves2_continuousstatetype), intent(out)  dxdt,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

This routine is required for the FAST framework, but is not actually needed for this module.

In the framework, this routine calculates the derivative of the continuous states. As this routine is not necessary in the Waves2 module, it simply issues a warning and returns.

Note
A few values will be set so that compilers are happy, but nothing of value is done.
Parameters
[in]timeCurrent simulation time in seconds
[in]uInputs at Time
[in]pParameters
[in]xContinuous states at Time
[in]xdDiscrete states at Time
[in]zConstraint states at Time
[in]otherstateOther states at Time
[in,out]mMisc/optimization variables
[out]dxdtContinuous state derivatives at Time
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

◆ waves2_calcoutput()

subroutine, public waves2::waves2_calcoutput ( real(dbki), intent(in)  Time,
type(waves2_inputtype), intent(in)  u,
type(waves2_parametertype), intent(in)  p,
type(waves2_continuousstatetype), intent(in)  x,
type(waves2_discretestatetype), intent(in)  xd,
type(waves2_constraintstatetype), intent(in)  z,
type(waves2_otherstatetype), intent(in)  OtherState,
type(waves2_outputtype), intent(inout)  y,
type(waves2_miscvartype), intent(inout)  m,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

Routine for computing outputs, used in both loose and tight coupling.

The Waves2 module second order wave kinematic corrections are processed at initialization and passed to other modules (such as Morrison) for processing. As a result, there is nothing that needs to be calculated by the CalcOutput routine other than the WriteOutput values at each timestep.

Parameters
[in]timeCurrent simulation time in seconds
[in]uInputs at Time
[in]pParameters
[in]xContinuous states at Time
[in]xdDiscrete states at Time
[in]zConstraint states at Time
[in]otherstateOther states at Time
[in,out]yOutputs computed at Time (Input only so that mesh connectivity information does not have to be recalculated)
[in,out]mMisc/optimization variables
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

◆ waves2_end()

subroutine, public waves2::waves2_end ( type(waves2_inputtype), intent(inout)  u,
type(waves2_parametertype), intent(inout)  p,
type(waves2_continuousstatetype), intent(inout)  x,
type(waves2_discretestatetype), intent(inout)  xd,
type(waves2_constraintstatetype), intent(inout)  z,
type(waves2_otherstatetype), intent(inout)  OtherState,
type(waves2_outputtype), intent(inout)  y,
type(waves2_miscvartype), intent(inout)  m,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

This routine is called at the end of the simulation.

The purpose of this routine is to destroy any data that is leftover. If we don't do this, we may leave memory tied up after the simulation ends. To destroy the data, we call several routines that are generated by the FAST registry, so any issues with the destroy routines should be addressed by the registry.exe which generates the Waves2_Types.f90 file.

Parameters
[in,out]uSystem inputs
[in,out]pParameters
[in,out]xContinuous states
[in,out]xdDiscrete states
[in,out]zConstraint states
[in,out]otherstateOther states
[in,out]ySystem outputs
[in,out]mMisc/optimization variables
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

Place any last minute operations or calculations here. For Waves2, most calculations all performed during the initialization, so there are no final calculations that need to be performed.

Destroy the input data:

Destroy the parameter data:

Destroy the state data:

Destroy the output data:

◆ waves2_init()

subroutine, public waves2::waves2_init ( type(waves2_initinputtype), intent(in)  InitInp,
type(waves2_inputtype), intent(out)  u,
type(waves2_parametertype), intent(out)  p,
type(waves2_continuousstatetype), intent(out)  x,
type(waves2_discretestatetype), intent(out)  xd,
type(waves2_constraintstatetype), intent(out)  z,
type(waves2_otherstatetype), intent(out)  OtherState,
type(waves2_outputtype), intent(out)  y,
type(waves2_miscvartype), intent(out)  misc,
real(dbki), intent(inout)  Interval,
type(waves2_initoutputtype), intent(out)  InitOut,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

This routine is called at the start of the simulation to perform initialization steps.

The parameters that are set here are not changed during the simulation. The initial states and initial guess for the input are defined.

Parameters
[in]initinpInput data for initialization routine
[out]uAn initial guess for the input; input mesh must be defined
[out]pParameters
[out]xInitial continuous states
[out]xdInitial discrete states
[out]zInitial guess of the constraint states
[out]otherstateInitial other states
[out]yInitial system outputs (outputs are not calculated; only the output mesh is initialized)
[out]miscMisc/optimization variables
[in,out]intervalCoupling interval in seconds: don't change it from the glue code provided value.
[out]initoutOutput for initialization routine
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

Before attempting to do any real calculations, we first check what was passed in through InitInp to make sure it makes sense. That routine will then copy over the relevant information that should be kept in parameters (p).

InitInp will also check the flags, existence of files, and set flags accordingly.

Note
Wave stretching will need to be incorporated here when we add it to the waves module.

Difference Frequency

The second order difference frequency corrections to the velocity, acceleration, and pressure can be written in generic form as:

\( V^{(2)-}(t) = 2 \Re \left[ \sum_{\mu^-=1}^{\frac{N}{2}-1} H^-(\omega_{\mu^-}) \exp(\imath \omega_{\mu^-} t) \right] = 2 \operatorname{IFFT}\left[H^-\right] \)

Notice that in the equations that follow, there is no term analagous to the mean drift term in the WAMIT2 module. Rather, for \( \omega_{\mu^-} = 0 \), the result is zero. So this term is not included.

Calculate the surface elevation corrections

For each (x,y) coordinate that a wave elevation is requested at (both from the (WaveElevxi,WaveElevyi) pairs, and the WaveElevXY pairs), a call is made to the subroutine waves2::waveelevtimeseriesatxy_diff to calculate the full time series for that point. The results are added to the wave elevation results from the sum frequency calculations later in the code.

Calculate the second order velocity, acceleration, and pressure corrections for all joints below surface.

  • \( \mu^- = n -m \)
  • \( \omega^- = \mu^- \Delta \omega \)

Calculate the dot product of the wavenumbers with the (x,y) location This is given by:

  • \( \exp\left(-\imath \left[\vec{k_n} - \vec{k_m} \right] \cdot \vec{x} \right) = \exp \left( -\imath \left[ \left( |\vec{k_n}| \cos \theta_n - |\vec{k_m}| cos \theta_m \right) ~ x + \left( |\vec{k_n}| \sin \theta_n - |\vec{k_m}| sin \theta_m \right) ~ y \right] \right) \)

Calculate \( U^- \) terms for the velocity calculations ( \(B^-\) provided by waves2::transfuncb_minus)

  • \( _x{U}_{nm}^- = B_{nm}^- \left(k_n \cos \theta_n - k_m \cos \theta_m \right) \)
  • \( _y{U}_{nm}^- = B_{nm}^- \left(k_n \sin \theta_n - k_m \sin \theta_m \right) \)
  • \( _z{U}_{nm}^- = \imath B_{nm}^- k_{nm} \tanh \left( k_{nm} ( h + z ) \right) \)

Acceleration calculations

  • \( _x\dot{U}_{nm}^- = \imath * _xU_{nm}^- * \omega_{\mu^-} \)
  • \( _y\dot{U}_{nm}^- = \imath * _yU_{nm}^- * \omega_{\mu^-} \)
  • \( _z\dot{U}_{nm}^- = \imath * _zU_{nm}^- * \omega_{\mu^-} \)

Dynamic pressure

  • \( P_{nm}^- = \rho_\mathrm{w} B_{nm}^- \omega_{\mu^-} \)

Calculate the inner summation \form#285 terms for the velocity, acceleration, and pressure.

Velocity terms:

  • \( H^-(\omega_{\mu^-}) = {\sum_{m=1}^{\frac{N}{2}-\mu^{-}}} A_n A^*_m U_{nm}^- \exp\left(-\imath (\vec{k_n} - \vec{k_m})\cdot\vec{x}\right) \)

Acceleration terms:

  • \( H^-(\omega_{\mu^-}) = {\sum_{m=1}^{\frac{N}{2}-\mu^{-}}} A_n A^*_m \dot{U}_{nm}^- \exp\left(-\imath (\vec{k_n} - \vec{k_m})\cdot\vec{x}\right) \)

Pressure term:

  • \( H^-(\omega_{\mu^-}) = {\sum_{m=1}^{\frac{N}{2}-\mu^{-}}} A_n A^*_m P_{nm}^- \exp\left(-\imath (\vec{k_n} - \vec{k_m})\cdot\vec{x}\right) \)

Apply the inverse FFT to each of the components to get the time domain result

  • \( V(t) = 2 \operatorname{IFFT}\left[H^-\right] \)

Sum Frequency

The sum frequency corrections to the velocity, acceleration, and pressure can be written in generic form as:

\begin{eqnarray*} V^{(2)+}(t) &=& \Re \left[ \sum_{n=1}^{\lfloor \frac{N}{4} \rfloor} K^+(\omega_n) \exp(\imath 2 \omega_n t) \right] + 2 \Re \left[ \sum_{\mu^+=2}^{\frac{N}{2}} H^+(\omega_{\mu^+}) \exp(\imath \omega_{\mu^+} t) \right]\\ &=& \operatorname{IFFT}\left[K(\omega_n)\right] + 2\operatorname{IFFT}\left[H(\omega_{\mu^+})\right] \end{eqnarray*}

Notice that the first term only contains the \( 2 \omega_n \) terms; the others are zero.

Calculate the surface elevation corrections

For each (x,y) coordinate that a wave elevation is requested at (both from the (WaveElevxi,WaveElevyi) pairs, and the WaveElevXY pairs), a call is made to the subroutine waves2::waveelevtimeseriesatxy_sum to calculate the full time series for that point. The results are added to the wave elevation results from the diff frequency calculations earlier in the code.

Calculate the second order velocity, acceleration, and pressure corrections for all joints below surface.

First term

This term is only the FFT over the diagonal elements where \( \omega_n = \omega_m \) (note that the sum frequency is \( 2 \omega_n \)). The index for the sum frequency is therefore \( 2 n \). Since we are placing the calculated value for the \( A_n A_n H^+ \) term in the \( 2 \omega \) location, we will only run through the first half of the frequencies (the sum frequency will exceed the bounds of the frequencies used in the FFT otherwise). The IFFT will be calculated later with the IFFT of the second term.

  • \( \omega^+ = \mu^+ \Delta \omega = 2 \omega_n \)

Calculate the dot product of the wavenumbers with the (x,y) location This is given by:

  • \( \exp\left(-\imath 2 \vec{k_n} \cdot \vec{x} \right) = \exp \left( -\imath 2 \left[ |\vec{k_n}| \cos \theta_n ~ x + |\vec{k_n}| \sin \theta_n ~ y \right] \right) \)

Calculate \( U^+ \) terms for the velocity calculations ( \(B^+\) provided by waves2::transfuncb_plus)

  • \( _x{U}_{nn}^+ = B_{nn}^+ 2 k_n \cos \theta_n \)
  • \( _y{U}_{nn}^+ = B_{nn}^+ 2 k_n \sin \theta_n \)
  • \( _z{U}_{nn}^+ = \imath B_{nn}^+ k_{nn} \tanh \left( k_{nn} ( h + z ) \right) \)

Acceleration calculations

  • \( _x\dot{U}_{nn}^+ = \imath * _xU_{nn}^+ * \omega_{\mu^+} \)
  • \( _y\dot{U}_{nn}^+ = \imath * _yU_{nn}^+ * \omega_{\mu^+} \)
  • \( _z\dot{U}_{nn}^+ = \imath * _zU_{nn}^+ * \omega_{\mu^+} \)

Dynamic pressure

  • \( P_{nn}^+ = \rho_\mathrm{w} B_{nn}^+ \omega_{\mu^+} \)

Calculate the array of \form#307 for the first term of the velocity, acceleration, and pressure.

Velocity terms:

  • \( K^+(\omega_n) = A_n A_n U_{nn}^+ \exp\left(-\imath 2 \vec{k_n} \cdot\vec{x}\right) \)

Acceleration terms:

  • \( K^+(\omega_n) = A_n A_n \dot{U}_{nn}^+ \exp\left(-\imath 2 \vec{k_n} \cdot\vec{x}\right) \)

Pressure term:

  • \( K^+(\omega_n) = A_n A_n P_{nn}^+ \exp\left(-\imath 2 \vec{k_n} \cdot\vec{x}\right) \)

Second term

In this term, we are are now stepping through the sum frequencies. The inner sum essentially covers all the off diagonal terms (omega_m /= omega_n). The limits on the outer integral that is the FFT run through the full frequency range that we are using.

  • \( \mu^+ = n + m \)
  • \( \omega^+ = \mu^+ \Delta \omega \)

Calculate the dot product of the wavenumbers with the (x,y) location This is given by:

  • \( \exp\left(-\imath \left[\vec{k_n} + \vec{k_m} \right] \cdot \vec{x} \right) = \exp \left( -\imath \left[ \left( |\vec{k_n}| \cos \theta_n + |\vec{k_m}| cos \theta_m \right) ~ x + \left( |\vec{k_n}| \sin \theta_n + |\vec{k_m}| sin \theta_m \right) ~ y \right] \right) \)

Calculate \( U^+ \) terms for the velocity calculations ( \(B^+\) provided by waves2::transfuncb_plus)

  • \( _x{U}_{nm}^+ = B_{nm}^+ \left(k_n \cos \theta_n + k_m \cos \theta_m \right) \)
  • \( _y{U}_{nm}^+ = B_{nm}^+ \left(k_n \sin \theta_n + k_m \sin \theta_m \right) \)
  • \( _z{U}_{nm}^+ = \imath B_{nm}^+ k_{nm} \tanh \left( k_{nm} ( h + z ) \right) \)

Acceleration calculations

  • \( _x\dot{U}_{nm}^+ = \imath * _xU_{nm}^+ * \omega_{\mu^+} \)
  • \( _y\dot{U}_{nm}^+ = \imath * _yU_{nm}^+ * \omega_{\mu^+} \)
  • \( _z\dot{U}_{nm}^+ = \imath * _zU_{nm}^+ * \omega_{\mu^+} \)

Dynamic pressure

  • \( P_{nm}^+ = \rho_\mathrm{w} B_{nm}^+ \omega_{\mu^+} \)

Calculate the inner summation \form#321 terms for the velocity, acceleration, and pressure.

Velocity terms:

  • \( H^+(\omega_{\mu^+}) = \sum_{m=1}^{\lfloor \frac{\mu^+-1}{2}\rfloor} A_n A_m U_{nm}^+ \exp\left(-\imath (\vec{k_n} + \vec{k_m})\cdot\vec{x}\right) \)

Acceleration terms:

  • \( H^+(\omega_{\mu^+}) = \sum_{m=1}^{\lfloor \frac{\mu^+-1}{2}\rfloor} A_n A_m \dot{U}_{nm}^+ \exp\left(-\imath (\vec{k_n} + \vec{k_m})\cdot\vec{x}\right) \)

Pressure term:

  • \( H^+(\omega_{\mu^+}) = \sum_{m=1}^{\lfloor \frac{\mu^+-1}{2}\rfloor} A_n A_m P_{nm}^+ \exp\left(-\imath (\vec{k_n} + \vec{k_m})\cdot\vec{x}\right) \)

Apply the inverse FFT to the first and second terms of each of the components to get the time domain result

  • \( V^{(2)+}(t) = \operatorname{IFFT}\left[K^+\right] + 2\operatorname{IFFT}\left[H^+\right] \)

◆ waves2_updatediscstate()

subroutine, public waves2::waves2_updatediscstate ( real(dbki), intent(in)  Time,
integer(intki), intent(in)  n,
type(waves2_inputtype), intent(in)  u,
type(waves2_parametertype), intent(in)  p,
type(waves2_continuousstatetype), intent(in)  x,
type(waves2_discretestatetype), intent(inout)  xd,
type(waves2_constraintstatetype), intent(in)  z,
type(waves2_otherstatetype), intent(in)  OtherState,
type(waves2_miscvartype), intent(inout)  m,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

This routine is required for the FAST framework, but is not actually needed for this module.

In the framework, this routine is used to update discrete states, by So, this routine will simply issue a warning and return.

Parameters
[in]timeCurrent simulation time in seconds
[in]nCurrent step of the simulation: t = n*Interval
[in]uInputs at Time
[in]pParameters
[in]xContinuous states at Time
[in,out]xdInput: Discrete states at Time; Output: Discrete states at Time + Interval
[in]zConstraint states at Time
[in]otherstateOther states at Time
[in,out]mMisc/optimization variables
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

◆ waves2_updatestates()

subroutine, public waves2::waves2_updatestates ( real(dbki), intent(in)  t,
integer(intki), intent(in)  n,
type(waves2_inputtype), dimension(:), intent(in)  Inputs,
real(dbki), dimension(:), intent(in)  InputTimes,
type(waves2_parametertype), intent(in)  p,
type(waves2_continuousstatetype), intent(inout)  x,
type(waves2_discretestatetype), intent(inout)  xd,
type(waves2_constraintstatetype), intent(inout)  z,
type(waves2_otherstatetype), intent(inout)  OtherState,
type(waves2_miscvartype), intent(inout)  m,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

Loose coupling routine for solving constraint states, integrating continuous states, and updating discrete states.

Continuous, constraint, discrete, and other states are updated to values at t + Interval.

Parameters
[in]tCurrent simulation time in seconds
[in]nCurrent step of the simulation: t = n*Interval
[in]inputsInputs at InputTimes
[in]inputtimesTimes in seconds associated with Inputs
[in]pParameters
[in,out]xInput: Continuous states at t; Output: Continuous states at t + Interval
[in,out]xdInput: Discrete states at t; Output: Discrete states at t + Interval
[in,out]zInput: Constraint states at t; Output: Constraint states at t + Interval
[in,out]otherstateInput: Other states at t; Output: Other states at t + Interval
[in,out]mMisc/optimization variables
[out]errstatError status of the operation
[out]errmsgError message if ErrStat /= ErrID_None

Variable Documentation

◆ waves2_progdesc

type(progdesc), parameter waves2::waves2_progdesc = ProgDesc( 'Waves2', '', '' )
private

This holds the name of the program, version info, and date.