Tudat/Astrodynamics/Aerodynamics/UnitTests/unitTestNRLMSISE00Atmosphere.cpp
//! Perform test of hashing function.
//  Hashing is important to speed up the model and prevent double
//  calculations, however it can be tricky too, so make sure to reset the hash when in doubt.
Perform test of hashing function.
Hashing is important to speed up the model and prevent double
calculations, however it can be tricky too, so make sure to reset the hash when in doubt.
Perform test of hashing function . Hashing is important to speed up the model and prevent double calculations however it can be tricky too so make sure to reset the hash when in doubt .
BOOST_AUTO_TEST_CASE( testNRLMSISE00AtmosphereTestHashing )
{
    NRLMSISE00Atmosphere model( std::bind( &function, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, false, false ) );
    data = gen_data;
    std::vector< double > input = gen_input;
    double density1 = model.getDensity( input[ 0 ], input[ 1 ],
            input[ 2 ], input[ 3 ] );
    data.f107 = 180.0;
    double density2 = model.getDensity( input[ 0 ], input[ 1 ],
            input[ 2 ], input[ 3 ] );
    BOOST_CHECK_EQUAL(density1, density2);
    model.resetHashKey( );
    double density3 = model.getDensity( input[ 0 ], input[ 1 ],
            input[ 2 ], input[ 3 ] );
    BOOST_CHECK_PREDICATE( std::not_equal_to< double >( ), ( density1 )( density3 ) );
    data.f107 = 150.0;
    model.resetHashKey( );
    double density1new = model.getDensity( input[ 0 ], input[ 1 ],
            input[ 2 ], input[ 3 ] );
    BOOST_CHECK_EQUAL( density1new, density1 );
    data.f107 = 180.0;
    double density4 = model.getDensity( input[ 0 ], input[ 1 ],
            input[ 2 ], input[ 3 ] + 42.0);
    BOOST_CHECK_PREDICATE(std::not_equal_to<double>( ), (density1)(density4));
    BOOST_CHECK_EQUAL(density3, density4);
}
BOOST_AUTO_TEST_CASE ( testNRLMSISE00AtmosphereTestHashing ) { NRLMSISE00Atmosphere model ( std :: bind ( & function , std :: placeholders :: _1 , std :: placeholders :: _2 , std :: placeholders :: _3 , std :: placeholders :: _4 , false , false ) ) ; data = gen_data ; std :: vector < double > input = gen_input ; double density1 = model . getDensity ( input [ 0 ] , input [ 1 ] , input [ 2 ] , input [ 3 ] ) ; data . f107 = 180.0 ; double density2 = model . getDensity ( input [ 0 ] , input [ 1 ] , input [ 2 ] , input [ 3 ] ) ; BOOST_CHECK_EQUAL ( density1 , density2 ) ; model . resetHashKey ( ) ; double density3 = model . getDensity ( input [ 0 ] , input [ 1 ] , input [ 2 ] , input [ 3 ] ) ; BOOST_CHECK_PREDICATE ( std :: not_equal_to < double > ( ) , ( density1 ) ( density3 ) ) ; data . f107 = 150.0 ; model . resetHashKey ( ) ; double density1new = model . getDensity ( input [ 0 ] , input [ 1 ] , input [ 2 ] , input [ 3 ] ) ; BOOST_CHECK_EQUAL ( density1new , density1 ) ; data . f107 = 180.0 ; double density4 = model . getDensity ( input [ 0 ] , input [ 1 ] , input [ 2 ] , input [ 3 ] + 42.0 ) ; BOOST_CHECK_PREDICATE ( std :: not_equal_to < double > ( ) , ( density1 ) ( density4 ) ) ; BOOST_CHECK_EQUAL ( density3 , density4 ) ; }
Perform test of hashing function.
Perform test of hashing function .
// Create the model // Create local copy of input and define variations // Define variations from the standard case // First case is the default case // Increase the daily F10.7 average (from 140.0) // See that although the F10.7 has changed, no recalculation was // triggered. The densities remain the same! // In order to trigger a recalculation we can // (A) reset the hash // And indeed observe a new density is calculated and is not equal // anymore to the old one. // Recalculate density1, to "reset" the internal state of the // model , for the next demo // (B) change any of the four indepedent parameters, namely // altitude, latitude, longitude, and/or time. Since time is not // used in our current NRLMSISE00InputFunction of this test, we // can change time without changing anything. // The densities are not equal (ergo recalculated). Furthermore // the density using method (B) is exactly equal to the density // obtained using solution (A), this shows that both are equal in // triggering recalculations.