Tudat/Astrodynamics/OrbitDetermination/AccelerationPartials/sphericalHarmonicAccelerationPartial.cpp
//! Function to calculate an acceleration partial wrt a tidal parameter.
Function to calculate an acceleration partial wrt a tidal parameter.
Function to calculate an acceleration partial wrt a tidal parameter .
void SphericalHarmonicsGravityPartial::wrtTidalModelParameter(
        const std::function< std::vector< Eigen::Matrix< double, 2, Eigen::Dynamic > >( ) > coefficientPartialFunctions,
        const int degree,
        const std::vector< int >& orders,
        const bool sumOrders,
        const int parameterSize,
        Eigen::MatrixXd& partialMatrix )
{
    partialMatrix = Eigen::Matrix< double, 3, Eigen::Dynamic >::Zero( 3, parameterSize );
    std::vector< Eigen::Matrix< double, 2, Eigen::Dynamic > > coefficientPartialsPerOrder_ = coefficientPartialFunctions( );
    int singleOrderPartialSize = coefficientPartialsPerOrder_.at( 0 ).cols( );
    Eigen::MatrixXd currentPartialContribution = Eigen::MatrixXd::Zero( 3, 1 );
    std::vector< std::pair< int, int > > blockIndices;
    blockIndices.resize( 1 );
    for( unsigned int i = 0; i < orders.size( ); i++ )
    {
        blockIndices[ 0 ] = std::make_pair( degree, orders.at( i ) );
        if( sumOrders )
        {
            calculateSphericalHarmonicGravityWrtCCoefficients(
                        bodyFixedSphericalPosition_, bodyReferenceRadius_( ), gravitationalParameterFunction_( ),
                        sphericalHarmonicCache_,
                        blockIndices, coordinate_conversions::getSphericalToCartesianGradientMatrix(
                            bodyFixedPosition_ ), fromBodyFixedToIntegrationFrameRotation_( ), currentPartialContribution );
            partialMatrix.block( 0, 0, 3, singleOrderPartialSize ) +=
                    currentPartialContribution * coefficientPartialsPerOrder_.at( i ).block( 0, 0, 1, singleOrderPartialSize );
            blockIndices[ 0 ] = std::make_pair( degree, orders.at( i ) );
            calculateSphericalHarmonicGravityWrtSCoefficients(
                        bodyFixedSphericalPosition_, bodyReferenceRadius_( ), gravitationalParameterFunction_( ),
                        sphericalHarmonicCache_,
                        blockIndices, coordinate_conversions::getSphericalToCartesianGradientMatrix(
                            bodyFixedPosition_ ), fromBodyFixedToIntegrationFrameRotation_( ), currentPartialContribution );
            partialMatrix.block( 0, 0, 3, singleOrderPartialSize ) +=
                    currentPartialContribution * coefficientPartialsPerOrder_.at( i ).block( 1, 0, 1, singleOrderPartialSize );
        }
        else
        {
            calculateSphericalHarmonicGravityWrtCCoefficients(
                        bodyFixedSphericalPosition_, bodyReferenceRadius_( ), gravitationalParameterFunction_( ),
                        sphericalHarmonicCache_,
                        blockIndices, coordinate_conversions::getSphericalToCartesianGradientMatrix(
                            bodyFixedPosition_ ), fromBodyFixedToIntegrationFrameRotation_( ), currentPartialContribution );
            partialMatrix.block( 0, i * singleOrderPartialSize, 3, singleOrderPartialSize ) +=
                    currentPartialContribution * coefficientPartialsPerOrder_.at( i ).block( 0, 0, 1, singleOrderPartialSize );
            calculateSphericalHarmonicGravityWrtSCoefficients(
                        bodyFixedSphericalPosition_, bodyReferenceRadius_( ), gravitationalParameterFunction_( ),
                        sphericalHarmonicCache_,
                        blockIndices, coordinate_conversions::getSphericalToCartesianGradientMatrix(
                            bodyFixedPosition_ ), fromBodyFixedToIntegrationFrameRotation_( ), currentPartialContribution );
            partialMatrix.block( 0, i * singleOrderPartialSize, 3, singleOrderPartialSize ) +=
                        currentPartialContribution * coefficientPartialsPerOrder_.at( i ).block( 1, 0, 1, singleOrderPartialSize );
        }
    }
}
void SphericalHarmonicsGravityPartial :: wrtTidalModelParameter ( const std :: function < std :: vector < Eigen :: Matrix < double , 2 , Eigen :: Dynamic > > ( ) > coefficientPartialFunctions , const int degree , const std :: vector < int > & orders , const bool sumOrders , const int parameterSize , Eigen :: MatrixXd & partialMatrix ) { partialMatrix = Eigen :: Matrix < double , 3 , Eigen :: Dynamic > :: Zero ( 3 , parameterSize ) ; std :: vector < Eigen :: Matrix < double , 2 , Eigen :: Dynamic > > coefficientPartialsPerOrder_ = coefficientPartialFunctions ( ) ; int singleOrderPartialSize = coefficientPartialsPerOrder_ . at ( 0 ) . cols ( ) ; Eigen :: MatrixXd currentPartialContribution = Eigen :: MatrixXd :: Zero ( 3 , 1 ) ; std :: vector < std :: pair < int , int > > blockIndices ; blockIndices . resize ( 1 ) ; for ( unsigned int i = 0 ; i < orders . size ( ) ; i ++ ) { blockIndices [ 0 ] = std :: make_pair ( degree , orders . at ( i ) ) ; if ( sumOrders ) { calculateSphericalHarmonicGravityWrtCCoefficients ( bodyFixedSphericalPosition_ , bodyReferenceRadius_ ( ) , gravitationalParameterFunction_ ( ) , sphericalHarmonicCache_ , blockIndices , coordinate_conversions :: getSphericalToCartesianGradientMatrix ( bodyFixedPosition_ ) , fromBodyFixedToIntegrationFrameRotation_ ( ) , currentPartialContribution ) ; partialMatrix . block ( 0 , 0 , 3 , singleOrderPartialSize ) += currentPartialContribution * coefficientPartialsPerOrder_ . at ( i ) . block ( 0 , 0 , 1 , singleOrderPartialSize ) ; blockIndices [ 0 ] = std :: make_pair ( degree , orders . at ( i ) ) ; calculateSphericalHarmonicGravityWrtSCoefficients ( bodyFixedSphericalPosition_ , bodyReferenceRadius_ ( ) , gravitationalParameterFunction_ ( ) , sphericalHarmonicCache_ , blockIndices , coordinate_conversions :: getSphericalToCartesianGradientMatrix ( bodyFixedPosition_ ) , fromBodyFixedToIntegrationFrameRotation_ ( ) , currentPartialContribution ) ; partialMatrix . block ( 0 , 0 , 3 , singleOrderPartialSize ) += currentPartialContribution * coefficientPartialsPerOrder_ . at ( i ) . block ( 1 , 0 , 1 , singleOrderPartialSize ) ; } else { calculateSphericalHarmonicGravityWrtCCoefficients ( bodyFixedSphericalPosition_ , bodyReferenceRadius_ ( ) , gravitationalParameterFunction_ ( ) , sphericalHarmonicCache_ , blockIndices , coordinate_conversions :: getSphericalToCartesianGradientMatrix ( bodyFixedPosition_ ) , fromBodyFixedToIntegrationFrameRotation_ ( ) , currentPartialContribution ) ; partialMatrix . block ( 0 , i * singleOrderPartialSize , 3 , singleOrderPartialSize ) += currentPartialContribution * coefficientPartialsPerOrder_ . at ( i ) . block ( 0 , 0 , 1 , singleOrderPartialSize ) ; calculateSphericalHarmonicGravityWrtSCoefficients ( bodyFixedSphericalPosition_ , bodyReferenceRadius_ ( ) , gravitationalParameterFunction_ ( ) , sphericalHarmonicCache_ , blockIndices , coordinate_conversions :: getSphericalToCartesianGradientMatrix ( bodyFixedPosition_ ) , fromBodyFixedToIntegrationFrameRotation_ ( ) , currentPartialContribution ) ; partialMatrix . block ( 0 , i * singleOrderPartialSize , 3 , singleOrderPartialSize ) += currentPartialContribution * coefficientPartialsPerOrder_ . at ( i ) . block ( 1 , 0 , 1 , singleOrderPartialSize ) ; } } }
Function to calculate an acceleration partial wrt a tidal parameter.
Function to calculate an acceleration partial wrt a tidal parameter .
// Initialize partial matrix to zero values. // Calculate multiplicative term found in all partial terms (partial of C,S coefficients w.r.t. parameter). // Iterate over all required orders in current degree. // Set coefficient degree/order for current partials // Compute acceleration w.r.t. C and S coefficients, and multiply with partials of C,S coefficients w.r.t. parameter