OpenFAST
Wind turbine multiphysics simulator
Data Types | Functions/Subroutines | Variables
wamit2 Module Reference

WAMIT2 module. More...

Data Types

type  w2_diffdata_type
 This type is used to hold the data for difference frequency methods. More...
 
type  w2_initdata3d_type
 This type is only used locally for holding data during the Initialization. More...
 
type  w2_initdata4d_type
 This type is only used locally for holding data during the Initialization. More...
 
type  w2_sumdata_type
 This type is used to hold the data for sum frequency method. More...
 

Functions/Subroutines

subroutine, public wamit2_init (InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut, ErrStat, ErrMsg)
 This routine is called at the start of the simulation to perform initialization steps. More...
 
subroutine, public wamit2_end (u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg)
 This routine is called at the end of the simulation. More...
 
subroutine, public wamit2_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 wamit2_calcoutput (Time, WaveTime, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg)
 Routine for computing outputs, used in both loose and tight coupling. More...
 
subroutine, public wamit2_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 wamit2_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 wamit2_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...
 
subroutine copy_initdata4dto3d (Data4D, Data3D, ErrStat, ErrMsg)
 This subroutine copies data stored from a W2_InitData4D_Type to a W2_InitData3D_Type. More...
 
subroutine destroy_initdata3d (Data3D)
 This subroutine destroys data stored in a W2_InitData3D_Type.
 
subroutine destroy_initdata4d (Data4D)
 This subroutine destroys data stored in a W2_InitData4D_Type.
 

Variables

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

Detailed Description

WAMIT2 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

◆ copy_initdata4dto3d()

subroutine wamit2::copy_initdata4dto3d ( type(w2_initdata4d_type), intent(in)  Data4D,
type(w2_initdata3d_type), intent(inout)  Data3D,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)
private

This subroutine copies data stored from a W2_InitData4D_Type to a W2_InitData3D_Type.

Parameters
[in]data4d4D data source
[in,out]data3d3D data where it will be copied to
[out]errstatError status
[out]errmsgError message

This routine should not have been called unless the data could be copied over, which means that the 4D data is either not sparse in the dimensions of interest, or the diagonal is complete. We won't simply trust that this is true though, so we will run the array and find out if the data we now have is sparse for the load components we have or not.

Find out if the data is sparse or full. Verification that the requested component directions were found will occur in the calling routine, not here (that information was not passed in). We will check this by sweeping through all three dimensions for only the values of k that have data in them.

◆ wamit2_calcconstrstateresidual()

