Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServoDyn and glue code bug fixes #46

Merged
5 commits merged into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules-local/fast-library/src/FAST_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ typedef ^ ^ SrvD_OutputType y - - - "System outputs"
typedef ^ ^ SrvD_MiscVarType m - - - "Misc (optimization) variables not associated with time"
typedef ^ ^ SrvD_InputType Input {:} - - "Array of inputs associated with InputTimes"
typedef ^ ^ DbKi InputTimes {:} - - "Array of times associated with Input Array"
typedef ^ ^ SrvD_OutputType y_prev - - - "previous outputs; a hack because this basically makes them states. Used in BladedDLL"

# ..... AeroDyn14 data .......................................................................................................
typedef FAST AeroDyn14_Data AD14_ContinuousStateType x {2} - - "Continuous states"
Expand Down
4 changes: 2 additions & 2 deletions modules-local/fast-library/src/FAST_Solver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4471,7 +4471,7 @@ SUBROUTINE CalcOutputs_And_SolveForInputs( n_t_global, this_time, this_state, ca


IF ( p_FAST%CompServo == Module_SrvD ) THEN
CALL SrvD_InputSolve( p_FAST, m_FAST, SrvD%Input(1), ED%Output(1), IfW%y, OpFM%y, BD%y, MeshmapData, ErrStat2, ErrMsg2 ) ! At initialization, we don't have a previous value, so we'll use the guess inputs instead. note that this violates the framework.... (done for the Bladed DLL)
CALL SrvD_InputSolve( p_FAST, m_FAST, SrvD%Input(1), ED%Output(1), IfW%y, OpFM%y, BD%y, MeshmapData, ErrStat2, ErrMsg2, SrvD%y ) ! At initialization, we don't have a previous value, so we'll use the guess inputs instead. note that this violates the framework.... (done for the Bladed DLL)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF

Expand Down Expand Up @@ -4790,7 +4790,7 @@ SUBROUTINE SolveOption2(this_time, this_state, p_FAST, m_FAST, ED, BD, AD14, AD,
IF ( firstCall ) THEN
CALL SrvD_InputSolve( p_FAST, m_FAST, SrvD%Input(1), ED%Output(1), IfW%y, OpFM%y, BD%y, MeshMapData, ErrStat2, ErrMsg2 ) ! At initialization, we don't have a previous value, so we'll use the guess inputs instead. note that this violates the framework.... (done for the Bladed DLL)
ELSE
CALL SrvD_InputSolve( p_FAST, m_FAST, SrvD%Input(1), ED%Output(1), IfW%y, OpFM%y, BD%y, MeshMapData, ErrStat2, ErrMsg2, SrvD%y_prev )
CALL SrvD_InputSolve( p_FAST, m_FAST, SrvD%Input(1), ED%Output(1), IfW%y, OpFM%y, BD%y, MeshMapData, ErrStat2, ErrMsg2, SrvD%y ) ! note that this uses the outputs from the previous step, violating the framework for the Bladed DLL (if SrvD%y is used in another way, this will need to be changed)
END IF
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )

Expand Down
56 changes: 22 additions & 34 deletions modules-local/fast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -621,29 +621,6 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
RETURN
END IF

! ........................
! some checks for AeroDyn inputs with the high-speed shaft brake hack in ElastoDyn:
! (DO NOT COPY THIS CODE!)
! ........................
IF ( p_FAST%CompServo == Module_SrvD ) THEN

! bjj: this is a hack to get high-speed shaft braking in FAST v8

IF ( InitOutData_SrvD%UseHSSBrake ) THEN
IF ( p_FAST%CompAero == Module_AD14 ) THEN
IF ( AD14%p%DYNINFL ) THEN
CALL SetErrStat(ErrID_Fatal,'AeroDyn v14 "DYNINFL" InfModel is invalid for models with high-speed shaft braking.',ErrStat,ErrMsg,RoutineName)
END IF
END IF


IF ( ED%p%method == 1 ) THEN ! bjj: should be using ElastoDyn's Method_ABM4 Method_AB4 parameters
CALL SetErrStat(ErrID_Fatal,'ElastoDyn must use the AB4 or ABM4 integration method to implement high-speed shaft braking.',ErrStat,ErrMsg,RoutineName)
END IF
END IF

END IF

! ........................
! some checks for AeroDyn14's Dynamic Inflow with Mean Wind Speed from InflowWind:
! (DO NOT COPY THIS CODE!)
Expand Down Expand Up @@ -704,10 +681,7 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
CALL SetModuleSubstepTime(Module_SrvD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)

!! initialize y%ElecPwr and y%GenTq because they are one timestep different (used as input for the next step)
!!bjj: perhaps this will require some better thought so that these two fields of y_SrvD_prev don't get set here in the glue code
!CALL SrvD_CopyOutput( SrvD%y, SrvD%y_prev, MESH_NEWCOPY, ErrStat, ErrMsg)
!
!! initialize SrvD%y%ElecPwr and SrvD%y%GenTq because they are one timestep different (used as input for the next step)

if (allocated(InitOutData_SrvD%LinNames_y)) call move_alloc(InitOutData_SrvD%LinNames_y,y_FAST%Lin%Modules(MODULE_SrvD)%Names_y )
if (allocated(InitOutData_SrvD%LinNames_u)) call move_alloc(InitOutData_SrvD%LinNames_u,y_FAST%Lin%Modules(MODULE_SrvD)%Names_u )
Expand All @@ -718,6 +692,27 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
CALL Cleanup()
RETURN
END IF

! ........................
! some checks for AeroDyn inputs with the high-speed shaft brake hack in ElastoDyn:
! (DO NOT COPY THIS CODE!)
! ........................
! bjj: this is a hack to get high-speed shaft braking in FAST v8

IF ( InitOutData_SrvD%UseHSSBrake ) THEN
IF ( p_FAST%CompAero == Module_AD14 ) THEN
IF ( AD14%p%DYNINFL ) THEN
CALL SetErrStat(ErrID_Fatal,'AeroDyn v14 "DYNINFL" InfModel is invalid for models with high-speed shaft braking.',ErrStat,ErrMsg,RoutineName)
END IF
END IF


IF ( ED%p%method == 1 ) THEN ! bjj: should be using ElastoDyn's Method_RK4 parameter
CALL SetErrStat(ErrID_Fatal,'ElastoDyn must use the AB4 or ABM4 integration method to implement high-speed shaft braking.',ErrStat,ErrMsg,RoutineName)
END IF
END IF


END IF

! ........................
Expand Down Expand Up @@ -4231,13 +4226,6 @@ SUBROUTINE FAST_InitIOarrays( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, A
END IF ! CompIce


! ServoDyn: copy current outputs to store as previous outputs for next step
!bjj: @todo: FIX ME (note that copying SrvD outputs here is a violation of the framework as this is basically a state,
! but it's only used for the GH-Bladed DLL, which itself violates the framework....
CALL SrvD_CopyOutput ( SrvD%y, SrvD%y_prev, MESH_NEWCOPY, ErrStat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )


END SUBROUTINE FAST_InitIOarrays
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that calls FAST_Solution for one instance of a Turbine data structure. This is a separate subroutine so that the FAST
Expand Down