Skip to content

Commit 2002cf7

Browse files
authored
Merge pull request #3115 from deslaughter/mr_reverse_rotor
Add loose coupling option to dev-tc, update regression tests
2 parents 82dc830 + e5cb010 commit 2002cf7

File tree

18 files changed

+185
-69
lines changed

18 files changed

+185
-69
lines changed

docs/source/user/api_change.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ Added in OpenFAST `dev`
3434
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3535
Module Line Flag Name Example Value
3636
============================================= ======== ==================== ========================================================================================================================================================================================================
37-
OpenFAST 16 NRotors 2 NRotors - Number of rotors in turbine (-)
38-
OpenFAST 50 ---------------------- INPUT FILES Rotor 2 -------------------------------------
39-
OpenFAST 51 EDFile "ElastoDyn.dat" EDFile - Name of file containing ElastoDyn input parameters (quoted string)
40-
OpenFAST 52 BDBldFile(1) "BeamDyn.dat" BDBldFile(1) - Name of file containing BeamDyn input parameters for blade 1 (quoted string)
41-
OpenFAST 53 BDBldFile(2) "BeamDyn.dat" BDBldFile(2) - Name of file containing BeamDyn input parameters for blade 2 (quoted string)
42-
OpenFAST 54 BDBldFile(3) "BeamDyn.dat" BDBldFile(3) - Name of file containing BeamDyn input parameters for blade 3 (quoted string)
43-
OpenFAST 55 ServoFile "ServoDyn_R2.dat" ServoFile - Name of file containing control and electrical-drive input parameters (quoted string)
44-
OpenFAST 56 MirrorRotor False MirrorRotor - Use CW rotor definition definition files for a CCW rotor (-)
37+
OpenFAST 8 ModCoupling 3 ModCoupling - Module coupling method (switch) {1=loose; 2=tight with fixed Jacobian updates (DT_UJac); 3=tight with automatic Jacobian updates}
38+
OpenFAST 17 NRotors 2 NRotors - Number of rotors in turbine (-)
39+
OpenFAST 28 MirrorRotor F MirrorRotor - Flag to reverse rotor rotation direction [1 to NRotors] {F=Normal, T=Mirror}
40+
OpenFAST 52 ---------------------- INPUT FILES Rotor 2 -------------------------------------
41+
OpenFAST 53 EDFile "ElastoDyn.dat" EDFile - Name of file containing ElastoDyn input parameters (quoted string)
42+
OpenFAST 54 BDBldFile(1) "BeamDyn.dat" BDBldFile(1) - Name of file containing BeamDyn input parameters for blade 1 (quoted string)
43+
OpenFAST 55 BDBldFile(2) "BeamDyn.dat" BDBldFile(2) - Name of file containing BeamDyn input parameters for blade 2 (quoted string)
44+
OpenFAST 56 BDBldFile(3) "BeamDyn.dat" BDBldFile(3) - Name of file containing BeamDyn input parameters for blade 3 (quoted string)
45+
OpenFAST 57 ServoFile "ServoDyn_R2.dat" ServoFile - Name of file containing control and electrical-drive input parameters (quoted string)
4546
AeroDyn blade file t_c 0.8651 [additional column in *Blade Properties* table]
4647
AeroDyn blade file BlCpn 1.0 [additional column in *Blade Properties* table]
4748
AeroDyn blade file BlCpt 1.0 [additional column in *Blade Properties* table]

