From 1792298bb7d646de8d9ba3a661fd35a69ff16a28 Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Tue, 20 Jun 2023 14:46:05 +0200 Subject: [PATCH 01/11] Atmosphere, Radiation, Solarsystem, thirdbody Pfunit tests addded --- tests/CMakeLists.txt | 31 ++++++- tests/test_atmosphere_Exponential.pf | 28 ++++++ tests/test_atmosphere_JB2008.pf | 30 +++++++ tests/test_gravity.pf | 96 ++++++++++++++++++++ tests/test_radiation.pf | 130 +++++++++++++++++++++++++++ tests/test_solarsystem.pf | 39 ++++++++ tests/test_thirdbody | 43 +++++++++ 7 files changed, 395 insertions(+), 2 deletions(-) create mode 100644 tests/test_atmosphere_Exponential.pf create mode 100644 tests/test_atmosphere_JB2008.pf create mode 100644 tests/test_gravity.pf create mode 100644 tests/test_radiation.pf create mode 100644 tests/test_solarsystem.pf create mode 100644 tests/test_thirdbody diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a34e68d..686a08b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,8 +16,35 @@ add_pfunit_ctest (atmosphere_tests_nrlmsis00 LINK_LIBRARIES neptune ${LIBSLAM} ) + add_pfunit_ctest (atmosphere_tests_JB2008 + TEST_SOURCES test_atmosphere_JB2008.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) + add_pfunit_ctest (atmosphere_tests_Exponential + TEST_SOURCES test_atmosphere_Exponential.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) + add_pfunit_ctest (solarsystem_tests + TEST_SOURCES test_solarsystem.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) + + add_pfunit_ctest (Thirdbody_tests + TEST_SOURCES test_thirdbody.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) + + add_pfunit_ctest (Radiation_tests + TEST_SOURCES test_radiation.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) + + # add_pfunit_ctest (gravity_tests + # TEST_SOURCES test_gravity.pf + # LINK_LIBRARIES neptune ${LIBSLAM} + # ) + add_pfunit_ctest (tides_tests TEST_SOURCES test_tides.pf LINK_LIBRARIES neptune ${LIBSLAM} - ) - \ No newline at end of file + ) \ No newline at end of file diff --git a/tests/test_atmosphere_Exponential.pf b/tests/test_atmosphere_Exponential.pf new file mode 100644 index 0000000..0d1755f --- /dev/null +++ b/tests/test_atmosphere_Exponential.pf @@ -0,0 +1,28 @@ +module test_atmosphere_Exponential + use funit + use atmosphere, only: Atmosphere_class, EXPONENTIAL + + implicit none + + contains + + @test + subroutine test_getDensityExponential() + ! Tests that a density is computed by the NRLMSIS2.0 model + + type(Atmosphere_class) :: atmosphere_model + + atmosphere_model = Atmosphere_class() + + atmosphere_model%nmodel = EXPONENTIAL + call atmosphere_model%setAtmosphereInitFlag() + call atmosphere_model%initAtmosphere('../../work/data') + + ! test #1 + @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.65d1), 0.10168617826293667d-002, tolerance=0.01) + ! test #2 + @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.20788356929965501d-002, tolerance=0.01) + + end subroutine test_getDensityExponential + +end module test_atmosphere_Exponential \ No newline at end of file diff --git a/tests/test_atmosphere_JB2008.pf b/tests/test_atmosphere_JB2008.pf new file mode 100644 index 0000000..df73742 --- /dev/null +++ b/tests/test_atmosphere_JB2008.pf @@ -0,0 +1,30 @@ +module test_atmosphere_JB2008 + use funit + use atmosphere, only: Atmosphere_class, JB08 + + + implicit none + + contains + + @test + subroutine test_getDensityJB2008() + ! Tests that a density is computed by the JB2008 model + ! inputs taken from the msis2.0_test_in file (File for JB208 ?) + + type(Atmosphere_class) :: atmosphere_model + + atmosphere_model = Atmosphere_class() + + atmosphere_model%nmodel = JB08 + call atmosphere_model%setAtmosphereInitFlag() + call atmosphere_model%initAtmosphere('../../work/data') + + ! test #1 + @assertRelativelyEqual(atmosphere_model%getDensityJB2008(500.d0, 0.65d1, 96.d0, 0.5276739668d5), 0.10168617826293667d-002, tolerance=0.01) + ! test #2 + @assertRelativelyEqual(atmosphere_model%getDensityJB2008(0.4688d3, -0.195d2, 0.446d2, 0.4389981823d5), 0.20788356929965501d-002, tolerance=0.01) + + end subroutine test_getDensityJB2008 + +end module test_atmosphere_JB2008 \ No newline at end of file diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf new file mode 100644 index 0000000..4b13a92 --- /dev/null +++ b/tests/test_gravity.pf @@ -0,0 +1,96 @@ +module test_gravity + use funit + use gravity + use slam_reduction_class, only: Reduction_type + use slam_math + use slam_error_handling + + implicit none + + contains + + @test + subroutine test_getGravityAccelaration() + ! Tests that a density is computed by the NRLMSIS2.0 model + + + type(Reduction_type) :: reduction_handler + class(Gravity_class) :: gravity + + real(dp), dimension(3) :: r_itrf + real(dp), dimension(3) :: v_itrf + real(dp) :: time_mjd, tolerance + + real(dp), dimension(3) :: accel, expected_accel + + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('data') + initialized = .true. + end if + + ! Set Up inputs + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + time_mjd = 59868.16721065 + ! Call the subroutine to be tested + call getGravityAcceleration(gravity, reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + ! Set up expected outputs + expected_accel = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(accel, expected_accel, tolerance) + + + end subroutine test_getGravityAccelaration + + + @test + subroutine test_getGravityCovariance() + ! Tests that a density is computed by the NRLMSIS2.0 model + + + type(Reduction_type) :: reduction_handler + class(Gravity_class) :: gravity + + real(dp), dimension(3) :: r_itrf + real(dp), dimension(3) :: v_itrf + real(dp), dimension(3) :: cov, expected_cov + real(dp) :: tolerance + + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('data') + initialized = .true. + end if + + + ! Set Up inputs + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + ! Call the subroutine to be tested + call getGravityCovariance(gravity, r_itrf, v_itrf) + + ! Set up expected outputs + expected_cov = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(cov, expected_cov, tolerance) + + + end subroutine test_getGravityCovariance + +end module test_gravity \ No newline at end of file diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf new file mode 100644 index 0000000..51a9638 --- /dev/null +++ b/tests/test_radiation.pf @@ -0,0 +1,130 @@ +module test_radiation + use funit + use radiation + use slam_reduction_class, only: Reduction_type + use slam_math + use slam_error_handling + use satellite + use solarsystem + + implicit none + + + contains + + @test + subroutine test_getShadow() + + class(Radiation_class) :: radiation + real(dp), dimension(3) :: r_sun + real(dp), dimension(3) :: r_sat + real(dp) :: getShadow,expected_shadow + + + ! Set Up inputs + r_sun = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + r_sat = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + ! Call the subroutine to be tested + call getShadow(radiation, r_sun, r_sat) + + ! Set up expected outputs + expected_shadow = 1.d0 + + + + ! Check if outputs match expected values + @assertEqual(getShadow, expected_shadow) + + + end subroutine test_getShadow + + + @test + subroutine test_getSrpAcceleration() + + class(Radiation_class) :: radiation + type(Satellite_class) :: satellite_model + type(Solarsystem_class) :: solarsystem_model + type(Reduction_type) :: reduction + real(dp), dimension(3) :: r_gcrf + real(dp), dimension(3) :: v_gcrf + real(dp) :: time_mjd, tolerance + + real(dp), dimension(3) :: acc_srp,expected_srp + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction = Reduction_type() + call reduction%initEop('data') + initialized = .true. + end if + + + ! Set Up inputs + r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + time_mjd = 59600 + ! Call the subroutine to be tested + call getSrpAcceleration(radiation, satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, acc_srp) + + ! Set up expected outputs + expected_srp = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_srp, expected_srp, tolerance) + + + + end subroutine test_getSrpAcceleration + + @test + subroutine test_getAlbedoAcceleration() + + class(Radiation_class) :: radiation + type(Satellite_class) :: satellite_model + type(Solarsystem_class) :: solarsystem_model + type(Reduction_type) :: reduction + real(dp), dimension(3) :: r_gcrf + real(dp), dimension(3) :: v_gcrf + real(dp) :: time_mjd, tolerance + + real(dp), dimension(3) :: acc_alb, expected_alb + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction = Reduction_type() + call reduction%initEop('data') + initialized = .true. + end if + + + ! Set Up inputs + r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + time_mjd = 59600 + ! Call the subroutine to be tested + call getAlbedoAcceleration(radiation, satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, expected_alb) + + ! Set up expected outputs + expected_alb = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_alb, expected_alb, tolerance) + + + + end subroutine test_getAlbedoAcceleration + + + + + +end module test_radiation \ No newline at end of file diff --git a/tests/test_solarsystem.pf b/tests/test_solarsystem.pf new file mode 100644 index 0000000..30f80f8 --- /dev/null +++ b/tests/test_solarsystem.pf @@ -0,0 +1,39 @@ +module test_solarsystem + use funit + use solarsystem + + implicit none + + contains + + @test + subroutine test_getBodyPosition() + + class(Solarsystem_class):: solarsystem + real(dp) :: time_mjd, tolerance + integer :: body_id + real(dp), dimension(3) :: getBodyPosition, expected_position + + + ! Set Up inputs + body_id = 1111 + time_mjd = 59868.16721065 + ! Call the subroutine to be tested + call getBodyPosition(time_mjd, body_id) + + ! Set up expected outputs + expected_position = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(getBodyPosition, expected_position, tolerance) + + + end subroutine test_getBodyPosition + + + + +end module test_solarsystem \ No newline at end of file diff --git a/tests/test_thirdbody b/tests/test_thirdbody new file mode 100644 index 0000000..ec844f0 --- /dev/null +++ b/tests/test_thirdbody @@ -0,0 +1,43 @@ +module test_thirdbody + use funit + use thirdbody + + implicit none + + contains + + @test + subroutine test_getThirdBodyAccelaration() + + class(ThirdBody_class) :: third_body + type(Solarsystem_class) :: solarsystem_model + real(dp), dimension(3), :: r_gcrf + real(dp), :: time_mjd + integer, :: body_id + + real(dp), dimension(3), :: acc_thirdbody, expected_acc + + + ! Set Up inputs + body_id = 1111 + time_mjd = 59868.16721065_dp + r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + ! Call the subroutine to be tested + call getThirdBodyAcceleration(third_body, solarsystem_model, r_gcrf time_mjd, body_id, acc_thirdbody) + + ! Set up expected outputs + expected_acc = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + + + end subroutine test_getThirdBodyAccelaration + + + + +end module test_thirdbody \ No newline at end of file From 31f45458b53c322db0691ce867cf75cb9856bfcd Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Tue, 27 Jun 2023 13:38:10 +0200 Subject: [PATCH 02/11] neptune tests added --- build.sh | 2 +- tests/CMakeLists.txt | 8 +- tests/test_atmosphere_Exponential.pf | 4 +- tests/test_atmosphere_JB2008.pf | 4 +- tests/test_atmosphere_nrlmsis00.pf | 3 +- tests/test_gravity.pf | 26 ++--- tests/test_radiation.pf | 151 ++++++++++++++++----------- tests/test_solarsystem.pf | 23 ++-- tests/test_thirdbody | 43 -------- tests/test_thirdbody.pf | 56 ++++++++++ 10 files changed, 184 insertions(+), 136 deletions(-) delete mode 100644 tests/test_thirdbody create mode 100644 tests/test_thirdbody.pf diff --git a/build.sh b/build.sh index fcf98b1..9cc8e62 100755 --- a/build.sh +++ b/build.sh @@ -121,7 +121,7 @@ fi cd build || exit echo "Updating cmake" export PFUNIT_DIR=..//pFUnit/build/installed -cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_OPI_SUPPORT=ON -DSKIP_MSIS_2=ON ../ +cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_OPI_SUPPORT=ON -DSKIP_MSIS_2=OFF ../ echo "Building NEPTUNE" make install if [[ $? -ne 0 ]]; then diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 686a08b..255ba4c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,10 +39,10 @@ add_pfunit_ctest (atmosphere_tests_nrlmsis00 LINK_LIBRARIES neptune ${LIBSLAM} ) - # add_pfunit_ctest (gravity_tests - # TEST_SOURCES test_gravity.pf - # LINK_LIBRARIES neptune ${LIBSLAM} - # ) + add_pfunit_ctest (gravity_tests + TEST_SOURCES test_gravity.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) add_pfunit_ctest (tides_tests TEST_SOURCES test_tides.pf diff --git a/tests/test_atmosphere_Exponential.pf b/tests/test_atmosphere_Exponential.pf index 0d1755f..a0b2f20 100644 --- a/tests/test_atmosphere_Exponential.pf +++ b/tests/test_atmosphere_Exponential.pf @@ -19,9 +19,9 @@ module test_atmosphere_Exponential call atmosphere_model%initAtmosphere('../../work/data') ! test #1 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.65d1), 0.10168617826293667d-002, tolerance=0.01) + @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.65d1), 499706396.76297361d0, tolerance=0.01) ! test #2 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.20788356929965501d-002, tolerance=0.01) + @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.11635971694422577d-002, tolerance=0.01) end subroutine test_getDensityExponential diff --git a/tests/test_atmosphere_JB2008.pf b/tests/test_atmosphere_JB2008.pf index df73742..f29fbf5 100644 --- a/tests/test_atmosphere_JB2008.pf +++ b/tests/test_atmosphere_JB2008.pf @@ -10,15 +10,17 @@ module test_atmosphere_JB2008 @test subroutine test_getDensityJB2008() ! Tests that a density is computed by the JB2008 model - ! inputs taken from the msis2.0_test_in file (File for JB208 ?) + ! inputs taken from the msis2.0_test_in file (File for JB2008 ?) type(Atmosphere_class) :: atmosphere_model atmosphere_model = Atmosphere_class() atmosphere_model%nmodel = JB08 + call atmosphere_model%setAtmosphereInitFlag() call atmosphere_model%initAtmosphere('../../work/data') + initAtmosphere%sgaDataType = 3 ! test #1 @assertRelativelyEqual(atmosphere_model%getDensityJB2008(500.d0, 0.65d1, 96.d0, 0.5276739668d5), 0.10168617826293667d-002, tolerance=0.01) diff --git a/tests/test_atmosphere_nrlmsis00.pf b/tests/test_atmosphere_nrlmsis00.pf index bd01261..98133f1 100644 --- a/tests/test_atmosphere_nrlmsis00.pf +++ b/tests/test_atmosphere_nrlmsis00.pf @@ -16,13 +16,12 @@ module test_atmosphere_nrlmsis00 ! Longitude: 0.0 ! rad type(Atmosphere_class) :: atmosphere_model - + atmosphere_model = Atmosphere_class() atmosphere_model%nmodel = MSIS2000 call atmosphere_model%setAtmosphereInitFlag() call atmosphere_model%initAtmosphere('../../work/data') - ! @assertRelativelyEqual(atmosphere_model%getDensityMSIS2000(500.d0, 0.d0, 0.d0, 51544.d0), 0.5712d-003, tolerance=0.01) @assertRelativelyEqual(atmosphere_model%getDensityMSIS2000(500.d0, 0.d0, 0.d0, 51544.d0), 0.79964653605310576d-003, tolerance=0.01) diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf index 4b13a92..f786daa 100644 --- a/tests/test_gravity.pf +++ b/tests/test_gravity.pf @@ -15,7 +15,7 @@ module test_gravity type(Reduction_type) :: reduction_handler - class(Gravity_class) :: gravity + type(Gravity_class) :: gravity_model real(dp), dimension(3) :: r_itrf real(dp), dimension(3) :: v_itrf @@ -28,7 +28,7 @@ module test_gravity call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") if (.not. initialized) then reduction_handler = Reduction_type() - call reduction_handler%initEop('data') + call reduction_handler%initEop('../../work/data') initialized = .true. end if @@ -37,10 +37,10 @@ module test_gravity v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) time_mjd = 59868.16721065 ! Call the subroutine to be tested - call getGravityAcceleration(gravity, reduction_handler, r_itrf, v_itrf, time_mjd, accel) + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) ! Set up expected outputs - expected_accel = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + expected_accel = (/-0.67427774119464268E-2, 0.0, 0.0/) ! Set up tolerances tolerance = 1e-6_dp @@ -54,35 +54,35 @@ module test_gravity @test subroutine test_getGravityCovariance() - ! Tests that a density is computed by the NRLMSIS2.0 model + ! Tests Gravity covariance type(Reduction_type) :: reduction_handler - class(Gravity_class) :: gravity + type(Gravity_class) :: gravity_model real(dp), dimension(3) :: r_itrf real(dp), dimension(3) :: v_itrf - real(dp), dimension(3) :: cov, expected_cov + real(dp), dimension(3,3):: cov, expected_cov real(dp) :: tolerance - logical :: initialized = .false. !** init reduction model and EOP call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") if (.not. initialized) then reduction_handler = Reduction_type() - call reduction_handler%initEop('data') + call reduction_handler%initEop('../../work/data') initialized = .true. end if - - ! Set Up inputs + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) ! Call the subroutine to be tested - call getGravityCovariance(gravity, r_itrf, v_itrf) + cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) ! Set up expected outputs - expected_cov = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + expected_cov = reshape((/0.2999999, 1.3877787807814457E-017, -0.1, & + 1.3877787807814457E-017, 0.28571428571428564, -0.14285714285714285, & + -0.1, -0.14285714285714285, 0.27142857142857146/), (/3, 3/)) ! Set up tolerances tolerance = 1e-6_dp diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index 51a9638..704db7c 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -6,122 +6,147 @@ module test_radiation use slam_error_handling use satellite use solarsystem + use Neptuneclass implicit none contains - @test - subroutine test_getShadow() +! @test +! subroutine test_getShadow() - class(Radiation_class) :: radiation - real(dp), dimension(3) :: r_sun - real(dp), dimension(3) :: r_sat - real(dp) :: getShadow,expected_shadow +! type(Radiation_class) :: radiation +! real(dp), dimension(3) :: r_sun +! real(dp), dimension(3) :: r_sat +! real :: expected_shadow, retreived_shadow - ! Set Up inputs - r_sun = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - r_sat = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - ! Call the subroutine to be tested - call getShadow(radiation, r_sun, r_sat) +! Set Up inputs +! r_sun = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! r_sat = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! ! Call the subroutine to be tested +! retreived_shadow = radiation%getShadow(radiation, r_sun, r_sat) - ! Set up expected outputs - expected_shadow = 1.d0 +! Set up expected outputs +! expected_shadow = 1.d0 - ! Check if outputs match expected values - @assertEqual(getShadow, expected_shadow) +! Check if outputs match expected values +! @assertEqual(retreived_shadow, expected_shadow) - end subroutine test_getShadow +! end subroutine test_getShadow @test subroutine test_getSrpAcceleration() - class(Radiation_class) :: radiation + type(Radiation_class) :: radiation_model type(Satellite_class) :: satellite_model type(Solarsystem_class) :: solarsystem_model - type(Reduction_type) :: reduction + type(Reduction_type) :: reduction_handler + type(Neptune_class) :: neptune real(dp), dimension(3) :: r_gcrf real(dp), dimension(3) :: v_gcrf real(dp) :: time_mjd, tolerance real(dp), dimension(3) :: acc_srp,expected_srp + type(time_t) :: epoch logical :: initialized = .false. - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction = Reduction_type() - call reduction%initEop('data') - initialized = .true. - end if + + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + !** init reduction model and EOP + + epoch%mjd = 59600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "/home/arkenz/neptune/work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 300 + satellite_model%cdrag = 2.5 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = ORIENT_SPHERE + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + ! Set Up inputs - r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + r_gcrf = (/-42044.21889179173, -3193.6719204189853, 7000000.000/) + v_gcrf = (/0.23272475970034712, -3.0658575760606777, 0.0006346736275647091/) time_mjd = 59600 ! Call the subroutine to be tested - call getSrpAcceleration(radiation, satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, acc_srp) + call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) ! Set up expected outputs - expected_srp = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + expected_srp = (/0.0, 0.0, 0.0/) ! Set up tolerances tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_srp, expected_srp, tolerance) + @assertEqual(acc_srp(1), expected_srp(1)) end subroutine test_getSrpAcceleration - @test - subroutine test_getAlbedoAcceleration() - - class(Radiation_class) :: radiation - type(Satellite_class) :: satellite_model - type(Solarsystem_class) :: solarsystem_model - type(Reduction_type) :: reduction - real(dp), dimension(3) :: r_gcrf - real(dp), dimension(3) :: v_gcrf - real(dp) :: time_mjd, tolerance - - real(dp), dimension(3) :: acc_alb, expected_alb - logical :: initialized = .false. - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction = Reduction_type() - call reduction%initEop('data') - initialized = .true. - end if +! @test +! subroutine test_getAlbedoAcceleration() + +! type(Radiation_class) :: radiation_model +! type(Satellite_class) :: satellite_model +! type(Solarsystem_class) :: solarsystem_model +! type(Reduction_type) :: reduction +! real(dp), dimension(3) :: r_gcrf +! real(dp), dimension(3) :: v_gcrf +! real(dp) :: time_mjd, tolerance + +! real(dp), dimension(3) :: acc_alb, expected_alb +! logical :: initialized = .false. +! !** init reduction model and EOP +! call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") +! if (.not. initialized) then +! reduction = Reduction_type() +! call reduction%initEop('data') +! initialized = .true. +! end if - ! Set Up inputs - r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - time_mjd = 59600 - ! Call the subroutine to be tested - call getAlbedoAcceleration(radiation, satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, expected_alb) +! ! Set Up inputs +! r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! time_mjd = 59600 +! ! Call the subroutine to be tested +! call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, expected_alb) - ! Set up expected outputs - expected_alb = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! ! Set up expected outputs +! expected_alb = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - ! Set up tolerances - tolerance = 1e-6_dp +! ! Set up tolerances +! tolerance = 1e-6_dp - ! Check if outputs match expected values - @assertRelativelyEqual(acc_alb, expected_alb, tolerance) +! ! Check if outputs match expected values +! @assertEqual(acc_alb, expected_alb) - end subroutine test_getAlbedoAcceleration +! end subroutine test_getAlbedoAcceleration diff --git a/tests/test_solarsystem.pf b/tests/test_solarsystem.pf index 30f80f8..9e6488c 100644 --- a/tests/test_solarsystem.pf +++ b/tests/test_solarsystem.pf @@ -1,6 +1,7 @@ module test_solarsystem use funit use solarsystem + use neptuneClass implicit none @@ -9,26 +10,34 @@ module test_solarsystem @test subroutine test_getBodyPosition() - class(Solarsystem_class):: solarsystem + type(Solarsystem_class):: solarsystem_model real(dp) :: time_mjd, tolerance integer :: body_id - real(dp), dimension(3) :: getBodyPosition, expected_position - + real(dp), dimension(3) :: expected_position, obtained_position + type(time_t) :: epoch + epoch%mjd = 59600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "/home/arkenz/neptune/work/data", & + 'DE-421', & + epoch & + ) + ! Set Up inputs - body_id = 1111 + body_id = 1 time_mjd = 59868.16721065 ! Call the subroutine to be tested - call getBodyPosition(time_mjd, body_id) + obtained_position = solarsystem_model%getBodyPosition(time_mjd, body_id) ! Set up expected outputs - expected_position = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) + expected_position = (/-137833056.98029408, -52290137.284895524, -22666159.999092821/) ! Set up tolerances tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(getBodyPosition, expected_position, tolerance) + @assertRelativelyEqual(obtained_position, expected_position, tolerance) end subroutine test_getBodyPosition diff --git a/tests/test_thirdbody b/tests/test_thirdbody deleted file mode 100644 index ec844f0..0000000 --- a/tests/test_thirdbody +++ /dev/null @@ -1,43 +0,0 @@ -module test_thirdbody - use funit - use thirdbody - - implicit none - - contains - - @test - subroutine test_getThirdBodyAccelaration() - - class(ThirdBody_class) :: third_body - type(Solarsystem_class) :: solarsystem_model - real(dp), dimension(3), :: r_gcrf - real(dp), :: time_mjd - integer, :: body_id - - real(dp), dimension(3), :: acc_thirdbody, expected_acc - - - ! Set Up inputs - body_id = 1111 - time_mjd = 59868.16721065_dp - r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - ! Call the subroutine to be tested - call getThirdBodyAcceleration(third_body, solarsystem_model, r_gcrf time_mjd, body_id, acc_thirdbody) - - ! Set up expected outputs - expected_acc = (/5543.7970992673218, -4028.7920091557758, 823.95095255406773/) - - ! Set up tolerances - tolerance = 1e-6_dp - - ! Check if outputs match expected values - @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) - - - end subroutine test_getThirdBodyAccelaration - - - - -end module test_thirdbody \ No newline at end of file diff --git a/tests/test_thirdbody.pf b/tests/test_thirdbody.pf new file mode 100644 index 0000000..3945233 --- /dev/null +++ b/tests/test_thirdbody.pf @@ -0,0 +1,56 @@ +module test_thirdbody + use funit + use thirdbody + use slam_reduction_class, only: Reduction_type + use slam_math + use slam_error_handling + use solarsystem + use neptuneClass + implicit none + + contains + + @test + subroutine test_getThirdBodyAccelaration() + + type(ThirdBody_class) :: third_body + type(Solarsystem_class) :: solarsystem_model + real(dp), dimension(3) :: r_gcrf + real(dp) :: time_mjd, tolerance + integer :: body_id + + real(dp), dimension(3) :: acc_thirdbody, expected_acc + + type(time_t) :: epoch + epoch%mjd = 59600 + + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "/home/arkenz/neptune/work/data", & + 'DE-421', & + epoch & + ) + third_body = ThirdBody_class() + ! Set Up inputs + body_id = 1 + time_mjd = 59868.16721065_dp + r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + ! Call the subroutine to be tested + call third_body%getThirdBodyAcceleration(solarsystem_model, r_gcrf, time_mjd, body_id, acc_thirdbody) + + ! Set up expected outputs + expected_acc = (/-0.43302027180447598E-9, 0.18789528607443213E-10, -0.12757560304668043E-9/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + + + end subroutine test_getThirdBodyAccelaration + + + + +end module test_thirdbody \ No newline at end of file From 1fab6bde733500e080e655a27903276c013227df Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Tue, 4 Jul 2023 14:16:53 +0200 Subject: [PATCH 03/11] some recent updates --- tests/test_atmosphere_JB2008.pf | 8 +- tests/test_gravity.pf | 135 ++++++++++--------- tests/test_radiation.pf | 225 ++++++++++++++++---------------- 3 files changed, 182 insertions(+), 186 deletions(-) diff --git a/tests/test_atmosphere_JB2008.pf b/tests/test_atmosphere_JB2008.pf index f29fbf5..8023a33 100644 --- a/tests/test_atmosphere_JB2008.pf +++ b/tests/test_atmosphere_JB2008.pf @@ -19,13 +19,13 @@ module test_atmosphere_JB2008 atmosphere_model%nmodel = JB08 call atmosphere_model%setAtmosphereInitFlag() + atmosphere_model%sgaDataFile = "SOLFSMY.TXT" call atmosphere_model%initAtmosphere('../../work/data') - initAtmosphere%sgaDataType = 3 ! test #1 - @assertRelativelyEqual(atmosphere_model%getDensityJB2008(500.d0, 0.65d1, 96.d0, 0.5276739668d5), 0.10168617826293667d-002, tolerance=0.01) - ! test #2 - @assertRelativelyEqual(atmosphere_model%getDensityJB2008(0.4688d3, -0.195d2, 0.446d2, 0.4389981823d5), 0.20788356929965501d-002, tolerance=0.01) + @assertRelativelyEqual(atmosphere_model%getDensityJB2008(500.d0, 0.d0, 0.d0, 51544.d0), 0.12405204124422383d-002, tolerance=0.01) + ! ! test #2 + ! @assertRelativelyEqual(atmosphere_model%getDensityJB2008(0.4688d3, -0.195d2, 0.446d2, 0.4389981823d5), 0.20788356929965501d-002, tolerance=0.01) end subroutine test_getDensityJB2008 diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf index f786daa..6e6a8ab 100644 --- a/tests/test_gravity.pf +++ b/tests/test_gravity.pf @@ -1,96 +1,93 @@ module test_gravity - use funit - use gravity - use slam_reduction_class, only: Reduction_type - use slam_math - use slam_error_handling - - implicit none +use funit +use gravity +use slam_reduction_class, only: Reduction_type +use slam_math +use slam_error_handling - contains +implicit none + +contains @test subroutine test_getGravityAccelaration() - ! Tests that a density is computed by the NRLMSIS2.0 model - - + ! Tests the gravity Acceleration delivered + type(Reduction_type) :: reduction_handler type(Gravity_class) :: gravity_model - real(dp), dimension(3) :: r_itrf real(dp), dimension(3) :: v_itrf real(dp) :: time_mjd, tolerance - real(dp), dimension(3) :: accel, expected_accel - logical :: initialized = .false. - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction_handler = Reduction_type() - call reduction_handler%initEop('../../work/data') - initialized = .true. - end if - - ! Set Up inputs - r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) - time_mjd = 59868.16721065 - ! Call the subroutine to be tested - call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) - - ! Set up expected outputs - expected_accel = (/-0.67427774119464268E-2, 0.0, 0.0/) - - ! Set up tolerances - tolerance = 1e-6_dp - - ! Check if outputs match expected values - @assertRelativelyEqual(accel, expected_accel, tolerance) - + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + + ! Set Up inputs + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + time_mjd = 59868.16721065 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) - end subroutine test_getGravityAccelaration + ! Set up expected outputs + expected_accel = (/-0.67427774119464268E-2, 0.48509952216293419E-2, -0.99863401410992978E-3/) + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(accel, expected_accel, tolerance) + + end subroutine test_getGravityAccelaration - @test + @test subroutine test_getGravityCovariance() ! Tests Gravity covariance - - + type(Reduction_type) :: reduction_handler type(Gravity_class) :: gravity_model real(dp), dimension(3) :: r_itrf real(dp), dimension(3) :: v_itrf real(dp), dimension(3,3):: cov, expected_cov - real(dp) :: tolerance + real(dp) :: time_mjd, tolerance + real(dp), dimension(3) :: accel logical :: initialized = .false. - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction_handler = Reduction_type() - call reduction_handler%initEop('../../work/data') - initialized = .true. - end if - ! Set Up inputs - - r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) - ! Call the subroutine to be tested - cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) - - ! Set up expected outputs - expected_cov = reshape((/0.2999999, 1.3877787807814457E-017, -0.1, & - 1.3877787807814457E-017, 0.28571428571428564, -0.14285714285714285, & - -0.1, -0.14285714285714285, 0.27142857142857146/), (/3, 3/)) + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + ! Set Up inputs + call gravity_model%initGravityPotential('../../work/data') + + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) + + ! Set up expected outputs + expected_cov = reshape((/0.2999999, 1.3877787807814457E-017, -0.1, & + 1.3877787807814457E-017, 0.28571428571428564, -0.14285714285714285, & + -0.1, -0.14285714285714285, 0.27142857142857146/), (/3, 3/)) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(cov, expected_cov, tolerance) - ! Set up tolerances - tolerance = 1e-6_dp - - ! Check if outputs match expected values - @assertRelativelyEqual(cov, expected_cov, tolerance) - - - end subroutine test_getGravityCovariance + + end subroutine test_getGravityCovariance end module test_gravity \ No newline at end of file diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index 704db7c..8d3715d 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -1,110 +1,113 @@ module test_radiation - use funit - use radiation - use slam_reduction_class, only: Reduction_type - use slam_math - use slam_error_handling - use satellite - use solarsystem - use Neptuneclass - - implicit none - - - contains - -! @test -! subroutine test_getShadow() - -! type(Radiation_class) :: radiation -! real(dp), dimension(3) :: r_sun -! real(dp), dimension(3) :: r_sat -! real :: expected_shadow, retreived_shadow - - -! Set Up inputs -! r_sun = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) -! r_sat = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) -! ! Call the subroutine to be tested -! retreived_shadow = radiation%getShadow(radiation, r_sun, r_sat) - -! Set up expected outputs -! expected_shadow = 1.d0 - - - -! Check if outputs match expected values -! @assertEqual(retreived_shadow, expected_shadow) - - -! end subroutine test_getShadow - - - @test - subroutine test_getSrpAcceleration() - - type(Radiation_class) :: radiation_model - type(Satellite_class) :: satellite_model - type(Solarsystem_class) :: solarsystem_model - type(Reduction_type) :: reduction_handler - type(Neptune_class) :: neptune - real(dp), dimension(3) :: r_gcrf - real(dp), dimension(3) :: v_gcrf - real(dp) :: time_mjd, tolerance - - real(dp), dimension(3) :: acc_srp,expected_srp - type(time_t) :: epoch - logical :: initialized = .false. - - - - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction_handler = Reduction_type() - call reduction_handler%initEop('../../work/data') - initialized = .true. - end if - !** init reduction model and EOP - - epoch%mjd = 59600 - solarsystem_model = Solarsystem_class() - call solarsystem_model%initSolarSystem( & - "/home/arkenz/neptune/work/data", & - 'DE-421', & - epoch & - ) - satellite_model = Satellite_class() - satellite_model%mass = 300 - satellite_model%cdrag = 2.5 - satellite_model%surface(1)%reflDiff = 0.d0 - satellite_model%surface(1)%reflSpec = 0.3d0 - satellite_model%surface(1)%area = 250.0 - satellite_model%surface(1)%normal_angle(:) = 0.d0 - satellite_model%surface(1)%orientation = ORIENT_SPHERE - satellite_model%surface(1)%id = 1 - satellite_model%nsurfaces = 1 - satellite_model%isSet = .true. - - ! Set Up inputs - r_gcrf = (/-42044.21889179173, -3193.6719204189853, 7000000.000/) - v_gcrf = (/0.23272475970034712, -3.0658575760606777, 0.0006346736275647091/) - time_mjd = 59600 - ! Call the subroutine to be tested - call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) - - ! Set up expected outputs - expected_srp = (/0.0, 0.0, 0.0/) +use funit +use radiation +use slam_reduction_class, only: Reduction_type +use slam_math +use slam_error_handling +use satellite +use solarsystem +use Neptuneclass + +implicit none + + +contains + +! @test +! subroutine test_getShadow() + +! type(Radiation_class) :: radiation +! real(dp), dimension(3) :: r_sun +! real(dp), dimension(3) :: r_sat +! real :: expected_shadow, retreived_shadow + + +! Set Up inputs +! r_sun = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! r_sat = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) +! ! Call the subroutine to be tested +! retreived_shadow = radiation%getShadow(radiation, r_sun, r_sat) + +! Set up expected outputs +! expected_shadow = 1.d0 + +! Check if outputs match expected values +! @assertEqual(retreived_shadow, expected_shadow) + +! end subroutine test_getShadow + + +@test +subroutine test_getSrpAcceleration() + + type(Radiation_class) :: radiation_model + type(Satellite_class) :: satellite_model + type(Solarsystem_class) :: solarsystem_model + type(Reduction_type) :: reduction_handler + type(Neptune_class) :: neptune + real(dp), dimension(3) :: r_gcrf + real(dp), dimension(3) :: v_gcrf + real(dp) :: time_mjd, tolerance + + real(dp), dimension(3) :: acc_srp,expected_srp, expected_alb + type(time_t) :: epoch + logical :: initialized = .false. + + + + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + !** init reduction model and EOP + + epoch%mjd = 59600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "/home/arkenz/neptune/work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%initAlbedo() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/-42044.21889179173d0, -3193.6719204189853d0, 7000.0d0/) + v_gcrf = (/0.23272475970034712d0, -3.0658575760606777d0, 0.0006346736275647091d0/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + write(*,*) satellite_model%getOrientationMode() + call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) + write(*,*) radiation_model%getSrpWithoutShadow(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd) + call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, expected_alb) + write(*,*) acc_srp + write(*,*) expected_alb + ! Set up expected outputs + expected_srp = (/0.d0, 0.d0, 0.d0/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertEqual(acc_srp(1), expected_srp(1)) + - ! Set up tolerances - tolerance = 1e-6_dp - - ! Check if outputs match expected values - @assertEqual(acc_srp(1), expected_srp(1)) - - - end subroutine test_getSrpAcceleration + end subroutine test_getSrpAcceleration ! @test ! subroutine test_getAlbedoAcceleration() @@ -127,29 +130,25 @@ module test_radiation ! initialized = .true. ! end if - + ! ! Set Up inputs ! r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) ! v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) ! time_mjd = 59600 ! ! Call the subroutine to be tested ! call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, expected_alb) - + ! ! Set up expected outputs ! expected_alb = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - + ! ! Set up tolerances ! tolerance = 1e-6_dp - + ! ! Check if outputs match expected values ! @assertEqual(acc_alb, expected_alb) - - - -! end subroutine test_getAlbedoAcceleration - +! end subroutine test_getAlbedoAcceleration end module test_radiation \ No newline at end of file From 993a8d2813a6a8fb72af674413fa861fc51ce7cd Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Wed, 5 Jul 2023 14:55:08 +0200 Subject: [PATCH 04/11] PFunit tests for Neptune prefinal --- tests/CMakeLists.txt | 5 + tests/test_GravityCov.pf | 78 ++++++++ tests/test_atmosphere_Exponential.pf | 28 ++- tests/test_atmosphere_JB2008.pf | 28 ++- tests/test_gravity.pf | 75 +++----- tests/test_radiation.pf | 260 +++++++++++++++------------ tests/test_solarsystem.pf | 19 +- tests/test_thirdbody.pf | 45 +++-- 8 files changed, 341 insertions(+), 197 deletions(-) create mode 100644 tests/test_GravityCov.pf diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 255ba4c..74e52f0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,6 +44,11 @@ add_pfunit_ctest (atmosphere_tests_nrlmsis00 LINK_LIBRARIES neptune ${LIBSLAM} ) + add_pfunit_ctest (gravitycov_tests + TEST_SOURCES test_GravityCov.pf + LINK_LIBRARIES neptune ${LIBSLAM} + ) + add_pfunit_ctest (tides_tests TEST_SOURCES test_tides.pf LINK_LIBRARIES neptune ${LIBSLAM} diff --git a/tests/test_GravityCov.pf b/tests/test_GravityCov.pf new file mode 100644 index 0000000..5057186 --- /dev/null +++ b/tests/test_GravityCov.pf @@ -0,0 +1,78 @@ +!============================================================================== +! +!> @anchor test_gravityCov +!! +!> @brief Program for testing the function that calculates the gravityCovariance +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing gravity functions in this case getGravityCovariance +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ +module test_GravityCov + +use funit +use gravity +use slam_reduction_class, only: Reduction_type +use slam_math +use slam_error_handling + +implicit none + +contains + + @test + subroutine test_getGravityCovariance() + ! Tests Gravity covariance + ! Reference Values : OREKIT + + type(Reduction_type) :: reduction_handler + type(Gravity_class) :: gravity_model + + real(dp), dimension(3) :: r_itrf + real(dp), dimension(3) :: v_itrf + real(dp), dimension(3,3):: cov, expected_cov + real(dp) :: time_mjd, tolerance + real(dp), dimension(3) :: accel + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + + gravity_model = Gravity_class() + call gravity_model%setGeoDegree(6) + call gravity_model%setGeoCovDegree(6) + ! Set Up inputs + call gravity_model%initGravityPotential('../../work/data') + + r_itrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) + v_itrf = (/-1.3525457950562447d0, -0.2804534841971075d0, -7.4721873681232385d0/) + time_mjd = 58324.d0 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) + + ! Set up expected outputs + expected_cov = reshape((/0.39374967173447407d-9, 0.31947373468752591d-8, -0.14864895574315657d-8, & + 0.31947373468752595d-8, 0.39051986351008705d-8, -0.25245746509934525d-8, & + -0.14864895574315659d-8, -0.25245746509934525d-8, -0.42989483068353419d-8/), (/3, 3/)) + + ! Set up tolerances + tolerance = 1e-10_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(cov, expected_cov, tolerance) + + + end subroutine test_getGravityCovariance + +end module test_GravityCov \ No newline at end of file diff --git a/tests/test_atmosphere_Exponential.pf b/tests/test_atmosphere_Exponential.pf index a0b2f20..bd28cf3 100644 --- a/tests/test_atmosphere_Exponential.pf +++ b/tests/test_atmosphere_Exponential.pf @@ -1,14 +1,30 @@ +!============================================================================== +! +!> @anchor test_atmosphere_Exponential +!! +!> @brief Program for testing the function responsable for calculating Density by Exponential model +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing atmosphere functions in this case getDensityExponential +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ module test_atmosphere_Exponential - use funit - use atmosphere, only: Atmosphere_class, EXPONENTIAL +use funit +use atmosphere, only: Atmosphere_class, EXPONENTIAL - implicit none +implicit none - contains +contains @test subroutine test_getDensityExponential() - ! Tests that a density is computed by the NRLMSIS2.0 model + ! Tests that a density is computed by the Exponential model + ! Reference Values : Orekit type(Atmosphere_class) :: atmosphere_model @@ -23,6 +39,6 @@ module test_atmosphere_Exponential ! test #2 @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.11635971694422577d-002, tolerance=0.01) - end subroutine test_getDensityExponential + end subroutine test_getDensityExponential end module test_atmosphere_Exponential \ No newline at end of file diff --git a/tests/test_atmosphere_JB2008.pf b/tests/test_atmosphere_JB2008.pf index 8023a33..14b7fbc 100644 --- a/tests/test_atmosphere_JB2008.pf +++ b/tests/test_atmosphere_JB2008.pf @@ -1,16 +1,30 @@ +!============================================================================== +! +!> @anchor test_atmosphere_JB2008 +!! +!> @brief Program for testing the function responsable for calculating Density by JB08 model +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing atmosphere functions in this case getDensityJB2008 +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ module test_atmosphere_JB2008 - use funit - use atmosphere, only: Atmosphere_class, JB08 - - - implicit none +use funit +use atmosphere, only: Atmosphere_class, JB08 + +implicit none - contains +contains @test subroutine test_getDensityJB2008() ! Tests that a density is computed by the JB2008 model - ! inputs taken from the msis2.0_test_in file (File for JB2008 ?) + ! inputs taken from the JB2008_test_in file and reference values from OREKIT type(Atmosphere_class) :: atmosphere_model diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf index 6e6a8ab..e1d00e6 100644 --- a/tests/test_gravity.pf +++ b/tests/test_gravity.pf @@ -1,3 +1,18 @@ +!============================================================================== +! +!> @anchor test_gravity +!! +!> @brief Program for testing the function that calculates the gravityAcceleration +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing gravity functions in this case getGravityAcceleration +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ module test_gravity use funit use gravity @@ -12,6 +27,7 @@ contains @test subroutine test_getGravityAccelaration() ! Tests the gravity Acceleration delivered + ! Reference Values : OREKIT type(Reduction_type) :: reduction_handler type(Gravity_class) :: gravity_model @@ -27,16 +43,22 @@ contains call reduction_handler%initEop('../../work/data') initialized = .true. end if - + + gravity_model = Gravity_class() + call gravity_model%setGeoDegree(6) + call gravity_model%setGeoCovDegree(6) + ! Set Up inputs + call gravity_model%initGravityPotential('../../work/data') + ! Set Up inputs - r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) - time_mjd = 59868.16721065 + r_itrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) + v_itrf = (/-1.3525457950562447d0, -0.2804534841971075d0, -7.4721873681232385d0/) + time_mjd = 59868.16721065d0 ! Call the subroutine to be tested call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) ! Set up expected outputs - expected_accel = (/-0.67427774119464268E-2, 0.48509952216293419E-2, -0.99863401410992978E-3/) + expected_accel = (/-0.67280939346878715d-2, 0.48893489982938815d-2, -0.10027985388093780d-2/) ! Set up tolerances tolerance = 1e-6_dp @@ -46,48 +68,5 @@ contains end subroutine test_getGravityAccelaration - @test - subroutine test_getGravityCovariance() - ! Tests Gravity covariance - - type(Reduction_type) :: reduction_handler - type(Gravity_class) :: gravity_model - - real(dp), dimension(3) :: r_itrf - real(dp), dimension(3) :: v_itrf - real(dp), dimension(3,3):: cov, expected_cov - real(dp) :: time_mjd, tolerance - real(dp), dimension(3) :: accel - logical :: initialized = .false. - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction_handler = Reduction_type() - call reduction_handler%initEop('../../work/data') - initialized = .true. - end if - ! Set Up inputs - call gravity_model%initGravityPotential('../../work/data') - - r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) - ! Call the subroutine to be tested - call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) - - cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) - - ! Set up expected outputs - expected_cov = reshape((/0.2999999, 1.3877787807814457E-017, -0.1, & - 1.3877787807814457E-017, 0.28571428571428564, -0.14285714285714285, & - -0.1, -0.14285714285714285, 0.27142857142857146/), (/3, 3/)) - - ! Set up tolerances - tolerance = 1e-6_dp - - ! Check if outputs match expected values - @assertRelativelyEqual(cov, expected_cov, tolerance) - - - end subroutine test_getGravityCovariance end module test_gravity \ No newline at end of file diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index 8d3715d..9c241c4 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -1,3 +1,18 @@ +!============================================================================== +! +!> @anchor test_radiation +!! +!> @brief Program for testing functions and subs inside the radiation module +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing gravity functions in this case getSrpAcceleration and getAlbedoAcceleration +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ module test_radiation use funit use radiation @@ -10,18 +25,140 @@ use Neptuneclass implicit none - contains -! @test + @test + subroutine test_getSrpAcceleration() + !Reference Values : OREKIT + type(Radiation_class) :: radiation_model + type(Satellite_class) :: satellite_model + type(Solarsystem_class) :: solarsystem_model + type(Reduction_type) :: reduction_handler + type(Neptune_class) :: neptune + real(dp), dimension(3) :: r_gcrf + real(dp), dimension(3) :: v_gcrf + real(dp) :: time_mjd, tolerance + real(dp), dimension(3) :: acc_srp,expected_srp + type(time_t) :: epoch + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + !** init reduction model and EOP + + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/-42044.21889179173d0, -3193.6719204189853d0, 7000.0d0/) + v_gcrf = (/0.23272475970034712d0, -3.0658575760606777d0, 0.0006346736275647091d0/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) + ! Set up expected outputs + expected_srp = (/-0.60255722245013490d-153, -0.40450803633383140d-153, -0.17530978208490918d-153/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_srp(1), expected_srp(1),tolerance) + @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) + @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + +end subroutine test_getSrpAcceleration + + @test + subroutine test_getAlbedoAcceleration() + ! Reference Values : OREKIT + type(Radiation_class) :: radiation_model + type(Satellite_class) :: satellite_model + type(Solarsystem_class) :: solarsystem_model + type(Reduction_type) :: reduction_handler + type(Neptune_class) :: neptune + real(dp), dimension(3) :: r_gcrf + real(dp), dimension(3) :: v_gcrf + real(dp) :: time_mjd, tolerance + real(dp), dimension(3) :: expected_alb, acc_alb + type(time_t) :: epoch + logical :: initialized = .false. + !** init reduction model and EOP + call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") + if (.not. initialized) then + reduction_handler = Reduction_type() + call reduction_handler%initEop('../../work/data') + initialized = .true. + end if + !** init reduction model and EOP + + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%initAlbedo() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/-42044.21889179173d0, -3193.6719204189853d0, 7000.0d0/) + v_gcrf = (/0.23272475970034712d0, -3.0658575760606777d0, 0.0006346736275647091d0/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_alb) + + ! Set up expected outputs + expected_alb = (/-1.0392032201753557d-157, -7.8937704905988008d-159 , 1.7301837762641064d-158/) + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_alb(1), expected_alb(1),tolerance) + @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) + @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + + end subroutine test_getAlbedoAcceleration + + ! @test ! subroutine test_getShadow() ! type(Radiation_class) :: radiation ! real(dp), dimension(3) :: r_sun ! real(dp), dimension(3) :: r_sat ! real :: expected_shadow, retreived_shadow - - ! Set Up inputs ! r_sun = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) ! r_sat = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) @@ -36,119 +173,4 @@ contains ! end subroutine test_getShadow - -@test -subroutine test_getSrpAcceleration() - - type(Radiation_class) :: radiation_model - type(Satellite_class) :: satellite_model - type(Solarsystem_class) :: solarsystem_model - type(Reduction_type) :: reduction_handler - type(Neptune_class) :: neptune - real(dp), dimension(3) :: r_gcrf - real(dp), dimension(3) :: v_gcrf - real(dp) :: time_mjd, tolerance - - real(dp), dimension(3) :: acc_srp,expected_srp, expected_alb - type(time_t) :: epoch - logical :: initialized = .false. - - - - !** init reduction model and EOP - call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") - if (.not. initialized) then - reduction_handler = Reduction_type() - call reduction_handler%initEop('../../work/data') - initialized = .true. - end if - !** init reduction model and EOP - - epoch%mjd = 59600 - solarsystem_model = Solarsystem_class() - call solarsystem_model%initSolarSystem( & - "/home/arkenz/neptune/work/data", & - 'DE-421', & - epoch & - ) - satellite_model = Satellite_class() - satellite_model%mass = 1.0d0 - satellite_model%cdrag = 2.5d0 - satellite_model%surface(1)%reflDiff = 0.d0 - satellite_model%surface(1)%reflSpec = 0.3d0 - satellite_model%surface(1)%area = 250.d0 - satellite_model%surface(1)%normal_angle(:) = 0.d0 - satellite_model%surface(1)%orientation = MODE_CANNON_BALL - satellite_model%surface(1)%id = 1 - satellite_model%nsurfaces = 1 - satellite_model%isSet = .true. - radiation_model = Radiation_class() - call radiation_model%initAlbedo() - call radiation_model%setShadowModel("NO_SHADOW") - ! Set Up inputs - r_gcrf = (/-42044.21889179173d0, -3193.6719204189853d0, 7000.0d0/) - v_gcrf = (/0.23272475970034712d0, -3.0658575760606777d0, 0.0006346736275647091d0/) - time_mjd = 58600.d0 - ! Call the subroutine to be tested - write(*,*) satellite_model%getOrientationMode() - call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) - write(*,*) radiation_model%getSrpWithoutShadow(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd) - call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, expected_alb) - write(*,*) acc_srp - write(*,*) expected_alb - ! Set up expected outputs - expected_srp = (/0.d0, 0.d0, 0.d0/) - - ! Set up tolerances - tolerance = 1e-6_dp - - ! Check if outputs match expected values - @assertEqual(acc_srp(1), expected_srp(1)) - - - - end subroutine test_getSrpAcceleration - -! @test -! subroutine test_getAlbedoAcceleration() - -! type(Radiation_class) :: radiation_model -! type(Satellite_class) :: satellite_model -! type(Solarsystem_class) :: solarsystem_model -! type(Reduction_type) :: reduction -! real(dp), dimension(3) :: r_gcrf -! real(dp), dimension(3) :: v_gcrf -! real(dp) :: time_mjd, tolerance - -! real(dp), dimension(3) :: acc_alb, expected_alb -! logical :: initialized = .false. -! !** init reduction model and EOP -! call initErrorHandler(control = "YES", errAction = "RETURN", traceback = "YES") -! if (.not. initialized) then -! reduction = Reduction_type() -! call reduction%initEop('data') -! initialized = .true. -! end if - - -! ! Set Up inputs -! r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) -! v_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) -! time_mjd = 59600 -! ! Call the subroutine to be tested -! call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction, r_gcrf, v_gcrf, time_mjd, expected_alb) - -! ! Set up expected outputs -! expected_alb = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - -! ! Set up tolerances -! tolerance = 1e-6_dp - -! ! Check if outputs match expected values -! @assertEqual(acc_alb, expected_alb) - - - -! end subroutine test_getAlbedoAcceleration - end module test_radiation \ No newline at end of file diff --git a/tests/test_solarsystem.pf b/tests/test_solarsystem.pf index 9e6488c..9f2a2c4 100644 --- a/tests/test_solarsystem.pf +++ b/tests/test_solarsystem.pf @@ -1,3 +1,18 @@ +!============================================================================== +! +!> @anchor test_solarsystem +!! +!> @brief Program for testing the function that calculates the Bodyposition +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing solarsystem functions in this case getBodyposition +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ module test_solarsystem use funit use solarsystem @@ -9,7 +24,7 @@ module test_solarsystem @test subroutine test_getBodyPosition() - + ! Reference Values : OREKIT type(Solarsystem_class):: solarsystem_model real(dp) :: time_mjd, tolerance integer :: body_id @@ -19,7 +34,7 @@ module test_solarsystem epoch%mjd = 59600 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & - "/home/arkenz/neptune/work/data", & + "../../work/data", & 'DE-421', & epoch & ) diff --git a/tests/test_thirdbody.pf b/tests/test_thirdbody.pf index 3945233..f376953 100644 --- a/tests/test_thirdbody.pf +++ b/tests/test_thirdbody.pf @@ -1,18 +1,33 @@ +!============================================================================== +! +!> @anchor test_thirdbody +!! +!> @brief Program for testing the function that calculates the third body Acceleration +!! +!> @author Arkene Chouchene (AC) +!! +!> @date
    +!!
  • 15.06.2023 (initial design)
  • +!!
