Skip to content

Commit

Permalink
More fixes to BeamDyn unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deslaughter committed Jun 21, 2024
1 parent 5b0fe25 commit 06d6c97
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 94 deletions.
58 changes: 29 additions & 29 deletions modules/beamdyn/tests/test_BD_Crv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ subroutine test_BD_CheckRotMat(error)
testname = "known valid rotation matrix: pi about x-axis:"
testR = calcRotationMatrix(angle, n)
call BD_CheckRotMat(testR, ErrStat, ErrMsg)
call check(error, 0, ErrStat, testname)
call check(error, 0, ErrStat, testname); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "known invalid rotation matrix: halve the angle of the diagonal elements:"
! this should produce a fatal error (ErrStat = 4)
testR(:, 2) = [testR(1, 2), cos(real(Pi / 2, BDKi)), testR(3, 2)]
testR(:, 3) = [testR(1, 2), testR(2, 2), cos(real(Pi / 2, BDKi))]
call BD_CheckRotMat(testR, ErrStat, ErrMsg)
call check(error, 4, ErrStat, testname)
call check(error, 4, ErrStat, testname); if (allocated(error)) return

end subroutine

Expand Down Expand Up @@ -82,8 +82,8 @@ subroutine test_BD_ComputeIniNodalCrv(error)

call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "Tangent at 45 degree w.r.t. y-axis and 0 degree twist:"
Expand All @@ -96,8 +96,8 @@ subroutine test_BD_ComputeIniNodalCrv(error)

call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "Tangent at -45 degree w.r.t. x-axis and 0 degree twist:"
Expand All @@ -110,8 +110,8 @@ subroutine test_BD_ComputeIniNodalCrv(error)

call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "Tangent along z-axis with 45 degree twist:"
Expand All @@ -124,8 +124,8 @@ subroutine test_BD_ComputeIniNodalCrv(error)

call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

end subroutine

Expand Down Expand Up @@ -170,7 +170,7 @@ subroutine test_BD_CrvCompose(error)
call BD_CrvCompose(composedparams, 4 * tan(angle1 / 4) * n1, 4 * tan(angle2 / 4) * n2, flag)
call BD_CrvMatrixR(composedparams, testrotation)

