###################################################################################################################################
# Registry for Simplified ElastoDyn in the FAST Modularization Framework
# This Registry file is used to create MODULE SED_Types  which contains all of the user-defined types needed in Simplified ElastoDyn.
# It also contains copy, destroy, pack, and unpack routines associated with each defined data types.
# See the NWTC Programmer's Handbook for further information on the format/contents of this file.
#
# Entries are of the form
# <keyword>   <ModuleName/ModName>   <TypeName>   <FieldType>   <FieldName>   <Dims>   <IO>   <DNAME>   <DESCRIP>   <UNITS>
#
# Use ^ as a shortcut for the value in the same column from the previous line.
###################################################################################################################################
# ...... Include files (definitions from NWTC Library) ............................................................................
include   Registry_NWTC_Library.txt

param   SED/SED   -   IntKi   SED_NMX   -   4   -   "Used in updating predictor-corrector values (size of state history)"   -

# ..... Initialization data .......................................................................................................
# SED input file
typedef  SED/SED  SED_InputFile     LOGICAL              Echo              -  - -   "Echo the input file"                    -
typedef  ^        SED_InputFile     DBKi                 DT                -  - -   "Time step for module time integration" s
typedef  ^        SED_InputFile     IntKi                IntMethod         -  - -   "Integration method {1: RK4, 2: AB4, or 3: ABM4}" -
typedef  ^        SED_InputFile     LOGICAL              GenDOF            -  - -   "whether the generator is fixed or free" -
typedef  ^        SED_InputFile     LOGICAL              YawDOF            -  - -   "Yaw controlled by controller, or fixed" -
typedef  ^        SED_InputFile     R8Ki                 Azimuth           -  - -   "Initial azimuth angle for blade 1" deg
typedef  ^        SED_InputFile     ReKi                 BlPitch           -  - -   "Initial blade pitch angles" radians
typedef  ^        SED_InputFile     ReKi                 RotSpeed          -  - -   "Initial or fixed rotor speed" RPM
typedef  ^        SED_InputFile     ReKi                 NacYaw            -  - -   "Initial or fixed nacelle yaw" deg
typedef  ^        SED_InputFile     ReKi                 PtfmPitch         -  - -   "Fixed pitch tilt rotational displacement of platform" deg
typedef  ^        SED_InputFile     IntKi                NumBl             -  - -   "Number of blades on the turbine" -
typedef  ^        SED_InputFile     ReKi                 TipRad            -  - -   "Preconed blade-tip radius (distance from the rotor apex to the blade tip)" m
typedef  ^        SED_InputFile     ReKi                 HubRad            -  - -   "Preconed hub radius (distance from the rotor apex to the blade root)" m
typedef  ^        SED_InputFile     ReKi                 PreCone           -  - -   "Rotor precone angles" deg
typedef  ^        SED_InputFile     ReKi                 OverHang          -  - -   "Distance from yaw axis to rotor apex or teeter pin" m
typedef  ^        SED_InputFile     ReKi                 ShftTilt          -  - -   "Rotor shaft tilt angle" deg
typedef  ^        SED_InputFile     ReKi                 Twr2Shft          -  - -   "Vertical distance from the tower-top to the rotor shaft" m
typedef  ^        SED_InputFile     ReKi                 TowerHt           -  - -   "Height of tower above ground level [onshore] or MSL [offshore]" m
typedef  ^        SED_InputFile     ReKi                 RotIner           -  - -   "Hub inertia about teeter axis (2-blader) or rotor axis (3-blader)" "kg m^2"
typedef  ^        SED_InputFile     ReKi                 GenIner           -  - -   "Generator inertia about HSS" "kg m^2"
typedef  ^        SED_InputFile     ReKi                 GBoxRatio         -  - -   "Gearbox ratio" -
typedef  ^        SED_InputFile     LOGICAL              SumPrint          -  - -   "Print summary data to <RootName>.sum" -
typedef  ^        SED_InputFile     IntKi                NumOuts           -  - -   "Number of outputs"   -
typedef  ^        SED_InputFile     CHARACTER(ChanLen)   OutList           :  - -   "List of user-requested output channels" -


# ..... Initialization data .......................................................................................................
# inputs for initialization:
typedef  SED/SED  InitInputType     CHARACTER(1024)      InputFile         -  - -   "Name of the input file"   -
typedef  ^        InitInputType     CHARACTER(1024)      RootName          -  - -   "RootName for writing output files" -
typedef  ^        InitInputType     LOGICAL              Linearize         - .false. - "this module cannot be linearized at present" -
typedef  ^        InitInputType     LOGICAL              UseInputFile      - .TRUE.  - "Supplied by Driver:  .TRUE. if using a input file, .FALSE. if all inputs are being passed in by the caller"    -
typedef  ^        InitInputType     FileInfoType         PassedFileData    -  - -   "If we don't use the input file, pass everything through this"   -