modules/nwtc-library/src/NWTC_Library_Types.f90

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ MODULE NWTC_Library_Types
6363
INTEGER(IntKi), PUBLIC, PARAMETER :: VF_DerivOrder2 = 4096 ! Variable is derivative order 2 in linearization file [-]
6464
INTEGER(IntKi), PUBLIC, PARAMETER :: VF_Mapping = 8192 ! Variable is used in a module-to-module transfer mapping [-]
6565
INTEGER(IntKi), PUBLIC, PARAMETER :: VF_NoLin = 16384 ! Variable is used in a module-to-module transfer mapping [-]
66-
INTEGER(IntKi), PUBLIC, PARAMETER :: VC_None = 0 ! [-]
67-
INTEGER(IntKi), PUBLIC, PARAMETER :: VC_Tight = 1 ! [-]
68-
INTEGER(IntKi), PUBLIC, PARAMETER :: VC_Option1 = 2 ! [-]
69-
INTEGER(IntKi), PUBLIC, PARAMETER :: VC_Option2 = 3 ! [-]
66+
INTEGER(IntKi), PUBLIC, PARAMETER :: MC_None = 0 ! [-]
67+
INTEGER(IntKi), PUBLIC, PARAMETER :: MC_Tight = 1 ! [-]
68+
INTEGER(IntKi), PUBLIC, PARAMETER :: MC_Option1 = 2 ! [-]
69+
INTEGER(IntKi), PUBLIC, PARAMETER :: MC_Option2 = 4 ! [-]
70+
INTEGER(IntKi), PUBLIC, PARAMETER :: MC_Post = 8 ! [-]
7071
! ========= ProgDesc =======
7172
TYPE, PUBLIC :: ProgDesc
7273
CHARACTER(99) :: Name !< Name of the program or module [-]
@@ -200,6 +201,7 @@ MODULE NWTC_Library_Types
200201
INTEGER(IntKi) :: Ins = 0 !< Module instance number [-]
201202
INTEGER(IntKi) :: iRotor = 0 !< Module rotor number [-]
202203
INTEGER(IntKi) :: SubSteps = 0 !< Module number of substeps per solver time step [-]
204+
INTEGER(IntKi) :: Category = 0 !< Module category tight, option 1, option 2 [-]
203205
REAL(R8Ki) :: DT = 0 !< Module time step [-]
204206
TYPE(ModVarsType) :: Vars !< Module variables type [-]
205207
TYPE(ModLinType) :: Lin !< Module linearization arrays and matrices [-]
@@ -1465,6 +1467,7 @@ subroutine NWTC_Library_CopyModDataType(SrcModDataTypeData, DstModDataTypeData,
14651467
DstModDataTypeData%Ins = SrcModDataTypeData%Ins
14661468
DstModDataTypeData%iRotor = SrcModDataTypeData%iRotor
14671469
DstModDataTypeData%SubSteps = SrcModDataTypeData%SubSteps
1470+
DstModDataTypeData%Category = SrcModDataTypeData%Category
14681471
DstModDataTypeData%DT = SrcModDataTypeData%DT
14691472
call NWTC_Library_CopyModVarsType(SrcModDataTypeData%Vars, DstModDataTypeData%Vars, CtrlCode, ErrStat2, ErrMsg2)
14701473
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
@@ -1500,6 +1503,7 @@ subroutine NWTC_Library_PackModDataType(RF, Indata)
15001503
call RegPack(RF, InData%Ins)
15011504
call RegPack(RF, InData%iRotor)
15021505
call RegPack(RF, InData%SubSteps)
1506+
call RegPack(RF, InData%Category)
15031507
call RegPack(RF, InData%DT)
15041508
call NWTC_Library_PackModVarsType(RF, InData%Vars)
15051509
call NWTC_Library_PackModLinType(RF, InData%Lin)
@@ -1517,6 +1521,7 @@ subroutine NWTC_Library_UnPackModDataType(RF, OutData)
15171521
call RegUnpack(RF, OutData%Ins); if (RegCheckErr(RF, RoutineName)) return
15181522
call RegUnpack(RF, OutData%iRotor); if (RegCheckErr(RF, RoutineName)) return
15191523
call RegUnpack(RF, OutData%SubSteps); if (RegCheckErr(RF, RoutineName)) return
1524+
call RegUnpack(RF, OutData%Category); if (RegCheckErr(RF, RoutineName)) return
15201525
call RegUnpack(RF, OutData%DT); if (RegCheckErr(RF, RoutineName)) return
15211526
call NWTC_Library_UnpackModVarsType(RF, OutData%Vars) ! Vars
15221527
call NWTC_Library_UnpackModLinType(RF, OutData%Lin) ! Lin

modules/nwtc-library/src/Registry_NWTC_Library.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ param ^ - IntKi VF_DerivOrder2 - 4096 -
7474
param ^ - IntKi VF_Mapping - 8192 - "Variable is used in a module-to-module transfer mapping" -
7575
param ^ - IntKi VF_NoLin - 16384 - "Variable is used in a module-to-module transfer mapping" -
7676

77-
param ^ - IntKi VC_None - 0 - "" -
78-
param ^ - IntKi VC_Tight - 1 - "" -
79-
param ^ - IntKi VC_Option1 - 2 - "" -
80-
param ^ - IntKi VC_Option2 - 3 - "" -
77+
param ^ - IntKi MC_None - 0 - "" -
78+
param ^ - IntKi MC_Tight - 1 - "" -
79+
param ^ - IntKi MC_Option1 - 2 - "" -
80+
param ^ - IntKi MC_Option2 - 4 - "" -
81+
param ^ - IntKi MC_Post - 8 - "" -
8182

8283
typedef ^ DatLoc IntKi Num - 0 - "Mesh number in module"
8384
typedef ^ ^ IntKi i1 - 0 - "Index 1"
@@ -144,6 +145,7 @@ typedef ^ ^ IntKi ID - 0 -
144145
typedef ^ ^ IntKi Ins - 0 - "Module instance number" -
145146
typedef ^ ^ IntKi iRotor - 0 - "Module rotor number" -
146147
typedef ^ ^ IntKi SubSteps - 0 - "Module number of substeps per solver time step" -
148+
typedef ^ ^ IntKi Category - 0 - "Module category tight, option 1, option 2" -
147149
typedef ^ ^ R8Ki DT - 0 - "Module time step" -
148150
typedef ^ ^ ModVarsType Vars - - - "Module variables type" -
149151
typedef ^ ^ ModLinType Lin - - - "Module linearization arrays and matrices"

modules/nwtc-library/src/Registry_NWTC_Library_base.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ param ^ - IntKi VF_DerivOrder2 - 4096 -
7474
param ^ - IntKi VF_Mapping - 8192 - "Variable is used in a module-to-module transfer mapping" -
7575
param ^ - IntKi VF_NoLin - 16384 - "Variable is used in a module-to-module transfer mapping" -
7676

77-
param ^ - IntKi VC_None - 0 - "" -
78-
param ^ - IntKi VC_Tight - 1 - "" -
79-
param ^ - IntKi VC_Option1 - 2 - "" -
80-
param ^ - IntKi VC_Option2 - 3 - "" -
77+
param ^ - IntKi MC_None - 0 - "" -
78+
param ^ - IntKi MC_Tight - 1 - "" -
79+
param ^ - IntKi MC_Option1 - 2 - "" -
80+
param ^ - IntKi MC_Option2 - 4 - "" -
81+
param ^ - IntKi MC_Post - 8 - "" -
8182

8283
typedef ^ DatLoc IntKi Num - 0 - "Mesh number in module"
8384
typedef ^ ^ IntKi i1 - 0 - "Index 1"
@@ -144,6 +145,7 @@ typedef ^ ^ IntKi ID - 0 -
144145
typedef ^ ^ IntKi Ins - 0 - "Module instance number" -
145146
typedef ^ ^ IntKi iRotor - 0 - "Module rotor number" -
146147
typedef ^ ^ IntKi SubSteps - 0 - "Module number of substeps per solver time step" -
148+
typedef ^ ^ IntKi Category - 0 - "Module category tight, option 1, option 2" -
147149
typedef ^ ^ R8Ki DT - 0 - "Module time step" -
148150
typedef ^ ^ ModVarsType Vars - - - "Module variables type" -
149151
typedef ^ ^ ModLinType Lin - - - "Module linearization arrays and matrices"

modules/openfast-library/src/FAST_Funcs.f90

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ module FAST_Funcs
4040
use BeamDyn, only: BD_JacobianPInput, &
4141
BD_JacobianPContState, &
4242
BD_CalcContStateDeriv, &
43+
BD_UpdateStates, &
4344
BD_CalcOutput, &
4445
BD_End
4546

4647
use ElastoDyn, only: ED_JacobianPInput, &
4748
ED_JacobianPContState, &
4849
ED_CalcContStateDeriv, &
50+
ED_UpdateStates, &
4951
ED_CalcOutput, &
5052
ED_End, &
5153
ED_PackExtInputAry
@@ -131,6 +133,7 @@ module FAST_Funcs
131133
use SubDyn, only: SD_JacobianPInput, &
132134
SD_JacobianPContState, &
133135
SD_CalcContStateDeriv, &
136+
SD_UpdateStates, &
134137
SD_CalcOutput, &
135138
SD_End
136139

@@ -435,6 +438,9 @@ subroutine FAST_UpdateStates(ModData, t_initial, n_t_global, T, ErrStat, ErrMsg)
435438
ErrStat = ErrID_None
436439
ErrMsg = ''
437440

441+
! Skip modules in the tight coupling category because the solver handles state updates
442+
if (iand(ModData%Category, MC_Tight) /= 0) return
443+
438444
! Select based on module ID
439445
select case (ModData%ID)
440446

@@ -472,10 +478,32 @@ subroutine FAST_UpdateStates(ModData, t_initial, n_t_global, T, ErrStat, ErrMsg)
472478
end do
473479

474480
case (Module_BD)
475-
! State update is handled by tight coupling solver
481+
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
482+
if (Failed()) return
483+
484+
do j_ss = 1, ModData%SubSteps
485+
n_t_module = n_t_global*ModData%SubSteps + j_ss - 1
486+
t_module = n_t_module*ModData%DT + t_initial
487+
call BD_UpdateStates(t_module, n_t_module, T%BD%Input(1:,ModData%Ins), T%BD%InputTimes(:,ModData%Ins), T%BD%p(ModData%Ins), &
488+
T%BD%x(ModData%Ins, STATE_PRED), T%BD%xd(ModData%Ins, STATE_PRED), &
489+
T%BD%z(ModData%Ins, STATE_PRED), T%BD%OtherSt(ModData%Ins, STATE_PRED), &
490+
T%BD%m(ModData%Ins), ErrStat2, ErrMsg2)
491+
if (Failed()) return
492+
end do
476493

477494
case (Module_ED)
478-
! State update is handled by tight coupling solver
495+
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
496+
if (Failed()) return
497+
498+
do j_ss = 1, ModData%SubSteps
499+
n_t_module = n_t_global*ModData%SubSteps + j_ss - 1
500+
t_module = n_t_module*ModData%DT + t_initial
501+
call ED_UpdateStates(t_module, n_t_module, T%ED%Input(1:,ModData%Ins), T%ED%InputTimes(:,ModData%Ins), T%ED%p(ModData%Ins), &
502+
T%ED%x(ModData%Ins, STATE_PRED), T%ED%xd(ModData%Ins, STATE_PRED), &
503+
T%ED%z(ModData%Ins, STATE_PRED), T%ED%OtherSt(ModData%Ins, STATE_PRED), &
504+
T%ED%m(ModData%Ins), ErrStat2, ErrMsg2)
505+
if (Failed()) return
506+
end do
479507

480508
case (Module_SED)
481509
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
@@ -599,8 +627,6 @@ subroutine FAST_UpdateStates(ModData, t_initial, n_t_global, T, ErrStat, ErrMsg)
599627
if (Failed()) return
600628
end do
601629

602-
! case (Module_OpFM)
603-
604630
case (Module_Orca)
605631
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
606632
if (Failed()) return
@@ -616,7 +642,18 @@ subroutine FAST_UpdateStates(ModData, t_initial, n_t_global, T, ErrStat, ErrMsg)
616642
end do
617643

618644
case (Module_SD)
619-
! State update is handled by tight coupling solver
645+
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
646+
if (Failed()) return
647+
648+
do j_ss = 1, ModData%SubSteps
649+
n_t_module = n_t_global*ModData%SubSteps + j_ss - 1
650+
t_module = n_t_module*ModData%DT + t_initial
651+
call SD_UpdateStates(t_module, n_t_module, T%SD%Input(1:), T%SD%InputTimes, T%SD%p, &
652+
T%SD%x(STATE_PRED), T%SD%xd(STATE_PRED), &
653+
T%SD%z(STATE_PRED), T%SD%OtherSt(STATE_PRED), &
654+
T%SD%m, ErrStat2, ErrMsg2)
655+
if (Failed()) return
656+
end do
620657

621658
case (Module_SeaSt)
622659
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)

