![]() |
OpenFAST
Wind turbine multiphysics simulator
|
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) |
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.
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.
[in] | time | Current simulation time in seconds |
[in] | u | Inputs at Time |
[in] | p | Parameters |
[in] | x | Continuous states at Time |
[in] | xd | Discrete states at Time |
[in] | z | Constraint states at Time (possibly a guess) |
[in] | otherstate | Other states at Time |
[in,out] | m | Misc/optimization variables |
[out] | z_residual | Residual of the constraint state equations using the input values described above |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error message if ErrStat /= ErrID_None |
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.
[in] | time | Current simulation time in seconds |
[in] | u | Inputs at Time |
[in] | p | Parameters |
[in] | x | Continuous states at Time |
[in] | xd | Discrete states at Time |
[in] | z | Constraint states at Time |
[in] | otherstate | Other states at Time |
[in,out] | m | Misc/optimization variables |
[out] | dxdt | Continuous state derivatives at Time |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error message if ErrStat /= ErrID_None |
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.
[in] | time | Current simulation time in seconds |
[in] | u | Inputs at Time |
[in] | p | Parameters |
[in] | x | Continuous states at Time |
[in] | xd | Discrete states at Time |
[in] | z | Constraint states at Time |
[in] | otherstate | Other states at Time |
[in,out] | y | Outputs computed at Time (Input only so that mesh connectivity information does not have to be recalculated) |
[in,out] | m | Misc/optimization variables |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error message if ErrStat /= ErrID_None |
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.
[in,out] | u | System inputs |
[in,out] | p | Parameters |
[in,out] | x | Continuous states |
[in,out] | xd | Discrete states |
[in,out] | z | Constraint states |
[in,out] | otherstate | Other states |
[in,out] | y | System outputs |
[in,out] | m | Misc/optimization variables |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error 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:
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.
[in] | initinp | Input data for initialization routine |
[out] | u | An initial guess for the input; input mesh must be defined |
[out] | p | Parameters |
[out] | x | Initial continuous states |
[out] | xd | Initial discrete states |
[out] | z | Initial guess of the constraint states |
[out] | otherstate | Initial other states |
[out] | y | Initial system outputs (outputs are not calculated; only the output mesh is initialized) |
[out] | misc | Misc/optimization variables |
[in,out] | interval | Coupling interval in seconds: don't change it from the glue code provided value. |
[out] | initout | Output for initialization routine |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error 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.
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.
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 dot product of the wavenumbers with the (x,y) location This is given by:
Calculate \( U^- \) terms for the velocity calculations ( \(B^-\) provided by waves2::transfuncb_minus)
Acceleration calculations
Dynamic pressure
Velocity terms:
Acceleration terms:
Pressure term:
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.
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.
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.
Calculate the dot product of the wavenumbers with the (x,y) location This is given by:
Calculate \( U^+ \) terms for the velocity calculations ( \(B^+\) provided by waves2::transfuncb_plus)
Acceleration calculations
Dynamic pressure
Velocity terms:
Acceleration terms:
Pressure 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.
Calculate the dot product of the wavenumbers with the (x,y) location This is given by:
Calculate \( U^+ \) terms for the velocity calculations ( \(B^+\) provided by waves2::transfuncb_plus)
Acceleration calculations
Dynamic pressure
Velocity terms:
Acceleration terms:
Pressure term:
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.
[in] | time | Current simulation time in seconds |
[in] | n | Current step of the simulation: t = n*Interval |
[in] | u | Inputs at Time |
[in] | p | Parameters |
[in] | x | Continuous states at Time |
[in,out] | xd | Input: Discrete states at Time; Output: Discrete states at Time + Interval |
[in] | z | Constraint states at Time |
[in] | otherstate | Other states at Time |
[in,out] | m | Misc/optimization variables |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error message if ErrStat /= ErrID_None |
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.
[in] | t | Current simulation time in seconds |
[in] | n | Current step of the simulation: t = n*Interval |
[in] | inputs | Inputs at InputTimes |
[in] | inputtimes | Times in seconds associated with Inputs |
[in] | p | Parameters |
[in,out] | x | Input: Continuous states at t; Output: Continuous states at t + Interval |
[in,out] | xd | Input: Discrete states at t; Output: Discrete states at t + Interval |
[in,out] | z | Input: Constraint states at t; Output: Constraint states at t + Interval |
[in,out] | otherstate | Input: Other states at t; Output: Other states at t + Interval |
[in,out] | m | Misc/optimization variables |
[out] | errstat | Error status of the operation |
[out] | errmsg | Error message if ErrStat /= ErrID_None |
|
private |
This holds the name of the program, version info, and date.