Skip to content

Commit

Permalink
Merge branch 'rc-3.5.3' into m/rc-3.5.3_to_dev-unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-platt committed Feb 20, 2024
2 parents a288870 + d6483eb commit 8ea7b55
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 132 deletions.
121 changes: 61 additions & 60 deletions .github/workflows/automated-dev-tests.yml

Large diffs are not rendered by default.

42 changes: 19 additions & 23 deletions modules/hydrodyn/src/HydroDyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2619,39 +2619,35 @@ SUBROUTINE HD_Perturb_x( p, n, perturb_sign, x, dx )


! local variables
integer(intKi) :: i, offset1, offset2, n2
integer(intKi) :: i, j, k

if ( p%totalStates == 0 ) return

!Note: All excitation states for all bodies are stored 1st, then all radiation states
dx = p%dx(n)
offset1 = 1
if ( n <= p%totalExctnStates ) then

! Find body index for exctn states
do i=1,p%nWAMITObj
offset2 = offset1 + p%WAMIT(i)%SS_Exctn%numStates
if ( n >= offset1 .and. n < offset2) then
n2 = n - offset1 + 1
x%WAMIT(i)%SS_Exctn%x( n2 ) = x%WAMIT(i)%SS_Exctn%x( n2 ) + dx * perturb_sign
exit
k = 1

! Find body index for exctn states
do i = 1, p%nWAMITObj
do j = 1, p%WAMIT(i)%SS_Exctn%numStates
if (n == k) then
x%WAMIT(i)%SS_Exctn%x(j) = x%WAMIT(i)%SS_Exctn%x(j) + dx * perturb_sign
return
end if
offset1 = offset2
k = k + 1
end do
end do

else
offset1 = p%totalExctnStates + 1
! Find body index for rdtn states
do i=1,p%nWAMITObj
offset2 = offset1 + p%WAMIT(i)%SS_Exctn%numStates
if ( n >= offset1 .and. n < offset2) then
n2 = n - offset1 + 1
x%WAMIT(i)%SS_Rdtn%x( n2 ) = x%WAMIT(i)%SS_Rdtn%x( n2 ) + dx * perturb_sign
exit
! Find body index for rdtn states
do i = 1, p%nWAMITObj
do j = 1, p%WAMIT(i)%SS_Rdtn%numStates
if (n == k) then
x%WAMIT(i)%SS_Rdtn%x(j) = x%WAMIT(i)%SS_Rdtn%x(j) + dx * perturb_sign
return
end if
offset1 = offset2
k = k + 1
end do
end if
end do

END SUBROUTINE HD_Perturb_x