# outputs from initialization:
typedef  ^        InitOutputType    CHARACTER(ChanLen)   WriteOutputHdr   {:} - -   "Names of the output-to-file channels"   -
typedef  ^        InitOutputType    CHARACTER(ChanLen)   WriteOutputUnt   {:} - -   "Units of the output-to-file channels"   -
typedef  ^        InitOutputType    ProgDesc             Ver               -  - -   "This module's name, version, and date"   -
typedef  ^        InitOutputType    IntKi                NumBl             -  - -   "Number of blades on the turbine"   -
typedef  ^        InitOutputType    ReKi                 BlPitch          {:} - -   "Initial blade pitch angles"   radians
typedef  ^        InitOutputType    ReKi                 BladeLength       -  - -   "Blade length (for AeroDsk)"   meters
typedef  ^        InitOutputType    ReKi                 TowerHt           -  - -   "Tower Height"   meters
typedef  ^        InitOutputType    ReKi                 HubHt             -  - -   "Height of the hub"   meters
typedef  ^        InitOutputType    ReKi                 PlatformPos      {6} - -   "Initial platform position (6 DOFs)"
typedef  ^        InitOutputType    ReKi                 HubRad            -  - -   "Preconed hub radius (distance from the rotor apex to the blade root)"   m
typedef  ^        InitOutputType    ReKi                 RotSpeed          -  - -   "Initial or fixed rotor speed"   rad/s
typedef  ^        InitOutputType    LOGICAL              GenDOF            -  - -   "whether the generator DOF is on (true) or off (false)" -


# ..... Inputs ....................................................................................................................
# inputs on meshes:
typedef  ^        InputType         MeshType             HubPtLoad         -  - -   "AeroDyn/AeroDisk maps load to hub" -
# inputs not on meshes:
typedef  ^        InputType         ReKi                 HSSBrTrqC         -  - -   "Commanded HSS brake torque"     N-m
typedef  ^        InputType         ReKi                 GenTrq            -  - -   "Electrical generator torque"    N-m
typedef  ^        InputType         ReKi                 BlPitchCom       {:} - 2pi "Commanded blade pitch angles"   radians
typedef  ^        InputType         ReKi                 YawPosCom         -  - -   "Yaw angle commanded"            rad
typedef  ^        InputType         ReKi                 YawRateCom        -  - -   "Yaw rate  commanded"            rad/s


# ..... Outputs ...................................................................................................................
# outputs on meshes:
typedef  ^        OutputType        MeshType             BladeRootMotion  {:} - -   "For AeroDyn: motions at the blade roots" -
typedef  ^        OutputType        MeshType             HubPtMotion       -  - -   "For AeroDyn/AeroDisk: motions of the hub" -
typedef  ^        OutputType        MeshType             NacelleMotion     -  - -   "For AeroDyn: for aero effects in AD (aero nacelle loads ignored)" -
typedef  ^        OutputType        MeshType             TowerLn2Mesh      -  - -   "Tower line2 mesh for visualization / Aero tower effects"   -
typedef  ^        OutputType        MeshType             PlatformPtMesh    -  - -   "Platform reference point for visualization"   -
#TODO: any mesh for visualization of blades/rotor disk?
# outputs not on meshes:
typedef  ^        OutputType        ReKi                 LSSTipPxa         -  - 2pi "Rotor azimuth angle (position)"   radians
typedef  ^        OutputType        ReKi                 RotSpeed          -  - -   "Rotor azimuth angular speed"   rad/s
typedef  ^        OutputType        ReKi                 RotPwr            -  - -   "Rotor power"  W 
typedef  ^        OutputType        ReKi                 RotTrq            -  - -   "Rotor torque" N-m
typedef  ^        OutputType        ReKi                 HSS_Spd           -  - -   "High-speed shaft (HSS) speed"   rad/s
# This is a feed through -- SrvD requires knowledge of current actual yaw
typedef  ^        OutputType        ReKi                 Yaw               -  - -   "Yaw angle"                      rad
typedef  ^        OutputType        ReKi                 YawRate           -  - -   "Yaw rate"                       rad/s
typedef  ^        OutputType        ReKi                 BlPitch          {:} - 2pi "Actual blade pitch"             radians
typedef  ^        OutputType        ReKi                 WriteOutput      {:} - -   "Data to be written to an output file: see WriteOutputHdr for names of each variable"   "see WriteOutputUnt"


# ..... States ....................................................................................................................
# continuous (differentiable) states:
typedef  ^       ContinuousStateType   R8Ki              QT               {:} - -   "Current estimate of Q (displacement matrix) for each degree of freedom"   -
typedef  ^       ContinuousStateType   ^                 QDT              {:} - -   "Current estimate of QD (velocity matrix) for each degree of freedom"

# Define discrete (nondifferentiable) states here:
typedef  ^       DiscreteStateType     ReKi              DummyDiscreteState - - -   "" -

# Define constraint states here:
typedef  ^       ConstraintStateType   ReKi              DummyConstrState  -  - -   "" -

