From 71c0a2ffa40647b5c5080ea6585f5bdda382fc4c Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Fri, 9 Aug 2024 11:27:53 -0600 Subject: [PATCH 01/10] Updated r-tests --- .../src/SuperController_Types.f90 | 1825 ----------------- reg_tests/r-test | 2 +- 2 files changed, 1 insertion(+), 1826 deletions(-) delete mode 100644 modules/supercontroller/src/SuperController_Types.f90 diff --git a/modules/supercontroller/src/SuperController_Types.f90 b/modules/supercontroller/src/SuperController_Types.f90 deleted file mode 100644 index 9663dfe3a3..0000000000 --- a/modules/supercontroller/src/SuperController_Types.f90 +++ /dev/null @@ -1,1825 +0,0 @@ -!STARTOFREGISTRYGENERATEDFILE 'SuperController_Types.f90' -! -! WARNING This file is generated automatically by the FAST registry. -! Do not edit. Your changes to this file will be lost. -! -! FAST Registry -!********************************************************************************************************************************* -! SuperController_Types -!................................................................................................................................. -! This file is part of SuperController. -! -! Copyright (C) 2012-2016 National Renewable Energy Laboratory -! -! Licensed under the Apache License, Version 2.0 (the "License"); -! you may not use this file except in compliance with the License. -! You may obtain a copy of the License at -! -! http://www.apache.org/licenses/LICENSE-2.0 -! -! Unless required by applicable law or agreed to in writing, software -! distributed under the License is distributed on an "AS IS" BASIS, -! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -! See the License for the specific language governing permissions and -! limitations under the License. -! -! -! W A R N I N G : This file was automatically generated from the FAST registry. Changes made to this file may be lost. -! -!********************************************************************************************************************************* -!> This module contains the user-defined types needed in SuperController. It also contains copy, destroy, pack, and -!! unpack routines associated with each defined data type. This code is automatically generated by the FAST Registry. -MODULE SuperController_Types -!--------------------------------------------------------------------------------------------------------------------------------- -USE NWTC_Library -IMPLICIT NONE -! ========= SC_InitInputType_C ======= - TYPE, BIND(C) :: SC_InitInputType_C - TYPE(C_PTR) :: object = C_NULL_PTR - INTEGER(KIND=C_INT) :: nTurbines - CHARACTER(KIND=C_CHAR), DIMENSION(1024) :: DLL_FileName - END TYPE SC_InitInputType_C - TYPE, PUBLIC :: SC_InitInputType - TYPE( SC_InitInputType_C ) :: C_obj - INTEGER(IntKi) :: nTurbines = 0_IntKi !< Number of turbines in the simulation [-] - CHARACTER(1024) :: DLL_FileName !< Name of the shared library which the super controller logic [-] - END TYPE SC_InitInputType -! ======================= -! ========= SC_InitOutputType_C ======= - TYPE, BIND(C) :: SC_InitOutputType_C - TYPE(C_PTR) :: object = C_NULL_PTR - INTEGER(KIND=C_INT) :: NumCtrl2SC - INTEGER(KIND=C_INT) :: nInpGlobal - INTEGER(KIND=C_INT) :: NumSC2Ctrl - INTEGER(KIND=C_INT) :: NumSC2CtrlGlob - END TYPE SC_InitOutputType_C - TYPE, PUBLIC :: SC_InitOutputType - TYPE( SC_InitOutputType_C ) :: C_obj - TYPE(ProgDesc) :: Ver !< This module's name, version, and date [-] - INTEGER(IntKi) :: NumCtrl2SC = 0_IntKi !< Number of turbine controller outputs [to supercontroller] [-] - INTEGER(IntKi) :: nInpGlobal = 0_IntKi !< Number of global inputs to SC [-] - INTEGER(IntKi) :: NumSC2Ctrl = 0_IntKi !< Number of turbine specific controller inputs [from supercontroller] [-] - INTEGER(IntKi) :: NumSC2CtrlGlob = 0_IntKi !< Number of global controller inputs [from supercontroller] [-] - END TYPE SC_InitOutputType -! ======================= -! ========= SC_ParameterType_C ======= - TYPE, BIND(C) :: SC_ParameterType_C - TYPE(C_PTR) :: object = C_NULL_PTR - REAL(KIND=C_DOUBLE) :: DT - INTEGER(KIND=C_INT) :: nTurbines - INTEGER(KIND=C_INT) :: NumCtrl2SC - INTEGER(KIND=C_INT) :: nInpGlobal - INTEGER(KIND=C_INT) :: NumSC2Ctrl - INTEGER(KIND=C_INT) :: NumSC2CtrlGlob - INTEGER(KIND=C_INT) :: NumStatesGlobal - INTEGER(KIND=C_INT) :: NumStatesTurbine - INTEGER(KIND=C_INT) :: NumParamGlobal - INTEGER(KIND=C_INT) :: NumParamTurbine - TYPE(C_ptr) :: ParamGlobal = C_NULL_PTR - INTEGER(C_int) :: ParamGlobal_Len = 0 - TYPE(C_ptr) :: ParamTurbine = C_NULL_PTR - INTEGER(C_int) :: ParamTurbine_Len = 0 - END TYPE SC_ParameterType_C - TYPE, PUBLIC :: SC_ParameterType - TYPE( SC_ParameterType_C ) :: C_obj - REAL(DbKi) :: DT = 0.0_R8Ki !< Time step for continuous state integration & discrete state update [secondstypedef] - INTEGER(IntKi) :: nTurbines = 0_IntKi !< Number of turbines in the simulation [-] - INTEGER(IntKi) :: NumCtrl2SC = 0_IntKi !< Number of turbine controller outputs [to supercontroller] [-] - INTEGER(IntKi) :: nInpGlobal = 0_IntKi !< Number of global inputs [-] - INTEGER(IntKi) :: NumSC2Ctrl = 0_IntKi !< Number of turbine specific controller inputs [from supercontroller] [-] - INTEGER(IntKi) :: NumSC2CtrlGlob = 0_IntKi !< Number of global controller inputs [from supercontroller] [-] - INTEGER(IntKi) :: NumStatesGlobal = 0_IntKi !< Number of global states [-] - INTEGER(IntKi) :: NumStatesTurbine = 0_IntKi !< Number of states per turbine [-] - INTEGER(IntKi) :: NumParamGlobal = 0_IntKi !< Number of global parameters [-] - INTEGER(IntKi) :: NumParamTurbine = 0_IntKi !< Number of parameters per turbine [-] - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: ParamGlobal => NULL() !< Global parameters [-] - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: ParamTurbine => NULL() !< Parameters per turbine [-] - TYPE(DLL_Type) :: DLL_Trgt !< The addresses and names of the super controller shared library and its procedures [-] - END TYPE SC_ParameterType -! ======================= -! ========= SC_DiscreteStateType_C ======= - TYPE, BIND(C) :: SC_DiscreteStateType_C - TYPE(C_PTR) :: object = C_NULL_PTR - TYPE(C_ptr) :: Global = C_NULL_PTR - INTEGER(C_int) :: Global_Len = 0 - TYPE(C_ptr) :: Turbine = C_NULL_PTR - INTEGER(C_int) :: Turbine_Len = 0 - END TYPE SC_DiscreteStateType_C - TYPE, PUBLIC :: SC_DiscreteStateType - TYPE( SC_DiscreteStateType_C ) :: C_obj - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: Global => NULL() !< Global states at time increment, n (total of nStatesGlobal of these states) [-] - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: Turbine => NULL() !< Turbine-dependent states at time increment, n (total of nTurbines*nStatesTurbine of these states) [-] - END TYPE SC_DiscreteStateType -! ======================= -! ========= SC_ContinuousStateType_C ======= - TYPE, BIND(C) :: SC_ContinuousStateType_C - TYPE(C_PTR) :: object = C_NULL_PTR - REAL(KIND=C_FLOAT) :: Dummy - END TYPE SC_ContinuousStateType_C - TYPE, PUBLIC :: SC_ContinuousStateType - TYPE( SC_ContinuousStateType_C ) :: C_obj - REAL(SiKi) :: Dummy = 0.0_R4Ki !< Remove this variable if you have continuous states [-] - END TYPE SC_ContinuousStateType -! ======================= -! ========= SC_ConstraintStateType_C ======= - TYPE, BIND(C) :: SC_ConstraintStateType_C - TYPE(C_PTR) :: object = C_NULL_PTR - REAL(KIND=C_FLOAT) :: Dummy - END TYPE SC_ConstraintStateType_C - TYPE, PUBLIC :: SC_ConstraintStateType - TYPE( SC_ConstraintStateType_C ) :: C_obj - REAL(SiKi) :: Dummy = 0.0_R4Ki !< Remove this variable if you have constraint states [-] - END TYPE SC_ConstraintStateType -! ======================= -! ========= SC_MiscVarType_C ======= - TYPE, BIND(C) :: SC_MiscVarType_C - TYPE(C_PTR) :: object = C_NULL_PTR - REAL(KIND=C_FLOAT) :: Dummy - END TYPE SC_MiscVarType_C - TYPE, PUBLIC :: SC_MiscVarType - TYPE( SC_MiscVarType_C ) :: C_obj - REAL(SiKi) :: Dummy = 0.0_R4Ki !< Remove this variable if you have misc vars [-] - END TYPE SC_MiscVarType -! ======================= -! ========= SC_OtherStateType_C ======= - TYPE, BIND(C) :: SC_OtherStateType_C - TYPE(C_PTR) :: object = C_NULL_PTR - INTEGER(KIND=C_INT) :: Dummy - END TYPE SC_OtherStateType_C - TYPE, PUBLIC :: SC_OtherStateType - TYPE( SC_OtherStateType_C ) :: C_obj - INTEGER(IntKi) :: Dummy = 0_IntKi !< Dummy Other State [-] - END TYPE SC_OtherStateType -! ======================= -! ========= SC_InputType_C ======= - TYPE, BIND(C) :: SC_InputType_C - TYPE(C_PTR) :: object = C_NULL_PTR - TYPE(C_ptr) :: toSCglob = C_NULL_PTR - INTEGER(C_int) :: toSCglob_Len = 0 - TYPE(C_ptr) :: toSC = C_NULL_PTR - INTEGER(C_int) :: toSC_Len = 0 - END TYPE SC_InputType_C - TYPE, PUBLIC :: SC_InputType - TYPE( SC_InputType_C ) :: C_obj - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: toSCglob => NULL() !< Global inputs [-] - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: toSC => NULL() !< inputs to the super controller (from the turbine controller) [-] - END TYPE SC_InputType -! ======================= -! ========= SC_OutputType_C ======= - TYPE, BIND(C) :: SC_OutputType_C - TYPE(C_PTR) :: object = C_NULL_PTR - TYPE(C_ptr) :: fromSCglob = C_NULL_PTR - INTEGER(C_int) :: fromSCglob_Len = 0 - TYPE(C_ptr) :: fromSC = C_NULL_PTR - INTEGER(C_int) :: fromSC_Len = 0 - END TYPE SC_OutputType_C - TYPE, PUBLIC :: SC_OutputType - TYPE( SC_OutputType_C ) :: C_obj - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: fromSCglob => NULL() !< Global outputs of the super controller (to the turbine controller) [-] - REAL(KIND=C_FLOAT) , DIMENSION(:), POINTER :: fromSC => NULL() !< Turbine specific outputs of the super controller (to the turbine controller) [-] - END TYPE SC_OutputType -! ======================= -CONTAINS - -subroutine SC_CopyInitInput(SrcInitInputData, DstInitInputData, CtrlCode, ErrStat, ErrMsg) - type(SC_InitInputType), intent(in) :: SrcInitInputData - type(SC_InitInputType), intent(inout) :: DstInitInputData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_CopyInitInput' - ErrStat = ErrID_None - ErrMsg = '' - DstInitInputData%nTurbines = SrcInitInputData%nTurbines - DstInitInputData%C_obj%nTurbines = SrcInitInputData%C_obj%nTurbines - DstInitInputData%DLL_FileName = SrcInitInputData%DLL_FileName - DstInitInputData%C_obj%DLL_FileName = SrcInitInputData%C_obj%DLL_FileName -end subroutine - -subroutine SC_DestroyInitInput(InitInputData, ErrStat, ErrMsg) - type(SC_InitInputType), intent(inout) :: InitInputData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyInitInput' - ErrStat = ErrID_None - ErrMsg = '' -end subroutine - -subroutine SC_PackInitInput(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_InitInputType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackInitInput' - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPack(RF, InData%nTurbines) - call RegPack(RF, InData%DLL_FileName) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackInitInput(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_InitInputType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackInitInput' - if (RF%ErrStat /= ErrID_None) return - call RegUnpack(RF, OutData%nTurbines); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%nTurbines = OutData%nTurbines - call RegUnpack(RF, OutData%DLL_FileName); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%DLL_FileName = transfer(OutData%DLL_FileName, OutData%C_obj%DLL_FileName ) -end subroutine - -SUBROUTINE SC_C2Fary_CopyInitInput(InitInputData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_InitInputType), INTENT(INOUT) :: InitInputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - InitInputData%nTurbines = InitInputData%C_obj%nTurbines - InitInputData%DLL_FileName = TRANSFER(InitInputData%C_obj%DLL_FileName, InitInputData%DLL_FileName ) -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyInitInput( InitInputData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_InitInputType), INTENT(INOUT) :: InitInputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - InitInputData%C_obj%nTurbines = InitInputData%nTurbines - InitInputData%C_obj%DLL_FileName = TRANSFER(InitInputData%DLL_FileName, InitInputData%C_obj%DLL_FileName) -END SUBROUTINE - -subroutine SC_CopyInitOutput(SrcInitOutputData, DstInitOutputData, CtrlCode, ErrStat, ErrMsg) - type(SC_InitOutputType), intent(in) :: SrcInitOutputData - type(SC_InitOutputType), intent(inout) :: DstInitOutputData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(IntKi) :: ErrStat2 - character(ErrMsgLen) :: ErrMsg2 - character(*), parameter :: RoutineName = 'SC_CopyInitOutput' - ErrStat = ErrID_None - ErrMsg = '' - call NWTC_Library_CopyProgDesc(SrcInitOutputData%Ver, DstInitOutputData%Ver, CtrlCode, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - if (ErrStat >= AbortErrLev) return - DstInitOutputData%NumCtrl2SC = SrcInitOutputData%NumCtrl2SC - DstInitOutputData%C_obj%NumCtrl2SC = SrcInitOutputData%C_obj%NumCtrl2SC - DstInitOutputData%nInpGlobal = SrcInitOutputData%nInpGlobal - DstInitOutputData%C_obj%nInpGlobal = SrcInitOutputData%C_obj%nInpGlobal - DstInitOutputData%NumSC2Ctrl = SrcInitOutputData%NumSC2Ctrl - DstInitOutputData%C_obj%NumSC2Ctrl = SrcInitOutputData%C_obj%NumSC2Ctrl - DstInitOutputData%NumSC2CtrlGlob = SrcInitOutputData%NumSC2CtrlGlob - DstInitOutputData%C_obj%NumSC2CtrlGlob = SrcInitOutputData%C_obj%NumSC2CtrlGlob -end subroutine - -subroutine SC_DestroyInitOutput(InitOutputData, ErrStat, ErrMsg) - type(SC_InitOutputType), intent(inout) :: InitOutputData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(IntKi) :: ErrStat2 - character(ErrMsgLen) :: ErrMsg2 - character(*), parameter :: RoutineName = 'SC_DestroyInitOutput' - ErrStat = ErrID_None - ErrMsg = '' - call NWTC_Library_DestroyProgDesc(InitOutputData%Ver, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) -end subroutine - -subroutine SC_PackInitOutput(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_InitOutputType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackInitOutput' - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call NWTC_Library_PackProgDesc(RF, InData%Ver) - call RegPack(RF, InData%NumCtrl2SC) - call RegPack(RF, InData%nInpGlobal) - call RegPack(RF, InData%NumSC2Ctrl) - call RegPack(RF, InData%NumSC2CtrlGlob) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackInitOutput(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_InitOutputType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackInitOutput' - if (RF%ErrStat /= ErrID_None) return - call NWTC_Library_UnpackProgDesc(RF, OutData%Ver) ! Ver - call RegUnpack(RF, OutData%NumCtrl2SC); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumCtrl2SC = OutData%NumCtrl2SC - call RegUnpack(RF, OutData%nInpGlobal); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%nInpGlobal = OutData%nInpGlobal - call RegUnpack(RF, OutData%NumSC2Ctrl); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumSC2Ctrl = OutData%NumSC2Ctrl - call RegUnpack(RF, OutData%NumSC2CtrlGlob); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumSC2CtrlGlob = OutData%NumSC2CtrlGlob -end subroutine - -SUBROUTINE SC_C2Fary_CopyInitOutput(InitOutputData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_InitOutputType), INTENT(INOUT) :: InitOutputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - InitOutputData%NumCtrl2SC = InitOutputData%C_obj%NumCtrl2SC - InitOutputData%nInpGlobal = InitOutputData%C_obj%nInpGlobal - InitOutputData%NumSC2Ctrl = InitOutputData%C_obj%NumSC2Ctrl - InitOutputData%NumSC2CtrlGlob = InitOutputData%C_obj%NumSC2CtrlGlob -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyInitOutput( InitOutputData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_InitOutputType), INTENT(INOUT) :: InitOutputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - InitOutputData%C_obj%NumCtrl2SC = InitOutputData%NumCtrl2SC - InitOutputData%C_obj%nInpGlobal = InitOutputData%nInpGlobal - InitOutputData%C_obj%NumSC2Ctrl = InitOutputData%NumSC2Ctrl - InitOutputData%C_obj%NumSC2CtrlGlob = InitOutputData%NumSC2CtrlGlob -END SUBROUTINE - -subroutine SC_CopyParam(SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg) - type(SC_ParameterType), intent(in) :: SrcParamData - type(SC_ParameterType), intent(inout) :: DstParamData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: ErrStat2 - character(ErrMsgLen) :: ErrMsg2 - character(*), parameter :: RoutineName = 'SC_CopyParam' - ErrStat = ErrID_None - ErrMsg = '' - DstParamData%DT = SrcParamData%DT - DstParamData%C_obj%DT = SrcParamData%C_obj%DT - DstParamData%nTurbines = SrcParamData%nTurbines - DstParamData%C_obj%nTurbines = SrcParamData%C_obj%nTurbines - DstParamData%NumCtrl2SC = SrcParamData%NumCtrl2SC - DstParamData%C_obj%NumCtrl2SC = SrcParamData%C_obj%NumCtrl2SC - DstParamData%nInpGlobal = SrcParamData%nInpGlobal - DstParamData%C_obj%nInpGlobal = SrcParamData%C_obj%nInpGlobal - DstParamData%NumSC2Ctrl = SrcParamData%NumSC2Ctrl - DstParamData%C_obj%NumSC2Ctrl = SrcParamData%C_obj%NumSC2Ctrl - DstParamData%NumSC2CtrlGlob = SrcParamData%NumSC2CtrlGlob - DstParamData%C_obj%NumSC2CtrlGlob = SrcParamData%C_obj%NumSC2CtrlGlob - DstParamData%NumStatesGlobal = SrcParamData%NumStatesGlobal - DstParamData%C_obj%NumStatesGlobal = SrcParamData%C_obj%NumStatesGlobal - DstParamData%NumStatesTurbine = SrcParamData%NumStatesTurbine - DstParamData%C_obj%NumStatesTurbine = SrcParamData%C_obj%NumStatesTurbine - DstParamData%NumParamGlobal = SrcParamData%NumParamGlobal - DstParamData%C_obj%NumParamGlobal = SrcParamData%C_obj%NumParamGlobal - DstParamData%NumParamTurbine = SrcParamData%NumParamTurbine - DstParamData%C_obj%NumParamTurbine = SrcParamData%C_obj%NumParamTurbine - if (associated(SrcParamData%ParamGlobal)) then - LB(1:1) = lbound(SrcParamData%ParamGlobal, kind=B8Ki) - UB(1:1) = ubound(SrcParamData%ParamGlobal, kind=B8Ki) - if (.not. associated(DstParamData%ParamGlobal)) then - allocate(DstParamData%ParamGlobal(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%ParamGlobal.', ErrStat, ErrMsg, RoutineName) - return - end if - DstParamData%C_obj%ParamGlobal_Len = size(DstParamData%ParamGlobal) - if (DstParamData%C_obj%ParamGlobal_Len > 0) & - DstParamData%C_obj%ParamGlobal = c_loc(DstParamData%ParamGlobal(LB(1))) - end if - DstParamData%ParamGlobal = SrcParamData%ParamGlobal - end if - if (associated(SrcParamData%ParamTurbine)) then - LB(1:1) = lbound(SrcParamData%ParamTurbine, kind=B8Ki) - UB(1:1) = ubound(SrcParamData%ParamTurbine, kind=B8Ki) - if (.not. associated(DstParamData%ParamTurbine)) then - allocate(DstParamData%ParamTurbine(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%ParamTurbine.', ErrStat, ErrMsg, RoutineName) - return - end if - DstParamData%C_obj%ParamTurbine_Len = size(DstParamData%ParamTurbine) - if (DstParamData%C_obj%ParamTurbine_Len > 0) & - DstParamData%C_obj%ParamTurbine = c_loc(DstParamData%ParamTurbine(LB(1))) - end if - DstParamData%ParamTurbine = SrcParamData%ParamTurbine - end if - DstParamData%DLL_Trgt = SrcParamData%DLL_Trgt -end subroutine - -subroutine SC_DestroyParam(ParamData, ErrStat, ErrMsg) - type(SC_ParameterType), intent(inout) :: ParamData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(IntKi) :: ErrStat2 - character(ErrMsgLen) :: ErrMsg2 - character(*), parameter :: RoutineName = 'SC_DestroyParam' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(ParamData%ParamGlobal)) then - deallocate(ParamData%ParamGlobal) - ParamData%ParamGlobal => null() - ParamData%C_obj%ParamGlobal = c_null_ptr - ParamData%C_obj%ParamGlobal_Len = 0 - end if - if (associated(ParamData%ParamTurbine)) then - deallocate(ParamData%ParamTurbine) - ParamData%ParamTurbine => null() - ParamData%C_obj%ParamTurbine = c_null_ptr - ParamData%C_obj%ParamTurbine_Len = 0 - end if - call FreeDynamicLib( ParamData%DLL_Trgt, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) -end subroutine - -subroutine SC_PackParam(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_ParameterType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackParam' - logical :: PtrInIndex - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPack(RF, InData%DT) - call RegPack(RF, InData%nTurbines) - call RegPack(RF, InData%NumCtrl2SC) - call RegPack(RF, InData%nInpGlobal) - call RegPack(RF, InData%NumSC2Ctrl) - call RegPack(RF, InData%NumSC2CtrlGlob) - call RegPack(RF, InData%NumStatesGlobal) - call RegPack(RF, InData%NumStatesTurbine) - call RegPack(RF, InData%NumParamGlobal) - call RegPack(RF, InData%NumParamTurbine) - call RegPackPtr(RF, InData%ParamGlobal) - call RegPackPtr(RF, InData%ParamTurbine) - call DLLTypePack(RF, InData%DLL_Trgt) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackParam(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_ParameterType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackParam' - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: stat - logical :: IsAllocAssoc - integer(B8Ki) :: PtrIdx - type(c_ptr) :: Ptr - if (RF%ErrStat /= ErrID_None) return - call RegUnpack(RF, OutData%DT); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%DT = OutData%DT - call RegUnpack(RF, OutData%nTurbines); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%nTurbines = OutData%nTurbines - call RegUnpack(RF, OutData%NumCtrl2SC); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumCtrl2SC = OutData%NumCtrl2SC - call RegUnpack(RF, OutData%nInpGlobal); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%nInpGlobal = OutData%nInpGlobal - call RegUnpack(RF, OutData%NumSC2Ctrl); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumSC2Ctrl = OutData%NumSC2Ctrl - call RegUnpack(RF, OutData%NumSC2CtrlGlob); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumSC2CtrlGlob = OutData%NumSC2CtrlGlob - call RegUnpack(RF, OutData%NumStatesGlobal); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumStatesGlobal = OutData%NumStatesGlobal - call RegUnpack(RF, OutData%NumStatesTurbine); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumStatesTurbine = OutData%NumStatesTurbine - call RegUnpack(RF, OutData%NumParamGlobal); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumParamGlobal = OutData%NumParamGlobal - call RegUnpack(RF, OutData%NumParamTurbine); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%NumParamTurbine = OutData%NumParamTurbine - call RegUnpackPtr(RF, OutData%ParamGlobal); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%ParamGlobal)) then - OutData%C_obj%ParamGlobal_Len = size(OutData%ParamGlobal) - if (OutData%C_obj%ParamGlobal_Len > 0) OutData%C_obj%ParamGlobal = c_loc(OutData%ParamGlobal(LB(1))) - end if - call RegUnpackPtr(RF, OutData%ParamTurbine); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%ParamTurbine)) then - OutData%C_obj%ParamTurbine_Len = size(OutData%ParamTurbine) - if (OutData%C_obj%ParamTurbine_Len > 0) OutData%C_obj%ParamTurbine = c_loc(OutData%ParamTurbine(LB(1))) - end if - call DLLTypeUnpack(RF, OutData%DLL_Trgt) ! DLL_Trgt -end subroutine - -SUBROUTINE SC_C2Fary_CopyParam(ParamData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_ParameterType), INTENT(INOUT) :: ParamData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - ParamData%DT = ParamData%C_obj%DT - ParamData%nTurbines = ParamData%C_obj%nTurbines - ParamData%NumCtrl2SC = ParamData%C_obj%NumCtrl2SC - ParamData%nInpGlobal = ParamData%C_obj%nInpGlobal - ParamData%NumSC2Ctrl = ParamData%C_obj%NumSC2Ctrl - ParamData%NumSC2CtrlGlob = ParamData%C_obj%NumSC2CtrlGlob - ParamData%NumStatesGlobal = ParamData%C_obj%NumStatesGlobal - ParamData%NumStatesTurbine = ParamData%C_obj%NumStatesTurbine - ParamData%NumParamGlobal = ParamData%C_obj%NumParamGlobal - ParamData%NumParamTurbine = ParamData%C_obj%NumParamTurbine - - ! -- ParamGlobal Param Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( ParamData%C_obj%ParamGlobal ) ) THEN - NULLIFY( ParamData%ParamGlobal ) - ELSE - CALL C_F_POINTER(ParamData%C_obj%ParamGlobal, ParamData%ParamGlobal, [ParamData%C_obj%ParamGlobal_Len]) - END IF - END IF - - ! -- ParamTurbine Param Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( ParamData%C_obj%ParamTurbine ) ) THEN - NULLIFY( ParamData%ParamTurbine ) - ELSE - CALL C_F_POINTER(ParamData%C_obj%ParamTurbine, ParamData%ParamTurbine, [ParamData%C_obj%ParamTurbine_Len]) - END IF - END IF -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyParam( ParamData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_ParameterType), INTENT(INOUT) :: ParamData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - ParamData%C_obj%DT = ParamData%DT - ParamData%C_obj%nTurbines = ParamData%nTurbines - ParamData%C_obj%NumCtrl2SC = ParamData%NumCtrl2SC - ParamData%C_obj%nInpGlobal = ParamData%nInpGlobal - ParamData%C_obj%NumSC2Ctrl = ParamData%NumSC2Ctrl - ParamData%C_obj%NumSC2CtrlGlob = ParamData%NumSC2CtrlGlob - ParamData%C_obj%NumStatesGlobal = ParamData%NumStatesGlobal - ParamData%C_obj%NumStatesTurbine = ParamData%NumStatesTurbine - ParamData%C_obj%NumParamGlobal = ParamData%NumParamGlobal - ParamData%C_obj%NumParamTurbine = ParamData%NumParamTurbine - - ! -- ParamGlobal Param Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(ParamData%ParamGlobal)) THEN - ParamData%C_obj%ParamGlobal_Len = 0 - ParamData%C_obj%ParamGlobal = C_NULL_PTR - ELSE - ParamData%C_obj%ParamGlobal_Len = SIZE(ParamData%ParamGlobal) - IF (ParamData%C_obj%ParamGlobal_Len > 0) & - ParamData%C_obj%ParamGlobal = C_LOC(ParamData%ParamGlobal(LBOUND(ParamData%ParamGlobal,1, kind=B8Ki))) - END IF - END IF - - ! -- ParamTurbine Param Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(ParamData%ParamTurbine)) THEN - ParamData%C_obj%ParamTurbine_Len = 0 - ParamData%C_obj%ParamTurbine = C_NULL_PTR - ELSE - ParamData%C_obj%ParamTurbine_Len = SIZE(ParamData%ParamTurbine) - IF (ParamData%C_obj%ParamTurbine_Len > 0) & - ParamData%C_obj%ParamTurbine = C_LOC(ParamData%ParamTurbine(LBOUND(ParamData%ParamTurbine,1, kind=B8Ki))) - END IF - END IF -END SUBROUTINE - -subroutine SC_CopyDiscState(SrcDiscStateData, DstDiscStateData, CtrlCode, ErrStat, ErrMsg) - type(SC_DiscreteStateType), intent(in) :: SrcDiscStateData - type(SC_DiscreteStateType), intent(inout) :: DstDiscStateData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: ErrStat2 - character(*), parameter :: RoutineName = 'SC_CopyDiscState' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(SrcDiscStateData%Global)) then - LB(1:1) = lbound(SrcDiscStateData%Global, kind=B8Ki) - UB(1:1) = ubound(SrcDiscStateData%Global, kind=B8Ki) - if (.not. associated(DstDiscStateData%Global)) then - allocate(DstDiscStateData%Global(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstDiscStateData%Global.', ErrStat, ErrMsg, RoutineName) - return - end if - DstDiscStateData%C_obj%Global_Len = size(DstDiscStateData%Global) - if (DstDiscStateData%C_obj%Global_Len > 0) & - DstDiscStateData%C_obj%Global = c_loc(DstDiscStateData%Global(LB(1))) - end if - DstDiscStateData%Global = SrcDiscStateData%Global - end if - if (associated(SrcDiscStateData%Turbine)) then - LB(1:1) = lbound(SrcDiscStateData%Turbine, kind=B8Ki) - UB(1:1) = ubound(SrcDiscStateData%Turbine, kind=B8Ki) - if (.not. associated(DstDiscStateData%Turbine)) then - allocate(DstDiscStateData%Turbine(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstDiscStateData%Turbine.', ErrStat, ErrMsg, RoutineName) - return - end if - DstDiscStateData%C_obj%Turbine_Len = size(DstDiscStateData%Turbine) - if (DstDiscStateData%C_obj%Turbine_Len > 0) & - DstDiscStateData%C_obj%Turbine = c_loc(DstDiscStateData%Turbine(LB(1))) - end if - DstDiscStateData%Turbine = SrcDiscStateData%Turbine - end if -end subroutine - -subroutine SC_DestroyDiscState(DiscStateData, ErrStat, ErrMsg) - type(SC_DiscreteStateType), intent(inout) :: DiscStateData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyDiscState' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(DiscStateData%Global)) then - deallocate(DiscStateData%Global) - DiscStateData%Global => null() - DiscStateData%C_obj%Global = c_null_ptr - DiscStateData%C_obj%Global_Len = 0 - end if - if (associated(DiscStateData%Turbine)) then - deallocate(DiscStateData%Turbine) - DiscStateData%Turbine => null() - DiscStateData%C_obj%Turbine = c_null_ptr - DiscStateData%C_obj%Turbine_Len = 0 - end if -end subroutine - -subroutine SC_PackDiscState(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_DiscreteStateType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackDiscState' - logical :: PtrInIndex - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPackPtr(RF, InData%Global) - call RegPackPtr(RF, InData%Turbine) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackDiscState(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_DiscreteStateType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackDiscState' - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: stat - logical :: IsAllocAssoc - integer(B8Ki) :: PtrIdx - type(c_ptr) :: Ptr - if (RF%ErrStat /= ErrID_None) return - call RegUnpackPtr(RF, OutData%Global); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%Global)) then - OutData%C_obj%Global_Len = size(OutData%Global) - if (OutData%C_obj%Global_Len > 0) OutData%C_obj%Global = c_loc(OutData%Global(LB(1))) - end if - call RegUnpackPtr(RF, OutData%Turbine); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%Turbine)) then - OutData%C_obj%Turbine_Len = size(OutData%Turbine) - if (OutData%C_obj%Turbine_Len > 0) OutData%C_obj%Turbine = c_loc(OutData%Turbine(LB(1))) - end if -end subroutine - -SUBROUTINE SC_C2Fary_CopyDiscState(DiscStateData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_DiscreteStateType), INTENT(INOUT) :: DiscStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - - ! -- Global DiscState Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( DiscStateData%C_obj%Global ) ) THEN - NULLIFY( DiscStateData%Global ) - ELSE - CALL C_F_POINTER(DiscStateData%C_obj%Global, DiscStateData%Global, [DiscStateData%C_obj%Global_Len]) - END IF - END IF - - ! -- Turbine DiscState Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( DiscStateData%C_obj%Turbine ) ) THEN - NULLIFY( DiscStateData%Turbine ) - ELSE - CALL C_F_POINTER(DiscStateData%C_obj%Turbine, DiscStateData%Turbine, [DiscStateData%C_obj%Turbine_Len]) - END IF - END IF -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyDiscState( DiscStateData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_DiscreteStateType), INTENT(INOUT) :: DiscStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - - ! -- Global DiscState Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(DiscStateData%Global)) THEN - DiscStateData%C_obj%Global_Len = 0 - DiscStateData%C_obj%Global = C_NULL_PTR - ELSE - DiscStateData%C_obj%Global_Len = SIZE(DiscStateData%Global) - IF (DiscStateData%C_obj%Global_Len > 0) & - DiscStateData%C_obj%Global = C_LOC(DiscStateData%Global(LBOUND(DiscStateData%Global,1, kind=B8Ki))) - END IF - END IF - - ! -- Turbine DiscState Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(DiscStateData%Turbine)) THEN - DiscStateData%C_obj%Turbine_Len = 0 - DiscStateData%C_obj%Turbine = C_NULL_PTR - ELSE - DiscStateData%C_obj%Turbine_Len = SIZE(DiscStateData%Turbine) - IF (DiscStateData%C_obj%Turbine_Len > 0) & - DiscStateData%C_obj%Turbine = C_LOC(DiscStateData%Turbine(LBOUND(DiscStateData%Turbine,1, kind=B8Ki))) - END IF - END IF -END SUBROUTINE - -subroutine SC_CopyContState(SrcContStateData, DstContStateData, CtrlCode, ErrStat, ErrMsg) - type(SC_ContinuousStateType), intent(in) :: SrcContStateData - type(SC_ContinuousStateType), intent(inout) :: DstContStateData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_CopyContState' - ErrStat = ErrID_None - ErrMsg = '' - DstContStateData%Dummy = SrcContStateData%Dummy - DstContStateData%C_obj%Dummy = SrcContStateData%C_obj%Dummy -end subroutine - -subroutine SC_DestroyContState(ContStateData, ErrStat, ErrMsg) - type(SC_ContinuousStateType), intent(inout) :: ContStateData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyContState' - ErrStat = ErrID_None - ErrMsg = '' -end subroutine - -subroutine SC_PackContState(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_ContinuousStateType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackContState' - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPack(RF, InData%Dummy) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackContState(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_ContinuousStateType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackContState' - if (RF%ErrStat /= ErrID_None) return - call RegUnpack(RF, OutData%Dummy); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%Dummy = OutData%Dummy -end subroutine - -SUBROUTINE SC_C2Fary_CopyContState(ContStateData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_ContinuousStateType), INTENT(INOUT) :: ContStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - ContStateData%Dummy = ContStateData%C_obj%Dummy -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyContState( ContStateData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_ContinuousStateType), INTENT(INOUT) :: ContStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - ContStateData%C_obj%Dummy = ContStateData%Dummy -END SUBROUTINE - -subroutine SC_CopyConstrState(SrcConstrStateData, DstConstrStateData, CtrlCode, ErrStat, ErrMsg) - type(SC_ConstraintStateType), intent(in) :: SrcConstrStateData - type(SC_ConstraintStateType), intent(inout) :: DstConstrStateData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_CopyConstrState' - ErrStat = ErrID_None - ErrMsg = '' - DstConstrStateData%Dummy = SrcConstrStateData%Dummy - DstConstrStateData%C_obj%Dummy = SrcConstrStateData%C_obj%Dummy -end subroutine - -subroutine SC_DestroyConstrState(ConstrStateData, ErrStat, ErrMsg) - type(SC_ConstraintStateType), intent(inout) :: ConstrStateData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyConstrState' - ErrStat = ErrID_None - ErrMsg = '' -end subroutine - -subroutine SC_PackConstrState(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_ConstraintStateType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackConstrState' - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPack(RF, InData%Dummy) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackConstrState(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_ConstraintStateType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackConstrState' - if (RF%ErrStat /= ErrID_None) return - call RegUnpack(RF, OutData%Dummy); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%Dummy = OutData%Dummy -end subroutine - -SUBROUTINE SC_C2Fary_CopyConstrState(ConstrStateData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_ConstraintStateType), INTENT(INOUT) :: ConstrStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - ConstrStateData%Dummy = ConstrStateData%C_obj%Dummy -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyConstrState( ConstrStateData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_ConstraintStateType), INTENT(INOUT) :: ConstrStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - ConstrStateData%C_obj%Dummy = ConstrStateData%Dummy -END SUBROUTINE - -subroutine SC_CopyMisc(SrcMiscData, DstMiscData, CtrlCode, ErrStat, ErrMsg) - type(SC_MiscVarType), intent(in) :: SrcMiscData - type(SC_MiscVarType), intent(inout) :: DstMiscData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_CopyMisc' - ErrStat = ErrID_None - ErrMsg = '' - DstMiscData%Dummy = SrcMiscData%Dummy - DstMiscData%C_obj%Dummy = SrcMiscData%C_obj%Dummy -end subroutine - -subroutine SC_DestroyMisc(MiscData, ErrStat, ErrMsg) - type(SC_MiscVarType), intent(inout) :: MiscData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyMisc' - ErrStat = ErrID_None - ErrMsg = '' -end subroutine - -subroutine SC_PackMisc(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_MiscVarType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackMisc' - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPack(RF, InData%Dummy) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackMisc(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_MiscVarType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackMisc' - if (RF%ErrStat /= ErrID_None) return - call RegUnpack(RF, OutData%Dummy); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%Dummy = OutData%Dummy -end subroutine - -SUBROUTINE SC_C2Fary_CopyMisc(MiscData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_MiscVarType), INTENT(INOUT) :: MiscData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - MiscData%Dummy = MiscData%C_obj%Dummy -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyMisc( MiscData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_MiscVarType), INTENT(INOUT) :: MiscData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - MiscData%C_obj%Dummy = MiscData%Dummy -END SUBROUTINE - -subroutine SC_CopyOtherState(SrcOtherStateData, DstOtherStateData, CtrlCode, ErrStat, ErrMsg) - type(SC_OtherStateType), intent(in) :: SrcOtherStateData - type(SC_OtherStateType), intent(inout) :: DstOtherStateData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_CopyOtherState' - ErrStat = ErrID_None - ErrMsg = '' - DstOtherStateData%Dummy = SrcOtherStateData%Dummy - DstOtherStateData%C_obj%Dummy = SrcOtherStateData%C_obj%Dummy -end subroutine - -subroutine SC_DestroyOtherState(OtherStateData, ErrStat, ErrMsg) - type(SC_OtherStateType), intent(inout) :: OtherStateData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyOtherState' - ErrStat = ErrID_None - ErrMsg = '' -end subroutine - -subroutine SC_PackOtherState(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_OtherStateType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackOtherState' - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPack(RF, InData%Dummy) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackOtherState(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_OtherStateType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackOtherState' - if (RF%ErrStat /= ErrID_None) return - call RegUnpack(RF, OutData%Dummy); if (RegCheckErr(RF, RoutineName)) return - OutData%C_obj%Dummy = OutData%Dummy -end subroutine - -SUBROUTINE SC_C2Fary_CopyOtherState(OtherStateData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_OtherStateType), INTENT(INOUT) :: OtherStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - OtherStateData%Dummy = OtherStateData%C_obj%Dummy -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyOtherState( OtherStateData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_OtherStateType), INTENT(INOUT) :: OtherStateData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - OtherStateData%C_obj%Dummy = OtherStateData%Dummy -END SUBROUTINE - -subroutine SC_CopyInput(SrcInputData, DstInputData, CtrlCode, ErrStat, ErrMsg) - type(SC_InputType), intent(in) :: SrcInputData - type(SC_InputType), intent(inout) :: DstInputData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: ErrStat2 - character(*), parameter :: RoutineName = 'SC_CopyInput' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(SrcInputData%toSCglob)) then - LB(1:1) = lbound(SrcInputData%toSCglob, kind=B8Ki) - UB(1:1) = ubound(SrcInputData%toSCglob, kind=B8Ki) - if (.not. associated(DstInputData%toSCglob)) then - allocate(DstInputData%toSCglob(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstInputData%toSCglob.', ErrStat, ErrMsg, RoutineName) - return - end if - DstInputData%C_obj%toSCglob_Len = size(DstInputData%toSCglob) - if (DstInputData%C_obj%toSCglob_Len > 0) & - DstInputData%C_obj%toSCglob = c_loc(DstInputData%toSCglob(LB(1))) - end if - DstInputData%toSCglob = SrcInputData%toSCglob - end if - if (associated(SrcInputData%toSC)) then - LB(1:1) = lbound(SrcInputData%toSC, kind=B8Ki) - UB(1:1) = ubound(SrcInputData%toSC, kind=B8Ki) - if (.not. associated(DstInputData%toSC)) then - allocate(DstInputData%toSC(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstInputData%toSC.', ErrStat, ErrMsg, RoutineName) - return - end if - DstInputData%C_obj%toSC_Len = size(DstInputData%toSC) - if (DstInputData%C_obj%toSC_Len > 0) & - DstInputData%C_obj%toSC = c_loc(DstInputData%toSC(LB(1))) - end if - DstInputData%toSC = SrcInputData%toSC - end if -end subroutine - -subroutine SC_DestroyInput(InputData, ErrStat, ErrMsg) - type(SC_InputType), intent(inout) :: InputData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyInput' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(InputData%toSCglob)) then - deallocate(InputData%toSCglob) - InputData%toSCglob => null() - InputData%C_obj%toSCglob = c_null_ptr - InputData%C_obj%toSCglob_Len = 0 - end if - if (associated(InputData%toSC)) then - deallocate(InputData%toSC) - InputData%toSC => null() - InputData%C_obj%toSC = c_null_ptr - InputData%C_obj%toSC_Len = 0 - end if -end subroutine - -subroutine SC_PackInput(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_InputType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackInput' - logical :: PtrInIndex - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPackPtr(RF, InData%toSCglob) - call RegPackPtr(RF, InData%toSC) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackInput(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_InputType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackInput' - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: stat - logical :: IsAllocAssoc - integer(B8Ki) :: PtrIdx - type(c_ptr) :: Ptr - if (RF%ErrStat /= ErrID_None) return - call RegUnpackPtr(RF, OutData%toSCglob); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%toSCglob)) then - OutData%C_obj%toSCglob_Len = size(OutData%toSCglob) - if (OutData%C_obj%toSCglob_Len > 0) OutData%C_obj%toSCglob = c_loc(OutData%toSCglob(LB(1))) - end if - call RegUnpackPtr(RF, OutData%toSC); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%toSC)) then - OutData%C_obj%toSC_Len = size(OutData%toSC) - if (OutData%C_obj%toSC_Len > 0) OutData%C_obj%toSC = c_loc(OutData%toSC(LB(1))) - end if -end subroutine - -SUBROUTINE SC_C2Fary_CopyInput(InputData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_InputType), INTENT(INOUT) :: InputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - - ! -- toSCglob Input Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( InputData%C_obj%toSCglob ) ) THEN - NULLIFY( InputData%toSCglob ) - ELSE - CALL C_F_POINTER(InputData%C_obj%toSCglob, InputData%toSCglob, [InputData%C_obj%toSCglob_Len]) - END IF - END IF - - ! -- toSC Input Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( InputData%C_obj%toSC ) ) THEN - NULLIFY( InputData%toSC ) - ELSE - CALL C_F_POINTER(InputData%C_obj%toSC, InputData%toSC, [InputData%C_obj%toSC_Len]) - END IF - END IF -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyInput( InputData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_InputType), INTENT(INOUT) :: InputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - - ! -- toSCglob Input Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(InputData%toSCglob)) THEN - InputData%C_obj%toSCglob_Len = 0 - InputData%C_obj%toSCglob = C_NULL_PTR - ELSE - InputData%C_obj%toSCglob_Len = SIZE(InputData%toSCglob) - IF (InputData%C_obj%toSCglob_Len > 0) & - InputData%C_obj%toSCglob = C_LOC(InputData%toSCglob(LBOUND(InputData%toSCglob,1, kind=B8Ki))) - END IF - END IF - - ! -- toSC Input Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(InputData%toSC)) THEN - InputData%C_obj%toSC_Len = 0 - InputData%C_obj%toSC = C_NULL_PTR - ELSE - InputData%C_obj%toSC_Len = SIZE(InputData%toSC) - IF (InputData%C_obj%toSC_Len > 0) & - InputData%C_obj%toSC = C_LOC(InputData%toSC(LBOUND(InputData%toSC,1, kind=B8Ki))) - END IF - END IF -END SUBROUTINE - -subroutine SC_CopyOutput(SrcOutputData, DstOutputData, CtrlCode, ErrStat, ErrMsg) - type(SC_OutputType), intent(in) :: SrcOutputData - type(SC_OutputType), intent(inout) :: DstOutputData - integer(IntKi), intent(in ) :: CtrlCode - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: ErrStat2 - character(*), parameter :: RoutineName = 'SC_CopyOutput' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(SrcOutputData%fromSCglob)) then - LB(1:1) = lbound(SrcOutputData%fromSCglob, kind=B8Ki) - UB(1:1) = ubound(SrcOutputData%fromSCglob, kind=B8Ki) - if (.not. associated(DstOutputData%fromSCglob)) then - allocate(DstOutputData%fromSCglob(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstOutputData%fromSCglob.', ErrStat, ErrMsg, RoutineName) - return - end if - DstOutputData%C_obj%fromSCglob_Len = size(DstOutputData%fromSCglob) - if (DstOutputData%C_obj%fromSCglob_Len > 0) & - DstOutputData%C_obj%fromSCglob = c_loc(DstOutputData%fromSCglob(LB(1))) - end if - DstOutputData%fromSCglob = SrcOutputData%fromSCglob - end if - if (associated(SrcOutputData%fromSC)) then - LB(1:1) = lbound(SrcOutputData%fromSC, kind=B8Ki) - UB(1:1) = ubound(SrcOutputData%fromSC, kind=B8Ki) - if (.not. associated(DstOutputData%fromSC)) then - allocate(DstOutputData%fromSC(LB(1):UB(1)), stat=ErrStat2) - if (ErrStat2 /= 0) then - call SetErrStat(ErrID_Fatal, 'Error allocating DstOutputData%fromSC.', ErrStat, ErrMsg, RoutineName) - return - end if - DstOutputData%C_obj%fromSC_Len = size(DstOutputData%fromSC) - if (DstOutputData%C_obj%fromSC_Len > 0) & - DstOutputData%C_obj%fromSC = c_loc(DstOutputData%fromSC(LB(1))) - end if - DstOutputData%fromSC = SrcOutputData%fromSC - end if -end subroutine - -subroutine SC_DestroyOutput(OutputData, ErrStat, ErrMsg) - type(SC_OutputType), intent(inout) :: OutputData - integer(IntKi), intent( out) :: ErrStat - character(*), intent( out) :: ErrMsg - character(*), parameter :: RoutineName = 'SC_DestroyOutput' - ErrStat = ErrID_None - ErrMsg = '' - if (associated(OutputData%fromSCglob)) then - deallocate(OutputData%fromSCglob) - OutputData%fromSCglob => null() - OutputData%C_obj%fromSCglob = c_null_ptr - OutputData%C_obj%fromSCglob_Len = 0 - end if - if (associated(OutputData%fromSC)) then - deallocate(OutputData%fromSC) - OutputData%fromSC => null() - OutputData%C_obj%fromSC = c_null_ptr - OutputData%C_obj%fromSC_Len = 0 - end if -end subroutine - -subroutine SC_PackOutput(RF, Indata) - type(RegFile), intent(inout) :: RF - type(SC_OutputType), intent(in) :: InData - character(*), parameter :: RoutineName = 'SC_PackOutput' - logical :: PtrInIndex - if (RF%ErrStat >= AbortErrLev) return - if (c_associated(InData%C_obj%object)) then - call SetErrStat(ErrID_Severe,'C_obj%object cannot be packed.', RF%ErrStat, RF%ErrMsg, RoutineName) - return - end if - call RegPackPtr(RF, InData%fromSCglob) - call RegPackPtr(RF, InData%fromSC) - if (RegCheckErr(RF, RoutineName)) return -end subroutine - -subroutine SC_UnPackOutput(RF, OutData) - type(RegFile), intent(inout) :: RF - type(SC_OutputType), intent(inout) :: OutData - character(*), parameter :: RoutineName = 'SC_UnPackOutput' - integer(B8Ki) :: LB(1), UB(1) - integer(IntKi) :: stat - logical :: IsAllocAssoc - integer(B8Ki) :: PtrIdx - type(c_ptr) :: Ptr - if (RF%ErrStat /= ErrID_None) return - call RegUnpackPtr(RF, OutData%fromSCglob); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%fromSCglob)) then - OutData%C_obj%fromSCglob_Len = size(OutData%fromSCglob) - if (OutData%C_obj%fromSCglob_Len > 0) OutData%C_obj%fromSCglob = c_loc(OutData%fromSCglob(LB(1))) - end if - call RegUnpackPtr(RF, OutData%fromSC); if (RegCheckErr(RF, RoutineName)) return - if (associated(OutData%fromSC)) then - OutData%C_obj%fromSC_Len = size(OutData%fromSC) - if (OutData%C_obj%fromSC_Len > 0) OutData%C_obj%fromSC = c_loc(OutData%fromSC(LB(1))) - end if -end subroutine - -SUBROUTINE SC_C2Fary_CopyOutput(OutputData, ErrStat, ErrMsg, SkipPointers) - TYPE(SC_OutputType), INTENT(INOUT) :: OutputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = "" - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - - ! -- fromSCglob Output Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( OutputData%C_obj%fromSCglob ) ) THEN - NULLIFY( OutputData%fromSCglob ) - ELSE - CALL C_F_POINTER(OutputData%C_obj%fromSCglob, OutputData%fromSCglob, [OutputData%C_obj%fromSCglob_Len]) - END IF - END IF - - ! -- fromSC Output Data fields - IF ( .NOT. SkipPointers_local ) THEN - IF ( .NOT. C_ASSOCIATED( OutputData%C_obj%fromSC ) ) THEN - NULLIFY( OutputData%fromSC ) - ELSE - CALL C_F_POINTER(OutputData%C_obj%fromSC, OutputData%fromSC, [OutputData%C_obj%fromSC_Len]) - END IF - END IF -END SUBROUTINE - -SUBROUTINE SC_F2C_CopyOutput( OutputData, ErrStat, ErrMsg, SkipPointers ) - TYPE(SC_OutputType), INTENT(INOUT) :: OutputData - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - LOGICAL,OPTIONAL,INTENT(IN ) :: SkipPointers - ! - LOGICAL :: SkipPointers_local - ErrStat = ErrID_None - ErrMsg = '' - - IF (PRESENT(SkipPointers)) THEN - SkipPointers_local = SkipPointers - ELSE - SkipPointers_local = .false. - END IF - - ! -- fromSCglob Output Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(OutputData%fromSCglob)) THEN - OutputData%C_obj%fromSCglob_Len = 0 - OutputData%C_obj%fromSCglob = C_NULL_PTR - ELSE - OutputData%C_obj%fromSCglob_Len = SIZE(OutputData%fromSCglob) - IF (OutputData%C_obj%fromSCglob_Len > 0) & - OutputData%C_obj%fromSCglob = C_LOC(OutputData%fromSCglob(LBOUND(OutputData%fromSCglob,1, kind=B8Ki))) - END IF - END IF - - ! -- fromSC Output Data fields - IF (.NOT. SkipPointers_local ) THEN - IF (.NOT. ASSOCIATED(OutputData%fromSC)) THEN - OutputData%C_obj%fromSC_Len = 0 - OutputData%C_obj%fromSC = C_NULL_PTR - ELSE - OutputData%C_obj%fromSC_Len = SIZE(OutputData%fromSC) - IF (OutputData%C_obj%fromSC_Len > 0) & - OutputData%C_obj%fromSC = C_LOC(OutputData%fromSC(LBOUND(OutputData%fromSC,1, kind=B8Ki))) - END IF - END IF -END SUBROUTINE - -subroutine SC_Input_ExtrapInterp(u, t, u_out, t_out, ErrStat, ErrMsg) - ! - ! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time - ! values of u (which has values associated with times in t). Order of the interpolation is given by the size of u - ! - ! expressions below based on either - ! - ! f(t) = a - ! f(t) = a + b * t, or - ! f(t) = a + b * t + c * t**2 - ! - ! where a, b and c are determined as the solution to - ! f(t1) = u1, f(t2) = u2, f(t3) = u3 (as appropriate) - ! - !---------------------------------------------------------------------------------------------------------------------------------- - - type(SC_InputType), intent(in) :: u(:) ! Input at t1 > t2 > t3 - real(DbKi), intent(in ) :: t(:) ! Times associated with the Inputs - type(SC_InputType), intent(inout) :: u_out ! Input at tin_out - real(DbKi), intent(in ) :: t_out ! time to be extrap/interp'd to - integer(IntKi), intent( out) :: ErrStat ! Error status of the operation - character(*), intent( out) :: ErrMsg ! Error message if ErrStat /= ErrID_None - ! local variables - integer(IntKi) :: order ! order of polynomial fit (max 2) - integer(IntKi) :: ErrStat2 ! local errors - character(ErrMsgLen) :: ErrMsg2 ! local errors - character(*), PARAMETER :: RoutineName = 'SC_Input_ExtrapInterp' - - ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = '' - if (size(t) /= size(u)) then - call SetErrStat(ErrID_Fatal, 'size(t) must equal size(u)', ErrStat, ErrMsg, RoutineName) - return - endif - order = size(u) - 1 - select case (order) - case (0) - call SC_CopyInput(u(1), u_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - case (1) - call SC_Input_ExtrapInterp1(u(1), u(2), t, u_out, t_out, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - case (2) - call SC_Input_ExtrapInterp2(u(1), u(2), u(3), t, u_out, t_out, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - case default - call SetErrStat(ErrID_Fatal, 'size(u) must be less than 4 (order must be less than 3).', ErrStat, ErrMsg, RoutineName) - return - end select -end subroutine - -SUBROUTINE SC_Input_ExtrapInterp1(u1, u2, tin, u_out, tin_out, ErrStat, ErrMsg ) -! -! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time -! values of u (which has values associated with times in t). Order of the interpolation is 1. -! -! f(t) = a + b * t, or -! -! where a and b are determined as the solution to -! f(t1) = u1, f(t2) = u2 -! -!.................................................................................................................................. - - TYPE(SC_InputType), INTENT(IN) :: u1 ! Input at t1 > t2 - TYPE(SC_InputType), INTENT(IN) :: u2 ! Input at t2 - REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Inputs - TYPE(SC_InputType), INTENT(INOUT) :: u_out ! Input at tin_out - REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to - INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation - CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None - ! local variables - REAL(DbKi) :: t(2) ! Times associated with the Inputs - REAL(DbKi) :: t_out ! Time to which to be extrap/interpd - CHARACTER(*), PARAMETER :: RoutineName = 'SC_Input_ExtrapInterp1' - REAL(DbKi) :: a1, a2 ! temporary for extrapolation/interpolation - INTEGER(IntKi) :: ErrStat2 ! local errors - CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors - INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts - INTEGER :: i1 ! dim1 counter variable for arrays - ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = '' - ! we'll subtract a constant from the times to resolve some - ! numerical issues when t gets large (and to simplify the equations) - t = tin - tin(1) - t_out = tin_out - tin(1) - - IF (EqualRealNos(t(1), t(2))) THEN - CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg, RoutineName) - RETURN - END IF - - ! Calculate weighting factors from Lagrange polynomial - a1 = -(t_out - t(2))/t(2) - a2 = t_out/t(2) - - IF (ASSOCIATED(u_out%toSCglob) .AND. ASSOCIATED(u1%toSCglob)) THEN - u_out%toSCglob = a1*u1%toSCglob + a2*u2%toSCglob - END IF ! check if allocated - IF (ASSOCIATED(u_out%toSC) .AND. ASSOCIATED(u1%toSC)) THEN - u_out%toSC = a1*u1%toSC + a2*u2%toSC - END IF ! check if allocated -END SUBROUTINE - -SUBROUTINE SC_Input_ExtrapInterp2(u1, u2, u3, tin, u_out, tin_out, ErrStat, ErrMsg ) -! -! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time -! values of u (which has values associated with times in t). Order of the interpolation is 2. -! -! expressions below based on either -! -! f(t) = a + b * t + c * t**2 -! -! where a, b and c are determined as the solution to -! f(t1) = u1, f(t2) = u2, f(t3) = u3 -! -!.................................................................................................................................. - - TYPE(SC_InputType), INTENT(IN) :: u1 ! Input at t1 > t2 > t3 - TYPE(SC_InputType), INTENT(IN) :: u2 ! Input at t2 > t3 - TYPE(SC_InputType), INTENT(IN) :: u3 ! Input at t3 - REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Inputs - TYPE(SC_InputType), INTENT(INOUT) :: u_out ! Input at tin_out - REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to - INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation - CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None - ! local variables - REAL(DbKi) :: t(3) ! Times associated with the Inputs - REAL(DbKi) :: t_out ! Time to which to be extrap/interpd - INTEGER(IntKi) :: order ! order of polynomial fit (max 2) - REAL(DbKi) :: a1,a2,a3 ! temporary for extrapolation/interpolation - INTEGER(IntKi) :: ErrStat2 ! local errors - CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors - CHARACTER(*), PARAMETER :: RoutineName = 'SC_Input_ExtrapInterp2' - INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts - INTEGER :: i1 ! dim1 counter variable for arrays - ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = '' - ! we'll subtract a constant from the times to resolve some - ! numerical issues when t gets large (and to simplify the equations) - t = tin - tin(1) - t_out = tin_out - tin(1) - - IF ( EqualRealNos( t(1), t(2) ) ) THEN - CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName) - RETURN - ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN - CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName) - RETURN - ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN - CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName) - RETURN - END IF - - ! Calculate Lagrange polynomial coefficients - a1 = (t_out - t(2))*(t_out - t(3))/((t(1) - t(2))*(t(1) - t(3))) - a2 = (t_out - t(1))*(t_out - t(3))/((t(2) - t(1))*(t(2) - t(3))) - a3 = (t_out - t(1))*(t_out - t(2))/((t(3) - t(1))*(t(3) - t(2))) - IF (ASSOCIATED(u_out%toSCglob) .AND. ASSOCIATED(u1%toSCglob)) THEN - u_out%toSCglob = a1*u1%toSCglob + a2*u2%toSCglob + a3*u3%toSCglob - END IF ! check if allocated - IF (ASSOCIATED(u_out%toSC) .AND. ASSOCIATED(u1%toSC)) THEN - u_out%toSC = a1*u1%toSC + a2*u2%toSC + a3*u3%toSC - END IF ! check if allocated -END SUBROUTINE - -subroutine SC_Output_ExtrapInterp(y, t, y_out, t_out, ErrStat, ErrMsg) - ! - ! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time - ! values of y (which has values associated with times in t). Order of the interpolation is given by the size of y - ! - ! expressions below based on either - ! - ! f(t) = a - ! f(t) = a + b * t, or - ! f(t) = a + b * t + c * t**2 - ! - ! where a, b and c are determined as the solution to - ! f(t1) = y1, f(t2) = y2, f(t3) = y3 (as appropriate) - ! - !---------------------------------------------------------------------------------------------------------------------------------- - - type(SC_OutputType), intent(in) :: y(:) ! Output at t1 > t2 > t3 - real(DbKi), intent(in ) :: t(:) ! Times associated with the Outputs - type(SC_OutputType), intent(inout) :: y_out ! Output at tin_out - real(DbKi), intent(in ) :: t_out ! time to be extrap/interp'd to - integer(IntKi), intent( out) :: ErrStat ! Error status of the operation - character(*), intent( out) :: ErrMsg ! Error message if ErrStat /= ErrID_None - ! local variables - integer(IntKi) :: order ! order of polynomial fit (max 2) - integer(IntKi) :: ErrStat2 ! local errors - character(ErrMsgLen) :: ErrMsg2 ! local errors - character(*), PARAMETER :: RoutineName = 'SC_Output_ExtrapInterp' - - ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = '' - if (size(t) /= size(y)) then - call SetErrStat(ErrID_Fatal, 'size(t) must equal size(y)', ErrStat, ErrMsg, RoutineName) - return - endif - order = size(y) - 1 - select case (order) - case (0) - call SC_CopyOutput(y(1), y_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - case (1) - call SC_Output_ExtrapInterp1(y(1), y(2), t, y_out, t_out, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - case (2) - call SC_Output_ExtrapInterp2(y(1), y(2), y(3), t, y_out, t_out, ErrStat2, ErrMsg2) - call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) - case default - call SetErrStat(ErrID_Fatal, 'size(y) must be less than 4 (order must be less than 3).', ErrStat, ErrMsg, RoutineName) - return - end select -end subroutine - -SUBROUTINE SC_Output_ExtrapInterp1(y1, y2, tin, y_out, tin_out, ErrStat, ErrMsg ) -! -! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time -! values of y (which has values associated with times in t). Order of the interpolation is 1. -! -! f(t) = a + b * t, or -! -! where a and b are determined as the solution to -! f(t1) = y1, f(t2) = y2 -! -!.................................................................................................................................. - - TYPE(SC_OutputType), INTENT(IN) :: y1 ! Output at t1 > t2 - TYPE(SC_OutputType), INTENT(IN) :: y2 ! Output at t2 - REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Outputs - TYPE(SC_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out - REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to - INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation - CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None - ! local variables - REAL(DbKi) :: t(2) ! Times associated with the Outputs - REAL(DbKi) :: t_out ! Time to which to be extrap/interpd - CHARACTER(*), PARAMETER :: RoutineName = 'SC_Output_ExtrapInterp1' - REAL(DbKi) :: a1, a2 ! temporary for extrapolation/interpolation - INTEGER(IntKi) :: ErrStat2 ! local errors - CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors - INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts - INTEGER :: i1 ! dim1 counter variable for arrays - ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = '' - ! we'll subtract a constant from the times to resolve some - ! numerical issues when t gets large (and to simplify the equations) - t = tin - tin(1) - t_out = tin_out - tin(1) - - IF (EqualRealNos(t(1), t(2))) THEN - CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg, RoutineName) - RETURN - END IF - - ! Calculate weighting factors from Lagrange polynomial - a1 = -(t_out - t(2))/t(2) - a2 = t_out/t(2) - - IF (ASSOCIATED(y_out%fromSCglob) .AND. ASSOCIATED(y1%fromSCglob)) THEN - y_out%fromSCglob = a1*y1%fromSCglob + a2*y2%fromSCglob - END IF ! check if allocated - IF (ASSOCIATED(y_out%fromSC) .AND. ASSOCIATED(y1%fromSC)) THEN - y_out%fromSC = a1*y1%fromSC + a2*y2%fromSC - END IF ! check if allocated -END SUBROUTINE - -SUBROUTINE SC_Output_ExtrapInterp2(y1, y2, y3, tin, y_out, tin_out, ErrStat, ErrMsg ) -! -! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time -! values of y (which has values associated with times in t). Order of the interpolation is 2. -! -! expressions below based on either -! -! f(t) = a + b * t + c * t**2 -! -! where a, b and c are determined as the solution to -! f(t1) = y1, f(t2) = y2, f(t3) = y3 -! -!.................................................................................................................................. - - TYPE(SC_OutputType), INTENT(IN) :: y1 ! Output at t1 > t2 > t3 - TYPE(SC_OutputType), INTENT(IN) :: y2 ! Output at t2 > t3 - TYPE(SC_OutputType), INTENT(IN) :: y3 ! Output at t3 - REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Outputs - TYPE(SC_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out - REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to - INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation - CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None - ! local variables - REAL(DbKi) :: t(3) ! Times associated with the Outputs - REAL(DbKi) :: t_out ! Time to which to be extrap/interpd - INTEGER(IntKi) :: order ! order of polynomial fit (max 2) - REAL(DbKi) :: a1,a2,a3 ! temporary for extrapolation/interpolation - INTEGER(IntKi) :: ErrStat2 ! local errors - CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors - CHARACTER(*), PARAMETER :: RoutineName = 'SC_Output_ExtrapInterp2' - INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts - INTEGER :: i1 ! dim1 counter variable for arrays - ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = '' - ! we'll subtract a constant from the times to resolve some - ! numerical issues when t gets large (and to simplify the equations) - t = tin - tin(1) - t_out = tin_out - tin(1) - - IF ( EqualRealNos( t(1), t(2) ) ) THEN - CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName) - RETURN - ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN - CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName) - RETURN - ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN - CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName) - RETURN - END IF - - ! Calculate Lagrange polynomial coefficients - a1 = (t_out - t(2))*(t_out - t(3))/((t(1) - t(2))*(t(1) - t(3))) - a2 = (t_out - t(1))*(t_out - t(3))/((t(2) - t(1))*(t(2) - t(3))) - a3 = (t_out - t(1))*(t_out - t(2))/((t(3) - t(1))*(t(3) - t(2))) - IF (ASSOCIATED(y_out%fromSCglob) .AND. ASSOCIATED(y1%fromSCglob)) THEN - y_out%fromSCglob = a1*y1%fromSCglob + a2*y2%fromSCglob + a3*y3%fromSCglob - END IF ! check if allocated - IF (ASSOCIATED(y_out%fromSC) .AND. ASSOCIATED(y1%fromSC)) THEN - y_out%fromSC = a1*y1%fromSC + a2*y2%fromSC + a3*y3%fromSC - END IF ! check if allocated -END SUBROUTINE -END MODULE SuperController_Types -!ENDOFREGISTRYGENERATEDFILE diff --git a/reg_tests/r-test b/reg_tests/r-test index 37ce0d28ed..1abd888ce2 160000 --- a/reg_tests/r-test +++ b/reg_tests/r-test @@ -1 +1 @@ -Subproject commit 37ce0d28ed629faa945975c3836bae5b1efe9050 +Subproject commit 1abd888ce2209432cf5d126d5bfcd989d221327b From d8ca05b4c7a3b3da4551319f3168fb0ed7b2f389 Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Fri, 9 Aug 2024 14:54:38 -0600 Subject: [PATCH 02/10] Update r-test pointer --- reg_tests/r-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reg_tests/r-test b/reg_tests/r-test index 1abd888ce2..548bf21436 160000 --- a/reg_tests/r-test +++ b/reg_tests/r-test @@ -1 +1 @@ -Subproject commit 1abd888ce2209432cf5d126d5bfcd989d221327b +Subproject commit 548bf2143633a7066f4582167fdf4180951fd7f6 From f4ba9eeb71b6b01347e6236a8d9dd5156ba9cc0d Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Fri, 27 Sep 2024 10:27:15 -0600 Subject: [PATCH 03/10] Update r-test pointer --- reg_tests/r-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reg_tests/r-test b/reg_tests/r-test index 548bf21436..8e5ffc8149 160000 --- a/reg_tests/r-test +++ b/reg_tests/r-test @@ -1 +1 @@ -Subproject commit 548bf2143633a7066f4582167fdf4180951fd7f6 +Subproject commit 8e5ffc814960d350733689c455980109f1d2bacb From 4cbcb9a784b1fc7c8cbcfd723808343d98dd615b Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Wed, 2 Oct 2024 08:47:20 -0600 Subject: [PATCH 04/10] Updated copyright, adjusted driver statement, updated dynamic stiffness --- modules/moordyn/src/MoorDyn.f90 | 12 +++-- modules/moordyn/src/MoorDyn_Driver.f90 | 2 +- modules/moordyn/src/MoorDyn_Line.f90 | 40 +++++++++++++---- modules/moordyn/src/MoorDyn_Registry.txt | 40 +++++++++-------- modules/moordyn/src/MoorDyn_Types.f90 | 52 ++++++++++++++-------- modules/moordyn/src/MoorDyn_bathymetry.txt | 8 ---- 6 files changed, 96 insertions(+), 58 deletions(-) delete mode 100644 modules/moordyn/src/MoorDyn_bathymetry.txt diff --git a/modules/moordyn/src/MoorDyn.f90 b/modules/moordyn/src/MoorDyn.f90 index ff21a2db4b..930f6f4fad 100644 --- a/modules/moordyn/src/MoorDyn.f90 +++ b/modules/moordyn/src/MoorDyn.f90 @@ -167,7 +167,7 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er InitOut%Ver = MD_ProgDesc CALL WrScr(' This is MoorDyn v2, with significant input file changes from v1.') - CALL DispCopyrightLicense( MD_ProgDesc%Name, 'Copyright (C) 2019 Matt Hall' ) + CALL DispCopyrightLicense( MD_ProgDesc%Name) !--------------------------------------------------------------------------------------------- @@ -638,10 +638,14 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! process stiffness coefficients CALL SplitByBars(tempString1, N, tempStrings) - if (N > 2) then - CALL SetErrStat( ErrID_Fatal, 'A line type EA entry can have at most 2 (comma-separated) values.', ErrStat, ErrMsg, RoutineName ) + if (N > 3) then + CALL SetErrStat( ErrID_Fatal, 'A line type EA entry can have at most 3 (bar-separated) values.', ErrStat, ErrMsg, RoutineName ) CALL CleanUp() - else if (N==2) then ! visco-elastic case! + else if (N==3) then ! visco-elastic case, load dependent dynamic stiffness! + m%LineTypeList(l)%ElasticMod = 2 + read(tempStrings(2), *) m%LineTypeList(l)%EA_Dc + read(tempStrings(3), *) m%LineTypeList(l)%EA_D_Lm + else if (N==2) then ! visco-elastic case, constant dynamic stiffness! m%LineTypeList(l)%ElasticMod = 2 read(tempStrings(2), *) m%LineTypeList(l)%EA_D else diff --git a/modules/moordyn/src/MoorDyn_Driver.f90 b/modules/moordyn/src/MoorDyn_Driver.f90 index f5a33ada5c..1e7e5950f7 100644 --- a/modules/moordyn/src/MoorDyn_Driver.f90 +++ b/modules/moordyn/src/MoorDyn_Driver.f90 @@ -144,7 +144,7 @@ PROGRAM MoorDyn_Driver CALL CPU_TIME ( ProgStrtCPU ) ! Initial time (this zeros the start time when used as a MATLAB function) - CALL WrScr('MD Driver updated '//TRIM( version%Date )) + CALL WrScr('MD Driver last updated '//TRIM( version%Date )) ! Parse the driver input file and run the simulation based on that file CALL get_command_argument(1, drvrFilename) diff --git a/modules/moordyn/src/MoorDyn_Line.f90 b/modules/moordyn/src/MoorDyn_Line.f90 index 144021456e..5e3e0183d9 100644 --- a/modules/moordyn/src/MoorDyn_Line.f90 +++ b/modules/moordyn/src/MoorDyn_Line.f90 @@ -1044,7 +1044,8 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, Real(DbKi) :: Yi ! used in interpolating from lookup table Real(DbKi) :: dl ! stretch of a segment [m] Real(DbKi) :: ld_1 ! rate of change of static stiffness portion of segment [m/s] - Real(DbKi) :: EA_1 ! stiffness of 'static stiffness' portion of segment, combines with dynamic stiffness to give static stiffnes [m/s] + Real(DbKi) :: EA_1 ! stiffness of 'slow' portion of segment, combines with dynamic stiffness to give static stiffnes [m/s] + Real(DbKi) :: EA_D ! stiffness of 'fast' portion of segment, combines with EA_1 stiffness to give static stiffnes [m/s] REAL(DbKi) :: surface_height ! Average the surface heights at the two nodes REAL(DbKi) :: firstNodeZ ! Difference of first node depth from surface height @@ -1268,21 +1269,42 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, else MagT = 0.0_DbKi ! cable can't "push" end if + ! line internal damping force based on line-specific BA value, including possibility of dynamic length changes in l and ld terms MagTd = Line%BA* ( Line%lstrd(I) - Line%lstr(I)*Line%ld(I)/Line%l(I) )/Line%l(I) - ! viscoelastic model - else if (Line%ElasticMod == 2) then + ! viscoelastic model from https://asmedigitalcollection.asme.org/OMAE/proceedings/IOWTC2023/87578/V001T01A029/1195018 + else if (Line%ElasticMod > 1) then + + if (Line%ElasticMod == 3) then + if (Line%dl_1(I) >= 0.0) then + ! Mean load dependent dynamic stiffness: from combining eqn. 2 and eqn. 10 from paper, taking mean load = k1 delta_L1 / MBL, and solving for k_D using WolframAlpha with following conditions: k_D > k_s, (MBL,alpha,beta,unstrLen,delta_L1) > 0 + EA_D = ((Line%EA_Dc) + (Line%EA_D_Lm*Line%dl_1(I)*Line%EA) + (Line%l(I)*Line%EA) + sqrt((Line%EA_Dc * Line%EA_Dc) + (2*Line%EA_Dc*Line%EA * (Line%EA_D_Lm*Line%dl_1(I) - Line%l(I))) + (Line%EA*Line%EA * (Line%EA_D_Lm*Line%dl_1(I) + Line%l(I))*(Line%EA_D_Lm*Line%dl_1(I) + Line%l(I))))) / (2*Line%l(I)) + else + EA_D = Line%EA_Dc ! mean load is considered to be 0 in this case. The second term in the above equation is not valid for delta_L1 < 0. + endif + + else if (Line%ElasticMod == 2) then + ! constant dynamic stiffness + EA_D = Line%EA_D + ! else + ! ErrStat = ErrID_Fatal + ! Errmsg = ' Line%ElasticMod > 3 for line '//trim(num2lstr(Line%IdNum))//' viscoelstic model.' ! TODO: make sure this is the right error level + endif - EA_1 = Line%EA_D*Line%EA/(Line%EA_D - Line%EA)! calculated EA_1 which is the stiffness in series with EA_D that will result in the desired static stiffness of EA_S + EA_1 = EA_D*Line%EA/(EA_D - Line%EA)! calculated EA_1 which is the stiffness in series with EA_D that will result in the desired static stiffness of EA_S dl = Line%lstr(I) - Line%l(I) ! delta l of this segment - ld_1 = (Line%EA_D*dl - (Line%EA_D + EA_1)*Line%dl_1(I) + Line%BA_D*Line%lstrd(I)) /( Line%BA_D + Line%BA) ! rate of change of static stiffness portion [m/s] - - !MagT = (Line%EA*Line%dl_S(I) + Line%BA*ld_S)/ Line%l(I) ! compute tension based on static portion (dynamic portion would give same) - MagT = EA_1*Line%dl_1(I)/ Line%l(I) - MagTd = Line%BA*ld_1 / Line%l(I) + ld_1 = (EA_D*dl - (EA_D + EA_1)*Line%dl_1(I) + Line%BA_D*Line%lstrd(I)) /( Line%BA_D + Line%BA) ! rate of change of static stiffness portion [m/s] + + if (dl >= 0.0) then ! if both spring 1 (the spring dashpot in parallel) and the whole segment are not in compression + MagT = EA_1*Line%dl_1(I) / Line%l(I) ! compute tension based on static portion (dynamic portion would give same). See eqn. 14 in paper + else + MagT = 0.0_DbKi ! cable can't "push" + endif + + MagTd = Line%BA*ld_1 / Line%l(I) ! compute tension based on static portion (dynamic portion would give same). See eqn. 14 in paper ! update state derivative for static stiffness stretch (last N entries in the state vector) Xd( 6*N-6 + I) = ld_1 diff --git a/modules/moordyn/src/MoorDyn_Registry.txt b/modules/moordyn/src/MoorDyn_Registry.txt index a12ef6b85b..63673c33e4 100644 --- a/modules/moordyn/src/MoorDyn_Registry.txt +++ b/modules/moordyn/src/MoorDyn_Registry.txt @@ -55,6 +55,8 @@ typedef ^ ^ DbKi d - typedef ^ ^ DbKi w - - - "per-length weight in air" "[kg/m]" typedef ^ ^ DbKi EA - - - "axial stiffness" "[N]" typedef ^ ^ DbKi EA_D - - - "axial stiffness" "[N]" +typedef ^ ^ DbKi EA_Dc - - - "dynamic stiffness constant: Krd alpha term x MBL" "[N]" +typedef ^ ^ DbKi EA_D_Lm - - - "dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load)" "[N]" typedef ^ ^ DbKi BA - - - "internal damping coefficient times area" "[N-s]" typedef ^ ^ DbKi BA_D - - - "internal damping coefficient times area" "[N-s]" typedef ^ ^ DbKi EI - - - "bending stiffness" "[N-m]" @@ -62,14 +64,14 @@ typedef ^ ^ DbKi Can - typedef ^ ^ DbKi Cat - - - "tangential added mass coefficient" typedef ^ ^ DbKi Cdn - - - "transverse drag coefficient" typedef ^ ^ DbKi Cdt - - - "tangential drag coefficient" -typedef ^ ^ IntKi ElasticMod - - - "Which elasticity model to use: {0 basic, 1 viscoelastic, 2 future SYCOM} " - -typedef ^ ^ IntKi nEApoints - 0 - "number of values in stress-strain lookup table (0 means using constant E)" +typedef ^ ^ IntKi ElasticMod - - - "Which elasticity model to use: {1 basic, 2 viscoelastic, 3 viscoelastic+meanload} " - +typedef ^ ^ IntKi nEApoints - - - "number of values in stress-strain lookup table (0 means using constant E)" typedef ^ ^ DbKi stiffXs {30} - - "x array for stress-strain lookup table (up to nCoef)" typedef ^ ^ DbKi stiffYs {30} - - "y array for stress-strain lookup table" -typedef ^ ^ IntKi nBApoints - 0 - "number of values in stress-strainrate lookup table (0 means using constant c)" +typedef ^ ^ IntKi nBApoints - - - "number of values in stress-strainrate lookup table (0 means using constant c)" typedef ^ ^ DbKi dampXs {30} - - "x array for stress-strainrate lookup table (up to nCoef)" typedef ^ ^ DbKi dampYs {30} - - "y array for stress-strainrate lookup table" -typedef ^ ^ IntKi nEIpoints - 0 - "number of values in bending stress-strain lookup table (0 means using constant E)" +typedef ^ ^ IntKi nEIpoints - - - "number of values in bending stress-strain lookup table (0 means using constant E)" typedef ^ ^ DbKi bstiffXs {30} - - "x array for stress-strain lookup table (up to nCoef)" typedef ^ ^ DbKi bstiffYs {30} - - "y array for stress-strain lookup table" @@ -92,8 +94,8 @@ typedef ^ MD_Body IntKi IdNum - typedef ^ ^ IntKi typeNum - - - "integer identifying the type. 0=free, 1=fixed, -1=coupled, 2=coupledpinned" typedef ^ ^ IntKi AttachedC {30} - - "list of IdNums of points attached to this body" typedef ^ ^ IntKi AttachedR {30} - - "list of IdNums of rods attached to this body" -typedef ^ ^ IntKi nAttachedC - 0 - "number of attached points" -typedef ^ ^ IntKi nAttachedR - 0 - "number of attached rods" +typedef ^ ^ IntKi nAttachedC - - - "number of attached points" +typedef ^ ^ IntKi nAttachedR - - - "number of attached rods" typedef ^ ^ DbKi rPointRel {3}{30} - - "relative position of point on body" typedef ^ ^ DbKi r6RodRel {6}{30} - - "relative position and orientation of rod on body" typedef ^ ^ DbKi bodyM - - - "body mass (seperate from attached objects)" "[kg]" @@ -121,7 +123,7 @@ typedef ^ ^ CHARACTER(10) type - typedef ^ ^ IntKi typeNum - - - "integer identifying the type. 1=fixed, -1=coupled, 0=free" typedef ^ ^ IntKi Attached {10} - - "list of IdNums of lines attached to this point node" typedef ^ ^ IntKi Top {10} - - "list of ints specifying whether each line is attached at 1 = top/fairlead(end B), 0 = bottom/anchor(end A)" -typedef ^ ^ IntKi nAttached - 0 - "number of attached lines" +typedef ^ ^ IntKi nAttached - - - "number of attached lines" typedef ^ ^ DbKi pointM - - - "point mass" "[kg]" typedef ^ ^ DbKi pointV - - - "point volume" "[m^3]" typedef ^ ^ DbKi pointFX - - - "" @@ -149,8 +151,8 @@ typedef ^ ^ IntKi AttachedA {10} typedef ^ ^ IntKi AttachedB {10} - - "list of IdNums of lines attached to end B" typedef ^ ^ IntKi TopA {10} - - "list of ints specifying whether each line is attached at 1 = top/fairlead(end B), 0 = bottom/anchor(end A)" typedef ^ ^ IntKi TopB {10} - - "list of ints specifying whether each line is attached at 1 = top/fairlead(end B), 0 = bottom/anchor(end A)" -typedef ^ ^ IntKi nAttachedA - 0 - "number of attached lines to Rod end A" -typedef ^ ^ IntKi nAttachedB - 0 - "number of attached lines to Rod end B" +typedef ^ ^ IntKi nAttachedA - - - "number of attached lines to Rod end A" +typedef ^ ^ IntKi nAttachedB - - - "number of attached lines to Rod end B" typedef ^ ^ IntKi OutFlagList {20} - - "array specifying what line quantities should be output (1 vs 0)" - typedef ^ ^ IntKi N - - - "The number of elements in the line" - typedef ^ ^ IntKi endTypeA - - - "type of point at end A: 0=pinned to Point, 1=cantilevered to Rod." - @@ -210,7 +212,7 @@ typedef ^ MD_Line IntKi IdNum - typedef ^ ^ IntKi PropsIdNum - - - "the IdNum of the associated line properties" - typedef ^ ^ IntKi ElasticMod - - - "Which elasticity model to use: {0 basic, 1 viscoelastic, 2 future SYCOM} " - typedef ^ ^ IntKi OutFlagList {20} - - "array specifying what line quantities should be output (1 vs 0)" - -typedef ^ ^ IntKi CtrlChan - 0 - "index of control channel that will drive line active tensioning (0 for none)" - +typedef ^ ^ IntKi CtrlChan - - - "index of control channel that will drive line active tensioning (0 for none)" - typedef ^ ^ IntKi FairPoint - - - "IdNum of Point at fairlead" typedef ^ ^ IntKi AnchPoint - - - "IdNum of Point at anchor" typedef ^ ^ IntKi N - - - "The number of elements in the line" - @@ -219,22 +221,24 @@ typedef ^ ^ IntKi endTypeB - typedef ^ ^ DbKi UnstrLen - - - "unstretched length of the line" - typedef ^ ^ DbKi rho - - - "density" "[kg/m3]" typedef ^ ^ DbKi d - - - "volume-equivalent diameter" "[m]" -typedef ^ ^ DbKi EA - 0 - "stiffness" "[N]" -typedef ^ ^ DbKi EA_D - 0 - "dynamic stiffness when using viscoelastic model" "[N]" -typedef ^ ^ DbKi BA - 0 - "internal damping coefficient times area for this line only" "[N-s]" -typedef ^ ^ DbKi BA_D - 0 - "dynamic internal damping coefficient times area when using viscoelastic model" "[N-s]" -typedef ^ ^ DbKi EI - 0 - "bending stiffness" "[N-m]" +typedef ^ ^ DbKi EA - - - "stiffness" "[N]" +typedef ^ ^ DbKi EA_D - - - "constant dynamic stiffness when using viscoelastic model" "[N]" +typedef ^ ^ DbKi EA_Dc - - - "load dependent dynamic stiffness constant: Krd alpha term x MBL" "[N]" +typedef ^ ^ DbKi EA_D_Lm - - - "load dependent dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load)" "[N]" +typedef ^ ^ DbKi BA - - - "internal damping coefficient times area for this line only" "[N-s]" +typedef ^ ^ DbKi BA_D - - - "dynamic internal damping coefficient times area when using viscoelastic model" "[N-s]" +typedef ^ ^ DbKi EI - - - "bending stiffness" "[N-m]" typedef ^ ^ DbKi Can - - - "" "[-]" typedef ^ ^ DbKi Cat - - - "" "[-]" typedef ^ ^ DbKi Cdn - - - "" "[-]" typedef ^ ^ DbKi Cdt - - - "" "[-]" -typedef ^ ^ IntKi nEApoints - 0 - "number of values in stress-strain lookup table (0 means using constant E)" +typedef ^ ^ IntKi nEApoints - - - "number of values in stress-strain lookup table (0 means using constant E)" typedef ^ ^ DbKi stiffXs {30} - - "x array for stress-strain lookup table (up to nCoef)" typedef ^ ^ DbKi stiffYs {30} - - "y array for stress-strain lookup table" -typedef ^ ^ IntKi nBApoints - 0 - "number of values in stress-strainrate lookup table (0 means using constant c)" +typedef ^ ^ IntKi nBApoints - - - "number of values in stress-strainrate lookup table (0 means using constant c)" typedef ^ ^ DbKi dampXs {30} - - "x array for stress-strainrate lookup table (up to nCoef)" typedef ^ ^ DbKi dampYs {30} - - "y array for stress-strainrate lookup table" -typedef ^ ^ IntKi nEIpoints - 0 - "number of values in bending stress-strain lookup table (0 means using constant E)" +typedef ^ ^ IntKi nEIpoints - - - "number of values in bending stress-strain lookup table (0 means using constant E)" typedef ^ ^ DbKi bstiffXs {30} - - "x array for stress-strain lookup table (up to nCoef)" typedef ^ ^ DbKi bstiffYs {30} - - "y array for stress-strain lookup table" typedef ^ ^ DbKi time - - - "current time" "[s]" diff --git a/modules/moordyn/src/MoorDyn_Types.f90 b/modules/moordyn/src/MoorDyn_Types.f90 index 7f171fdd4b..9e53b1dc01 100644 --- a/modules/moordyn/src/MoorDyn_Types.f90 +++ b/modules/moordyn/src/MoorDyn_Types.f90 @@ -68,6 +68,8 @@ MODULE MoorDyn_Types REAL(DbKi) :: w = 0.0_R8Ki !< per-length weight in air [[kg/m]] REAL(DbKi) :: EA = 0.0_R8Ki !< axial stiffness [[N]] REAL(DbKi) :: EA_D = 0.0_R8Ki !< axial stiffness [[N]] + REAL(DbKi) :: EA_Dc = 0.0_R8Ki !< dynamic stiffness constant: Krd alpha term x MBL [[N]] + REAL(DbKi) :: EA_D_Lm = 0.0_R8Ki !< dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load) [[N]] REAL(DbKi) :: BA = 0.0_R8Ki !< internal damping coefficient times area [[N-s]] REAL(DbKi) :: BA_D = 0.0_R8Ki !< internal damping coefficient times area [[N-s]] REAL(DbKi) :: EI = 0.0_R8Ki !< bending stiffness [[N-m]] @@ -75,14 +77,14 @@ MODULE MoorDyn_Types REAL(DbKi) :: Cat = 0.0_R8Ki !< tangential added mass coefficient [-] REAL(DbKi) :: Cdn = 0.0_R8Ki !< transverse drag coefficient [-] REAL(DbKi) :: Cdt = 0.0_R8Ki !< tangential drag coefficient [-] - INTEGER(IntKi) :: ElasticMod = 0_IntKi !< Which elasticity model to use: {0 basic, 1 viscoelastic, 2 future SYCOM} [-] - INTEGER(IntKi) :: nEApoints = 0 !< number of values in stress-strain lookup table (0 means using constant E) [-] + INTEGER(IntKi) :: ElasticMod = 0_IntKi !< Which elasticity model to use: {1 basic, 2 viscoelastic, 3 viscoelastic+meanload} [-] + INTEGER(IntKi) :: nEApoints = 0_IntKi !< number of values in stress-strain lookup table (0 means using constant E) [-] REAL(DbKi) , DIMENSION(1:30) :: stiffXs = 0.0_R8Ki !< x array for stress-strain lookup table (up to nCoef) [-] REAL(DbKi) , DIMENSION(1:30) :: stiffYs = 0.0_R8Ki !< y array for stress-strain lookup table [-] - INTEGER(IntKi) :: nBApoints = 0 !< number of values in stress-strainrate lookup table (0 means using constant c) [-] + INTEGER(IntKi) :: nBApoints = 0_IntKi !< number of values in stress-strainrate lookup table (0 means using constant c) [-] REAL(DbKi) , DIMENSION(1:30) :: dampXs = 0.0_R8Ki !< x array for stress-strainrate lookup table (up to nCoef) [-] REAL(DbKi) , DIMENSION(1:30) :: dampYs = 0.0_R8Ki !< y array for stress-strainrate lookup table [-] - INTEGER(IntKi) :: nEIpoints = 0 !< number of values in bending stress-strain lookup table (0 means using constant E) [-] + INTEGER(IntKi) :: nEIpoints = 0_IntKi !< number of values in bending stress-strain lookup table (0 means using constant E) [-] REAL(DbKi) , DIMENSION(1:30) :: bstiffXs = 0.0_R8Ki !< x array for stress-strain lookup table (up to nCoef) [-] REAL(DbKi) , DIMENSION(1:30) :: bstiffYs = 0.0_R8Ki !< y array for stress-strain lookup table [-] END TYPE MD_LineProp @@ -109,8 +111,8 @@ MODULE MoorDyn_Types INTEGER(IntKi) :: typeNum = 0_IntKi !< integer identifying the type. 0=free, 1=fixed, -1=coupled, 2=coupledpinned [-] INTEGER(IntKi) , DIMENSION(1:30) :: AttachedC = 0_IntKi !< list of IdNums of points attached to this body [-] INTEGER(IntKi) , DIMENSION(1:30) :: AttachedR = 0_IntKi !< list of IdNums of rods attached to this body [-] - INTEGER(IntKi) :: nAttachedC = 0 !< number of attached points [-] - INTEGER(IntKi) :: nAttachedR = 0 !< number of attached rods [-] + INTEGER(IntKi) :: nAttachedC = 0_IntKi !< number of attached points [-] + INTEGER(IntKi) :: nAttachedR = 0_IntKi !< number of attached rods [-] REAL(DbKi) , DIMENSION(1:3,1:30) :: rPointRel = 0.0_R8Ki !< relative position of point on body [-] REAL(DbKi) , DIMENSION(1:6,1:30) :: r6RodRel = 0.0_R8Ki !< relative position and orientation of rod on body [-] REAL(DbKi) :: bodyM = 0.0_R8Ki !< body mass (seperate from attached objects) [[kg]] @@ -140,7 +142,7 @@ MODULE MoorDyn_Types INTEGER(IntKi) :: typeNum = 0_IntKi !< integer identifying the type. 1=fixed, -1=coupled, 0=free [-] INTEGER(IntKi) , DIMENSION(1:10) :: Attached = 0_IntKi !< list of IdNums of lines attached to this point node [-] INTEGER(IntKi) , DIMENSION(1:10) :: Top = 0_IntKi !< list of ints specifying whether each line is attached at 1 = top/fairlead(end B), 0 = bottom/anchor(end A) [-] - INTEGER(IntKi) :: nAttached = 0 !< number of attached lines [-] + INTEGER(IntKi) :: nAttached = 0_IntKi !< number of attached lines [-] REAL(DbKi) :: pointM = 0.0_R8Ki !< point mass [[kg]] REAL(DbKi) :: pointV = 0.0_R8Ki !< point volume [[m^3]] REAL(DbKi) :: pointFX = 0.0_R8Ki !< [-] @@ -170,8 +172,8 @@ MODULE MoorDyn_Types INTEGER(IntKi) , DIMENSION(1:10) :: AttachedB = 0_IntKi !< list of IdNums of lines attached to end B [-] INTEGER(IntKi) , DIMENSION(1:10) :: TopA = 0_IntKi !< list of ints specifying whether each line is attached at 1 = top/fairlead(end B), 0 = bottom/anchor(end A) [-] INTEGER(IntKi) , DIMENSION(1:10) :: TopB = 0_IntKi !< list of ints specifying whether each line is attached at 1 = top/fairlead(end B), 0 = bottom/anchor(end A) [-] - INTEGER(IntKi) :: nAttachedA = 0 !< number of attached lines to Rod end A [-] - INTEGER(IntKi) :: nAttachedB = 0 !< number of attached lines to Rod end B [-] + INTEGER(IntKi) :: nAttachedA = 0_IntKi !< number of attached lines to Rod end A [-] + INTEGER(IntKi) :: nAttachedB = 0_IntKi !< number of attached lines to Rod end B [-] INTEGER(IntKi) , DIMENSION(1:20) :: OutFlagList = 0_IntKi !< array specifying what line quantities should be output (1 vs 0) [-] INTEGER(IntKi) :: N = 0_IntKi !< The number of elements in the line [-] INTEGER(IntKi) :: endTypeA = 0_IntKi !< type of point at end A: 0=pinned to Point, 1=cantilevered to Rod. [-] @@ -231,7 +233,7 @@ MODULE MoorDyn_Types INTEGER(IntKi) :: PropsIdNum = 0_IntKi !< the IdNum of the associated line properties [-] INTEGER(IntKi) :: ElasticMod = 0_IntKi !< Which elasticity model to use: {0 basic, 1 viscoelastic, 2 future SYCOM} [-] INTEGER(IntKi) , DIMENSION(1:20) :: OutFlagList = 0_IntKi !< array specifying what line quantities should be output (1 vs 0) [-] - INTEGER(IntKi) :: CtrlChan = 0 !< index of control channel that will drive line active tensioning (0 for none) [-] + INTEGER(IntKi) :: CtrlChan = 0_IntKi !< index of control channel that will drive line active tensioning (0 for none) [-] INTEGER(IntKi) :: FairPoint = 0_IntKi !< IdNum of Point at fairlead [-] INTEGER(IntKi) :: AnchPoint = 0_IntKi !< IdNum of Point at anchor [-] INTEGER(IntKi) :: N = 0_IntKi !< The number of elements in the line [-] @@ -240,22 +242,24 @@ MODULE MoorDyn_Types REAL(DbKi) :: UnstrLen = 0.0_R8Ki !< unstretched length of the line [-] REAL(DbKi) :: rho = 0.0_R8Ki !< density [[kg/m3]] REAL(DbKi) :: d = 0.0_R8Ki !< volume-equivalent diameter [[m]] - REAL(DbKi) :: EA = 0 !< stiffness [[N]] - REAL(DbKi) :: EA_D = 0 !< dynamic stiffness when using viscoelastic model [[N]] - REAL(DbKi) :: BA = 0 !< internal damping coefficient times area for this line only [[N-s]] - REAL(DbKi) :: BA_D = 0 !< dynamic internal damping coefficient times area when using viscoelastic model [[N-s]] - REAL(DbKi) :: EI = 0 !< bending stiffness [[N-m]] + REAL(DbKi) :: EA = 0.0_R8Ki !< stiffness [[N]] + REAL(DbKi) :: EA_D = 0.0_R8Ki !< constant dynamic stiffness when using viscoelastic model [[N]] + REAL(DbKi) :: EA_Dc = 0.0_R8Ki !< load dependent dynamic stiffness constant: Krd alpha term x MBL [[N]] + REAL(DbKi) :: EA_D_Lm = 0.0_R8Ki !< load dependent dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load) [[N]] + REAL(DbKi) :: BA = 0.0_R8Ki !< internal damping coefficient times area for this line only [[N-s]] + REAL(DbKi) :: BA_D = 0.0_R8Ki !< dynamic internal damping coefficient times area when using viscoelastic model [[N-s]] + REAL(DbKi) :: EI = 0.0_R8Ki !< bending stiffness [[N-m]] REAL(DbKi) :: Can = 0.0_R8Ki !< [[-]] REAL(DbKi) :: Cat = 0.0_R8Ki !< [[-]] REAL(DbKi) :: Cdn = 0.0_R8Ki !< [[-]] REAL(DbKi) :: Cdt = 0.0_R8Ki !< [[-]] - INTEGER(IntKi) :: nEApoints = 0 !< number of values in stress-strain lookup table (0 means using constant E) [-] + INTEGER(IntKi) :: nEApoints = 0_IntKi !< number of values in stress-strain lookup table (0 means using constant E) [-] REAL(DbKi) , DIMENSION(1:30) :: stiffXs = 0.0_R8Ki !< x array for stress-strain lookup table (up to nCoef) [-] REAL(DbKi) , DIMENSION(1:30) :: stiffYs = 0.0_R8Ki !< y array for stress-strain lookup table [-] - INTEGER(IntKi) :: nBApoints = 0 !< number of values in stress-strainrate lookup table (0 means using constant c) [-] + INTEGER(IntKi) :: nBApoints = 0_IntKi !< number of values in stress-strainrate lookup table (0 means using constant c) [-] REAL(DbKi) , DIMENSION(1:30) :: dampXs = 0.0_R8Ki !< x array for stress-strainrate lookup table (up to nCoef) [-] REAL(DbKi) , DIMENSION(1:30) :: dampYs = 0.0_R8Ki !< y array for stress-strainrate lookup table [-] - INTEGER(IntKi) :: nEIpoints = 0 !< number of values in bending stress-strain lookup table (0 means using constant E) [-] + INTEGER(IntKi) :: nEIpoints = 0_IntKi !< number of values in bending stress-strain lookup table (0 means using constant E) [-] REAL(DbKi) , DIMENSION(1:30) :: bstiffXs = 0.0_R8Ki !< x array for stress-strain lookup table (up to nCoef) [-] REAL(DbKi) , DIMENSION(1:30) :: bstiffYs = 0.0_R8Ki !< y array for stress-strain lookup table [-] REAL(DbKi) :: time = 0.0_R8Ki !< current time [[s]] @@ -688,6 +692,8 @@ subroutine MD_CopyLineProp(SrcLinePropData, DstLinePropData, CtrlCode, ErrStat, DstLinePropData%w = SrcLinePropData%w DstLinePropData%EA = SrcLinePropData%EA DstLinePropData%EA_D = SrcLinePropData%EA_D + DstLinePropData%EA_Dc = SrcLinePropData%EA_Dc + DstLinePropData%EA_D_Lm = SrcLinePropData%EA_D_Lm DstLinePropData%BA = SrcLinePropData%BA DstLinePropData%BA_D = SrcLinePropData%BA_D DstLinePropData%EI = SrcLinePropData%EI @@ -727,6 +733,8 @@ subroutine MD_PackLineProp(RF, Indata) call RegPack(RF, InData%w) call RegPack(RF, InData%EA) call RegPack(RF, InData%EA_D) + call RegPack(RF, InData%EA_Dc) + call RegPack(RF, InData%EA_D_Lm) call RegPack(RF, InData%BA) call RegPack(RF, InData%BA_D) call RegPack(RF, InData%EI) @@ -758,6 +766,8 @@ subroutine MD_UnPackLineProp(RF, OutData) call RegUnpack(RF, OutData%w); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA_D); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%EA_Dc); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%EA_D_Lm); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA_D); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EI); if (RegCheckErr(RF, RoutineName)) return @@ -1599,6 +1609,8 @@ subroutine MD_CopyLine(SrcLineData, DstLineData, CtrlCode, ErrStat, ErrMsg) DstLineData%d = SrcLineData%d DstLineData%EA = SrcLineData%EA DstLineData%EA_D = SrcLineData%EA_D + DstLineData%EA_Dc = SrcLineData%EA_Dc + DstLineData%EA_D_Lm = SrcLineData%EA_D_Lm DstLineData%BA = SrcLineData%BA DstLineData%BA_D = SrcLineData%BA_D DstLineData%EI = SrcLineData%EI @@ -2085,6 +2097,8 @@ subroutine MD_PackLine(RF, Indata) call RegPack(RF, InData%d) call RegPack(RF, InData%EA) call RegPack(RF, InData%EA_D) + call RegPack(RF, InData%EA_Dc) + call RegPack(RF, InData%EA_D_Lm) call RegPack(RF, InData%BA) call RegPack(RF, InData%BA_D) call RegPack(RF, InData%EI) @@ -2160,6 +2174,8 @@ subroutine MD_UnPackLine(RF, OutData) call RegUnpack(RF, OutData%d); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA_D); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%EA_Dc); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%EA_D_Lm); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA_D); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EI); if (RegCheckErr(RF, RoutineName)) return diff --git a/modules/moordyn/src/MoorDyn_bathymetry.txt b/modules/moordyn/src/MoorDyn_bathymetry.txt deleted file mode 100644 index bfe4ffbbbd..0000000000 --- a/modules/moordyn/src/MoorDyn_bathymetry.txt +++ /dev/null @@ -1,8 +0,0 @@ ---- MoorDyn Bathymetry Input File --- -nGridX 4 -nGridY 4 - -800 -10 10 800 --800 400 400 500 500 - -10 400 400 500 500 - 10 600 600 600 600 - 800 600 600 600 600 \ No newline at end of file From 5ab5eaa0be4a7bb021e50fa6ab94cdb363835bca Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Fri, 11 Oct 2024 11:28:24 -0600 Subject: [PATCH 05/10] Viscoelastic bug fixes: state allocation and assinging variables --- modules/moordyn/src/MoorDyn.f90 | 6 +++--- modules/moordyn/src/MoorDyn_Line.f90 | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/moordyn/src/MoorDyn.f90 b/modules/moordyn/src/MoorDyn.f90 index 930f6f4fad..8afb8ad3ca 100644 --- a/modules/moordyn/src/MoorDyn.f90 +++ b/modules/moordyn/src/MoorDyn.f90 @@ -642,7 +642,7 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL SetErrStat( ErrID_Fatal, 'A line type EA entry can have at most 3 (bar-separated) values.', ErrStat, ErrMsg, RoutineName ) CALL CleanUp() else if (N==3) then ! visco-elastic case, load dependent dynamic stiffness! - m%LineTypeList(l)%ElasticMod = 2 + m%LineTypeList(l)%ElasticMod = 3 read(tempStrings(2), *) m%LineTypeList(l)%EA_Dc read(tempStrings(3), *) m%LineTypeList(l)%EA_D_Lm else if (N==2) then ! visco-elastic case, constant dynamic stiffness! @@ -665,7 +665,7 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL CleanUp() else if (N==2) then ! visco-elastic case when two BA values provided read(tempStrings(2), *) m%LineTypeList(l)%BA_D - else if (m%LineTypeList(l)%ElasticMod == 2) then ! case where there is no dynamic damping for viscoelastic model (will it work)? + else if (m%LineTypeList(l)%ElasticMod > 1) then ! case where there is no dynamic damping for viscoelastic model (will it work)? CALL WrScr("Warning, viscoelastic model being used with zero damping on the dynamic stiffness.") if (p%writeLog > 0) then write(p%UnLog,'(A)') "Warning, viscoelastic model being used with zero damping on the dynamic stiffness." @@ -1442,7 +1442,7 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! account for states of line m%LineStateIs1(l) = Nx + 1 - if (m%LineTypeList(m%LineList(l)%PropsIdNum)%ElasticMod == 2) then + if (m%LineTypeList(m%LineList(l)%PropsIdNum)%ElasticMod > 1) then ! todo add an error check here? or change to 2 or 3? Nx = Nx + 7*m%LineList(l)%N - 6 ! if using viscoelastic model, need one more state per segment m%LineStateIsN(l) = Nx else diff --git a/modules/moordyn/src/MoorDyn_Line.f90 b/modules/moordyn/src/MoorDyn_Line.f90 index 5e3e0183d9..177f90be14 100644 --- a/modules/moordyn/src/MoorDyn_Line.f90 +++ b/modules/moordyn/src/MoorDyn_Line.f90 @@ -69,11 +69,13 @@ SUBROUTINE SetupLine (Line, LineProp, p, ErrStat, ErrMsg) Line%d = LineProp%d Line%rho = LineProp%w/(Pi/4.0 * Line%d * Line%d) - Line%EA = LineProp%EA + Line%EA = LineProp%EA ! note: Line%BA is set later - Line%EA_D = LineProp%EA_D - Line%BA_D = LineProp%BA_D - Line%EI = LineProp%EI !<<< for bending stiffness + Line%EA_D = LineProp%EA_D + Line%EA_Dc = LineProp%EA_Dc + Line%EA_D_Lm = LineProp%EA_D_Lm + Line%BA_D = LineProp%BA_D + Line%EI = LineProp%EI !<<< for bending stiffness Line%Can = LineProp%Can Line%Cat = LineProp%Cat @@ -141,7 +143,7 @@ SUBROUTINE SetupLine (Line, LineProp, p, ErrStat, ErrMsg) END IF ! if using viscoelastic model, allocate additional state quantities - if (Line%ElasticMod == 2) then + if (Line%ElasticMod > 1) then ALLOCATE ( Line%dl_1(N), STAT = ErrStat ) IF ( ErrStat /= ErrID_None ) THEN ErrMsg = ' Error allocating dl_1 array.' @@ -991,7 +993,7 @@ SUBROUTINE Line_SetState(Line, X, t) END DO ! if using viscoelastic model, also set the static stiffness stretch - if (Line%ElasticMod == 2) then + if (Line%ElasticMod > 1) then do I=1,Line%N Line%dl_1(I) = X( 6*Line%N-6 + I) ! these will be the last N entries in the state vector end do @@ -1289,10 +1291,10 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, EA_D = Line%EA_D ! else ! ErrStat = ErrID_Fatal - ! Errmsg = ' Line%ElasticMod > 3 for line '//trim(num2lstr(Line%IdNum))//' viscoelstic model.' ! TODO: make sure this is the right error level + ! Errmsg = ' Line%ElasticMod > 3 for line '//trim(num2lstr(Line%IdNum))//' viscoelstic model.' ! TODO: make sure this is the right error level. Do this for every if (Line%ElasticMod > 1) to make sure its never 4 endif - EA_1 = EA_D*Line%EA/(EA_D - Line%EA)! calculated EA_1 which is the stiffness in series with EA_D that will result in the desired static stiffness of EA_S + EA_1 = EA_D*Line%EA/(EA_D - Line%EA)! calculated EA_1 which is the stiffness in series with EA_D that will result in the desired static stiffness of EA_S. TODO: Make sure EA != EA_D or else nans, also make sure EA_D != 0 or else nans. dl = Line%lstr(I) - Line%l(I) ! delta l of this segment From 92d3c8f66bb068d18cd75796e88efb24b8637a6f Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Fri, 11 Oct 2024 14:09:55 -0600 Subject: [PATCH 06/10] Update viscoelastic varible names, fix dynamic stiffness model --- modules/moordyn/src/MoorDyn.f90 | 4 +- modules/moordyn/src/MoorDyn_Line.f90 | 16 +++- modules/moordyn/src/MoorDyn_Registry.txt | 8 +- modules/moordyn/src/MoorDyn_Types.f90 | 32 +++---- .../src/Registry_NWTC_Library.txt | 84 +++++++++---------- 5 files changed, 76 insertions(+), 68 deletions(-) diff --git a/modules/moordyn/src/MoorDyn.f90 b/modules/moordyn/src/MoorDyn.f90 index 8afb8ad3ca..6c1ab47128 100644 --- a/modules/moordyn/src/MoorDyn.f90 +++ b/modules/moordyn/src/MoorDyn.f90 @@ -643,8 +643,8 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL CleanUp() else if (N==3) then ! visco-elastic case, load dependent dynamic stiffness! m%LineTypeList(l)%ElasticMod = 3 - read(tempStrings(2), *) m%LineTypeList(l)%EA_Dc - read(tempStrings(3), *) m%LineTypeList(l)%EA_D_Lm + read(tempStrings(2), *) m%LineTypeList(l)%alphaMBL + read(tempStrings(3), *) m%LineTypeList(l)%vbeta else if (N==2) then ! visco-elastic case, constant dynamic stiffness! m%LineTypeList(l)%ElasticMod = 2 read(tempStrings(2), *) m%LineTypeList(l)%EA_D diff --git a/modules/moordyn/src/MoorDyn_Line.f90 b/modules/moordyn/src/MoorDyn_Line.f90 index 177f90be14..b4bc158137 100644 --- a/modules/moordyn/src/MoorDyn_Line.f90 +++ b/modules/moordyn/src/MoorDyn_Line.f90 @@ -72,8 +72,8 @@ SUBROUTINE SetupLine (Line, LineProp, p, ErrStat, ErrMsg) Line%EA = LineProp%EA ! note: Line%BA is set later Line%EA_D = LineProp%EA_D - Line%EA_Dc = LineProp%EA_Dc - Line%EA_D_Lm = LineProp%EA_D_Lm + Line%alphaMBL = LineProp%alphaMBL + Line%vbeta = LineProp%vbeta Line%BA_D = LineProp%BA_D Line%EI = LineProp%EI !<<< for bending stiffness @@ -1281,9 +1281,11 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, if (Line%ElasticMod == 3) then if (Line%dl_1(I) >= 0.0) then ! Mean load dependent dynamic stiffness: from combining eqn. 2 and eqn. 10 from paper, taking mean load = k1 delta_L1 / MBL, and solving for k_D using WolframAlpha with following conditions: k_D > k_s, (MBL,alpha,beta,unstrLen,delta_L1) > 0 - EA_D = ((Line%EA_Dc) + (Line%EA_D_Lm*Line%dl_1(I)*Line%EA) + (Line%l(I)*Line%EA) + sqrt((Line%EA_Dc * Line%EA_Dc) + (2*Line%EA_Dc*Line%EA * (Line%EA_D_Lm*Line%dl_1(I) - Line%l(I))) + (Line%EA*Line%EA * (Line%EA_D_Lm*Line%dl_1(I) + Line%l(I))*(Line%EA_D_Lm*Line%dl_1(I) + Line%l(I))))) / (2*Line%l(I)) + EA_D = 0.5 * ((Line%alphaMBL) + (Line%vbeta*Line%dl_1(I)*(Line%EA / Line%l(I))) + Line%EA + sqrt((Line%alphaMBL * Line%alphaMBL) + (2*Line%alphaMBL*(Line%EA / Line%l(I)) * (Line%vbeta*Line%dl_1(I) - Line%l(I))) + ((Line%EA / Line%l(I))*(Line%EA / Line%l(I)) * (Line%vbeta*Line%dl_1(I) + Line%l(I))*(Line%vbeta*Line%dl_1(I) + Line%l(I))))) + ! print*, "Delta L1:", Line%dl_1(I) + ! print*, "EA_D calc:", EA_D else - EA_D = Line%EA_Dc ! mean load is considered to be 0 in this case. The second term in the above equation is not valid for delta_L1 < 0. + EA_D = Line%alphaMBL ! mean load is considered to be 0 in this case. The second term in the above equation is not valid for delta_L1 < 0. endif else if (Line%ElasticMod == 2) then @@ -1306,6 +1308,12 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, MagT = 0.0_DbKi ! cable can't "push" endif + ! print*, "alphaMBL:", Line%alphaMBL + ! print*, "EA_D:", EA_D + ! print*, "EA:", Line%EA + ! print*, "EA_1:", EA_1 + ! print*, "MagT:", MagT + MagTd = Line%BA*ld_1 / Line%l(I) ! compute tension based on static portion (dynamic portion would give same). See eqn. 14 in paper ! update state derivative for static stiffness stretch (last N entries in the state vector) diff --git a/modules/moordyn/src/MoorDyn_Registry.txt b/modules/moordyn/src/MoorDyn_Registry.txt index 63673c33e4..7f9011f9c7 100644 --- a/modules/moordyn/src/MoorDyn_Registry.txt +++ b/modules/moordyn/src/MoorDyn_Registry.txt @@ -55,8 +55,8 @@ typedef ^ ^ DbKi d - typedef ^ ^ DbKi w - - - "per-length weight in air" "[kg/m]" typedef ^ ^ DbKi EA - - - "axial stiffness" "[N]" typedef ^ ^ DbKi EA_D - - - "axial stiffness" "[N]" -typedef ^ ^ DbKi EA_Dc - - - "dynamic stiffness constant: Krd alpha term x MBL" "[N]" -typedef ^ ^ DbKi EA_D_Lm - - - "dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load)" "[N]" +typedef ^ ^ DbKi alphaMBL - - - "dynamic stiffness constant: Krd alpha term x MBL" "[N]" +typedef ^ ^ DbKi vbeta - - - "dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load)" "[N]" typedef ^ ^ DbKi BA - - - "internal damping coefficient times area" "[N-s]" typedef ^ ^ DbKi BA_D - - - "internal damping coefficient times area" "[N-s]" typedef ^ ^ DbKi EI - - - "bending stiffness" "[N-m]" @@ -223,8 +223,8 @@ typedef ^ ^ DbKi rho - typedef ^ ^ DbKi d - - - "volume-equivalent diameter" "[m]" typedef ^ ^ DbKi EA - - - "stiffness" "[N]" typedef ^ ^ DbKi EA_D - - - "constant dynamic stiffness when using viscoelastic model" "[N]" -typedef ^ ^ DbKi EA_Dc - - - "load dependent dynamic stiffness constant: Krd alpha term x MBL" "[N]" -typedef ^ ^ DbKi EA_D_Lm - - - "load dependent dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load)" "[N]" +typedef ^ ^ DbKi alphaMBL - - - "load dependent dynamic stiffness constant: Krd alpha term x MBL" "[N]" +typedef ^ ^ DbKi vbeta - - - "load dependent dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load)" "[N]" typedef ^ ^ DbKi BA - - - "internal damping coefficient times area for this line only" "[N-s]" typedef ^ ^ DbKi BA_D - - - "dynamic internal damping coefficient times area when using viscoelastic model" "[N-s]" typedef ^ ^ DbKi EI - - - "bending stiffness" "[N-m]" diff --git a/modules/moordyn/src/MoorDyn_Types.f90 b/modules/moordyn/src/MoorDyn_Types.f90 index 9e53b1dc01..2b857bef9d 100644 --- a/modules/moordyn/src/MoorDyn_Types.f90 +++ b/modules/moordyn/src/MoorDyn_Types.f90 @@ -68,8 +68,8 @@ MODULE MoorDyn_Types REAL(DbKi) :: w = 0.0_R8Ki !< per-length weight in air [[kg/m]] REAL(DbKi) :: EA = 0.0_R8Ki !< axial stiffness [[N]] REAL(DbKi) :: EA_D = 0.0_R8Ki !< axial stiffness [[N]] - REAL(DbKi) :: EA_Dc = 0.0_R8Ki !< dynamic stiffness constant: Krd alpha term x MBL [[N]] - REAL(DbKi) :: EA_D_Lm = 0.0_R8Ki !< dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load) [[N]] + REAL(DbKi) :: alphaMBL = 0.0_R8Ki !< dynamic stiffness constant: Krd alpha term x MBL [[N]] + REAL(DbKi) :: vbeta = 0.0_R8Ki !< dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load) [[N]] REAL(DbKi) :: BA = 0.0_R8Ki !< internal damping coefficient times area [[N-s]] REAL(DbKi) :: BA_D = 0.0_R8Ki !< internal damping coefficient times area [[N-s]] REAL(DbKi) :: EI = 0.0_R8Ki !< bending stiffness [[N-m]] @@ -244,8 +244,8 @@ MODULE MoorDyn_Types REAL(DbKi) :: d = 0.0_R8Ki !< volume-equivalent diameter [[m]] REAL(DbKi) :: EA = 0.0_R8Ki !< stiffness [[N]] REAL(DbKi) :: EA_D = 0.0_R8Ki !< constant dynamic stiffness when using viscoelastic model [[N]] - REAL(DbKi) :: EA_Dc = 0.0_R8Ki !< load dependent dynamic stiffness constant: Krd alpha term x MBL [[N]] - REAL(DbKi) :: EA_D_Lm = 0.0_R8Ki !< load dependent dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load) [[N]] + REAL(DbKi) :: alphaMBL = 0.0_R8Ki !< load dependent dynamic stiffness constant: Krd alpha term x MBL [[N]] + REAL(DbKi) :: vbeta = 0.0_R8Ki !< load dependent dynamic stiffness Lm slope: Krd beta term (to be multiplied by mean load) [[N]] REAL(DbKi) :: BA = 0.0_R8Ki !< internal damping coefficient times area for this line only [[N-s]] REAL(DbKi) :: BA_D = 0.0_R8Ki !< dynamic internal damping coefficient times area when using viscoelastic model [[N-s]] REAL(DbKi) :: EI = 0.0_R8Ki !< bending stiffness [[N-m]] @@ -692,8 +692,8 @@ subroutine MD_CopyLineProp(SrcLinePropData, DstLinePropData, CtrlCode, ErrStat, DstLinePropData%w = SrcLinePropData%w DstLinePropData%EA = SrcLinePropData%EA DstLinePropData%EA_D = SrcLinePropData%EA_D - DstLinePropData%EA_Dc = SrcLinePropData%EA_Dc - DstLinePropData%EA_D_Lm = SrcLinePropData%EA_D_Lm + DstLinePropData%alphaMBL = SrcLinePropData%alphaMBL + DstLinePropData%vbeta = SrcLinePropData%vbeta DstLinePropData%BA = SrcLinePropData%BA DstLinePropData%BA_D = SrcLinePropData%BA_D DstLinePropData%EI = SrcLinePropData%EI @@ -733,8 +733,8 @@ subroutine MD_PackLineProp(RF, Indata) call RegPack(RF, InData%w) call RegPack(RF, InData%EA) call RegPack(RF, InData%EA_D) - call RegPack(RF, InData%EA_Dc) - call RegPack(RF, InData%EA_D_Lm) + call RegPack(RF, InData%alphaMBL) + call RegPack(RF, InData%vbeta) call RegPack(RF, InData%BA) call RegPack(RF, InData%BA_D) call RegPack(RF, InData%EI) @@ -766,8 +766,8 @@ subroutine MD_UnPackLineProp(RF, OutData) call RegUnpack(RF, OutData%w); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA_D); if (RegCheckErr(RF, RoutineName)) return - call RegUnpack(RF, OutData%EA_Dc); if (RegCheckErr(RF, RoutineName)) return - call RegUnpack(RF, OutData%EA_D_Lm); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%alphaMBL); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%vbeta); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA_D); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EI); if (RegCheckErr(RF, RoutineName)) return @@ -1609,8 +1609,8 @@ subroutine MD_CopyLine(SrcLineData, DstLineData, CtrlCode, ErrStat, ErrMsg) DstLineData%d = SrcLineData%d DstLineData%EA = SrcLineData%EA DstLineData%EA_D = SrcLineData%EA_D - DstLineData%EA_Dc = SrcLineData%EA_Dc - DstLineData%EA_D_Lm = SrcLineData%EA_D_Lm + DstLineData%alphaMBL = SrcLineData%alphaMBL + DstLineData%vbeta = SrcLineData%vbeta DstLineData%BA = SrcLineData%BA DstLineData%BA_D = SrcLineData%BA_D DstLineData%EI = SrcLineData%EI @@ -2097,8 +2097,8 @@ subroutine MD_PackLine(RF, Indata) call RegPack(RF, InData%d) call RegPack(RF, InData%EA) call RegPack(RF, InData%EA_D) - call RegPack(RF, InData%EA_Dc) - call RegPack(RF, InData%EA_D_Lm) + call RegPack(RF, InData%alphaMBL) + call RegPack(RF, InData%vbeta) call RegPack(RF, InData%BA) call RegPack(RF, InData%BA_D) call RegPack(RF, InData%EI) @@ -2174,8 +2174,8 @@ subroutine MD_UnPackLine(RF, OutData) call RegUnpack(RF, OutData%d); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EA_D); if (RegCheckErr(RF, RoutineName)) return - call RegUnpack(RF, OutData%EA_Dc); if (RegCheckErr(RF, RoutineName)) return - call RegUnpack(RF, OutData%EA_D_Lm); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%alphaMBL); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%vbeta); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%BA_D); if (RegCheckErr(RF, RoutineName)) return call RegUnpack(RF, OutData%EI); if (RegCheckErr(RF, RoutineName)) return diff --git a/modules/nwtc-library/src/Registry_NWTC_Library.txt b/modules/nwtc-library/src/Registry_NWTC_Library.txt index d7d4de29ee..a4cd50c404 100644 --- a/modules/nwtc-library/src/Registry_NWTC_Library.txt +++ b/modules/nwtc-library/src/Registry_NWTC_Library.txt @@ -6,38 +6,38 @@ #............................................................. -typedef NWTC_Library ProgDesc CHARACTER(99) Name - - - "Name of the program or module" -typedef ^ ^ CHARACTER(99) Ver - - - "Version number of the program or module" -typedef ^ ^ CHARACTER(24) Date - - - "String containing date module was last updated" - -typedef NWTC_Library FASTdataType CHARACTER(1024) File - - - "Name of the FAST-style binary file" -typedef ^ ^ CHARACTER(1024) Descr - - - "String describing file" -typedef ^ ^ IntKi NumChans - - - "Number of output channels in this binary file (not including the time channel)" -typedef ^ ^ IntKi NumRecs - - - "Number of records (rows) of data in the file" -typedef ^ ^ DbKi TimeStep - - - "Time step for evenly-spaced data in the output file (when NumRecs is not allo" -typedef ^ ^ CHARACTER(ChanLen) ChanNames {:} - - "Strings describing the names of the channels from the binary file (including the time channel)" -typedef ^ ^ CHARACTER(ChanLen) ChanUnits {:} - - "Strings describing the units of the channels from the binary file (including the time channel)" -typedef ^ ^ ReKi Data {:}{:} - - "numeric data (rows and columns) from the binary file, including the time channel" - -typedef NWTC_Library OutParmType IntKi Indx - - - "An index into AllOuts array where this channel is computed/stored" -typedef ^ ^ CHARACTER(ChanLen) Name - - - "Name of the output channel" -typedef ^ ^ CHARACTER(ChanLen) Units - - - "Units this channel is specified in" -typedef ^ ^ IntKi SignM - - - "Multiplier for output channel; usually -1 (minus) or 0 (invalid channel)" - -typedef NWTC_Library FileInfoType IntKi NumLines -typedef ^ ^ IntKi NumFiles -typedef ^ ^ IntKi FileLine {:} -typedef ^ ^ IntKi FileIndx {:} +typedef NWTC_Library ProgDesc CHARACTER(99) Name - - - "Name of the program or module" +typedef ^ ^ CHARACTER(99) Ver - - - "Version number of the program or module" +typedef ^ ^ CHARACTER(24) Date - - - "String containing date module was last updated" + +typedef NWTC_Library FASTdataType CHARACTER(1024) File - - - "Name of the FAST-style binary file" +typedef ^ ^ CHARACTER(1024) Descr - - - "String describing file" +typedef ^ ^ IntKi NumChans - - - "Number of output channels in this binary file (not including the time channel)" +typedef ^ ^ IntKi NumRecs - - - "Number of records (rows) of data in the file" +typedef ^ ^ DbKi TimeStep - - - "Time step for evenly-spaced data in the output file (when NumRecs is not allo" +typedef ^ ^ CHARACTER(ChanLen) ChanNames {:} - - "Strings describing the names of the channels from the binary file (including the time channel)" +typedef ^ ^ CHARACTER(ChanLen) ChanUnits {:} - - "Strings describing the units of the channels from the binary file (including the time channel)" +typedef ^ ^ ReKi Data {:}{:} - - "numeric data (rows and columns) from the binary file, including the time channel" + +typedef NWTC_Library OutParmType IntKi Indx - - - "An index into AllOuts array where this channel is computed/stored" +typedef ^ ^ CHARACTER(ChanLen) Name - - - "Name of the output channel" +typedef ^ ^ CHARACTER(ChanLen) Units - - - "Units this channel is specified in" +typedef ^ ^ IntKi SignM - - - "Multiplier for output channel; usually -1 (minus) or 0 (invalid channel)" + +typedef NWTC_Library FileInfoType IntKi NumLines +typedef ^ ^ IntKi NumFiles +typedef ^ ^ IntKi FileLine {:} +typedef ^ ^ IntKi FileIndx {:} typedef ^ ^ CHARACTER(MaxFileInfoLineLen) FileList {:} typedef ^ ^ CHARACTER(MaxFileInfoLineLen) Lines {:} -typedef NWTC_Library Quaternion ReKi q0 -typedef ^ ^ ReKi v {3} +typedef NWTC_Library Quaternion ReKi q0 +typedef ^ ^ ReKi v {3} -typedef NWTC_Library NWTC_RandomNumber_ParameterType IntKi pRNG -typedef ^ ^ IntKi RandSeed {3} -typedef ^ ^ IntKi RandSeedAry {:} -typedef ^ ^ CHARACTER(6) RNG_type +typedef NWTC_Library NWTC_RandomNumber_ParameterType IntKi pRNG +typedef ^ ^ IntKi RandSeed {3} +typedef ^ ^ IntKi RandSeedAry {:} +typedef ^ ^ CHARACTER(6) RNG_type #------------------------------------------------------------------------------- # Module Variables @@ -133,22 +133,22 @@ typedef ^ ^ IntKi DstMaps : - - #BJJ: the following three types will actually be placed in the ModMesh_Mapping.f90 file instead of NWTC_Library_Types.f90 -typedef NWTC_Library MapType IntKi OtherMesh_Element - - - "Node (for point meshes) or Element (for line2 meshes) number on other mesh; for loads, other mesh is Dest, for motions/scalars, other mesh is Src" +typedef NWTC_Library MapType IntKi OtherMesh_Element - - - "Node (for point meshes) or Element (for line2 meshes) number on other mesh; for loads, other mesh is Dest, for motions/scalars, other mesh is Src" - typedef ^ ^ R8Ki distance - - - "Magnitude of couple_arm" m typedef ^ ^ R8Ki couple_arm {3} - - "Vector between a point and node 1 of an element (p_ODR - p_OSR)" m typedef ^ ^ R8Ki shape_fn {2} - - "shape functions: 1-D element-level location [0,1] based on closest-line projection of point" - -typedef NWTC_Library MeshMapLinearizationType R8Ki mi {:}{:} - - "block matrix of motions that reflects identity (i.e., solely the mapping of one quantity to itself on another mesh)" -typedef ^ ^ R8Ki fx_p {:}{:} - - "block matrix of motions that reflects skew-symmetric (cross-product) matrix" -typedef ^ ^ R8Ki tv_uD {:}{:} - - "block matrix of translational velocity that is multiplied by destination translational displacement" -typedef ^ ^ R8Ki tv_uS {:}{:} - - "block matrix of translational velocity that is multiplied by source translational displacement" -typedef ^ ^ R8Ki ta_uD {:}{:} - - "block matrix of translational acceleration that is multiplied by destination translational displacement" -typedef ^ ^ R8Ki ta_uS {:}{:} - - "block matrix of translational acceleration that is multiplied by source translational displacement" -typedef ^ ^ R8Ki ta_rv {:}{:} - - "block matrix of translational acceleration that is multiplied by omega (RotationVel)" -typedef ^ ^ R8Ki li {:}{:} - - "block matrix of loads that reflects identity (i.e., solely the mapping on one quantity to itself on another mesh)" -typedef ^ ^ R8Ki M_uS {:}{:} - - "block matrix of moment that is multiplied by Source u (translationDisp)" -typedef ^ ^ R8Ki M_uD {:}{:} - - "block matrix of moment that is multiplied by Destination u (translationDisp)" -typedef ^ ^ R8Ki M_f {:}{:} - - "block matrix of moment that is multiplied by force" +typedef NWTC_Library MeshMapLinearizationType R8Ki mi {:}{:} - - "block matrix of motions that reflects identity (i.e., solely the mapping of one quantity to itself on another mesh)" +typedef ^ ^ R8Ki fx_p {:}{:} - - "block matrix of motions that reflects skew-symmetric (cross-product) matrix" +typedef ^ ^ R8Ki tv_uD {:}{:} - - "block matrix of translational velocity that is multiplied by destination translational displacement" +typedef ^ ^ R8Ki tv_uS {:}{:} - - "block matrix of translational velocity that is multiplied by source translational displacement" +typedef ^ ^ R8Ki ta_uD {:}{:} - - "block matrix of translational acceleration that is multiplied by destination translational displacement" +typedef ^ ^ R8Ki ta_uS {:}{:} - - "block matrix of translational acceleration that is multiplied by source translational displacement" +typedef ^ ^ R8Ki ta_rv {:}{:} - - "block matrix of translational acceleration that is multiplied by omega (RotationVel)" +typedef ^ ^ R8Ki li {:}{:} - - "block matrix of loads that reflects identity (i.e., solely the mapping on one quantity to itself on another mesh)" +typedef ^ ^ R8Ki M_uS {:}{:} - - "block matrix of moment that is multiplied by Source u (translationDisp)" +typedef ^ ^ R8Ki M_uD {:}{:} - - "block matrix of moment that is multiplied by Destination u (translationDisp)" +typedef ^ ^ R8Ki M_f {:}{:} - - "block matrix of moment that is multiplied by force" typedef NWTC_Library MeshMapType MapType MapLoads {:} - - "mapping data structure for load fields on the mesh" typedef ^ ^ MapType MapMotions {:} - - "mapping data structure for motion and/or scalar fields on the mesh" @@ -160,6 +160,6 @@ typedef ^ ^ R8Ki DisplacedPo typedef ^ ^ R8Ki LoadLn2_A_Mat {:}{:} - - "The 3-components of the forces for each node of an element in the point-to-line load mapping (for each element)" typedef ^ ^ R8Ki LoadLn2_F {:}{:} - - "The 6-by-6 matrix that makes up the diagonal of the [A 0; B A] matrix in the point-to-line load mapping" typedef ^ ^ R8Ki LoadLn2_M {:}{:} - - "The 3-components of the moments for each node of an element in the point-to-line load mapping (for each element)" -typedef ^ ^ MeshMapLinearizationType dM -#typedef ^ ^ MeshType Lumped_Points_Dest - - - "temporary mesh for debugging the lumped values in the line2-to-line2" +typedef ^ ^ MeshMapLinearizationType dM +#typedef ^ ^ MeshType Lumped_Points_Dest - - - "temporary mesh for debugging the lumped values in the line2-to-line2" From 7743f6f8cc5896459ff1a6a04440ccf40ec73eb3 Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Fri, 11 Oct 2024 16:12:35 -0600 Subject: [PATCH 07/10] Add viscoelastic error checking --- modules/moordyn/src/MoorDyn.f90 | 5 +++- modules/moordyn/src/MoorDyn_Line.f90 | 36 +++++++++++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/modules/moordyn/src/MoorDyn.f90 b/modules/moordyn/src/MoorDyn.f90 index 6c1ab47128..0124599ca7 100644 --- a/modules/moordyn/src/MoorDyn.f90 +++ b/modules/moordyn/src/MoorDyn.f90 @@ -3502,7 +3502,10 @@ SUBROUTINE MD_CalcContStateDeriv( t, u, p, x, xd, z, other, m, dxdt, ErrStat, Er ! calculate line dynamics (and calculate line forces and masses attributed to points) DO l = 1,p%nLines - CALL Line_GetStateDeriv(m%LineList(l), dxdt%states(m%LineStateIs1(l):m%LineStateIsN(l)), m, p) !dt might also be passed for fancy friction models + CALL Line_GetStateDeriv(m%LineList(l), dxdt%states(m%LineStateIs1(l):m%LineStateIsN(l)), m, p, ErrStat, ErrMsg) !dt might also be passed for fancy friction models + if (ErrStat == ErrID_Fatal) then + return + endif END DO ! calculate point dynamics (including contributions from attached lines diff --git a/modules/moordyn/src/MoorDyn_Line.f90 b/modules/moordyn/src/MoorDyn_Line.f90 index b4bc158137..fe1131f32e 100644 --- a/modules/moordyn/src/MoorDyn_Line.f90 +++ b/modules/moordyn/src/MoorDyn_Line.f90 @@ -84,6 +84,12 @@ SUBROUTINE SetupLine (Line, LineProp, p, ErrStat, ErrMsg) ! copy over elasticity data Line%ElasticMod = LineProp%ElasticMod + + if (Line%ElasticMod > 3) then + ErrStat = ErrID_Fatal + ErrMsg = "Line ElasticMod > 3. This is not possible." + RETURN + endif Line%nEApoints = LineProp%nEApoints DO I = 1,Line%nEApoints @@ -1003,12 +1009,15 @@ END SUBROUTINE Line_SetState !-------------------------------------------------------------- !-------------------------------------------------------------- - SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, AnchMtot) + SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p, ErrStat, ErrMsg) !, FairFtot, FairMtot, AnchFtot, AnchMtot) TYPE(MD_Line), INTENT(INOUT) :: Line ! the current Line object Real(DbKi), INTENT(INOUT) :: Xd(:) ! state derivative vector section for this line TYPE(MD_MiscVarType), INTENT(INOUT) :: m ! passing along all mooring objects TYPE(MD_ParameterType), INTENT(IN ) :: p ! Parameters + INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation + CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None + ! Real(DbKi), INTENT( IN ) :: X(:) ! state vector, provided ! Real(DbKi), INTENT( INOUT ) :: Xd(:) ! derivative of state vector, returned ! cahnged to INOUT @@ -1280,10 +1289,8 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, if (Line%ElasticMod == 3) then if (Line%dl_1(I) >= 0.0) then - ! Mean load dependent dynamic stiffness: from combining eqn. 2 and eqn. 10 from paper, taking mean load = k1 delta_L1 / MBL, and solving for k_D using WolframAlpha with following conditions: k_D > k_s, (MBL,alpha,beta,unstrLen,delta_L1) > 0 + ! Mean load dependent dynamic stiffness: from combining eqn. 2 and eqn. 10 from original MD viscoelastic paper, taking mean load = k1 delta_L1 / MBL, and solving for k_D using WolframAlpha with following conditions: k_D > k_s, (MBL,alpha,beta,unstrLen,delta_L1) > 0 EA_D = 0.5 * ((Line%alphaMBL) + (Line%vbeta*Line%dl_1(I)*(Line%EA / Line%l(I))) + Line%EA + sqrt((Line%alphaMBL * Line%alphaMBL) + (2*Line%alphaMBL*(Line%EA / Line%l(I)) * (Line%vbeta*Line%dl_1(I) - Line%l(I))) + ((Line%EA / Line%l(I))*(Line%EA / Line%l(I)) * (Line%vbeta*Line%dl_1(I) + Line%l(I))*(Line%vbeta*Line%dl_1(I) + Line%l(I))))) - ! print*, "Delta L1:", Line%dl_1(I) - ! print*, "EA_D calc:", EA_D else EA_D = Line%alphaMBL ! mean load is considered to be 0 in this case. The second term in the above equation is not valid for delta_L1 < 0. endif @@ -1291,12 +1298,19 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, else if (Line%ElasticMod == 2) then ! constant dynamic stiffness EA_D = Line%EA_D - ! else - ! ErrStat = ErrID_Fatal - ! Errmsg = ' Line%ElasticMod > 3 for line '//trim(num2lstr(Line%IdNum))//' viscoelstic model.' ! TODO: make sure this is the right error level. Do this for every if (Line%ElasticMod > 1) to make sure its never 4 + endif + + if (EA_D == 0.0) then ! Make sure EA != EA_D or else nans, also make sure EA_D != 0 or else nans. + ErrStat = ErrID_Fatal + ErrMsg = "Viscoelastic model: Dynamic stiffness cannot equal zero" + return + else if (EA_D == Line%EA) then + ErrStat = ErrID_Fatal + ErrMsg = "Viscoelastic model: Dynamic stiffness cannot equal static stiffness" + return endif - EA_1 = EA_D*Line%EA/(EA_D - Line%EA)! calculated EA_1 which is the stiffness in series with EA_D that will result in the desired static stiffness of EA_S. TODO: Make sure EA != EA_D or else nans, also make sure EA_D != 0 or else nans. + EA_1 = EA_D*Line%EA/(EA_D - Line%EA)! calculated EA_1 which is the stiffness in series with EA_D that will result in the desired static stiffness of EA_S. dl = Line%lstr(I) - Line%l(I) ! delta l of this segment @@ -1308,12 +1322,6 @@ SUBROUTINE Line_GetStateDeriv(Line, Xd, m, p) !, FairFtot, FairMtot, AnchFtot, MagT = 0.0_DbKi ! cable can't "push" endif - ! print*, "alphaMBL:", Line%alphaMBL - ! print*, "EA_D:", EA_D - ! print*, "EA:", Line%EA - ! print*, "EA_1:", EA_1 - ! print*, "MagT:", MagT - MagTd = Line%BA*ld_1 / Line%l(I) ! compute tension based on static portion (dynamic portion would give same). See eqn. 14 in paper ! update state derivative for static stiffness stretch (last N entries in the state vector) From 36020b717b0334b14dd0ce4958d87026d3157fdc Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Thu, 17 Oct 2024 15:25:19 -0600 Subject: [PATCH 08/10] typo fix in MD viscoelastic --- modules/moordyn/src/MoorDyn.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/moordyn/src/MoorDyn.f90 b/modules/moordyn/src/MoorDyn.f90 index 0124599ca7..9e161eac65 100644 --- a/modules/moordyn/src/MoorDyn.f90 +++ b/modules/moordyn/src/MoorDyn.f90 @@ -661,7 +661,7 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! process damping coefficients CALL SplitByBars(tempString2, N, tempStrings) if (N > m%LineTypeList(l)%ElasticMod) then - CALL SetErrStat( ErrID_Fatal, 'A line type BA entry cannot have more (comma-separated) values its EA entry.', ErrStat, ErrMsg, RoutineName ) + CALL SetErrStat( ErrID_Fatal, 'A line type BA entry cannot have more (bar-separated) values its EA entry.', ErrStat, ErrMsg, RoutineName ) CALL CleanUp() else if (N==2) then ! visco-elastic case when two BA values provided read(tempStrings(2), *) m%LineTypeList(l)%BA_D From bab4d457d6ead0b2a4b2a42c9ee88b6174df7b4e Mon Sep 17 00:00:00 2001 From: RyanDavies19 Date: Thu, 17 Oct 2024 15:34:49 -0600 Subject: [PATCH 09/10] One more typo fix --- modules/moordyn/src/MoorDyn.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/moordyn/src/MoorDyn.f90 b/modules/moordyn/src/MoorDyn.f90 index 9e161eac65..fdc69610ba 100644 --- a/modules/moordyn/src/MoorDyn.f90 +++ b/modules/moordyn/src/MoorDyn.f90 @@ -661,7 +661,7 @@ SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! process damping coefficients CALL SplitByBars(tempString2, N, tempStrings) if (N > m%LineTypeList(l)%ElasticMod) then - CALL SetErrStat( ErrID_Fatal, 'A line type BA entry cannot have more (bar-separated) values its EA entry.', ErrStat, ErrMsg, RoutineName ) + CALL SetErrStat( ErrID_Fatal, 'A line type BA entry cannot have more (bar-separated) values than its EA entry.', ErrStat, ErrMsg, RoutineName ) CALL CleanUp() else if (N==2) then ! visco-elastic case when two BA values provided read(tempStrings(2), *) m%LineTypeList(l)%BA_D From a15e465ac652ad3fec773872aa844055ed36473f Mon Sep 17 00:00:00 2001 From: andrew-platt Date: Mon, 21 Oct 2024 12:18:19 -0600 Subject: [PATCH 10/10] Revert incidental changes to Registr_NWTC_Library --- .../src/Registry_NWTC_Library.txt | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/modules/nwtc-library/src/Registry_NWTC_Library.txt b/modules/nwtc-library/src/Registry_NWTC_Library.txt index a4cd50c404..d7d4de29ee 100644 --- a/modules/nwtc-library/src/Registry_NWTC_Library.txt +++ b/modules/nwtc-library/src/Registry_NWTC_Library.txt @@ -6,38 +6,38 @@ #............................................................. -typedef NWTC_Library ProgDesc CHARACTER(99) Name - - - "Name of the program or module" -typedef ^ ^ CHARACTER(99) Ver - - - "Version number of the program or module" -typedef ^ ^ CHARACTER(24) Date - - - "String containing date module was last updated" - -typedef NWTC_Library FASTdataType CHARACTER(1024) File - - - "Name of the FAST-style binary file" -typedef ^ ^ CHARACTER(1024) Descr - - - "String describing file" -typedef ^ ^ IntKi NumChans - - - "Number of output channels in this binary file (not including the time channel)" -typedef ^ ^ IntKi NumRecs - - - "Number of records (rows) of data in the file" -typedef ^ ^ DbKi TimeStep - - - "Time step for evenly-spaced data in the output file (when NumRecs is not allo" -typedef ^ ^ CHARACTER(ChanLen) ChanNames {:} - - "Strings describing the names of the channels from the binary file (including the time channel)" -typedef ^ ^ CHARACTER(ChanLen) ChanUnits {:} - - "Strings describing the units of the channels from the binary file (including the time channel)" -typedef ^ ^ ReKi Data {:}{:} - - "numeric data (rows and columns) from the binary file, including the time channel" - -typedef NWTC_Library OutParmType IntKi Indx - - - "An index into AllOuts array where this channel is computed/stored" -typedef ^ ^ CHARACTER(ChanLen) Name - - - "Name of the output channel" -typedef ^ ^ CHARACTER(ChanLen) Units - - - "Units this channel is specified in" -typedef ^ ^ IntKi SignM - - - "Multiplier for output channel; usually -1 (minus) or 0 (invalid channel)" - -typedef NWTC_Library FileInfoType IntKi NumLines -typedef ^ ^ IntKi NumFiles -typedef ^ ^ IntKi FileLine {:} -typedef ^ ^ IntKi FileIndx {:} +typedef NWTC_Library ProgDesc CHARACTER(99) Name - - - "Name of the program or module" +typedef ^ ^ CHARACTER(99) Ver - - - "Version number of the program or module" +typedef ^ ^ CHARACTER(24) Date - - - "String containing date module was last updated" + +typedef NWTC_Library FASTdataType CHARACTER(1024) File - - - "Name of the FAST-style binary file" +typedef ^ ^ CHARACTER(1024) Descr - - - "String describing file" +typedef ^ ^ IntKi NumChans - - - "Number of output channels in this binary file (not including the time channel)" +typedef ^ ^ IntKi NumRecs - - - "Number of records (rows) of data in the file" +typedef ^ ^ DbKi TimeStep - - - "Time step for evenly-spaced data in the output file (when NumRecs is not allo" +typedef ^ ^ CHARACTER(ChanLen) ChanNames {:} - - "Strings describing the names of the channels from the binary file (including the time channel)" +typedef ^ ^ CHARACTER(ChanLen) ChanUnits {:} - - "Strings describing the units of the channels from the binary file (including the time channel)" +typedef ^ ^ ReKi Data {:}{:} - - "numeric data (rows and columns) from the binary file, including the time channel" + +typedef NWTC_Library OutParmType IntKi Indx - - - "An index into AllOuts array where this channel is computed/stored" +typedef ^ ^ CHARACTER(ChanLen) Name - - - "Name of the output channel" +typedef ^ ^ CHARACTER(ChanLen) Units - - - "Units this channel is specified in" +typedef ^ ^ IntKi SignM - - - "Multiplier for output channel; usually -1 (minus) or 0 (invalid channel)" + +typedef NWTC_Library FileInfoType IntKi NumLines +typedef ^ ^ IntKi NumFiles +typedef ^ ^ IntKi FileLine {:} +typedef ^ ^ IntKi FileIndx {:} typedef ^ ^ CHARACTER(MaxFileInfoLineLen) FileList {:} typedef ^ ^ CHARACTER(MaxFileInfoLineLen) Lines {:} -typedef NWTC_Library Quaternion ReKi q0 -typedef ^ ^ ReKi v {3} +typedef NWTC_Library Quaternion ReKi q0 +typedef ^ ^ ReKi v {3} -typedef NWTC_Library NWTC_RandomNumber_ParameterType IntKi pRNG -typedef ^ ^ IntKi RandSeed {3} -typedef ^ ^ IntKi RandSeedAry {:} -typedef ^ ^ CHARACTER(6) RNG_type +typedef NWTC_Library NWTC_RandomNumber_ParameterType IntKi pRNG +typedef ^ ^ IntKi RandSeed {3} +typedef ^ ^ IntKi RandSeedAry {:} +typedef ^ ^ CHARACTER(6) RNG_type #------------------------------------------------------------------------------- # Module Variables @@ -133,22 +133,22 @@ typedef ^ ^ IntKi DstMaps : - - #BJJ: the following three types will actually be placed in the ModMesh_Mapping.f90 file instead of NWTC_Library_Types.f90 -typedef NWTC_Library MapType IntKi OtherMesh_Element - - - "Node (for point meshes) or Element (for line2 meshes) number on other mesh; for loads, other mesh is Dest, for motions/scalars, other mesh is Src" - +typedef NWTC_Library MapType IntKi OtherMesh_Element - - - "Node (for point meshes) or Element (for line2 meshes) number on other mesh; for loads, other mesh is Dest, for motions/scalars, other mesh is Src" typedef ^ ^ R8Ki distance - - - "Magnitude of couple_arm" m typedef ^ ^ R8Ki couple_arm {3} - - "Vector between a point and node 1 of an element (p_ODR - p_OSR)" m typedef ^ ^ R8Ki shape_fn {2} - - "shape functions: 1-D element-level location [0,1] based on closest-line projection of point" - -typedef NWTC_Library MeshMapLinearizationType R8Ki mi {:}{:} - - "block matrix of motions that reflects identity (i.e., solely the mapping of one quantity to itself on another mesh)" -typedef ^ ^ R8Ki fx_p {:}{:} - - "block matrix of motions that reflects skew-symmetric (cross-product) matrix" -typedef ^ ^ R8Ki tv_uD {:}{:} - - "block matrix of translational velocity that is multiplied by destination translational displacement" -typedef ^ ^ R8Ki tv_uS {:}{:} - - "block matrix of translational velocity that is multiplied by source translational displacement" -typedef ^ ^ R8Ki ta_uD {:}{:} - - "block matrix of translational acceleration that is multiplied by destination translational displacement" -typedef ^ ^ R8Ki ta_uS {:}{:} - - "block matrix of translational acceleration that is multiplied by source translational displacement" -typedef ^ ^ R8Ki ta_rv {:}{:} - - "block matrix of translational acceleration that is multiplied by omega (RotationVel)" -typedef ^ ^ R8Ki li {:}{:} - - "block matrix of loads that reflects identity (i.e., solely the mapping on one quantity to itself on another mesh)" -typedef ^ ^ R8Ki M_uS {:}{:} - - "block matrix of moment that is multiplied by Source u (translationDisp)" -typedef ^ ^ R8Ki M_uD {:}{:} - - "block matrix of moment that is multiplied by Destination u (translationDisp)" -typedef ^ ^ R8Ki M_f {:}{:} - - "block matrix of moment that is multiplied by force" +typedef NWTC_Library MeshMapLinearizationType R8Ki mi {:}{:} - - "block matrix of motions that reflects identity (i.e., solely the mapping of one quantity to itself on another mesh)" +typedef ^ ^ R8Ki fx_p {:}{:} - - "block matrix of motions that reflects skew-symmetric (cross-product) matrix" +typedef ^ ^ R8Ki tv_uD {:}{:} - - "block matrix of translational velocity that is multiplied by destination translational displacement" +typedef ^ ^ R8Ki tv_uS {:}{:} - - "block matrix of translational velocity that is multiplied by source translational displacement" +typedef ^ ^ R8Ki ta_uD {:}{:} - - "block matrix of translational acceleration that is multiplied by destination translational displacement" +typedef ^ ^ R8Ki ta_uS {:}{:} - - "block matrix of translational acceleration that is multiplied by source translational displacement" +typedef ^ ^ R8Ki ta_rv {:}{:} - - "block matrix of translational acceleration that is multiplied by omega (RotationVel)" +typedef ^ ^ R8Ki li {:}{:} - - "block matrix of loads that reflects identity (i.e., solely the mapping on one quantity to itself on another mesh)" +typedef ^ ^ R8Ki M_uS {:}{:} - - "block matrix of moment that is multiplied by Source u (translationDisp)" +typedef ^ ^ R8Ki M_uD {:}{:} - - "block matrix of moment that is multiplied by Destination u (translationDisp)" +typedef ^ ^ R8Ki M_f {:}{:} - - "block matrix of moment that is multiplied by force" typedef NWTC_Library MeshMapType MapType MapLoads {:} - - "mapping data structure for load fields on the mesh" typedef ^ ^ MapType MapMotions {:} - - "mapping data structure for motion and/or scalar fields on the mesh" @@ -160,6 +160,6 @@ typedef ^ ^ R8Ki DisplacedPo typedef ^ ^ R8Ki LoadLn2_A_Mat {:}{:} - - "The 3-components of the forces for each node of an element in the point-to-line load mapping (for each element)" typedef ^ ^ R8Ki LoadLn2_F {:}{:} - - "The 6-by-6 matrix that makes up the diagonal of the [A 0; B A] matrix in the point-to-line load mapping" typedef ^ ^ R8Ki LoadLn2_M {:}{:} - - "The 3-components of the moments for each node of an element in the point-to-line load mapping (for each element)" -typedef ^ ^ MeshMapLinearizationType dM -#typedef ^ ^ MeshType Lumped_Points_Dest - - - "temporary mesh for debugging the lumped values in the line2-to-line2" +typedef ^ ^ MeshMapLinearizationType dM +#typedef ^ ^ MeshType Lumped_Points_Dest - - - "temporary mesh for debugging the lumped values in the line2-to-line2"