-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Space-Systems/add-more-unittests
Add more pf unittests
- Loading branch information
Showing
11 changed files
with
946 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
!============================================================================== | ||
! | ||
!> @anchor test_gravityCov | ||
!! | ||
!> @brief Program for testing the function that calculates the gravityCovariance | ||
!! | ||
!> @author Arkene Chouchene (AC) | ||
!! | ||
!> @date <ul> | ||
!! <li>15.06.2023 (initial design)</li> | ||
!! </ul> | ||
!! | ||
!! @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 | ||
! Test 1 | ||
|
||
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(expected_cov, cov, tolerance) | ||
|
||
! 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(expected_cov, 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 | ||
! 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(expected_cov, cov, tolerance) | ||
|
||
end subroutine test_getGravityCovariance | ||
|
||
end module test_GravityCov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
!============================================================================== | ||
! | ||
!> @anchor test_atmosphere_Exponential | ||
!! | ||
!> @brief Program for testing the function responsable for calculating Density by Exponential model | ||
!! | ||
!> @author Arkene Chouchene (AC) | ||
!! | ||
!> @date <ul> | ||
!! <li>15.06.2023 (initial design)</li> | ||
!! </ul> | ||
!! | ||
!! @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 | ||
|
||
implicit none | ||
|
||
contains | ||
|
||
@test | ||
subroutine test_getDensityExponential() | ||
! Tests that a density is computed by the Exponential model | ||
! Reference Values : Orekit | ||
|
||
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(38990000.0d0, atmosphere_model%getDensityExponential(25.d0), tolerance=0.01) | ||
! test #2 | ||
@assertRelativelyEqual(0.11635971694422577d-2, atmosphere_model%getDensityExponential(0.4688d3), tolerance=0.01) | ||
! test #3 | ||
@assertRelativelyEqual(499706396.76297361d0, atmosphere_model%getDensityExponential(0.65d1), tolerance=0.01) | ||
end subroutine test_getDensityExponential | ||
|
||
end module test_atmosphere_Exponential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
!============================================================================== | ||
! | ||
!> @anchor test_atmosphere_JB2008 | ||
!! | ||
!> @brief Program for testing the function responsable for calculating Density by JB08 model | ||
!! | ||
!> @author Arkene Chouchene (AC) | ||
!! | ||
!> @date <ul> | ||
!! <li>15.06.2023 (initial design)</li> | ||
!! </ul> | ||
!! | ||
!! @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 | ||
|
||
contains | ||
|
||
@test | ||
subroutine test_getDensityJB2008() | ||
! Tests that a density is computed by the JB2008 model | ||
! inputs taken from the JB2008_test_in file and reference values from OREKIT | ||
|
||
type(Atmosphere_class) :: atmosphere_model | ||
|
||
atmosphere_model = Atmosphere_class() | ||
|
||
atmosphere_model%nmodel = JB08 | ||
|
||
call atmosphere_model%setAtmosphereInitFlag() | ||
atmosphere_model%sgaDataFile = "SOLFSMY.TXT" | ||
call atmosphere_model%initAtmosphere('../../work/data') | ||
|
||
! test #1 | ||
@assertRelativelyEqual(0.12405204124422383d-002, atmosphere_model%getDensityJB2008(500.d0, 0.d0, 0.d0, 51544.d0), tolerance=0.01) | ||
! ! test #2 | ||
@assertRelativelyEqual(0.79968484021225802d+27, atmosphere_model%getDensityJB2008(150.d0, 0.d0, 0.446d2, 58600.d0), tolerance=0.01) | ||
|
||
end subroutine test_getDensityJB2008 | ||
|
||
end module test_atmosphere_JB2008 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.