+!! +!! @details Program for testing thirdbody functions in this case getThirdBodyAcceleration +!! Sources and Examples are mentioned above every test +!------------------------------------------------------------------------ module test_thirdbody - use funit - use thirdbody - use slam_reduction_class, only: Reduction_type - use slam_math - use slam_error_handling - use solarsystem - use neptuneClass - implicit none +use funit +use thirdbody +use slam_reduction_class, only: Reduction_type +use slam_math +use slam_error_handling +use solarsystem +use neptuneClass +implicit none - contains +contains @test subroutine test_getThirdBodyAccelaration() - + ! Reference Values : OREKIT type(ThirdBody_class) :: third_body type(Solarsystem_class) :: solarsystem_model real(dp), dimension(3) :: r_gcrf @@ -22,24 +37,24 @@ module test_thirdbody real(dp), dimension(3) :: acc_thirdbody, expected_acc type(time_t) :: epoch - epoch%mjd = 59600 + epoch%mjd = 59600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & - "/home/arkenz/neptune/work/data", & + "../../work/data", & 'DE-421', & epoch & ) third_body = ThirdBody_class() ! Set Up inputs body_id = 1 - time_mjd = 59868.16721065_dp - r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + time_mjd = 59868.16721065d0 + r_gcrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) ! Call the subroutine to be tested call third_body%getThirdBodyAcceleration(solarsystem_model, r_gcrf, time_mjd, body_id, acc_thirdbody) ! Set up expected outputs - expected_acc = (/-0.43302027180447598E-9, 0.18789528607443213E-10, -0.12757560304668043E-9/) + expected_acc = (/-0.43302027180447598d-9, 0.18789528607443213d-10, -0.12757560304668043d-9/) ! Set up tolerances tolerance = 1e-6_dp From 6ec8eda7ae89bef7bebca49f54f0eedcc38e41b3 Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Mon, 17 Jul 2023 11:08:17 +0200 Subject: [PATCH 05/11] more cases added and return values compared --- tests/test_GravityCov.pf | 26 ++++++++- tests/test_atmosphere_Exponential.pf | 7 ++- tests/test_atmosphere_JB2008.pf | 2 +- tests/test_gravity.pf | 36 +++++++++++- tests/test_radiation.pf | 82 +++++++++++++++++++++++++++- tests/test_solarsystem.pf | 48 ++++++++++++---- tests/test_thirdbody.pf | 50 +++++++++++++---- 7 files changed, 220 insertions(+), 31 deletions(-) diff --git a/tests/test_GravityCov.pf b/tests/test_GravityCov.pf index 5057186..3974e57 100644 --- a/tests/test_GravityCov.pf +++ b/tests/test_GravityCov.pf @@ -50,7 +50,10 @@ contains gravity_model = Gravity_class() call gravity_model%setGeoDegree(6) call gravity_model%setGeoCovDegree(6) + ! Set Up inputs + ! Test 1 + call gravity_model%initGravityPotential('../../work/data') r_itrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) @@ -71,7 +74,28 @@ contains ! Check if outputs match expected values @assertRelativelyEqual(cov, expected_cov, tolerance) - + + ! Test 2 + call gravity_model%initGravityPotential('../../work/data') + + r_itrf = (/31986.08889084533, 3886.249797563777, -17606.478382491812/) + v_itrf = (/-0.1326762314352175, 2.0844489979862724, -0.13643320490635982/) + time_mjd = 58324.d0 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) + + ! Set up expected outputs + expected_cov = reshape((/-0.84889040107535929d-12, -0.10613410850253561d-12, -0.11518613812098011d-11, & + -0.10613410850253560d-12, 0.40163065395133233d-13, -0.14287823362922449d-12, & + -0.11518613812098011d-11, -0.14287823362922446d-12, 0.80872733568022548d-12/), (/3, 3/)) + + ! Set up tolerances + tolerance = 1e-10_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(cov, expected_cov, tolerance) end subroutine test_getGravityCovariance diff --git a/tests/test_atmosphere_Exponential.pf b/tests/test_atmosphere_Exponential.pf index bd28cf3..c8def72 100644 --- a/tests/test_atmosphere_Exponential.pf +++ b/tests/test_atmosphere_Exponential.pf @@ -35,10 +35,11 @@ contains call atmosphere_model%initAtmosphere('../../work/data') ! test #1 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.65d1), 499706396.76297361d0, tolerance=0.01) + @assertRelativelyEqual(atmosphere_model%getDensityExponential(25.d0), 38990000.0d0, tolerance=0.01) ! test #2 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.11635971694422577d-002, tolerance=0.01) - + @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.11635971694422577d-2, tolerance=0.01) + ! test #3 + @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.65d1), 499706396.76297361d0, tolerance=0.01) end subroutine test_getDensityExponential end module test_atmosphere_Exponential \ No newline at end of file diff --git a/tests/test_atmosphere_JB2008.pf b/tests/test_atmosphere_JB2008.pf index 14b7fbc..0babd2d 100644 --- a/tests/test_atmosphere_JB2008.pf +++ b/tests/test_atmosphere_JB2008.pf @@ -39,7 +39,7 @@ contains ! test #1 @assertRelativelyEqual(atmosphere_model%getDensityJB2008(500.d0, 0.d0, 0.d0, 51544.d0), 0.12405204124422383d-002, tolerance=0.01) ! ! test #2 - ! @assertRelativelyEqual(atmosphere_model%getDensityJB2008(0.4688d3, -0.195d2, 0.446d2, 0.4389981823d5), 0.20788356929965501d-002, tolerance=0.01) + @assertRelativelyEqual(atmosphere_model%getDensityJB2008(150.d0, 0.d0, 0.446d2, 58600.d0), 0.79968484021225802d+27, tolerance=0.01) end subroutine test_getDensityJB2008 diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf index e1d00e6..cd93de1 100644 --- a/tests/test_gravity.pf +++ b/tests/test_gravity.pf @@ -51,6 +51,7 @@ contains call gravity_model%initGravityPotential('../../work/data') ! Set Up inputs + ! Test 1 r_itrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) v_itrf = (/-1.3525457950562447d0, -0.2804534841971075d0, -7.4721873681232385d0/) time_mjd = 59868.16721065d0 @@ -65,8 +66,39 @@ contains ! Check if outputs match expected values @assertRelativelyEqual(accel, expected_accel, tolerance) - - end subroutine test_getGravityAccelaration + + ! Test 2 + r_itrf = (/31986.08889084533, 3886.249797563777, -17606.478382491812/) + v_itrf = (/-0.1326762314352175, 2.0844489979862724, -0.13643320490635982/) + time_mjd = 59868.16721065d0 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + ! Set up expected outputs + expected_accel = (/0.70700674902942066d-5, -0.25935354264578517d-3, 0.14177271746361654d-3/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(accel, expected_accel, tolerance) + ! Test 2 + r_itrf = (/-42044.21889179173, -3193.6719204189853, 105.63094940415252/) + v_itrf = (/0.23272475970034712, -3.0658575760606777, 0.0006346736275647091/) + time_mjd = 59324.0d0 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + ! Set up expected outputs + expected_accel = (/-0.18935385065918674d-3, -0.12004903786810252d-3, -0.17494056709662443d-6/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(accel, expected_accel, tolerance) + + end subroutine test_getGravityAccelaration end module test_gravity \ No newline at end of file diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index 9c241c4..d982b98 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -48,8 +48,8 @@ contains call reduction_handler%initEop('../../work/data') initialized = .true. end if - !** init reduction model and EOP - + !** init solarsystem & satellite model + ! Test 1 epoch%mjd = 58600 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & @@ -87,6 +87,45 @@ contains @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + !** init solarsystem & satellite model + ! Test 2 + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/31986.08889084533, 3886.249797563777, -17606.478382491812/) + v_gcrf = (/-0.1326762314352175, 2.0844489979862724, -0.13643320490635982/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) + ! Set up expected outputs + expected_srp = (/-0.60297265785803238d-153, -0.40499850972939443d-153, -0.17565974446211355d-153/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_srp(1), expected_srp(1),tolerance) + @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) + @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + end subroutine test_getSrpAcceleration @test @@ -150,6 +189,45 @@ end subroutine test_getSrpAcceleration @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + ! Test 2 + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%initAlbedo() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/-32044.21889179173d0, -3193.6719204189853d0, 7000.0d0/) + v_gcrf = (/0.33272475970034712d0, -3.0658575760606777d0, 0.0006346736275647091d0/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_alb) + + ! Set up expected outputs + expected_alb = (/-0.16460185156863555d-156, -0.16404965687535655d-157 , 0.35956968240395888d-157/) + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_alb(1), expected_alb(1),tolerance) + @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) + @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + end subroutine test_getAlbedoAcceleration ! @test diff --git a/tests/test_solarsystem.pf b/tests/test_solarsystem.pf index 9f2a2c4..faece2b 100644 --- a/tests/test_solarsystem.pf +++ b/tests/test_solarsystem.pf @@ -31,6 +31,7 @@ module test_solarsystem real(dp), dimension(3) :: expected_position, obtained_position type(time_t) :: epoch + ! Test 1 : epoch%mjd = 59600 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & @@ -40,20 +41,45 @@ module test_solarsystem ) ! Set Up inputs - body_id = 1 - time_mjd = 59868.16721065 - ! Call the subroutine to be tested - obtained_position = solarsystem_model%getBodyPosition(time_mjd, body_id) + body_id = 1 + time_mjd = 59868.16721065 + ! Call the subroutine to be tested + obtained_position = solarsystem_model%getBodyPosition(time_mjd, body_id) - ! Set up expected outputs - expected_position = (/-137833056.98029408, -52290137.284895524, -22666159.999092821/) + ! Set up expected outputs + expected_position = (/-137833056.98029408, -52290137.284895524, -22666159.999092821/) - ! Set up tolerances - tolerance = 1e-6_dp + ! Set up tolerances + tolerance = 1e-6_dp - ! Check if outputs match expected values - @assertRelativelyEqual(obtained_position, expected_position, tolerance) - + ! Check if outputs match expected values + @assertRelativelyEqual(obtained_position, expected_position, tolerance) + + + ! Test 2 : + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + + ! Set Up inputs + body_id = 2 + time_mjd = 58600.d0 + ! Call the subroutine to be tested + obtained_position = solarsystem_model%getBodyPosition(time_mjd, body_id) + + ! Set up expected outputs + expected_position = (/242037.66047749575, -291029.18822841981, -137196.91059160809/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(obtained_position, expected_position, tolerance) + end subroutine test_getBodyPosition diff --git a/tests/test_thirdbody.pf b/tests/test_thirdbody.pf index f376953..6ac9d14 100644 --- a/tests/test_thirdbody.pf +++ b/tests/test_thirdbody.pf @@ -39,6 +39,34 @@ contains type(time_t) :: epoch epoch%mjd = 59600.d0 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + third_body = ThirdBody_class() + ! Test 1: + ! Set Up inputs + body_id = 1 + time_mjd = 59868.16721065d0 + r_gcrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) + ! Call the subroutine to be tested + call third_body%getThirdBodyAcceleration(solarsystem_model, r_gcrf, time_mjd, body_id, acc_thirdbody) + + ! Set up expected outputs + expected_acc = (/-0.43302027180447598d-9, 0.18789528607443213d-10, -0.12757560304668043d-9/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + + + ! Test 2 : + epoch%mjd = 58600.d0 + solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -47,20 +75,20 @@ contains ) third_body = ThirdBody_class() ! Set Up inputs - body_id = 1 - time_mjd = 59868.16721065d0 - r_gcrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) - ! Call the subroutine to be tested - call third_body%getThirdBodyAcceleration(solarsystem_model, r_gcrf, time_mjd, body_id, acc_thirdbody) + body_id = 1 + time_mjd = 58600d0 + r_gcrf = (/31986.08889084533d0, 3886.249797563777d0, -17606.478382491812d0/) + ! Call the subroutine to be tested + call third_body%getThirdBodyAcceleration(solarsystem_model, r_gcrf, time_mjd, body_id, acc_thirdbody) - ! Set up expected outputs - expected_acc = (/-0.43302027180447598d-9, 0.18789528607443213d-10, -0.12757560304668043d-9/) + ! Set up expected outputs + expected_acc = (/0.99500426861622400d-9, 0.13527752884204714d-8, 0.13370953584132247d-8/) - ! Set up tolerances - tolerance = 1e-6_dp + ! Set up tolerances + tolerance = 1e-6_dp - ! Check if outputs match expected values - @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + ! Check if outputs match expected values + @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) end subroutine test_getThirdBodyAccelaration From a5067c96cf121d5679bc5c5220e08f070c0fe95c Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Thu, 20 Jul 2023 11:48:08 +0200 Subject: [PATCH 06/11] low orbit tests added --- tests/test_GravityCov.pf | 25 +++++++++++- tests/test_gravity.pf | 16 ++++++++ tests/test_radiation.pf | 81 ++++++++++++++++++++++++++++++++++++++- tests/test_solarsystem.pf | 25 ++++++++++++ tests/test_thirdbody.pf | 26 +++++++++++++ 5 files changed, 171 insertions(+), 2 deletions(-) diff --git a/tests/test_GravityCov.pf b/tests/test_GravityCov.pf index 3974e57..b1736b8 100644 --- a/tests/test_GravityCov.pf +++ b/tests/test_GravityCov.pf @@ -78,6 +78,29 @@ contains ! Test 2 call gravity_model%initGravityPotential('../../work/data') + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + cov = gravity_model%getGravityCovariance(r_itrf, v_itrf) + + ! Set up expected outputs + expected_cov = reshape((/0.39374974311657738d-9, 0.31947377200775617d-8, -0.14864897215596233d-8, & + 0.31947377200775617d-8, 0.39051990534417329d-8, -0.25245749095440029d-8, & + -0.14864897215596233d-8, -0.25245749095440029d-8, -0.42989487965583128d-8/), (/3, 3/)) + + ! Set up tolerances + tolerance = 1e-10_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(cov, expected_cov, tolerance) + + + ! Test 3 : + call gravity_model%initGravityPotential('../../work/data') + r_itrf = (/31986.08889084533, 3886.249797563777, -17606.478382491812/) v_itrf = (/-0.1326762314352175, 2.0844489979862724, -0.13643320490635982/) time_mjd = 58324.d0 @@ -95,7 +118,7 @@ contains tolerance = 1e-10_dp ! Check if outputs match expected values - @assertRelativelyEqual(cov, expected_cov, tolerance) + @assertRelativelyEqual(cov, expected_cov, tolerance) end subroutine test_getGravityCovariance diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf index cd93de1..7f5992d 100644 --- a/tests/test_gravity.pf +++ b/tests/test_gravity.pf @@ -98,6 +98,22 @@ contains ! Check if outputs match expected values @assertRelativelyEqual(accel, expected_accel, tolerance) + + ! Test 3 : + r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_itrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + time_mjd = 58600.0d0 + ! Call the subroutine to be tested + call gravity_model%getGravityAcceleration(reduction_handler, r_itrf, v_itrf, time_mjd, accel) + + ! Set up expected outputs + expected_accel = (/0.55885575784497528d-3, -0.82963084273004768d-2, -0.10185937617941453d-2/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(accel, expected_accel, tolerance) end subroutine test_getGravityAccelaration diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index d982b98..d14ec75 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -126,6 +126,46 @@ contains @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + + ! Test 3 : + !** init solarsystem & satellite model + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_gcrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) + ! Set up expected outputs + expected_srp = (/-0.60274248388036179d-153, -0.40477424957861742d-153, -0.17544992173487258d-153/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_srp(1), expected_srp(1),tolerance) + @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) + @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + end subroutine test_getSrpAcceleration @test @@ -189,7 +229,7 @@ end subroutine test_getSrpAcceleration @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) - ! Test 2 + ! Test 2 : epoch%mjd = 58600 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & @@ -228,6 +268,45 @@ end subroutine test_getSrpAcceleration @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + ! Test 3 : + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + satellite_model = Satellite_class() + satellite_model%mass = 1.0d0 + satellite_model%cdrag = 2.5d0 + satellite_model%surface(1)%reflDiff = 0.d0 + satellite_model%surface(1)%reflSpec = 0.3d0 + satellite_model%surface(1)%area = 250.d0 + satellite_model%surface(1)%normal_angle(:) = 0.d0 + satellite_model%surface(1)%orientation = MODE_CANNON_BALL + satellite_model%surface(1)%id = 1 + satellite_model%nsurfaces = 1 + satellite_model%isSet = .true. + radiation_model = Radiation_class() + call radiation_model%initAlbedo() + call radiation_model%setShadowModel("NO_SHADOW") + ! Set Up inputs + r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) + v_gcrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + time_mjd = 58600.d0 + ! Call the subroutine to be tested + call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_alb) + + ! Set up expected outputs + expected_alb = (/-0.40982300587138906d-155, -0.69350056733006604d-155 , 0.98284437556502546d-156/) + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_alb(1), expected_alb(1),tolerance) + @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) + @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + end subroutine test_getAlbedoAcceleration ! @test diff --git a/tests/test_solarsystem.pf b/tests/test_solarsystem.pf index faece2b..62e0353 100644 --- a/tests/test_solarsystem.pf +++ b/tests/test_solarsystem.pf @@ -80,6 +80,31 @@ module test_solarsystem ! Check if outputs match expected values @assertRelativelyEqual(obtained_position, expected_position, tolerance) + ! Test 3 : + epoch%mjd = 58600 + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + + ! Set Up inputs + body_id = 2 + time_mjd = 58600.d0 + ! Call the subroutine to be tested + obtained_position = solarsystem_model%getBodyPosition(time_mjd, body_id) + + ! Set up expected outputs + expected_position = (/242037.66047749575, -291029.18822841981, -137196.91059160809/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(obtained_position, expected_position, tolerance) + + end subroutine test_getBodyPosition diff --git a/tests/test_thirdbody.pf b/tests/test_thirdbody.pf index 6ac9d14..3564318 100644 --- a/tests/test_thirdbody.pf +++ b/tests/test_thirdbody.pf @@ -89,6 +89,32 @@ contains ! Check if outputs match expected values @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + + ! Test 2 : + epoch%mjd = 58600.d0 + + solarsystem_model = Solarsystem_class() + call solarsystem_model%initSolarSystem( & + "../../work/data", & + 'DE-421', & + epoch & + ) + third_body = ThirdBody_class() + ! Set Up inputs + body_id = 1 + time_mjd = 58600d0 + r_gcrf = (/31986.08889084533d0, 3886.249797563777d0, -17606.478382491812d0/) + ! Call the subroutine to be tested + call third_body%getThirdBodyAcceleration(solarsystem_model, r_gcrf, time_mjd, body_id, acc_thirdbody) + + ! Set up expected outputs + expected_acc = (/0.99500426861622400d-9, 0.13527752884204714d-8, 0.13370953584132247d-8/) + + ! Set up tolerances + tolerance = 1e-6_dp + + ! Check if outputs match expected values + @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) end subroutine test_getThirdBodyAccelaration From 3f2c1413d23ab92dc005ef7fc259ecb474174114 Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Wed, 2 Aug 2023 14:32:41 +0200 Subject: [PATCH 07/11] Msis enabled --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9cc8e62..fcf98b1 100755 --- a/build.sh +++ b/build.sh @@ -121,7 +121,7 @@ fi cd build || exit echo "Updating cmake" export PFUNIT_DIR=..//pFUnit/build/installed -cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_OPI_SUPPORT=ON -DSKIP_MSIS_2=OFF ../ +cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_OPI_SUPPORT=ON -DSKIP_MSIS_2=ON ../ echo "Building NEPTUNE" make install if [[ $? -ne 0 ]]; then From 52d7b93a26104acafefaa57f3de24b945e0e6998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=BCck?= Date: Thu, 14 Sep 2023 11:59:34 +0200 Subject: [PATCH 08/11] Add verbose test output for pipelines --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 2e312fd..c7d830b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -79,4 +79,4 @@ jobs: working-directory: ${{github.workspace}}/build # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: LD_LIBRARY_PATH=${{github.workspace}}/lib ctest -C ${{env.BUILD_TYPE}} \ No newline at end of file + run: LD_LIBRARY_PATH=${{github.workspace}}/lib ctest -C ${{env.BUILD_TYPE}} --verbose From ec210da6781409aeb80c3814523d849d7d217cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=BCck?= Date: Thu, 14 Sep 2023 14:16:01 +0200 Subject: [PATCH 09/11] Add d0 in tests where it is missing --- tests/test_radiation.pf | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index d14ec75..cda29fd 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -50,7 +50,7 @@ contains end if !** init solarsystem & satellite model ! Test 1 - epoch%mjd = 58600 + epoch%mjd = 58600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -89,7 +89,7 @@ contains !** init solarsystem & satellite model ! Test 2 - epoch%mjd = 58600 + epoch%mjd = 58600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -110,8 +110,8 @@ contains radiation_model = Radiation_class() call radiation_model%setShadowModel("NO_SHADOW") ! Set Up inputs - r_gcrf = (/31986.08889084533, 3886.249797563777, -17606.478382491812/) - v_gcrf = (/-0.1326762314352175, 2.0844489979862724, -0.13643320490635982/) + r_gcrf = (/31986.08889084533d0, 3886.249797563777d0, -17606.478382491812d0/) + v_gcrf = (/-0.1326762314352175d0, 2.0844489979862724d0, -0.13643320490635982d0/) time_mjd = 58600.d0 ! Call the subroutine to be tested call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) @@ -129,7 +129,7 @@ contains ! Test 3 : !** init solarsystem & satellite model - epoch%mjd = 58600 + epoch%mjd = 58600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -150,8 +150,8 @@ contains radiation_model = Radiation_class() call radiation_model%setShadowModel("NO_SHADOW") ! Set Up inputs - r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_gcrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + r_gcrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) + v_gcrf = (/-1.3525457950562447d0, -0.2804534841971075d0, -7.4721873681232385d0/) time_mjd = 58600.d0 ! Call the subroutine to be tested call radiation_model%getSrpAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_srp) @@ -191,7 +191,7 @@ end subroutine test_getSrpAcceleration end if !** init reduction model and EOP - epoch%mjd = 58600 + epoch%mjd = 58600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -230,7 +230,7 @@ end subroutine test_getSrpAcceleration @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) ! Test 2 : - epoch%mjd = 58600 + epoch%mjd = 58600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -269,7 +269,7 @@ end subroutine test_getSrpAcceleration @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) ! Test 3 : - epoch%mjd = 58600 + epoch%mjd = 58600.d0 solarsystem_model = Solarsystem_class() call solarsystem_model%initSolarSystem( & "../../work/data", & @@ -291,8 +291,8 @@ end subroutine test_getSrpAcceleration call radiation_model%initAlbedo() call radiation_model%setShadowModel("NO_SHADOW") ! Set Up inputs - r_gcrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) - v_gcrf = (/-1.3525457950562447, -0.2804534841971075, -7.4721873681232385/) + r_gcrf = (/-3485.799126707284d0, -5898.652976745232d0, 835.9701786284777d0/) + v_gcrf = (/-1.3525457950562447d0, -0.2804534841971075d0, -7.4721873681232385d0/) time_mjd = 58600.d0 ! Call the subroutine to be tested call radiation_model%getAlbedoAcceleration(satellite_model, solarsystem_model, reduction_handler, r_gcrf, v_gcrf, time_mjd, acc_alb) From b3806afff14c51b20a25a30313ac4ef663e5dfab Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Wed, 1 Nov 2023 13:14:07 +0100 Subject: [PATCH 10/11] Switch effected in assertion test_GravityCov.pf --- tests/test_GravityCov.pf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_GravityCov.pf b/tests/test_GravityCov.pf index b1736b8..67d1e00 100644 --- a/tests/test_GravityCov.pf +++ b/tests/test_GravityCov.pf @@ -118,7 +118,7 @@ contains tolerance = 1e-10_dp ! Check if outputs match expected values - @assertRelativelyEqual(cov, expected_cov, tolerance) + @assertRelativelyEqual(expected_cov, cov, tolerance) end subroutine test_getGravityCovariance From 327a0053759de420ccfcbc89ce7e85d6758d1f4e Mon Sep 17 00:00:00 2001 From: Arkene Chouchene Date: Mon, 11 Dec 2023 13:52:28 +0100 Subject: [PATCH 11/11] assertions rechecked and updated --- tests/test_GravityCov.pf | 4 ++-- tests/test_atmosphere_Exponential.pf | 6 ++--- tests/test_atmosphere_JB2008.pf | 4 ++-- tests/test_atmosphere_msis2.pf | 4 ++-- tests/test_atmosphere_nrlmsis00.pf | 2 +- tests/test_gravity.pf | 8 +++---- tests/test_radiation.pf | 36 ++++++++++++++-------------- tests/test_solarsystem.pf | 6 ++--- tests/test_thirdbody.pf | 7 +++--- 9 files changed, 38 insertions(+), 39 deletions(-) diff --git a/tests/test_GravityCov.pf b/tests/test_GravityCov.pf index 67d1e00..a8a06fa 100644 --- a/tests/test_GravityCov.pf +++ b/tests/test_GravityCov.pf @@ -73,7 +73,7 @@ contains tolerance = 1e-10_dp ! Check if outputs match expected values - @assertRelativelyEqual(cov, expected_cov, tolerance) + @assertRelativelyEqual(expected_cov, cov, tolerance) ! Test 2 call gravity_model%initGravityPotential('../../work/data') @@ -95,7 +95,7 @@ contains tolerance = 1e-10_dp ! Check if outputs match expected values - @assertRelativelyEqual(cov, expected_cov, tolerance) + @assertRelativelyEqual(expected_cov, cov, tolerance) ! Test 3 : diff --git a/tests/test_atmosphere_Exponential.pf b/tests/test_atmosphere_Exponential.pf index c8def72..f42b1ed 100644 --- a/tests/test_atmosphere_Exponential.pf +++ b/tests/test_atmosphere_Exponential.pf @@ -35,11 +35,11 @@ contains call atmosphere_model%initAtmosphere('../../work/data') ! test #1 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(25.d0), 38990000.0d0, tolerance=0.01) + @assertRelativelyEqual(38990000.0d0, atmosphere_model%getDensityExponential(25.d0), tolerance=0.01) ! test #2 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.4688d3), 0.11635971694422577d-2, tolerance=0.01) + @assertRelativelyEqual(0.11635971694422577d-2, atmosphere_model%getDensityExponential(0.4688d3), tolerance=0.01) ! test #3 - @assertRelativelyEqual(atmosphere_model%getDensityExponential(0.65d1), 499706396.76297361d0, tolerance=0.01) + @assertRelativelyEqual(499706396.76297361d0, atmosphere_model%getDensityExponential(0.65d1), tolerance=0.01) end subroutine test_getDensityExponential end module test_atmosphere_Exponential \ No newline at end of file diff --git a/tests/test_atmosphere_JB2008.pf b/tests/test_atmosphere_JB2008.pf index 0babd2d..04e7399 100644 --- a/tests/test_atmosphere_JB2008.pf +++ b/tests/test_atmosphere_JB2008.pf @@ -37,9 +37,9 @@ contains call atmosphere_model%initAtmosphere('../../work/data') ! test #1 - @assertRelativelyEqual(atmosphere_model%getDensityJB2008(500.d0, 0.d0, 0.d0, 51544.d0), 0.12405204124422383d-002, tolerance=0.01) + @assertRelativelyEqual(0.12405204124422383d-002, atmosphere_model%getDensityJB2008(500.d0, 0.d0, 0.d0, 51544.d0), tolerance=0.01) ! ! test #2 - @assertRelativelyEqual(atmosphere_model%getDensityJB2008(150.d0, 0.d0, 0.446d2, 58600.d0), 0.79968484021225802d+27, tolerance=0.01) + @assertRelativelyEqual(0.79968484021225802d+27, atmosphere_model%getDensityJB2008(150.d0, 0.d0, 0.446d2, 58600.d0), tolerance=0.01) end subroutine test_getDensityJB2008 diff --git a/tests/test_atmosphere_msis2.pf b/tests/test_atmosphere_msis2.pf index 9fb799f..700d02c 100644 --- a/tests/test_atmosphere_msis2.pf +++ b/tests/test_atmosphere_msis2.pf @@ -20,9 +20,9 @@ module test_atmosphere_msis2 call atmosphere_model%initAtmosphere('../../work/data') ! test #1 - @assertRelativelyEqual(atmosphere_model%getDensityNRLMSISv2(500.d0, 0.65d1, 96.d0, 0.5276739668d5), 0.10168617826293667d-002, tolerance=0.01) + @assertRelativelyEqual(0.10168617826293667d-002, atmosphere_model%getDensityNRLMSISv2(500.d0, 0.65d1, 96.d0, 0.5276739668d5), tolerance=0.01) ! test #2 - @assertRelativelyEqual(atmosphere_model%getDensityNRLMSISv2(0.4688d3, -0.195d2, 0.446d2, 0.4389981823d5), 0.20788356929965501d-002, tolerance=0.01) + @assertRelativelyEqual(0.20788356929965501d-002, atmosphere_model%getDensityNRLMSISv2(0.4688d3, -0.195d2, 0.446d2, 0.4389981823d5), tolerance=0.01) end subroutine test_getDensityNRLMSISv2 diff --git a/tests/test_atmosphere_nrlmsis00.pf b/tests/test_atmosphere_nrlmsis00.pf index 98133f1..1e3904a 100644 --- a/tests/test_atmosphere_nrlmsis00.pf +++ b/tests/test_atmosphere_nrlmsis00.pf @@ -23,7 +23,7 @@ module test_atmosphere_nrlmsis00 call atmosphere_model%setAtmosphereInitFlag() call atmosphere_model%initAtmosphere('../../work/data') ! @assertRelativelyEqual(atmosphere_model%getDensityMSIS2000(500.d0, 0.d0, 0.d0, 51544.d0), 0.5712d-003, tolerance=0.01) - @assertRelativelyEqual(atmosphere_model%getDensityMSIS2000(500.d0, 0.d0, 0.d0, 51544.d0), 0.79964653605310576d-003, tolerance=0.01) + @assertRelativelyEqual(0.79964653605310576d-003, atmosphere_model%getDensityMSIS2000(500.d0, 0.d0, 0.d0, 51544.d0), tolerance=0.01) end subroutine test_getDensityMSIS2000 diff --git a/tests/test_gravity.pf b/tests/test_gravity.pf index 7f5992d..d2a36d9 100644 --- a/tests/test_gravity.pf +++ b/tests/test_gravity.pf @@ -65,7 +65,7 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(accel, expected_accel, tolerance) + @assertRelativelyEqual(expected_accel, accel, tolerance) ! Test 2 r_itrf = (/31986.08889084533, 3886.249797563777, -17606.478382491812/) @@ -81,7 +81,7 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(accel, expected_accel, tolerance) + @assertRelativelyEqual(expected_accel, accel, tolerance) ! Test 2 r_itrf = (/-42044.21889179173, -3193.6719204189853, 105.63094940415252/) @@ -97,7 +97,7 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(accel, expected_accel, tolerance) + @assertRelativelyEqual(expected_accel, accel, tolerance) ! Test 3 : r_itrf = (/-3485.799126707284, -5898.652976745232, 835.9701786284777/) @@ -113,7 +113,7 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(accel, expected_accel, tolerance) + @assertRelativelyEqual(expected_accel, accel, tolerance) end subroutine test_getGravityAccelaration diff --git a/tests/test_radiation.pf b/tests/test_radiation.pf index cda29fd..9c5170b 100644 --- a/tests/test_radiation.pf +++ b/tests/test_radiation.pf @@ -83,9 +83,9 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_srp(1), expected_srp(1),tolerance) - @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) - @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + @assertRelativelyEqual(expected_srp(1), acc_srp(1), tolerance) + @assertRelativelyEqual(expected_srp(2), acc_srp(2), tolerance) + @assertRelativelyEqual(expected_srp(3), acc_srp(3), tolerance) !** init solarsystem & satellite model ! Test 2 @@ -122,9 +122,9 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_srp(1), expected_srp(1),tolerance) - @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) - @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + @assertRelativelyEqual(expected_srp(1), acc_srp(1), tolerance) + @assertRelativelyEqual(expected_srp(2), acc_srp(2), tolerance) + @assertRelativelyEqual(expected_srp(3), acc_srp(3), tolerance) ! Test 3 : @@ -162,9 +162,9 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_srp(1), expected_srp(1),tolerance) - @assertRelativelyEqual(acc_srp(2), expected_srp(2),tolerance) - @assertRelativelyEqual(acc_srp(3), expected_srp(3),tolerance) + @assertRelativelyEqual(expected_srp(1), acc_srp(1), tolerance) + @assertRelativelyEqual(expected_srp(2), acc_srp(2), tolerance) + @assertRelativelyEqual(expected_srp(3), acc_srp(3), tolerance) end subroutine test_getSrpAcceleration @@ -225,9 +225,9 @@ end subroutine test_getSrpAcceleration tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_alb(1), expected_alb(1),tolerance) - @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) - @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + @assertRelativelyEqual(expected_alb(1), acc_alb(1), tolerance) + @assertRelativelyEqual(expected_alb(2), acc_alb(2), tolerance) + @assertRelativelyEqual(expected_alb(3), acc_alb(3), tolerance) ! Test 2 : epoch%mjd = 58600.d0 @@ -264,9 +264,9 @@ end subroutine test_getSrpAcceleration tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_alb(1), expected_alb(1),tolerance) - @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) - @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + @assertRelativelyEqual(expected_alb(1), acc_alb(1), tolerance) + @assertRelativelyEqual(expected_alb(2), acc_alb(2), tolerance) + @assertRelativelyEqual(expected_alb(3), acc_alb(3), tolerance) ! Test 3 : epoch%mjd = 58600.d0 @@ -303,9 +303,9 @@ end subroutine test_getSrpAcceleration tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_alb(1), expected_alb(1),tolerance) - @assertRelativelyEqual(acc_alb(2), expected_alb(2),tolerance) - @assertRelativelyEqual(acc_alb(3), expected_alb(3),tolerance) + @assertRelativelyEqual(expected_alb(1), acc_alb(1), tolerance) + @assertRelativelyEqual(expected_alb(2), acc_alb(2), tolerance) + @assertRelativelyEqual(expected_alb(3), acc_alb(3), tolerance) end subroutine test_getAlbedoAcceleration diff --git a/tests/test_solarsystem.pf b/tests/test_solarsystem.pf index 62e0353..7114ea9 100644 --- a/tests/test_solarsystem.pf +++ b/tests/test_solarsystem.pf @@ -53,7 +53,7 @@ module test_solarsystem tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(obtained_position, expected_position, tolerance) + @assertRelativelyEqual(expected_position, obtained_position, tolerance) ! Test 2 : @@ -78,7 +78,7 @@ module test_solarsystem tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(obtained_position, expected_position, tolerance) + @assertRelativelyEqual(expected_position, obtained_position, tolerance) ! Test 3 : epoch%mjd = 58600 @@ -102,7 +102,7 @@ module test_solarsystem tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(obtained_position, expected_position, tolerance) + @assertRelativelyEqual(expected_position, obtained_position, tolerance) diff --git a/tests/test_thirdbody.pf b/tests/test_thirdbody.pf index 3564318..78744ee 100644 --- a/tests/test_thirdbody.pf +++ b/tests/test_thirdbody.pf @@ -61,7 +61,7 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + @assertRelativelyEqual(expected_acc, acc_thirdbody, tolerance) ! Test 2 : @@ -88,7 +88,7 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + @assertRelativelyEqual(expected_acc, acc_thirdbody, tolerance) ! Test 2 : epoch%mjd = 58600.d0 @@ -114,9 +114,8 @@ contains tolerance = 1e-6_dp ! Check if outputs match expected values - @assertRelativelyEqual(acc_thirdbody, expected_acc, tolerance) + @assertRelativelyEqual(expected_acc, acc_thirdbody, tolerance) - end subroutine test_getThirdBodyAccelaration