subroutine, public wamit2::wamit2_calcconstrstateresidual ( real(dbki), intent(in)  Time,
type(wamit2_inputtype), intent(in)  u,
type(wamit2_parametertype), intent(in)  p,
type(wamit2_continuousstatetype), intent(in)  x,
type(wamit2_discretestatetype), intent(in)  xd,
type(wamit2_constraintstatetype), intent(in)  z,
type(wamit2_otherstatetype), intent(in)  OtherState,
type(wamit2_miscvartype), intent(inout)  m,
type(wamit2_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

◆ wamit2_calccontstatederiv()

subroutine, public wamit2::wamit2_calccontstatederiv ( real(dbki), intent(in)  Time,
type(wamit2_inputtype), intent(in)  u,
type(wamit2_parametertype), intent(in)  p,
type(wamit2_continuousstatetype), intent(in)  x,
type(wamit2_discretestatetype), intent(in)  xd,
type(wamit2_constraintstatetype), intent(in)  z,
type(wamit2_otherstatetype), intent(in)  OtherState,
type(wamit2_miscvartype), intent(inout)  m,
type(wamit2_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 WAMIT2 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

◆ wamit2_calcoutput()

subroutine, public wamit2::wamit2_calcoutput ( real(dbki), intent(in)  Time,
real(siki), dimension(:), intent(in)  WaveTime,
type(wamit2_inputtype), intent(in)  u,
type(wamit2_parametertype), intent(in)  p,
type(wamit2_continuousstatetype), intent(in)  x,
type(wamit2_discretestatetype), intent(in)  xd,
type(wamit2_constraintstatetype), intent(in)  z,
type(wamit2_otherstatetype), intent(in)  OtherState,
type(wamit2_outputtype), intent(inout)  y,
type(wamit2_miscvartype), intent(inout)  m,
integer(intki), intent(out)  ErrStat,
character(*), intent(out)  ErrMsg 
)

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

Parameters
[in]timeCurrent simulation time in seconds
[in]wavetimeArray of wave kinematic time samples, (sec)
[in]uInputs at Time
[in]pParameters
[in]xContinuous states at Time
[in]xdDiscrete states at Time
[in]zConstraint states at Time
[in]otherstateOther states
[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

◆ wamit2_end()

subroutine, public wamit2::wamit2_end ( type(wamit2_inputtype), intent(inout)  u,
type(wamit2_parametertype), intent(inout)  p,
type(wamit2_continuousstatetype), intent(inout)  x,
type(wamit2_discretestatetype), intent(inout)  xd,
type(wamit2_constraintstatetype), intent(inout)  z,
type(wamit2_otherstatetype), intent(inout)  OtherState,
type(wamit2_outputtype), intent(inout)  y,
type(wamit2_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 WAMIT2_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 WAMIT2, most calculations are performed during the initialization, so there are no final calculations that need to be performed.

Close files here. The only files that are opened for WAMIT2 take place during the initialization routine. They should have been closed then.

Todo:
Check to make sure nothing is left open by this module.

Destroy the input data:

Destroy the parameter data:

Destroy the state data:

Destroy the output data:

◆ wamit2_init()

subroutine, public wamit2::wamit2_init ( type(wamit2_initinputtype), intent(in)  InitInp,
type(wamit2_inputtype), intent(out)  u,
type(wamit2_parametertype), intent(out)  p,
type(wamit2_continuousstatetype), intent(out)  x,
type(wamit2_discretestatetype), intent(out)  xd,
type(wamit2_constraintstatetype), intent(out)  z,
type(wamit2_otherstatetype), intent(out)  OtherState,
type(wamit2_outputtype), intent(out)  y,
type(wamit2_miscvartype), intent(out)  m,
real(dbki), intent(inout)  Interval,
type(wamit2_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]mInitial misc/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

Initialize Error handling variables

Initialize the data storage

Initialize the NWTC Subroutine Library and display the information about this module.

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.

  1. Check the data file related values (MnDrift, MnDriftF etc). Also copy over important things from InitInp to p and InitOut.
  2. Now read in the data files and store the data and information about it using Read_DataFile3D or Read_DataFile4D. Flags should have been set in the CheckInitInput subroutine to indicate what type of data is going to be read in. The consistency of the WAMIT 2nd order data files is checked during the reading in subroutines.

If the MnDrift method will be used, read in the data for it.

If the NewmanApp method will be used, read in the data for it.

If the DiffQTF method will be used, read in the data for it. This can only be 4D data even though DiffQTF can hold 3D data. This was an intentional choice so that DiffQTFData could be passed to the MnDrift method (the first term of the DiffQTF method equations is the MnDrift term).

If the SumQTF method will be used, read in the data for it. This can only be 4D data (SumQTFData only holds 4D).

  1. Now check the data to ensure that all the dimensions that were requested acually exist in the file. At this point, the MnDriftData and NewmanApp data will be either 3D or 4D, but not both.

Check the MnDrift data: check both in case we have already copied 4D data into the 3D. Will decide later which is used.

Check the NewmanApp data: check both in case we have already copied 4D data into the 3D. Will decide later which is used.

Check the DiffQTF data: Don't check the 3D data. We may have copied 4D into it for the MnDrift term.

Check the SumQTF data

  1. At this point, all the data from the WAMIT second order output files should be loaded. We can now proceed to perform the calculations for each of the methods. For the call to the method, we pass the dataset corresponding to each method. The calculation methods for MnDrift and NewmanApp can handle both 3D and 4D data, so the entire MnDriftData and NewmanAppData sets are handed to the calculation subroutines.
Note
The frequency range and wave direction range present in the QTF information that was read in has not been checked. The frequency range needed by the Newman approximation is different than that of the other methods. Therefore the decision has been made to check and apply the frequency check and wave directionality checks at the start of the calculation subroutine for each method.

For the DiffQTF and SumQTF methods, only 4D data can be used in the calculations. Again, the entire dataset for each is passed into the respective calculation subroutine. In the case of the DiffQTFData, only the 4D data portion should be populated above. If 3D data is present in it, the subroutine will exit with a warning about a programming error. For the SumQTF method, the data can only be 4D.

Note
The wamit2:mndrift_initcalc routine will be called from wamit2::diffqtf_initcalc. The first term of the DiffQTF method is the MnDrift method.

For the MnDrift and NewmanApp methods, it is possible to convert 4D data where the diagonal is complete but off diagonal values are not. The data in this case will have to be ported over to a 3D storage. This will be handled in the MnDrift_InitCalc and NewmanApp_InitCalc functions.

Note
The MnDrift and NewmanApp can use the 4D data if the diagonal is not complete, but the full QTF is. This would only occur when the stepsize in \( \omega_1 \) and \( \omega_2 \) are not the same resulting in no cases where \( \omega_1 == \omega_2 \).

If the MnDrift method will be used, call the subroutine to calculate the force time series

If the NewmanApp method will be used, call the subroutine to calculate the force time series

If the DiffQTF method will be used, call the subroutine to calculate the force time series Note that the MnDrift calculation is included.

If the SumQTF method will be used, call the subroutine to calculate the force time series

Copy output forces over to parameters as needed.

  1. Create the mesh used for exporting the 2nd order forces from the WAMIT2_CalcOuput routine at each timestep. Also set the outputs for each timestep.
  2. Set zero values for unused outputs. This is mostly so that the compiler does not complain.

◆ wamit2_updatediscstate()

subroutine, public wamit2::wamit2_updatediscstate ( real(dbki), intent(in)  Time,
integer(intki), intent(in)  n,
type(wamit2_inputtype), intent(in)  u,
type(wamit2_parametertype), intent(in)  p,
type(wamit2_continuousstatetype), intent(in)  x,
type(wamit2_discretestatetype), intent(inout)  xd,
type(wamit2_constraintstatetype), intent(in)  z,
type(wamit2_otherstatetype), intent(in)  OtherState,
type(wamit2_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

◆ wamit2_updatestates()

subroutine, public wamit2::wamit2_updatestates ( real(dbki), intent(in)  t,
integer(intki), intent(in)  n,
type(wamit2_inputtype), dimension(:), intent(in)  Inputs,
real(dbki), dimension(:), intent(in)  InputTimes,
type(wamit2_parametertype), intent(in)  p,
type(wamit2_continuousstatetype), intent(inout)  x,
type(wamit2_discretestatetype), intent(inout)  xd,
type(wamit2_constraintstatetype), intent(inout)  z,
type(wamit2_otherstatetype), intent(inout)  OtherState,
type(wamit2_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, and discrete 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

◆ wamit2_progdesc

type(progdesc), parameter wamit2::wamit2_progdesc = ProgDesc( 'WAMIT2', '', '' )
private

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