call check_array(error, baselinerotation, testrotation, testname, tolerance)
call check_array(error, baselinerotation, testrotation, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "delta2 > 0, no transpose of input rotations (flag = 0):"
Expand All @@ -185,7 +185,7 @@ subroutine test_BD_CrvCompose(error)
call BD_CrvCompose(composedparams, 4 * tan(angle1 / 4) * n1, 4 * tan(angle2 / 4) * n2, flag)
call BD_CrvMatrixR(composedparams, testrotation)

call check_array(error, baselinerotation, testrotation, testname, tolerance)
call check_array(error, baselinerotation, testrotation, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "delta2 < 0, no transpose of input rotations (flag = 0):"
Expand All @@ -200,7 +200,7 @@ subroutine test_BD_CrvCompose(error)
call BD_CrvCompose(composedparams, 4 * tan(angle1 / 4) * n1, 4 * tan(angle2 / 4) * n2, flag)
call BD_CrvMatrixR(composedparams, testrotation)

call check_array(error, baselinerotation, testrotation, testname, tolerance)
call check_array(error, baselinerotation, testrotation, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "delta2 > 0, transpose of first rotation (flag = 1):"
Expand All @@ -215,7 +215,7 @@ subroutine test_BD_CrvCompose(error)
call BD_CrvCompose(composedparams, 4 * tan(angle1 / 4) * n1, 4 * tan(angle2 / 4) * n2, flag)
call BD_CrvMatrixR(composedparams, testrotation)

call check_array(error, baselinerotation, testrotation, testname, tolerance)
call check_array(error, baselinerotation, testrotation, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "delta2 > 0, transpose of second rotation (flag = 2):"
Expand All @@ -230,7 +230,7 @@ subroutine test_BD_CrvCompose(error)
call BD_CrvCompose(composedparams, 4 * tan(angle1 / 4) * n1, 4 * tan(angle2 / 4) * n2, flag)
call BD_CrvMatrixR(composedparams, testrotation)

call check_array(error, baselinerotation, testrotation, testname, tolerance)
call check_array(error, baselinerotation, testrotation, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "delta2 > 0, transpose of both rotations (flag = 3):"
Expand All @@ -245,7 +245,7 @@ subroutine test_BD_CrvCompose(error)
call BD_CrvCompose(composedparams, 4 * tan(angle1 / 4) * n1, 4 * tan(angle2 / 4) * n2, flag)
call BD_CrvMatrixR(composedparams, testrotation)

call check_array(error, baselinerotation, testrotation, testname, tolerance)
call check_array(error, baselinerotation, testrotation, testname, tolerance); if (allocated(error)) return

end subroutine

Expand Down Expand Up @@ -277,8 +277,8 @@ subroutine test_BD_CrvExtractCrv(error)
r = RonXAxis(angle)
call BD_CrvExtractCrv(r, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "0 rotation:"
Expand All @@ -290,8 +290,8 @@ subroutine test_BD_CrvExtractCrv(error)
r = RonXAxis(angle)
call BD_CrvExtractCrv(r, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "small rotation with baseline WM parameters calculated:"
Expand All @@ -303,8 +303,8 @@ subroutine test_BD_CrvExtractCrv(error)
r = RonXAxis(angle)
call BD_CrvExtractCrv(r, test_wmparams, ErrStat, ErrMsg)

call check(error, ErrID_None, ErrStat, testname)
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance)
call check(error, ErrID_None, ErrStat, testname); if (allocated(error)) return
call check_array(error, baseline_wmparams, test_wmparams, testname, tolerance); if (allocated(error)) return

end subroutine

Expand Down Expand Up @@ -341,7 +341,7 @@ subroutine test_BD_CrvMatrixH(error)

call BD_CrvMatrixH(wmparams, testH)

call check_array(error, baselineH*1.1, testH, testname, tolerance)
call check_array(error, baselineH, testH, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "0 rotation:"
Expand All @@ -354,7 +354,7 @@ subroutine test_BD_CrvMatrixH(error)

call BD_CrvMatrixH(wmparams, testH)

call check_array(error, baselineH, testH, testname, tolerance)
call check_array(error, baselineH, testH, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "small rotation with baseline WM parameters calculated:"
Expand All @@ -367,7 +367,7 @@ subroutine test_BD_CrvMatrixH(error)

call BD_CrvMatrixH(wmparams, testH)

call check_array(error, baselineH, testH, testname, tolerance)
call check_array(error, baselineH, testH, testname, tolerance); if (allocated(error)) return

contains
function H(c)
Expand Down Expand Up @@ -416,7 +416,7 @@ subroutine test_BD_CrvMatrixR(error)
wmparams = [4.0, 0.0, 0.0]
call BD_CrvMatrixR(wmparams, testR)

call check_array(error, baselineR, testR, testname, tolerance)
call check_array(error, baselineR, testR, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "0 rotation:"
Expand All @@ -428,7 +428,7 @@ subroutine test_BD_CrvMatrixR(error)
wmparams = [0.0, 0.0, 0.0]
call BD_CrvMatrixR(wmparams, testR)

call check_array(error, baselineR, testR, testname, tolerance)
call check_array(error, baselineR, testR, testname, tolerance); if (allocated(error)) return

! --------------------------------------------------------------------------
testname = "small rotation with baseline WM parameters calculated:"
Expand All @@ -440,7 +440,7 @@ subroutine test_BD_CrvMatrixR(error)
wmparams = 4 * tan(angle / 4) * n
call BD_CrvMatrixR(wmparams, testR)

call check_array(error, baselineR, testR, testname, tolerance)
call check_array(error, baselineR, testR, testname, tolerance); if (allocated(error)) return

end subroutine

Expand All @@ -459,7 +459,7 @@ subroutine test_BD_ExtractRelativeRotation(error)
otherstate = simpleOtherState()
parametertype = simpleParameterType(1, 16, 16, 0, 0)
call ExtractRelativeRotation(identity(), parametertype, otherstate, rr, ErrStat, ErrMsg)
call check_array(error, rr, [0.0_BDKi, 0.0_BDKi, 0.0_BDKi], testname, tolerance)
call check_array(error, rr, [0.0_BDKi, 0.0_BDKi, 0.0_BDKi], testname, tolerance); if (allocated(error)) return
end subroutine

end module
9 changes: 1 addition & 8 deletions modules/beamdyn/tests/test_BD_InitializeNodalLocations.F90
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,7 @@ subroutine test_BD_InitializeNodalLocations_np5_p6(error)
! write(*,*) i, baseline_uuN0(4,i,1), baseline_uuN0(5,i,1), baseline_uuN0(6,i,1), p%uuN0(4,i,1), p%uuN0(5,i,1), p%uuN0(6,i,1)
!enddo

call check_array(error, baseline_uuN0, p%uuN0, testname, tolerance)

deallocate (kp_member)
deallocate (kp_coordinate)
deallocate (gll)
deallocate (baseline_uuN0)
deallocate (baseline_tangent)
deallocate (baseline_twist)
call check_array(error, baseline_uuN0, p%uuN0, testname, tolerance); if (allocated(error)) return

call BD_DestroyParam(p, ErrStat, ErrMsg)

Expand Down
4 changes: 2 additions & 2 deletions modules/beamdyn/tests/test_BD_MemberEta.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ subroutine test_BD_MemberEta_5node(error)

call BD_MemberEta(member_total, baseline_QPtW, baseline_jac, test_member_eta, test_total_length)

call check(error, baseline_total_length, test_total_length, testname, thr=tolerance)
call check_array(error, baseline_member_eta, test_member_eta, testname, tolerance)
call check(error, baseline_total_length, test_total_length, testname, thr=tolerance); if (allocated(error)) return
call check_array(error, baseline_member_eta, test_member_eta, testname, tolerance); if (allocated(error)) return

deallocate (baseline_Jac)
deallocate (baseline_QPtW)
Expand Down
30 changes: 15 additions & 15 deletions modules/beamdyn/tests/test_BD_Misc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ subroutine test_BD_DistrLoadCopy(error)

do j = 1, parametertype%elem_total
do i = 1, parametertype%nqp
call check_array(error, real([9 * (j - 1) + 3 * (i - 1) + 1, 9 * (j - 1) + 3 * (i - 1) + 2, 9 * (j - 1) + 3 * (i - 1) + 3], R8Ki), miscvartype%DistrLoad_QP(1:3, i, j))
call check_array(error, real([-9 * (j - 1) - 3 * (i - 1) - 1, -9 * (j - 1) - 3 * (i - 1) - 2, -9 * (j - 1) - 3 * (i - 1) - 3], R8Ki), miscvartype%DistrLoad_QP(4:6, i, j))
call check_array(error, real([9 * (j - 1) + 3 * (i - 1) + 1, 9 * (j - 1) + 3 * (i - 1) + 2, 9 * (j - 1) + 3 * (i - 1) + 3], R8Ki), miscvartype%DistrLoad_QP(1:3, i, j)); if (allocated(error)) return
call check_array(error, real([-9 * (j - 1) - 3 * (i - 1) - 1, -9 * (j - 1) - 3 * (i - 1) - 2, -9 * (j - 1) - 3 * (i - 1) - 3], R8Ki), miscvartype%DistrLoad_QP(4:6, i, j)); if (allocated(error)) return
end do
end do

Expand Down Expand Up @@ -128,24 +128,24 @@ subroutine test_BD_InputGlobalLocal(error)
call BD_InputGlobalLocal(parametertype, otherstate, inputtype)

! test the values
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%TranslationDisp(:, 1), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%TranslationVel(:, 1), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%RotationVel(:, 1), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%TranslationAcc(:, 1), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%RotationAcc(:, 1), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%TranslationDisp(:, 1), BDKi), testname, tolerance); if (allocated(error)) return
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%TranslationVel(:, 1), BDKi), testname, tolerance); if (allocated(error)) return
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%RotationVel(:, 1), BDKi), testname, tolerance); if (allocated(error)) return
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%TranslationAcc(:, 1), BDKi), testname, tolerance); if (allocated(error)) return
call check_array(error, vectorAfterRotation, real(inputtype%RootMotion%RotationAcc(:, 1), BDKi), testname, tolerance); if (allocated(error)) return

do i = 1, parametertype%node_total
call check_array(error, vectorAfterRotation, real(inputtype%PointLoad%Force(1:3, i), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%PointLoad%Moment(1:3, i), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%PointLoad%Force(1:3, i), BDKi), testname, tolerance); if (allocated(error)) return
call check_array(error, vectorAfterRotation, real(inputtype%PointLoad%Moment(1:3, i), BDKi), testname, tolerance); if (allocated(error)) return
end do

inputtype%DistrLoad%Nnodes = totalnodes
do i = 1, inputtype%DistrLoad%Nnodes
call check_array(error, vectorAfterRotation, real(inputtype%DistrLoad%Force(1:3, i), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%DistrLoad%Moment(1:3, i), BDKi), testname, tolerance)
call check_array(error, vectorAfterRotation, real(inputtype%DistrLoad%Force(1:3, i), BDKi), testname, tolerance); if (allocated(error)) return
call check_array(error, vectorAfterRotation, real(inputtype%DistrLoad%Moment(1:3, i), BDKi), testname, tolerance); if (allocated(error)) return
end do

call check_array(error, transpose(otherstate%GlbRot), inputtype%RootMotion%Orientation(:, :, 1), testname, tolerance)
call check_array(error, transpose(otherstate%GlbRot), inputtype%RootMotion%Orientation(:, :, 1), testname, tolerance); if (allocated(error)) return

end subroutine

Expand Down Expand Up @@ -175,7 +175,7 @@ subroutine test_BD_GravityForce(error)
call BD_GravityForce(1, parametertype, miscvartype, gravity)

! test the values
call check_array(error, baseline, miscvartype%qp%Fg(:, 1, 1), testname, tolerance)
call check_array(error, baseline, miscvartype%qp%Fg(:, 1, 1), testname, tolerance); if (allocated(error)) return

call BD_DestroyParam(parametertype, ErrStat, ErrMsg)

Expand Down Expand Up @@ -209,8 +209,8 @@ subroutine test_BD_QPData_mEta_rho(error)

do j = 1, parametertype%elem_total
do i = 1, parametertype%nqp
call check_array(error, baselineRho, miscvartype%qp%rho(:, :, i, j), testname, tolerance)
call check_array(error, baselineRR0mEta, miscvartype%qp%RR0mEta(:, i, j), testname, tolerance)
call check_array(error, baselineRho, miscvartype%qp%rho(:, :, i, j), testname, tolerance); if (allocated(error)) return
call check_array(error, baselineRR0mEta, miscvartype%qp%RR0mEta(:, i, j), testname, tolerance); if (allocated(error)) return
end do
end do
call BD_DestroyParam(parametertype, ErrStat, ErrMsg)
Expand Down
Loading

0 comments on commit 06d6c97

Please sign in to comment.