Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix extended precision #240

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
3 changes: 2 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ jobs:
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_C_COMPILER_LAUNCHER=ccache
#-DTUDAT_BUILD_WITH_EXTENDED_PRECISION_PROPAGATION_TOOLS=ON
-DTUDAT_BUILD_GITHUB_ACTIONS=ON


- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). Use multiple cpu cores available in the runner.
shell: bash -l {0}
run: cmake --build "${{ github.workspace }}/build" --config "${{ matrix.build_type }}" -j4
run: cmake --build "${{ github.workspace }}/build" --config "${{ matrix.build_type }}" -j3


- name: Test
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ option(TUDAT_BUILD_STATIC_LIBRARY "Build tudat as a static library, instead of d

# Build static library instead of dynamic.
option(TUDAT_BUILD_WITH_FILTERS "Build Tudat with preliminary Kalman Filter functionality." OFF)

# Build sofa interface.
option(TUDAT_BUILD_WITH_SOFA_INTERFACE "Build Tudat with sofa interface." ON)

Expand Down
3 changes: 2 additions & 1 deletion include/tudat/astro/basic_astro/timeConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ TimeScalarType convertJulianDayToSecondsSinceEpoch(
const TimeScalarType julianDay,
const TimeScalarType epochSinceJulianDayZero = getJulianDayOnJ2000< TimeScalarType >( ) )
{
return ( julianDay - epochSinceJulianDayZero ) * physical_constants::getJulianDay< TimeScalarType >( );

return ( julianDay - epochSinceJulianDayZero ) * physical_constants::getJulianDay< TimeScalarType >( );
}

//! Compute Julian day from seconds since reference Julian day epoch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ std::map< TimeType, Eigen::Matrix< StateScalarType, Eigen::Dynamic, 1 > > > >

template< typename TimeType = double, typename StateScalarType = double >
std::shared_ptr< DampedInitialRotationalStateResults< TimeType, StateScalarType > >
getZeroProperModeRotationalStateWithStruct(
getZeroProperModeRotationalStateWithStruct(
const simulation_setup::SystemOfBodies& bodies,
const std::shared_ptr< SingleArcPropagatorSettings< StateScalarType, TimeType > > propagatorSettings,
const double bodyMeanRotationRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ std::shared_ptr< EstimationOutput< StateScalarType, TimeType > > createBestFitTo

std::pair< std::vector< std::shared_ptr< observation_models::ObservationModelSettings > >,
std::shared_ptr< observation_models::ObservationCollection< StateScalarType, TimeType > > >
observationCollectionAndModelSettings = simulatePseudoObservations(
observationCollectionAndModelSettings = simulatePseudoObservations< TimeType, StateScalarType >(
bodies, bodiesToPropagate, centralBodies, initialTime, finalTime, dataPointInterval );
std::shared_ptr< observation_models::ObservationCollection< StateScalarType, TimeType > > observationCollection = observationCollectionAndModelSettings.second;

Expand Down
4 changes: 2 additions & 2 deletions include/tudat/simulation/estimation_setup/observations.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class ObservationCollection
return utilities::staticCastVector<double, TimeType>( concatenatedTimes_ );
}

std::vector< TimeType > getConcatenatedWeightVector( )
std::vector< ObservationScalarType > getConcatenatedWeightVector( )
{
// for now, this only takes the weights set from the single observation sets.
// TODO may require a change later to accomodate other sources.
Expand Down Expand Up @@ -1126,7 +1126,7 @@ inline std::shared_ptr< SingleObservationSet< ObservationScalarType, TimeType >
{
return std::make_shared< SingleObservationSet< ObservationScalarType, TimeType > >(
observableType, linkEnds, observations, observationTimes, referenceLinkEnd,
std::vector< Eigen::Matrix< ObservationScalarType, Eigen::Dynamic, 1 > >( ), nullptr, ancilliarySettings );
std::vector< Eigen::VectorXd >( ), nullptr, ancilliarySettings );
}

//template< typename ObservationScalarType = double, typename TimeType = double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ createTrackingTxtFileObservationCollection(
std::vector<ObservableType> observableTypesToProcess = std::vector<ObservableType>(),
const std::map<std::string, Eigen::Vector3d> earthFixedGroundStationPositions = simulation_setup::getApproximateDsnGroundStationPositions(),
// const std::map<std::string, Eigen::Vector3d> earthFixedGroundStationPositions = simulation_setup::getApproximateGroundStationPositionsFromFile(), // TODO: get ground stations from file
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings(),
const std::pair<TimeType, TimeType> startAndEndTimesToProcess = std::make_pair<TimeType, TimeType>(TUDAT_NAN, TUDAT_NAN))
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings() )
{

// Make sure processing the tracking file was successful
Expand Down Expand Up @@ -332,8 +331,7 @@ createTrackingTxtFileObservationCollection(
const std::vector<ObservableType> observableTypesToProcess = std::vector<ObservableType>(),
const std::map<std::string, Eigen::Vector3d> earthFixedGroundStationPositions = simulation_setup::getApproximateDsnGroundStationPositions(),
// std::map<std::string, Eigen::Vector3d> earthFixedGroundStationPositions = simulation_setup::getApproximateGroundStationPositionsFromFile(),
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings(),
std::pair<TimeType, TimeType> startAndEndTimesToProcess = std::make_pair<TimeType, TimeType>(TUDAT_NAN, TUDAT_NAN))
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings())
{
// Create processed tracking file contents
auto processedTrackingTxtFileContents = std::make_shared<observation_models::ProcessedTrackingTxtFileContents>(rawTrackingTxtFileContents,
Expand All @@ -344,8 +342,7 @@ createTrackingTxtFileObservationCollection(
return createTrackingTxtFileObservationCollection(processedTrackingTxtFileContents,
observableTypesToProcess,
earthFixedGroundStationPositions,
ancillarySettings,
startAndEndTimesToProcess);
ancillarySettings);
}

} // namespace observation_models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ std::shared_ptr< observation_models::ObservationCollection< ObservationScalarTyp
std::shared_ptr< observation_models::SingleObservationSet<ObservationScalarType,TimeType> > observationSet =
std::make_shared< observation_models::SingleObservationSet<ObservationScalarType,TimeType> >(
observableType, linkEnds, observationsTimesAndValues.first, observationsTimesAndValues.second, referenceLinkEnd,
std::vector< Eigen::Matrix< ObservationScalarType, Eigen::Dynamic, 1 > >( ), nullptr, currentAncilliarySettings );
std::vector< Eigen::VectorXd >( ), nullptr, currentAncilliarySettings );

