Skip to content

Commit

Permalink
Handling of Paths for SrvD UserSubs Input Files
Browse files Browse the repository at this point in the history
@rdamiani pointed out in issue #2059 that the existing method for handling file paths with `UserSubs` is difficult as it requires putting all the user input files in the same location as the ServoDyn file.  This commit is from recomendations from @rdamiani for a method he has had good success with.

Co-authored-by:rdamiani <r.damiani@RRDengineering.com>
  • Loading branch information
rdamiani authored and andrew-platt committed Mar 8, 2024
1 parent e5a3bbd commit f2ab5bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
14 changes: 7 additions & 7 deletions modules/servodyn/src/ServoDyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ SUBROUTINE SrvD_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitO
! Display the module information

CALL DispNVD( SrvD_Ver )
CALL GetPath( InitInp%InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located.
CALL GetPath( InitInp%InputFile, p%PriPath ) ! Input files will be relative to the path where the primary input file is located.

!............................................................................................
! Read the input file and validate the data
Expand Down Expand Up @@ -5241,7 +5241,7 @@ SUBROUTINE CalculateStandardYaw(t, u, p, m, YawPosCom, YawRateCom, YawPosComInt,

CASE ( ControlMode_USER ) ! User-defined from routine UserYawCont().

CALL UserYawCont ( u%Yaw, u%YawRate, u%WindDir, u%YawErr, p%NumBl, t, p%DT, p%RootName, YawPosCom, YawRateCom )
CALL UserYawCont ( u%Yaw, u%YawRate, u%WindDir, u%YawErr, p%NumBl, t, p%DT, p%PriPath, YawPosCom, YawRateCom )

CASE ( ControlMode_EXTERN ) ! User-defined from Simulink or LabVIEW

Expand Down Expand Up @@ -5380,7 +5380,7 @@ SUBROUTINE Pitch_CalcOutput( t, u, p, x, xd, z, OtherState, BlPitchCom, ElecPwr,

CASE ( ControlMode_USER ) ! User-defined from routine PitchCntrl().

CALL PitchCntrl ( u%BlPitch, ElecPwr, u%LSS_Spd, u%TwrAccel, p%NumBl, t, p%DT, p%RootName, BlPitchCom )
CALL PitchCntrl ( u%BlPitch, ElecPwr, u%LSS_Spd, u%TwrAccel, p%NumBl, t, p%DT, p%PriPath, BlPitchCom )

CASE ( ControlMode_EXTERN ) ! User-defined from Simulink or LabVIEW.

Expand Down Expand Up @@ -5733,7 +5733,7 @@ SUBROUTINE Torque_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrM

CASE ( ControlMode_USER ) ! User-defined HSS brake model.

CALL UserHSSBr ( y%GenTrq, y%ElecPwr, u%HSS_Spd, p%NumBl, t, p%DT, p%RootName, HSSBrFrac )
CALL UserHSSBr ( y%GenTrq, y%ElecPwr, u%HSS_Spd, p%NumBl, t, p%DT, p%PriPath, HSSBrFrac )

IF ( ( HSSBrFrac < 0.0_ReKi ) .OR. ( HSSBrFrac > 1.0_ReKi ) ) THEN ! 0 (off) <= HSSBrFrac <= 1 (full); else Abort.
ErrStat = ErrID_Fatal
Expand Down Expand Up @@ -5938,8 +5938,8 @@ SUBROUTINE CalculateTorque( t, u, p, m, GenTrq, ElecPwr, ErrStat, ErrMsg )
CASE ( ControlMode_USER ) ! User-defined generator model.


! CALL UserGen ( u%HSS_Spd, u%LSS_Spd, p%NumBl, t, DT, p%GenEff, DelGenTrq, DirRoot, GenTrq, ElecPwr )
CALL UserGen ( u%HSS_Spd, u%LSS_Spd, p%NumBl, t, p%DT, p%GenEff, 0.0_ReKi, p%RootName, GenTrq, ElecPwr )
CALL UserGen ( u%HSS_Spd, u%LSS_Spd, p%NumBl, t, p%DT, p%GenEff, 0.0_ReKi, p%PriPath, GenTrq, ElecPwr )


END SELECT

Expand Down Expand Up @@ -5974,7 +5974,7 @@ SUBROUTINE CalculateTorque( t, u, p, m, GenTrq, ElecPwr, ErrStat, ErrMsg )
CASE ( ControlMode_USER ) ! User-defined variable-speed control for routine UserVSCont().


CALL UserVSCont ( u%HSS_Spd, u%LSS_Spd, p%NumBl, t, p%DT, p%GenEff, 0.0_ReKi, p%RootName, GenTrq, ElecPwr )
CALL UserVSCont ( u%HSS_Spd, u%LSS_Spd, p%NumBl, t, p%DT, p%GenEff, 0.0_ReKi, p%PriPath, GenTrq, ElecPwr )

CASE ( ControlMode_DLL ) ! User-defined variable-speed control from Bladed-style DLL

Expand Down
1 change: 1 addition & 0 deletions modules/servodyn/src/ServoDyn_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ typedef ^ ParameterType IntKi StCCmode - - - "Structural control control mode {0
typedef ^ ParameterType IntKi NumOuts - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ParameterType IntKi NumOuts_DLL - - - "Number of logging channels output from the DLL (set at initialization)" -
typedef ^ ParameterType CHARACTER(1024) RootName - - - "RootName for writing output files" -
typedef ^ ParameterType CHARACTER(1024) PriPath - - - "Path of the primary SD input file " -
typedef ^ ParameterType OutParmType OutParam {:} - - "Names and units (and other characteristics) of all requested output parameters" -
typedef ^ ParameterType CHARACTER(1) Delim - - - "Column delimiter for output text files" -
# parameters for Bladed Interface (dynamic-link library)
Expand Down
11 changes: 11 additions & 0 deletions modules/servodyn/src/ServoDyn_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ MODULE ServoDyn_Types
INTEGER(IntKi) :: NumOuts !< Number of parameters in the output list (number of outputs requested) [-]
INTEGER(IntKi) :: NumOuts_DLL !< Number of logging channels output from the DLL (set at initialization) [-]
CHARACTER(1024) :: RootName !< RootName for writing output files [-]
CHARACTER(1024) :: PriPath !< Path of the primary SD input file [-]
TYPE(OutParmType) , DIMENSION(:), ALLOCATABLE :: OutParam !< Names and units (and other characteristics) of all requested output parameters [-]
CHARACTER(1) :: Delim !< Column delimiter for output text files [-]
LOGICAL :: UseBladedInterface !< Flag that determines if BladedInterface was used [-]
Expand Down Expand Up @@ -12645,6 +12646,7 @@ SUBROUTINE SrvD_CopyParam( SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg
DstParamData%NumOuts = SrcParamData%NumOuts
DstParamData%NumOuts_DLL = SrcParamData%NumOuts_DLL
DstParamData%RootName = SrcParamData%RootName
DstParamData%PriPath = SrcParamData%PriPath
IF (ALLOCATED(SrcParamData%OutParam)) THEN
i1_l = LBOUND(SrcParamData%OutParam,1)
i1_u = UBOUND(SrcParamData%OutParam,1)
Expand Down Expand Up @@ -13247,6 +13249,7 @@ SUBROUTINE SrvD_PackParam( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg,
Int_BufSz = Int_BufSz + 1 ! NumOuts
Int_BufSz = Int_BufSz + 1 ! NumOuts_DLL
Int_BufSz = Int_BufSz + 1*LEN(InData%RootName) ! RootName
Int_BufSz = Int_BufSz + 1*LEN(InData%PriPath) ! PriPath
Int_BufSz = Int_BufSz + 1 ! OutParam allocated yes/no
IF ( ALLOCATED(InData%OutParam) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! OutParam upper/lower bounds for each dimension
Expand Down Expand Up @@ -13733,6 +13736,10 @@ SUBROUTINE SrvD_PackParam( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg,
IntKiBuf(Int_Xferred) = ICHAR(InData%RootName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(InData%PriPath)
IntKiBuf(Int_Xferred) = ICHAR(InData%PriPath(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
IF ( .NOT. ALLOCATED(InData%OutParam) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
Expand Down Expand Up @@ -14621,6 +14628,10 @@ SUBROUTINE SrvD_UnPackParam( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMs
OutData%RootName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(OutData%PriPath)
OutData%PriPath(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! OutParam not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Expand Down

0 comments on commit f2ab5bc

Please sign in to comment.