Expand Down
8 changes: 4 additions & 4 deletions modules/moordyn/src/MoorDyn_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ SUBROUTINE setupBathymetry(inputString, defaultDepth, BathGrid, BathGrid_Xs, Bat

INTEGER(IntKi) :: ErrStat4
CHARACTER(120) :: ErrMsg4
CHARACTER(120) :: Line2
CHARACTER(4096) :: Line2

CHARACTER(20) :: nGridX_string ! string to temporarily hold the nGridX string from Line2
CHARACTER(20) :: nGridY_string ! string to temporarily hold the nGridY string from Line3
Expand Down Expand Up @@ -182,7 +182,7 @@ SUBROUTINE setupBathymetry(inputString, defaultDepth, BathGrid, BathGrid_Xs, Bat
READ(UnCoef,*,IOSTAT=ErrStat4) nGridY_string, nGridY ! read in the third line as the number of y values in the BathGrid

! Allocate the bathymetry matrix and associated grid x and y values
ALLOCATE(BathGrid(nGridX, nGridY), STAT=ErrStat4)
ALLOCATE(BathGrid(nGridY, nGridX), STAT=ErrStat4)
ALLOCATE(BathGrid_Xs(nGridX), STAT=ErrStat4)
ALLOCATE(BathGrid_Ys(nGridY), STAT=ErrStat4)

Expand Down Expand Up @@ -567,7 +567,7 @@ SUBROUTINE MDIO_ProcessOutList(OutList, p, m, y, InitOut, ErrStat, ErrMsg )
END IF

! Point case
ELSE IF (let1(1:1) == 'P') THEN ! Look for P?xxx or Point?xxx
ELSE IF (let1(1:1) == 'P' .OR. let1(1:1) == 'C') THEN ! Look for P?xxx or Point?xxx (C?xxx and Con?xxx for backwards compatability)
p%OutParam(I)%OType = 2 ! Point object type
qVal = let2 ! quantity type string

Expand Down Expand Up @@ -605,7 +605,7 @@ SUBROUTINE MDIO_ProcessOutList(OutList, p, m, y, InitOut, ErrStat, ErrMsg )
! error
ELSE
CALL DenoteInvalidOutput(p%OutParam(I)) ! flag as invalid
CALL WrScr('Warning: invalid output specifier '//trim(OutListTmp)//'. Must start with L, C, R, or B')
CALL WrScr('Warning: invalid output specifier '//trim(OutListTmp)//'. Must start with L, R, or B')
CYCLE
END IF

Expand Down
5 changes: 2 additions & 3 deletions modules/moordyn/src/MoorDyn_Misc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ SUBROUTINE getDepthFromBathymetry(BathymetryGrid, BathGrid_Xs, BathGrid_Ys, Line
else
dc_dx = 0.0_DbKi ! maybe this should raise an error
end if
if ( dx > 0.0 ) then
if ( dy > 0.0 ) then
dc_dy = (cx1-cx0)/dy
else
dc_dy = 0.0_DbKi ! maybe this should raise an error
Expand Down Expand Up @@ -1300,8 +1300,7 @@ SUBROUTINE setupWaterKin(WaterKinString, p, Tmax, ErrStat, ErrMsg)
REAL(SiKi) :: t, Frac
CHARACTER(1024) :: FileName ! Name of MoorDyn input file
CHARACTER(120) :: Line
! CHARACTER(120) :: Line2
CHARACTER(120) :: entries2
CHARACTER(4096) :: entries2
INTEGER(IntKi) :: coordtype

INTEGER(IntKi) :: NStepWave !
Expand Down
11 changes: 8 additions & 3 deletions reg_tests/CTestList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,17 @@ of_regression_aeroacoustic("IEA_LB_RWT-AeroAcoustics" "openfast;aerodyn15;aeroa
#of_regression_linear("Fake5MW_AeroLin_B1_UA4_DBEMT3" "-highpass=0.05" "openfast;linear;elastodyn;aerodyn")
#of_regression_linear("Fake5MW_AeroLin_B3_UA6" "-highpass=0.05" "openfast;linear;elastodyn;aerodyn")
of_regression_linear("WP_Stationary_Linear" "" "openfast;linear;elastodyn")
of_regression_linear("Ideal_Beam_Fixed_Free_Linear" "-highpass=0.05" "openfast;linear;beamdyn")
of_regression_linear("Ideal_Beam_Free_Free_Linear" "-highpass=0.05" "openfast;linear;beamdyn")
of_regression_linear("Ideal_Beam_Fixed_Free_Linear" "-highpass=0.10" "openfast;linear;beamdyn")
of_regression_linear("Ideal_Beam_Free_Free_Linear" "-highpass=0.10" "openfast;linear;beamdyn")
#of_regression_linear("5MW_Land_Linear_Aero" "-highpass=0.05" "openfast;linear;elastodyn;servodyn;aerodyn")
of_regression_linear("5MW_Land_BD_Linear" "" "openfast;linear;beamdyn;servodyn")
of_regression_linear("5MW_OC4Semi_Linear" "" "openfast;linear;hydrodyn;servodyn")
#of_regression_linear("5MW_Land_BD_Linear_Aero" "-highpass=0.05" "openfast;linear;beamdyn;servodyn;aerodyn")
of_regression_linear("5MW_OC4Semi_Linear" "" "openfast;linear;hydrodyn;servodyn;map")
of_regression_linear("5MW_OC4Semi_MD_Linear" "" "openfast;linear;hydrodyn;servodyn;moordyn")
of_regression_linear("StC_test_OC4Semi_Linear_Nac" "" "openfast;linear;servodyn;stc")
of_regression_linear("StC_test_OC4Semi_Linear_Tow" "" "openfast;linear;servodyn;stc")
of_regression_linear("WP_Stationary_Linear" "" "openfast;linear;elastodyn")
of_regression_linear("5MW_OC3Spar_Linear" "" "openfast;linear;map;hydrodyn")

# FAST Farm regression tests
if(BUILD_FASTFARM)
Expand Down
54 changes: 32 additions & 22 deletions reg_tests/executeOpenfastLinearRegressionCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,46 +340,56 @@ def ApplyHighPass(freq,zeta):
newError(Err)

# --- Compare individual matrices/vectors
KEYS= ['A','B','C','D','dUdu','dUdy']
KEYS+=['x','y','u','xdot']
KEYS= ['A','B','C','D','dUdu','dUdy', 'x','y','u','xdot']
for k,v in fbas.items():
if k in KEYS and v is not None:
if verbose:
print(errPrefix+'key:', k)

# Arrays
Mloc=np.atleast_2d(floc[k])
Mbas=np.atleast_2d(fbas[k])
Mloc = np.atleast_2d(floc[k])
Mbas = np.atleast_2d(fbas[k])

# --- Compare dimensions
try:
np.testing.assert_equal(Mloc.shape, Mbas.shape)
dimEqual=True
except Exception as e:
Err = 'Different dimensions for variable `{}`.\n'.format(k)
Err+= '\tNew:{}\n'.format(Mloc.shape)
Err+= '\tRef:{}\n'.format(Mbas.shape)
Err+= '\tLinfile: {}.\n'.format(local_file2)
Err = f'Different dimensions for variable `{k}`.\n'
Err+= f'\tNew: {Mloc.shape}\n'
Err+= f'\tRef: {Mbas.shape}\n'
Err+= f'\tLinfile: {local_file2}.\n'
newError(Err)
dimEqual=False

if not dimEqual:
# We don't compare elements if shapes are different
continue

# Get matrix of which M elements are in/not in tolerance
M_diff_in_tol = np.isclose(Mloc, Mbas, rtol=rtol, atol=atol)

# We for loop below to get the first element that mismatch
# Otherwise, do: np.testing.assert_allclose(floc[k], fbas[k], rtol=rtol, atol=atol)
for i in range(Mbas.shape[0]):
for j in range(Mbas.shape[1]):
# Old method:
#if not isclose(Mloc[i,j], Mbas[i,j], rtol=rtol, atol=atol):
# sElem = 'Element [{},{}], new : {}, baseline: {}'.format(i+1,j+1,Mloc[i,j], Mbas[i,j])
# raise Exception('Failed to compare variable `{}`, {} \n\tLinfile: {}.'.format(k, sElem, local_file)) #, e.args[0]))
try:
np.testing.assert_allclose(Mloc[i,j], Mbas[i,j], rtol=rtol, atol=atol)
except Exception as e:
sElem = 'Element [{},{}], new : {}, baseline: {}'.format(i+1,j+1,Mloc[i,j], Mbas[i,j])
Err=errPrefix+'Failed to compare variable `{}`, {} \n\tLinfile: {}.\n\tException: {}'.format(k, sElem, local_file2, indent(e.args[0]))
ElemErrors.append(Err)
# Loop through indices of elements not in tolerance
for (i,j) in zip(*np.where(M_diff_in_tol == False)):
try:
# Redo compare to get error message
np.testing.assert_allclose(Mloc[i,j], Mbas[i,j], rtol=rtol, atol=atol)
except Exception as e:
sElem = f'Element [{i+1},{j+1}], new: {Mloc[i,j]}, baseline: {Mbas[i,j]}'
if k in ['dXdx', 'A', 'dXdu', 'B']:
sElem += '\n\t\t row: ' + fbas['x_info']['Description'][i]
if k in ['dYdx', 'C', 'dYdu', 'D']:
sElem += '\n\t\t row: ' + fbas['y_info']['Description'][i]
if k in ['dUdu', 'dUdy']:
sElem += '\n\t\t row: ' + fbas['u_info']['Description'][i]
if k in ['dXdx', 'A', 'dYdx', 'C']:
sElem += '\n\t\t col: ' + fbas['x_info']['Description'][j]
if k in ['dXdu', 'B', 'dYdu', 'D', 'dUdu']:
sElem += '\n\t\t col: ' + fbas['u_info']['Description'][j]
if k in ['dUdy']:
sElem += '\n\t\t col: ' + fbas['y_info']['Description'][j]
Err = errPrefix + f'Failed to compare variable `{k}`, {sElem} \n\tLinfile: {local_file2}.\n\tException: {indent(e.args[0])}'
ElemErrors.append(Err)
return Errors, ElemErrors


Expand Down
32 changes: 16 additions & 16 deletions reg_tests/lib/fast_linearization_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ def readOP(fid, n, name=''):
OP=[]
Var = {'RotatingFrame': [], 'DerivativeOrder': [], 'Description': []}
colNames=fid.readline().strip()
dummy= fid.readline().strip()
fid.readline().strip()
bHasDeriv= colNames.find('Derivative Order')>=0
for i, line in enumerate(fid):
sp=line.strip().split()
if sp[1].find(',')>=0:
sp = line.strip().split()
if sp[1].find(',') >= 0:
# Most likely this OP has three values (e.g. orientation angles)
# For now we discard the two other values
OP.append(float(sp[1][:-1]))
OP.append(np.float32(sp[1][:-1]))
iRot=4
else:
OP.append(float(sp[1]))
OP.append(np.float32(sp[1]))
iRot=2
Var['RotatingFrame'].append(sp[iRot])
if bHasDeriv:
Expand All @@ -109,23 +109,23 @@ def readOP(fid, n, name=''):
return OP, Var

def readMat(fid, n, m, name=''):
pattern = re.compile(r"[\*]+")
vals=[pattern.sub(' inf ', fid.readline().strip() ).split() for i in np.arange(n)]
vals = np.array(vals)

# Read rows from file, raise exception on failure
try:
vals = np.array(vals).astype(float) # This could potentially fail
vals = np.genfromtxt(fid, dtype=np.float64, max_rows=n)
except:
raise Exception('Failed to convert into an array of float the matrix `{}`\n\tin linfile: {}'.format(name, self.filename))

# Raise exception if actual matrix shape does not match expected shape
if vals.shape[0]!=n or vals.shape[1]!=m:
shape1 = vals.shape
shape2 = (n,m)
raise Exception('Shape of matrix `{}` has wrong dimension ({} instead of {})\n\tin linfile: {}'.format(name, shape1, shape2, name, self.filename))

nNaN = sum(np.isnan(vals.ravel()))
nInf = sum(np.isinf(vals.ravel()))
if nInf>0:
# Raise exceptions if any elements are NaN or infinity
if np.any(np.isnan(vals.ravel())):
raise Exception('Some ill-formated/infinite values (e.g. `*******`) were found in the matrix `{}`\n\tin linflile: {}'.format(name, self.filename))
if nNaN>0:
if np.any(np.isinf(vals.ravel())):
raise Exception('Some NaN values were found in the matrix `{}`\n\tin linfile: `{}`.'.format(name, self.filename))
return vals

Expand All @@ -142,15 +142,15 @@ def readMat(fid, n, m, name=''):
ny = int(extractVal(self['header'],'Number of outputs:' ))
bJac = extractVal(self['header'],'Jacobians included in this file?')
try:
self['Azimuth'] = float(extractVal(self['header'],'Azimuth:'))
self['Azimuth'] = np.float32(extractVal(self['header'],'Azimuth:'))
except:
self['Azimuth'] = None
try:
self['RotSpeed'] = float(extractVal(self['header'],'Rotor Speed:')) # rad/s
self['RotSpeed'] = np.float32(extractVal(self['header'],'Rotor Speed:')) # rad/s
except:
self['RotSpeed'] = None
try:
self['WindSpeed'] = float(extractVal(self['header'],'Wind Speed:'))
self['WindSpeed'] = np.float32(extractVal(self['header'],'Wind Speed:'))
except:
self['WindSpeed'] = None

Expand Down
2 changes: 1 addition & 1 deletion reg_tests/r-test
Submodule r-test updated 51 files
+1,004 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.AD.lin
+243 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.BD1.lin
+243 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.BD2.lin
+243 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.BD3.lin
+169 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.ED.lin
+39 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.IfW.lin
+27 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.SrvD.lin
+1,984 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.1.lin
+73 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.fst
+ glue-codes/openfast/5MW_Land_BD_Linear_Aero/5MW_Land_BD_Linear_Aero.outb
+96 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/NRELOffshrBsline5MW_Onshore_AeroDyn15.dat
+144 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/NRELOffshrBsline5MW_Onshore_ElastoDyn_BDoutputs.dat
+54 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/NRELOffshrBsline5MW_Onshore_ElastoDyn_Tower.dat
+111 −0 glue-codes/openfast/5MW_Land_BD_Linear_Aero/NRELOffshrBsline5MW_Onshore_ServoDyn.dat
+1,004 −0 glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.1.AD.lin
+274 −0 glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.1.ED.lin
+39 −0 glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.1.IfW.lin
+27 −0 glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.1.SrvD.lin
+1,261 −0 glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.1.lin
+73 −0 glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.fst
+ glue-codes/openfast/5MW_Land_Linear_Aero/5MW_Land_Linear_Aero.outb
+96 −0 glue-codes/openfast/5MW_Land_Linear_Aero/NRELOffshrBsline5MW_Onshore_AeroDyn15.dat
+155 −0 glue-codes/openfast/5MW_Land_Linear_Aero/NRELOffshrBsline5MW_Onshore_ElastoDyn.dat
+54 −0 glue-codes/openfast/5MW_Land_Linear_Aero/NRELOffshrBsline5MW_Onshore_ElastoDyn_Tower.dat
+111 −0 glue-codes/openfast/5MW_Land_Linear_Aero/NRELOffshrBsline5MW_Onshore_ServoDyn.dat
+614 −0 glue-codes/openfast/5MW_OC3Spar_Linear/5MW_OC3Spar_Linear.1.lin
+73 −0 glue-codes/openfast/5MW_OC3Spar_Linear/5MW_OC3Spar_Linear.fst
+ glue-codes/openfast/5MW_OC3Spar_Linear/5MW_OC3Spar_Linear.outb
+204 −0 glue-codes/openfast/5MW_OC3Spar_Linear/NRELOffshrBsline5MW_OC3Hywind_ElastoDyn.dat
+54 −0 glue-codes/openfast/5MW_OC3Spar_Linear/NRELOffshrBsline5MW_OC3Hywind_ElastoDyn_Tower.dat
+158 −0 glue-codes/openfast/5MW_OC3Spar_Linear/NRELOffshrBsline5MW_OC3Hywind_HydroDyn.dat
+17 −0 glue-codes/openfast/5MW_OC3Spar_Linear/NRELOffshrBsline5MW_OC3Hywind_MAP.dat
+72 −0 glue-codes/openfast/5MW_OC3Spar_Linear/SeaState.dat
+25 −25 glue-codes/openfast/5MW_OC4Semi_Linear/5MW_OC4Semi_Linear.1.lin
+0 −0 glue-codes/openfast/5MW_OC4Semi_Linear/5MW_OC4Semi_Linear.fst
+ glue-codes/openfast/5MW_OC4Semi_Linear/5MW_OC4Semi_Linear.outb
+0 −0 glue-codes/openfast/5MW_OC4Semi_Linear/NRELOffshrBsline5MW_Blade.dat
+0 −0 glue-codes/openfast/5MW_OC4Semi_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_ElastoDyn.dat
+0 −0 glue-codes/openfast/5MW_OC4Semi_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_ElastoDyn_Tower.dat
+0 −0 glue-codes/openfast/5MW_OC4Semi_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_MAP.dat
+2,010 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/5MW_OC4Semi_MD_Linear.1.lin
+73 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/5MW_OC4Semi_MD_Linear.fst
+ glue-codes/openfast/5MW_OC4Semi_MD_Linear/5MW_OC4Semi_MD_Linear.outb
+83 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/NRELOffshrBsline5MW_Blade.dat
+136 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_ElastoDyn.dat
+54 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_ElastoDyn_Tower.dat
+208 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_HydroDyn.dat
+39 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_MoorDyn.dat
+109 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/NRELOffshrBsline5MW_OC4DeepCwindSemi_ServoDyn.dat
+72 −0 glue-codes/openfast/5MW_OC4Semi_MD_Linear/SeaState.dat
+8 −0 glue-codes/openfast/CaseList.md

0 comments on commit 8ea7b55

Please sign in to comment.