modules/openfast-library/src/FAST_Registry.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ usefrom ExtPtfm_MCKF_Registry.txt
3737
# MODULE IDENTIFIERS:
3838
# NOTE WELL: The order of these modules is the order they get written to the output file;
3939
# Make sure the module identifiers start at 1 and that this order matches the orders in WrOutputLine and FAST_InitOutput!!!
40-
param FAST - INTEGER Module_Unknown - -1 - "Unknown" -
40+
param FAST - INTEGER LooseCoupling - 1 - "Loose Module Coupling" -
41+
param FAST - INTEGER TightCouplingFixed - 2 - "Tight Module Coupling with fixed Jacobian updates (DT_UJac)" -
42+
param FAST - INTEGER TightCouplingAdaptive - 3 - "Tight Module Coupling with adaptive Jacobian updates" -
43+
# Module Identifiers
44+
param ^ - INTEGER Module_Unknown - -1 - "Unknown" -
4145
param ^ - INTEGER Module_None - 0 - "No module selected" -
4246
param ^ - INTEGER Module_Glue - 1 - "Glue code" -
4347
param ^ - INTEGER Module_IfW - 2 - "InflowWind" -
@@ -113,12 +117,13 @@ typedef ^ FAST_ParameterType IntKi NumCrctn - - - "Number of correction iteratio
113117
typedef ^ FAST_ParameterType IntKi KMax - - - "Maximum number of input-output-solve or nonlinear solve residual equation iterations (KMax >= 1) [>0]" -
114118
typedef ^ FAST_ParameterType IntKi numIceLegs - - - "number of suport-structure legs in contact with ice (IceDyn coupling)" -
115119
typedef ^ FAST_ParameterType IntKi RotNumBld : - - "number of blades in each rotor" -
116-
typedef ^ FAST_ParameterType logical RotMirror : - - "Array of flags indicating if rotor rotation should be mirrored (true=mirror)" -
120+
typedef ^ FAST_ParameterType logical MirrorRotor : - - "Array of flags indicating if rotor rotation should be mirrored (true=mirror)" -
117121
typedef ^ FAST_ParameterType IntKi NumBD - - - "number of BeamDyn instances" -
118122
typedef ^ FAST_ParameterType IntKi BDRotMap : - - "array mapping BeamDyn instance to rotor number" -
119123
typedef ^ FAST_ParameterType IntKi BDBldMap : - - "array mapping BeamDyn instance to blade number" -
120124
typedef ^ FAST_ParameterType LOGICAL BD_OutputSibling - - - "flag to determine if BD input is sibling of output mesh" -
121125
# Data for TC Solver:
126+
typedef ^ FAST_ParameterType IntKi ModCoupling - - - "Module coupling type {1=loose; 2=tight with fixed Jacobian updates (DT_UJac); 3=tight with automatic Jacobian updates}" -
122127
typedef ^ FAST_ParameterType DbKi RhoInf - - - "Numerical damping parameter for tight coupling generalized-alpha integrator (-) [0.0 to 1.0]" -
123128
typedef ^ FAST_ParameterType DbKi ConvTol - - - "Convergence iteration error tolerance for tight coupling generalized alpha integrator (-)" -
124129
typedef ^ FAST_ParameterType IntKi MaxConvIter - - - "Maximum number of convergence iterations for tight coupling generalized alpha integrator (-)" -

0 commit comments

Comments
 (0)