Skip to content

Commit 9a28d15

Browse files
authored
Merge pull request OpenFAST#18 from andrew-platt/MDv2-farm
Updates from SrvD_linearization
2 parents 78efc1b + 27de1d4 commit 9a28d15

File tree

12 files changed

+235
-265
lines changed

12 files changed

+235
-265
lines changed

modules/aerodyn/src/AeroDyn.f90

+7-3
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ subroutine AD_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut
276276
if (Failed()) return;
277277
NumBlades(iR) = InitInp%rotors(iR)%NumBlades
278278
p%rotors(iR)%NumBlades = InitInp%rotors(iR)%NumBlades
279-
if (size(InitInp%rotors)>1) then
279+
if (nRotors > 1) then
280280
p%rotors(iR)%RootName = TRIM(InitInp%RootName)//'.AD.R'//trim(num2lstr(iR))
281281
else
282282
p%rotors(iR)%RootName = TRIM(InitInp%RootName)//'.AD'
@@ -1160,7 +1160,8 @@ subroutine AD_End( u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg )
11601160
TYPE(AD_MiscVarType), INTENT(INOUT) :: m !< Misc/optimization variables
11611161
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
11621162
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
1163-
integer :: iW
1163+
1164+
integer :: iW
11641165

11651166

11661167

@@ -1668,6 +1669,7 @@ subroutine SetInputs(p, p_AD, u, m, indx, errStat, errMsg)
16681669
endif
16691670
end subroutine SetInputs
16701671

1672+
!----------------------------------------------------------------------------------------------------------------------------------
16711673
!> Disturbed inflow on the blade if tower shadow or tower influence are enabled
16721674
subroutine SetDisturbedInflow(p, u, m, errStat, errMsg)
16731675
type(RotParameterType), intent(in ) :: p !< AD parameters
@@ -1798,8 +1800,10 @@ subroutine SetInputsForBEMT(p, u, m, indx, errStat, errMsg)
17981800

17991801
m%BEMT_u(indx)%UserProp = u%UserProp
18001802

1801-
! ................ TSR .....................
18021803

1804+
!..........................
1805+
! TSR
1806+
!..........................
18031807
if ( EqualRealNos( m%V_dot_x, 0.0_ReKi ) ) then
18041808
m%BEMT_u(indx)%TSR = 0.0_ReKi
18051809
else

modules/aerodyn/src/AeroDyn_IO.f90

+200-244
Large diffs are not rendered by default.

modules/aerodyn/src/FVW_Subs.f90

