Thanks Jason
Below is what I found out. I discovered a few little rules along the way, could you have a quick look to see if I’ve missed any?
Also, there is a slightly unrelated question at the end.
So, for outputs you need to add your variable name to the list in the MODULE Output of FAST_Mods:
...
INTEGER(4), PARAMETER :: Wave9Axi = 531
INTEGER(4), PARAMETER :: Wave9Ayi = 532
INTEGER(4), PARAMETER :: Wave9Azi = 533
INTEGER(4), PARAMETER :: FUVar1 = 544
FUVar1 is short for FAST User Variable 1. There is a 10 character limit on these variable names, and they shouldn’t begin with a ‘-’, ‘_’, ‘m’ or ‘M’ (or they’ll be made negative and the first character would be dropped from the name).
This defines the location of FUVar1 in the AllOuts array of reals. All your array element numbers are sequential, so if I wanted to add something about Blade 2 Tip motions (array elements 40 to 51) I’d need to renumber about 482 variables or play about with excel to help a little. (actually excel makes it fairly easy)
The size of AllOuts () needs to be tweaked a little to cater for my new variable. There is a note elsewhere not to exceed 1000.
...
!jmj general purpose, quasi-static solution based on the analytical catenary
!jmj cable equations with seabed interaction:
!remove6.02bREAL(ReKi) :: AllOuts (0:389) ! An array holding the value of all of the calculated (not selected) output channels.
REAL(ReKi) :: AllOuts (0:544) ! An array holding the value of all of the calculated (not selected) output channels.
!jmj End of proposed change. v6.02b-jmj 15-Nov-2006.
!jmj End of proposed change. v6.02a-jmj 25-Aug-2006.
...
! SEE NOTE ABOVE FOR SIZE (DIMENSION) OF THE PREVIOUS VARIABLE:
Next in FAST_IO in Subroutine ChckOutLst:
CASE ( 'FUVAR1' )
OutInd (I) = FUVar1
OutParam(I)%Units = '(user set)'
The string of the CASE seems to need to be in uppercase, even though my variable name isn’t. A quick hunt on google didn’t reveal any reason why. The case variable needs to match the text in the .fst file under the OUTPUT section, and you’d be nuts not to make it the same as your variable name.
I wanted to have FUVar1 calculated in BladedDLLInterface, but AllOuts() would need to be added under the declaration as INTENT (out), so it will be worthwhile passing it through an intermediate variable.
For making a new input:
You need to declare it with all the other inputs in FAST_Mods, a good place would be MODULE TurbCont, but I made a new one, MODULE Faults:
Module Faults
USE Precision
INTEGER(4) :: FltCndtn ! The fault condition to be simulated
END MODULE Faults
In FAST_IO, SUBROUTINE GetPrimary, there is code that makes a list that matches the variables in the .fst file. Find where you want to add your new variable in the .fst file and add your code in a similar location. Here’s mine:
! FltCndtn - Fault Condition to be simulated.
CALL ReadIVar ( UnIn, PriFile, FltCndtn, 'FltCndtn', 'Fault Condition to be applied' )
IF ( ( Cmpl4SFun ) .AND. ( VSContrl /= 0 ) ) THEN
CALL ProgAbort ( ' FltCndtn can only equal 0 (no fault) when FAST is interfaced with Simulink.' )
ENDIF
If I was feeling fancy I could do something like you did in AeroSubs.f90 with the tower shadow:
!bjj: this is a hack job to allow both the new tower influence and the old tower wake models to be used
!rm CALL ReadStr( UnIn, AeroInFile, Line, 'TwrShad', 'Tower shadow deficit', ErrStat )
CALL ReadStr( UnIn, AeroInFile, Line, 'NewTowerModel?', 'Check for tower influence model', ErrStat )
IF ( ErrStat /= 0 ) RETURN
! Check if this is the "special string" to indicate the new tower influence model
CALL Conv2UC( Line )
IF ( INDEX(Line, "NEWTOWER" ) > 0 ) THEN
!----------------------------------------------------------------------------------------------
! New tower influence model, as implemented by PJM
!----------------------------------------------------------------------------------------------
PJM_Version = .TRUE.
! Read in the tower potential flow switch
CALL ReadVar( UnIn, AeroInFile, TwrPotent, 'TwrPotent', 'Tower influence model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Read in the tower shadow switch
CALL ReadVar( UnIn, AeroInFile, TwrShadow, 'TwrShadow', 'Tower shadow model', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Read in the tower drag file name
CALL ReadVar( UnIn, AeroInFile, TwrFile, 'TwrFile', 'Tower data file name', ErrStat)
IF ( ErrStat /= 0 ) RETURN
ELSE
!----------------------------------------------------------------------------------------------
! Old tower influence model, read TwrShad from Line for now
!----------------------------------------------------------------------------------------------
PJM_Version = .FALSE.
TwrPotent = .FALSE. ! We don't want to read the tower file!
TwrShadow = .FALSE. ! We don't want to read the tower file!
!
! ! Read in the tower shadow deficit
! CALL ReadVar( UnIn, AeroInFile, TwrShad, 'TwrShad', 'Tower shadow deficit', ErrStat)
! IF ( ErrStat /= 0 ) RETURN
! Read in the tower shadow deficit
IF ( INDEX( 'FTft', Line(:1) ) > 0 ) THEN
CALL ProgWarn( ' Invalid numeric input. "'//TRIM( Line )//'" found when trying to read TwrShad.' )
ErrStat = 1
RETURN
ELSE
READ (Line,*,IOSTAT=ErrStat) TwrShad
CALL CheckIOS ( ErrStat, AeroInFile, 'TwrShad', NumType, .TRUE. )
IF ( Echo ) THEN
WRITE (UnEc,"( 2X, ES11.4e2, 2X, A, T30, ' - ', A )") TwrShad, "TwrShad", 'Tower shadow deficit'
END IF
END IF
!----------------
IF ( TwrShad >= 1.0 ) THEN
CALL ProgWarn( ' Tower shadow deficit cannot be >= 1. Setting default deficit = 0.3' )
TwrShad = 0.3
END IF
! Read in the tower shadow width
CALL ReadVar( UnIn, AeroInFile, ShadHWid, 'ShadHWid', 'Tower shadow half width', ErrStat)
IF ( ErrStat /= 0 ) RETURN
IF ( ShadHWid <= 0.0 ) THEN
CALL ProgWarn( ' Tower shadow width cannot be <= zero. Setting default half width = 1.0' )
ShadHWid = 1.0
END IF
! Read in the tower shadow reference point (distance from yaw axis to hub)
CALL ReadVar( UnIn, AeroInFile, T_Shad_Refpt, 'T_Shad_Refpt', 'Tower shadow reference point', ErrStat)
IF ( ErrStat /= 0 ) RETURN
! Constants used in tower shadow calculations
TShadC1 = ShadHWid / SQRT ( ABS( T_Shad_Refpt ) )
TShadC2 = TwrShad * SQRT ( ABS( T_Shad_Refpt ) )
END IF
!bjj end
But I’m not. Do you think it would be worth getting the FAST executable version number to be an input in the .fst file to check for this sort of issue? It could give a warning if the .fst file didn’t match the version of the .exe…
Thanks for your help.
Alec