sortedObservations[ observableType ][ linkEnds ].push_back( observationSet );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ namespace tudat

std::vector< std::map< TimeType, Eigen::VectorXd > > getConcatenatedDependentVariableResults( )
{
std::vector< std::map< TimeType, Eigen::VectorXd > > concatenatedResults;
std::vector< std::map< TimeType, Eigen::VectorXd > > concatenatedResults;
if( singleArcResults_->getSolutionIsCleared( ) != multiArcResults_->getSolutionIsCleared( ) )
{
throw std::runtime_error( "Error when getting concatenated hybrid-arc results, constituent results have inconsistent cleared state." );
Expand All @@ -946,9 +946,9 @@ namespace tudat
}
if( !singleArcResults_->getSolutionIsCleared( ) )
{
concatenatedResults.push_back( singleArcResults_->getEquationsOfMotionNumericalSolution( ) );
concatenatedResults.push_back( singleArcResults_->getDependentVariableHistory( ) );
std::vector< std::map< TimeType, Eigen::VectorXd > >
multiArcResults = multiArcResults_->getConcatenatedEquationsOfMotionResults( );
multiArcResults = multiArcResults_->getConcatenatedDependentVariableResults( );
concatenatedResults.insert( concatenatedResults.end( ), multiArcResults.begin( ), multiArcResults.end( ) );
}
return concatenatedResults;
Expand Down
5 changes: 3 additions & 2 deletions tests/src/astro/basic_astro/unitTestTimeConversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ BOOST_AUTO_TEST_CASE( testJulianDayToSecondsConversions )
const long double computedSecondsSinceEpoch = convertJulianDayToSecondsSinceEpoch< long double >(
julianDay, referenceEpoch );

std::cout<<std::setprecision( 19 )<<std::numeric_limits< long double >::epsilon( )<<" "<<referenceEpoch<<" "<<julianDay<<" "<<computedSecondsSinceEpoch<<" "<<expectedSecondsSinceEpoch<<" "<<computedSecondsSinceEpoch - expectedSecondsSinceEpoch<<std::endl;
// Test that computed result matches expected result.
// Test is run at reduced tolerance, because the final digits of the seconds were lost
// when converting to Julian day.
#if( TUDAT_BUILD_WITH_EXTENDED_PRECISION_PROPAGATION_TOOLS )
BOOST_CHECK_CLOSE_FRACTION( computedSecondsSinceEpoch, expectedSecondsSinceEpoch,
1.0e-14 );
#endif
}
#endif

// Test conversion from Julian day to seconds since J2000 epoch with long doubles
{
Expand Down Expand Up @@ -419,7 +420,7 @@ BOOST_AUTO_TEST_CASE( testTimeConversions )
BOOST_AUTO_TEST_CASE( testTimeConversionsLong )
{
// Define test dates (arbitrary).
const long double testModifiedJulianDay = static_cast< long double >( 54583.87 );
const long double testModifiedJulianDay = 54583.87L;
const long double testJulianDay = testModifiedJulianDay + JULIAN_DAY_AT_0_MJD_LONG;

// Test whether back and forth conversion between JD and MJD provides correct resulats.
Expand Down
Loading