+10-2
Original file line numberDiff line numberDiff line change
@@ -1453,8 +1453,16 @@ subroutine FVW_AeroOuts( M_sg, M_ag, PitchAndTwist, Vstr_g, Vind_g, Vwnd_g, Kin
14531453
Vwnd_s = matmul(M_sg, Vwnd_g)
14541454
Urel_s = Vwnd_s - Vstr_s ! relative wind
14551455
Vtot_s = Vwnd_s - Vstr_s + Vind_s
1456-
AxInd = -Vind_s(1)/Urel_s(1)
1457-
TanInd = Vind_s(2)/Urel_s(2)
1456+
if (EqualRealNos(Urel_s(1),0.0_ReKi)) then
1457+
AxInd = 0.0_ReKi
1458+
else
1459+
AxInd = -Vind_s(1)/Urel_s(1)
1460+
endif
1461+
if (EqualRealNos(Urel_s(2),0.0_ReKi)) then
1462+
TanInd = 0.0_ReKi
1463+
else
1464+
TanInd = Vind_s(2)/Urel_s(2)
1465+
end if
14581466
phi = atan2( Vtot_s(1), Vtot_s(2) ) ! flow angle
14591467

14601468
if(.false.) print*,PitchAndTwist ! just to avoid unused var for now

modules/hydrodyn/src/HydroDyn.f90

-4
Original file line numberDiff line numberDiff line change
@@ -2579,8 +2579,6 @@ SUBROUTINE HD_JacobianPInput( t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrM
25792579
! For the case where either RdtnMod=0 and ExtcnMod=0 and hence %SS_Rdtn data or %SS_Exctn data is not valid then we do not have states, so simply return
25802580
! The key here is to never allocate the dXdu and related state Jacobian arrays because then the glue-code will behave properly
25812581

2582-
if ( p%totalStates == 0 ) return
2583-
25842582
! Calculate the partial derivative of the continuous state functions (X) with respect to the inputs (u) here:
25852583

25862584
! allocate dXdu if necessary
@@ -2753,8 +2751,6 @@ SUBROUTINE HD_JacobianPContState( t, u, p, x, xd, z, OtherState, y, m, ErrStat,
27532751
ErrStat = ErrID_None
27542752
ErrMsg = ''
27552753

2756-
if ( p%totalStates == 0 ) return
2757-
27582754
! Calculate the partial derivative of the output functions (Y) with respect to the continuous states (x) here:
27592755

27602756

modules/map/src/makefile

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ifeq ($(OS),Windows_NT)
3131
CFLAGS = $(BITS) -g -std=c99 -DMAP_DLL_EXPORTS -DCMINPACK_NO_DLL -DNDEBUG -D_WINDOWS -D_USRDLL -D_MINGW
3232
LDFLAGS = $(BITS) -g -shared -Wl,--export-all-symbols
3333
LIB_FLAGS :=
34+
CC_TOOLS = gcc
3435
else
3536
PLATFORM = $(shell uname -s)
3637
DEL_CMD = rm -rf

modules/map/src/mapapi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ MAP_EXTERNCALL void map_offset_vessel(MAP_OtherStateType_t* other_type, MAP_Inpu
358358

359359
/* define transformation matrix */
360360
R[0][0] = cpsi*cthe; R[0][1] = cpsi*sthe*sphi - spsi*cphi; R[0][2] = cpsi*sthe*cphi + spsi*sphi;
361-
R[1][0] = spsi*cthe; R[1][1] = sphi*sthe*sphi + cpsi*cphi; R[1][2] = spsi*sthe*cphi - cpsi*sphi;
361+
R[1][0] = spsi*cthe; R[1][1] = sphi*sthe*spsi + cpsi*cphi; R[1][2] = spsi*sthe*cphi - cpsi*sphi;
362362
R[2][0] = -sthe; R[2][1] = cthe*sphi; R[2][2] = cthe*cphi;
363363

364364
for (i=0 ; i<u_size ; i++) {

modules/map/src/mapinit.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -2433,19 +2433,19 @@ MAP_ERROR_CODE set_output_list(Domain* domain, MAP_InitOutputType_t* io_type, ch
24332433
};
24342434

24352435
if (line_iter->options.azimuth_flag) {
2436-
success = push_variable_to_output_list(y_list, line_num, &line_iter->psi, "psi", "[m]");
2436+
success = push_variable_to_output_list(y_list, line_num, &line_iter->psi, "psi", "[rad]");
24372437
io_type->writeOutputHdr_Len++;
24382438
io_type->writeOutputUnt_Len++;
24392439
};
24402440

24412441
if (line_iter->options.altitude_flag) {
2442-
success = push_variable_to_output_list(y_list, line_num, &line_iter->alpha, "alpha", "[m]");
2442+
success = push_variable_to_output_list(y_list, line_num, &line_iter->alpha, "alpha", "[rad]");
24432443
io_type->writeOutputHdr_Len++;
24442444
io_type->writeOutputUnt_Len++;
24452445
};
24462446

24472447
if (line_iter->options.altitude_anchor_flag) {
2448-
success = push_variable_to_output_list(y_list, line_num, &line_iter->alpha_at_anchor, "alpha_a", "[m]");
2448+
success = push_variable_to_output_list(y_list, line_num, &line_iter->alpha_at_anchor, "alpha_a", "[rad]");
24492449
io_type->writeOutputHdr_Len++;
24502450
io_type->writeOutputUnt_Len++;
24512451
};
@@ -2797,8 +2797,8 @@ MAP_ERROR_CODE print_help_to_screen()
27972797
printf(" -v_anch, --Vertical force at anchor (does NOT include applied forces) [N]\n");
27982798
printf(" -tension_fair, --Line force-magnitude at fairlead (include applied loads) [N]\n");
27992799
printf(" -tension_anch, --Line force-magnitude at anchor (include applied loads) [N]\n");
2800-
printf(" -azimuth, --Line lateral offset angle global X axis [deg]\n");
2801-
printf(" -altitude, --Line inclination angle relative to global XY plane at fairlead [deg]\n");
2800+
printf(" -azimuth, --Line lateral offset angle global X axis [rad]\n");
2801+
printf(" -altitude, --Line inclination angle relative to global XY plane at fairlead [rad]\n");
28022802
printf(" -lay_length, --Length of line on seabed [m]\n");
28032803
printf(" -line_tension, -- \n");
28042804
printf(" Model features:\n");

modules/openfast-library/src/FAST_Lin.f90

+1-2
Original file line numberDiff line numberDiff line change
@@ -4987,7 +4987,7 @@ FUNCTION Indx_y_ED_BladeRoot_Start(y_ED, y_FAST, BladeNum) RESULT(ED_Out_Start)
49874987
end do
49884988
END FUNCTION Indx_y_ED_BladeRoot_Start
49894989
!----------------------------------------------------------------------------------------------------------------------------------
4990-
!> This routine returns the starting index for the y_ED%BladeRootMotion(BladeNum) mesh in the FAST linearization outputs.
4990+
!> This routine returns the starting index for the y_ED%NacelleMotion mesh in the FAST linearization outputs.
49914991
FUNCTION Indx_y_ED_Nacelle_Start(y_ED, y_FAST) RESULT(ED_Out_Start)
49924992
TYPE(FAST_OutputFileType), INTENT(IN ) :: y_FAST !< FAST output file data (for linearization)
49934993
TYPE(ED_OutputType), INTENT(IN ) :: y_ED !< ED outputs at t
@@ -4997,7 +4997,6 @@ FUNCTION Indx_y_ED_Nacelle_Start(y_ED, y_FAST) RESULT(ED_Out_Start)
49974997

49984998
ED_Out_Start = Indx_y_ED_BladeRoot_Start(y_ED, y_FAST, size(y_ED%BladeRootMotion)) ! start of last blade root
49994999
ED_Out_Start = ED_Out_Start + y_ED%BladeRootMotion(size(y_ED%BladeRootMotion))%NNodes*18 ! N blade roots, 6 fields with 3 components per blade.
5000-
ED_Out_Start = ED_Out_Start + y_ED%NacelleMotion%NNodes*18 ! 6 fields with 3 components
50015000
END FUNCTION Indx_y_ED_Nacelle_Start
50025001
!----------------------------------------------------------------------------------------------------------------------------------
50035002
!> This routine returns the starting index for y_ED%Yaw in the FAST linearization outputs.

modules/servodyn/src/ServoDyn.f90

+5-1
Original file line numberDiff line numberDiff line change
@@ -2812,7 +2812,11 @@ subroutine dYdu_YawGen()
28122812
! jacobian with the proper sign:
28132813
!...............................................................................
28142814
do I = 1,p%NumOuts ! Loop through all selected output channels
2815-
dYdu(I+SrvD_Indx_Y_WrOutput,1:3) = p%OutParam(I)%SignM * AllOuts( 1:3, p%OutParam(I)%Indx )
2815+
if (p%OutParam(I)%Indx > 0_IntKi) then
2816+
dYdu(I+SrvD_Indx_Y_WrOutput,1:3) = p%OutParam(I)%SignM * AllOuts( 1:3, p%OutParam(I)%Indx )
2817+
else
2818+
dYdu(I+SrvD_Indx_Y_WrOutput,1:3) = 0.0_R8Ki
2819+
endif
28162820
enddo ! I - All selected output channels
28172821
end subroutine dYdu_YawGen
28182822

modules/servodyn/src/ServoDyn_IO.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -2368,7 +2368,7 @@ SUBROUTINE SetOutParam(OutList, p, ErrStat, ErrMsg )
23682368

23692369
IF ( Indx > 0 ) THEN ! we found the channel name
23702370
IF ( InvalidOutput( ParamIndxAry(Indx) ) ) THEN ! but, it isn't valid for these settings
2371-
p%OutParam(I)%Indx = 0 ! pick any valid channel (I just picked "Time=0" here because it's universal)
2371+
p%OutParam(I)%Indx = ParamIndxAry(Indx) ! don't reset the index -- causes issues in linearization
23722372
p%OutParam(I)%Units = "INVALID"
23732373
p%OutParam(I)%SignM = 0
23742374
ELSE

reg_tests/CTestList.cmake

+3-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ of_regression("5MW_Land_BD_DLL_WTurb" "openfast;beamdyn;aerodyn
195195
of_regression("5MW_OC4Jckt_ExtPtfm" "openfast;elastodyn;extptfm")
196196
of_regression("HelicalWake_OLAF" "openfast;aerodyn15;olaf")
197197
of_regression("EllipticalWing_OLAF" "openfast;aerodyn15;olaf")
198-
of_regression("StC_test_OC4Semi" "openfast;servodyn;hydrodyn;moordyn;offshore")
198+
of_regression("StC_test_OC4Semi" "openfast;servodyn;hydrodyn;moordyn;offshore;stc")
199199

200200
# OpenFAST C++ API test
201201
if(BUILD_OPENFAST_CPP_API)
@@ -211,6 +211,8 @@ of_regression_linear("Ideal_Beam_Fixed_Free_Linear" "openfast;linear;beamdyn")
211211
of_regression_linear("Ideal_Beam_Free_Free_Linear" "openfast;linear;beamdyn")
212212
of_regression_linear("5MW_Land_BD_Linear" "openfast;linear;beamdyn;servodyn")
213213
of_regression_linear("5MW_OC4Semi_Linear" "openfast;linear;hydrodyn;servodyn")
214+
of_regression_linear("StC_test_OC4Semi_Linear_Nac" "openfast;linear;servodyn;stc")
215+
of_regression_linear("StC_test_OC4Semi_Linear_Tow" "openfast;linear;servodyn;stc")
214216

215217
# FAST Farm regression tests
216218
if(BUILD_FASTFARM)

reg_tests/r-test

Submodule r-test updated 42 files

0 commit comments

Comments
 (0)