# any other states
typedef  ^        OtherStateType       IntKi             n                 -  - -   "tracks time step for which OtherState was updated" -
typedef  ^        OtherStateType SED_ContinuousStateType xdot       {SED_NMX} - -   "previous state deriv for multi-step" -
typedef  ^        OtherStateType       IntKi             IC         {SED_NMX} - -   "Array which stores pointers to predictor-corrector results" -
typedef  ^        OtherStateType       ReKi              HSSBrTrq          -  - -   "HSSBrTrq from update states; a hack to get this working with a single integrator"   -
typedef  ^        OtherStateType       ReKi              HSSBrTrqC         -  - -   "Commanded HSS brake torque (adjusted for sign)"   N-m
typedef  ^        OtherStateType       IntKi             SgnPrvLSTQ        -  - -   "The sign of the low-speed shaft torque from the previous call to RtHS(). NOTE: The low-speed shaft torque is assumed to be positive at the beginning of the run!"   -
typedef  ^        OtherStateType       IntKi             SgnLSTQ    {SED_NMX} - -   "history of sign of LSTQ (for HSS brake)"



# ..... Parameters.................................................................................................................
# unchanging parameters:
typedef  ^        ParameterType        CHARACTER(1024)   RootName          -  - -   "RootName for writing output files" -
typedef  ^        ParameterType        LOGICAL           GenDOF            -  - -   "whether the generator DOF is on (free) or off (fixed)" -
typedef  ^        ParameterType        LOGICAL           YawDOF            -  - -   "Yaw controlled by controller, or fixed" -
typedef  ^        ParameterType        DbKi              DT                -  - -   "Time step for module time integration" s
typedef  ^        ParameterType        DbKi              DT24              -  - -   "Time step for solver" s
typedef  ^        ParameterType        IntKi             IntMethod         -  - -   "Integration method {1: RK4, 2: AB4, or 3: ABM4}" -
typedef  ^        ParameterType        ReKi              J_DT              -  - -   "Drivetrain inertia (blades+hub+shaft+generator)" "kgm^2"
typedef  ^        ParameterType        ReKi              PtfmPitch         -  - -   "Static platform tilt angle" rad
typedef  ^        ParameterType        ReKi              InitYaw           -  - -   "Initial or fixed nacelle yaw -- store in case YawDOF is off" deg
typedef  ^        ParameterType        R8Ki              InitAzimuth       -  - -   "Initial azimuth angle for blade 1" deg
typedef  ^        ParameterType        ReKi              RotIner           -  - -   "Hub inertia about teeter axis (2-blader) or rotor axis (3-blader)" "kg m^2"
typedef  ^        ParameterType        ReKi              GenIner           -  - -   "Generator inertia about HSS" "kg m^2"
typedef  ^        ParameterType        ReKi              GBoxRatio         -  - -   "Gearbox ratio" -
typedef  ^        ParameterType        IntKi             NumBl             -  - -   "Number of blades on the turbine" -
typedef  ^        ParameterType        ReKi              TipRad            -  - -   "Preconed blade-tip radius (distance from the rotor apex to the blade tip)" m
typedef  ^        ParameterType        ReKi              HubRad            -  - -   "Preconed hub radius (distance from the rotor apex to the blade root)" m
typedef  ^        ParameterType        ReKi              BladeLength       -  - -   "Length of blades" m
typedef  ^        ParameterType        ReKi              PreCone           -  - -   "Rotor precone angles" deg
typedef  ^        ParameterType        ReKi              OverHang          -  - -   "Distance from yaw axis to rotor apex or teeter pin" m
typedef  ^        ParameterType        ReKi              ShftTilt          -  - -   "Rotor shaft tilt angle" deg
typedef  ^        ParameterType        ReKi              Twr2Shft          -  - -   "Vertical distance from the tower-top to the rotor shaft" m
typedef  ^        ParameterType        ReKi              TowerHt           -  - -   "Height of tower above ground level [onshore] or MSL [offshore]" m
typedef  ^        ParameterType        ReKi              HubHt             -  - -   "Height of hub center above ground level [onshore] or MSL [offshore]" m
typedef  ^        ParameterType        IntKi             NumOuts           -  - -   "Number of outputs"   -
typedef  ^        ParameterType        OutParmType       OutParam         {:} - -   "Names and units (and other characteristics) of all requested output parameters"  -

# ..... Misc/Optimization variables.................................................................................................
typedef  ^        MiscVarType          ReKi              AllOuts          {:} - -   "Array of all outputs"                             -
typedef  ^        MiscVarType          MeshMapType       mapNac2Hub        -  - -   "Mesh mapping from Nacelle to Hub (hub rotation overwritten in calc)" -
typedef  ^        MiscVarType          MeshMapType       mapHub2Root      {:} - -   "Mesh mapping from Hub to BladeRootMotion (blade pitch overwritten in calc)" -
typedef  ^        MiscVarType          R8Ki              QD2T             {:} - -   "Current estimate of first derivative of QD (acceleration matrix) for each degree of freedom"
typedef  ^        MiscVarType          ReKi              HubPt_X          {3} - -   "X orientation of hub calculated in CalcOutput -- saving so we don't recalculate a bunch of things to get it in UpdateStates"

