From dd92ae7de2406243dfdd4d7b8fcc1395fc014033 Mon Sep 17 00:00:00 2001 From: asharma Date: Thu, 7 Jan 2021 14:25:43 -0700 Subject: [PATCH 1/2] Add unit tests for BD_ComputeIniNodalCrv.F90 --- .../tests/test_BD_ComputeIniNodalCrv.F90 | 83 +++++++++++++++++++ unit_tests/beamdyn/CMakeLists.txt | 1 + 2 files changed, 84 insertions(+) create mode 100644 modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 diff --git a/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 b/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 new file mode 100644 index 0000000000..d09b8bb4a1 --- /dev/null +++ b/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 @@ -0,0 +1,83 @@ +@test +subroutine test_BD_ComputeIniNodalCrv() + ! test branches + ! - simple rotation with known parameters: Pi on xaxis + ! - 0 rotation + ! - small rotation with baseline WM parameters calculated + + use pFUnit_mod + use BeamDyn_Subs + use NWTC_Num + use test_tools + + implicit none + + real(BDKi), dimension(3,3) :: r + real(BDKi), dimension(3) :: test_wmparams, baseline_wmparams + real(BDKi) :: angle, param, n(3) + character(1024) :: testname + real(BDKi) :: tolerance + integer(IntKi) :: ErrStat + character :: ErrMsg + + ! initialize NWTC_Num constants + call SetConstants() + + tolerance = 1e-14 + + ! -------------------------------------------------------------------------- + testname = "Tangent aligned with z-axis and 0 degree twist:" + n = (/ 0.0_BDKi, 0.0_BDKi, 1.0_BDKi /) ! tangent axis + angle = 0 + + ! Baseline Wiener-Milenkovic parameters + baseline_wmparams = (/ 0.0, 0.0, 0.0 /) + + call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg) + + @assertEqual(0.0_BDKi, ErrStat, tolerance, testname) + @assertEqual(baseline_wmparams, test_wmparams, tolerance, testname) + + ! -------------------------------------------------------------------------- + testname = "Tangent at 45 degree w.r.t. y-axis and 0 degree twist:" + n = (/ 1.0_BDKi/sqrt(2.0_BDKi), 0.0_BDKi, 1.0_BDKi/sqrt(2.0_BDKi) /) ! tangent axis + angle = 0.0_BDKi + + ! Baseline Wiener-Milenkovic parameters + param = 4*tan((Pi_D/4)/4) + baseline_wmparams = (/ 0.0, param, 0.0 /) + + call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg) + + @assertEqual(0.0_BDKi, ErrStat, tolerance, testname) + @assertEqual(baseline_wmparams, test_wmparams, tolerance, testname) + + ! -------------------------------------------------------------------------- + testname = "Tangent at -45 degree w.r.t. x-axis and 0 degree twist:" + n = (/ 0.0_BDKi, 1.0_BDKi/sqrt(2.0_BDKi), 1.0_BDKi/sqrt(2.0_BDKi) /) ! tangent axis + angle = 0.0_BDKi + + ! Baseline Wiener-Milenkovic parameters + param = 4*tan((-Pi_D/4)/4) + baseline_wmparams = (/ param, 0.0, 0.0 /) + + call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg) + + @assertEqual(0.0_BDKi, ErrStat, tolerance, testname) + @assertEqual(baseline_wmparams, test_wmparams, tolerance, testname) + + ! -------------------------------------------------------------------------- + testname = "Tangent along z-axis with 45 degree twist:" + n = (/ 0.0_BDKi, 0.0, 1.0_BDKi /) ! tangent axis + angle = 45.0_BDKi + + ! Baseline Wiener-Milenkovic parameters + param = 4*tan((Pi_D/4)/4) + baseline_wmparams = (/ 0.0, 0.0, param /) + + call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg) + + @assertEqual(0.0_BDKi, ErrStat, tolerance, testname) + @assertEqual(baseline_wmparams, test_wmparams, tolerance, testname) + +end subroutine test_BD_ComputeIniNodalCrv diff --git a/unit_tests/beamdyn/CMakeLists.txt b/unit_tests/beamdyn/CMakeLists.txt index 2ae37b0fc4..c93ac28494 100644 --- a/unit_tests/beamdyn/CMakeLists.txt +++ b/unit_tests/beamdyn/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories( set(testlist test_tools + test_BD_ComputeIniNodalCrv test_BD_CrvCompose test_BD_CheckRotMat test_BD_CrvExtractCrv From cfa78a14230c69c57773787817f75cb121b1c3d5 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 19 Jan 2021 10:29:35 -0600 Subject: [PATCH 2/2] Fix type-casting issue --- modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 b/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 index d09b8bb4a1..17f476db34 100644 --- a/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 +++ b/modules/beamdyn/tests/test_BD_ComputeIniNodalCrv.F90 @@ -27,7 +27,7 @@ subroutine test_BD_ComputeIniNodalCrv() ! -------------------------------------------------------------------------- testname = "Tangent aligned with z-axis and 0 degree twist:" - n = (/ 0.0_BDKi, 0.0_BDKi, 1.0_BDKi /) ! tangent axis + n = (/ real(0.0, BDKi), real(0.0, BDKi), real(1.0, BDKi) /) ! tangent axis angle = 0 ! Baseline Wiener-Milenkovic parameters @@ -45,7 +45,7 @@ subroutine test_BD_ComputeIniNodalCrv() ! Baseline Wiener-Milenkovic parameters param = 4*tan((Pi_D/4)/4) - baseline_wmparams = (/ 0.0, param, 0.0 /) + baseline_wmparams = (/ real(0.0, BDKi), param, real(0.0, BDKi) /) call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg) @@ -59,7 +59,7 @@ subroutine test_BD_ComputeIniNodalCrv() ! Baseline Wiener-Milenkovic parameters param = 4*tan((-Pi_D/4)/4) - baseline_wmparams = (/ param, 0.0, 0.0 /) + baseline_wmparams = (/ param, real(0.0, BDKi), real(0.0, BDKi) /) call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg) @@ -68,12 +68,12 @@ subroutine test_BD_ComputeIniNodalCrv() ! -------------------------------------------------------------------------- testname = "Tangent along z-axis with 45 degree twist:" - n = (/ 0.0_BDKi, 0.0, 1.0_BDKi /) ! tangent axis + n = (/ real(0.0, BDKi), real(0.0, BDKi), 1.0_BDKi /) ! tangent axis angle = 45.0_BDKi ! Baseline Wiener-Milenkovic parameters param = 4*tan((Pi_D/4)/4) - baseline_wmparams = (/ 0.0, 0.0, param /) + baseline_wmparams = (/ real(0.0, BDKi), real(0.0, BDKi), param /) call BD_ComputeIniNodalCrv(n, angle, test_wmparams, ErrStat, ErrMsg)