Parameter access in user subroutines

Hello,

I have a question regarding the parameter access in user subroutines like UserVSCont or UserYawCont. The user guide states that it is possible to access the current value of any output parameter from FAST but I don’t know how. Is there a specific module which has to be loaded or can I just use specific variable names?

Are there any examples available where a user subroutine uses this feature, or could someone give some example code maybe how the rotor speed is used in the UserYawCont subroutine?

Thank you very much.

Best regards,

Matthias

Dear Matthias,

Are you using FAST v7 or FAST v8 / OpenFAST? The source code implementation is quite different between these forms of FAST.

Best regards,

Dear Jason,

I’m using OpenFAST.

Best regrads,

Matthias

Dear Matthias,

That comment was added for an older version of FAST, when all data was global and accessible from any routine. The FAST modularization framework used in FAST v8 and OpenFAST supports data encapsulation, so that specific data is not available to a given routine unless that data is made accessible to that routine, e.g. by passing it as an argument.

Is the rotor speed what you want in SUBROUTINE UserVSCont()? This is already passed into UserVSCont() as the second argument, named LSS_Spd, in rad/s. Otherwise, please clarify what you want to do.

Best regards,

Dear Jason,

for my current problem I need to know the rotor speed in the UserYawCont() as I want to yaw the turbine out of the wind when a certain rotational speed is reached.

Best regards,

Matthias

Dear Matthias,

I would simply add LSS_Spd as an input argument to routine UserYawCont(). Routine CalculateStandardYaw, which calls routine UserYawCont(), already has access to the current value of the LSS_Spd in the input data structure, so, all you need do is add u%LSS_Spd to the argument list of UserYawCont().

Best regards,

Dear Jason,

thank you very much for your help. I think I have successfully implemented my user subroutine.

Now I have a follow-up question regarding the necessary DOF settings. The v7 user guide states that the UserYawCont() subroutine can be used either with the YawDOF enabled or disabled. When the YawDOF is enabled the YawPosCom output is used as the new neutral yaw position, otherwise it is used directly as new yaw position.

With my test setup I only see an effect in the NacYawP output variable if the YawDOF is enabled (and YawSpr is set). Should it be also possible in OpenFAST to directly prescribe the yaw position with the YawDOF disabled?

Thank you very much.
Best regards,

Matthias

Dear Matthias,

It was possible in FAST v7 to directly control the yaw angle without enabling the YawDOF. However, this capability was removed from FAST v8 and OpenFAST. Yaw control is only possible in FAST v8 and OpenFAST when YawDOF is enabled.

Best regards,

Dear Jason,

I am learning how to implement a yaw controller in OpenFAST using the UsrYawCont() subroutine in the UserSubs.f90 file. Playing around it, I wrote this piece of code below in the UserYawCont() subroutine to set the yaw angle at 40° from t=0s to t=30s, then at 20° from t=30s to t=90s, and finally follow the mean wind direction from t>=90s. All this happens at a Yaw rate of 5°/s = 0.0873 rad/s. But from t=30s to t=90s, the Yaw rate seems to be different from the one I set (-5°/s), more closely to 1°/s and I don’t understand why this happens.
Do you have any suggestions?

IF (ZTime <30) THEN
    IF ( YawPos < 0.698 ) THEN
        YawRateCom = 0.0873 !5 deg/s
        YawPosCom=YawRateCom*DT+YawPos
    ELSE IF ( YawPos > 0.698 ) THEN
        YawRateCom = 0.0873 !5 deg/s
        YawPosCom=-YawRateCom*DT+YawPos
    ELSE
        YawPosCom  = YawPos
        YawRateCom = 0.0
    END IF
    
ELSE IF ( (ZTime>=30) .AND. (ZTime<90) ) THEN
    IF ( YawPos < 0.349 ) THEN ! 0.349 rad = 20 degrees
        YawRateCom = 0.0873 !5 deg/s
        YawPosCom=YawRateCom*DT+YawPos
    ELSE IF ( YawPos > 0.349 ) THEN
        YawRateCom = 0.0873 !5 deg/s
        YawPosCom=-YawRateCom*DT+YawPos
    ELSE
        YawPosCom  = YawPos
        YawRateCom = 0.0
    END IF
    
ELSE IF (ZTime>=90) THEN
    IF ( YawPos-WindDir <0 ) THEN
        YawRateCom = 0.0873 !5 deg/s
        YawPosCom=YawRateCom*DT+YawPos
    ELSE IF ( YawPos-WindDir >0 ) THEN
        YawRateCom = 0.0873 !5 deg/s
        YawPosCom=-YawRateCom*DT+YawPos
    ELSE
        YawPosCom  = YawPos
        YawRateCom = 0.0
    END IF
END IF

Kindest regards

Younes

Dear Younes,

Two comments:

  • I think the yaw rate is not as you expect during the second transient because you’ve set the sign of YawRateCom to always be positive. While you switched the sign of YawRateCom in the calculation of YawPosCom, you have not switched the actual sign of YawRateCom. The sign of YawRateCom will influence the yaw torque calculated by the yaw actuator.
  • I would think it would be preferred to integrate YawRateCom to calculate YawPosCom independently from the actual yaw angle (YawPos). I would suggest making YawPosCom a state of UserYawCont() and use it directly in the integration, e.g., change:

YawPosCom=YawRateCom*DT+YawPos to:

YawPosCom=YawRateCom*DT+YawPosCom With this change, I would not expect that you’d need to check the value of YawPos within UserYawCont().

Best regards,

Dear Jason,

You’re right about the YawRateCom sign issue. It works perfectly now. Thanks a lot!

Kindest regards

Younes

Dear Jason,
When changing the pitch angle, I encountered two problems as shown in the figure.
. I modify the pitch angle in discon.f90, when the pitch angle changes, there will be a spike that is 2° larger than the expected value. As shown in the picture B1pitch, B2pitch,B3pitch. To make it easy to see, I enlarged the position of the spike(the corresponding running time in the figure is 100s, and the FAST running time step is 0.00625s) in B1Pitch, and B2Pitch and B3Pitch are full pictures. At the beginning, I thought that this might be caused by the PitRate being too large, but after it was changed to a smaller value, this problem still occurred, as shown in the program on the left.
.When pitch angle changes at the second time, the power began to fluctuate. I don’t know why.

Thanks for your help!
Best regards,
Liye

Dear Liye,

A similar question was asked and answered in the following forum topic: http://forums.nrel.gov/t/measured-pitch-angle-differs-to-demanded-pitch-angle/2085/2.

Best regards,