Tudat/SimulationSetup/PropagationSetup/createTorqueModel.cpp
//! Function to create an aerodynamic torque model.
Function to create an aerodynamic torque model.
Function to create an aerodynamic torque model .
std::shared_ptr< aerodynamics::AerodynamicTorque > createAerodynamicTorqueModel(
        const std::shared_ptr< simulation_setup::Body > bodyUndergoingTorque,
        const std::shared_ptr< simulation_setup::Body > bodyExertingTorque,
        const std::string& nameOfBodyUndergoingTorque,
        const std::string& nameOfBodyExertingTorque )
{
    if( bodyUndergoingTorque->getAerodynamicCoefficientInterface( ) == nullptr )
    {
        throw std::runtime_error( "Error when making aerodynamic torque, body " +
                                  nameOfBodyUndergoingTorque +
                                  "has no aerodynamic coefficients." );
    }
    if( bodyExertingTorque->getAtmosphereModel( ) == nullptr )
    {
        throw std::runtime_error(  "Error when making aerodynamic torque, central body " +
                                   nameOfBodyExertingTorque + " has no atmosphere model.");
    }
    if( bodyExertingTorque->getShapeModel( ) == nullptr )
    {
        throw std::runtime_error( "Error when making aerodynamic torque, central body " +
                                  nameOfBodyExertingTorque + " has no shape model." );
    }
    std::shared_ptr< aerodynamics::AtmosphericFlightConditions > bodyFlightConditions =
            std::dynamic_pointer_cast< aerodynamics::AtmosphericFlightConditions >(
                bodyUndergoingTorque->getFlightConditions( ) );
    if( bodyFlightConditions == nullptr && bodyUndergoingTorque->getFlightConditions( ) == nullptr )
    {
        bodyFlightConditions = createAtmosphericFlightConditions( bodyUndergoingTorque,
                                                       bodyExertingTorque,
                                                       nameOfBodyUndergoingTorque,
                                                       nameOfBodyExertingTorque ) ;
        bodyUndergoingTorque->setFlightConditions(
                    bodyFlightConditions );
    }
    else if( bodyFlightConditions == nullptr && bodyUndergoingTorque->getFlightConditions( ) != nullptr )
    {
        throw std::runtime_error( "Error when making aerodynamic torque, found flight conditions that are not atmospheric." );
    }
    std::shared_ptr< aerodynamics::AerodynamicCoefficientInterface > aerodynamicCoefficients =
            bodyUndergoingTorque->getAerodynamicCoefficientInterface( );
    reference_frames::AerodynamicsReferenceFrames torqueFrame;
    if( aerodynamicCoefficients->getAreCoefficientsInAerodynamicFrame( ) )
    {
        torqueFrame = reference_frames::aerodynamic_frame;
    }
    else
    {
        torqueFrame = reference_frames::body_frame;
    }
    std::function< Eigen::Vector3d( const Eigen::Vector3d& ) > toPropagationFrameTransformation;
    toPropagationFrameTransformation =
            reference_frames::getAerodynamicForceTransformationFunction(
                bodyFlightConditions->getAerodynamicAngleCalculator( ),
                torqueFrame,
                std::bind( &Body::getCurrentRotationToGlobalFrame, bodyExertingTorque ),
                reference_frames::body_frame );
    std::function< Eigen::Vector3d( ) > coefficientFunction =
            std::bind( &aerodynamics::AerodynamicCoefficientInterface::getCurrentMomentCoefficients,
                         aerodynamicCoefficients );
    std::function< Eigen::Vector3d( ) > coefficientInPropagationFrameFunction =
            std::bind( &reference_frames::transformVectorFunctionFromVectorFunctions,
                         coefficientFunction, toPropagationFrameTransformation );
    return std::make_shared< aerodynamics::AerodynamicTorque >(
                coefficientInPropagationFrameFunction,
                std::bind( &aerodynamics::AtmosphericFlightConditions::getCurrentDensity, bodyFlightConditions ),
                std::bind( &aerodynamics::AtmosphericFlightConditions::getCurrentAirspeed, bodyFlightConditions ),
                std::bind( &aerodynamics::AerodynamicCoefficientInterface::getReferenceArea, aerodynamicCoefficients ),
                std::bind( &aerodynamics::AerodynamicCoefficientInterface::getReferenceLengths, aerodynamicCoefficients ),
                aerodynamicCoefficients->getAreCoefficientsInNegativeAxisDirection( ) );
}
std :: shared_ptr < aerodynamics :: AerodynamicTorque > createAerodynamicTorqueModel ( const std :: shared_ptr < simulation_setup :: Body > bodyUndergoingTorque , const std :: shared_ptr < simulation_setup :: Body > bodyExertingTorque , const std :: string & nameOfBodyUndergoingTorque , const std :: string & nameOfBodyExertingTorque ) { if ( bodyUndergoingTorque -> getAerodynamicCoefficientInterface ( ) == nullptr ) { throw std :: runtime_error ( " " + nameOfBodyUndergoingTorque + " " ) ; } if ( bodyExertingTorque -> getAtmosphereModel ( ) == nullptr ) { throw std :: runtime_error ( " " + nameOfBodyExertingTorque + " " ) ; } if ( bodyExertingTorque -> getShapeModel ( ) == nullptr ) { throw std :: runtime_error ( " " + nameOfBodyExertingTorque + " " ) ; } std :: shared_ptr < aerodynamics :: AtmosphericFlightConditions > bodyFlightConditions = std :: dynamic_pointer_cast < aerodynamics :: AtmosphericFlightConditions > ( bodyUndergoingTorque -> getFlightConditions ( ) ) ; if ( bodyFlightConditions == nullptr && bodyUndergoingTorque -> getFlightConditions ( ) == nullptr ) { bodyFlightConditions = createAtmosphericFlightConditions ( bodyUndergoingTorque , bodyExertingTorque , nameOfBodyUndergoingTorque , nameOfBodyExertingTorque ) ; bodyUndergoingTorque -> setFlightConditions ( bodyFlightConditions ) ; } else if ( bodyFlightConditions == nullptr && bodyUndergoingTorque -> getFlightConditions ( ) != nullptr ) { throw std :: runtime_error ( " " ) ; } std :: shared_ptr < aerodynamics :: AerodynamicCoefficientInterface > aerodynamicCoefficients = bodyUndergoingTorque -> getAerodynamicCoefficientInterface ( ) ; reference_frames :: AerodynamicsReferenceFrames torqueFrame ; if ( aerodynamicCoefficients -> getAreCoefficientsInAerodynamicFrame ( ) ) { torqueFrame = reference_frames :: aerodynamic_frame ; } else { torqueFrame = reference_frames :: body_frame ; } std :: function < Eigen :: Vector3d ( const Eigen :: Vector3d & ) > toPropagationFrameTransformation ; toPropagationFrameTransformation = reference_frames :: getAerodynamicForceTransformationFunction ( bodyFlightConditions -> getAerodynamicAngleCalculator ( ) , torqueFrame , std :: bind ( & Body :: getCurrentRotationToGlobalFrame , bodyExertingTorque ) , reference_frames :: body_frame ) ; std :: function < Eigen :: Vector3d ( ) > coefficientFunction = std :: bind ( & aerodynamics :: AerodynamicCoefficientInterface :: getCurrentMomentCoefficients , aerodynamicCoefficients ) ; std :: function < Eigen :: Vector3d ( ) > coefficientInPropagationFrameFunction = std :: bind ( & reference_frames :: transformVectorFunctionFromVectorFunctions , coefficientFunction , toPropagationFrameTransformation ) ; return std :: make_shared < aerodynamics :: AerodynamicTorque > ( coefficientInPropagationFrameFunction , std :: bind ( & aerodynamics :: AtmosphericFlightConditions :: getCurrentDensity , bodyFlightConditions ) , std :: bind ( & aerodynamics :: AtmosphericFlightConditions :: getCurrentAirspeed , bodyFlightConditions ) , std :: bind ( & aerodynamics :: AerodynamicCoefficientInterface :: getReferenceArea , aerodynamicCoefficients ) , std :: bind ( & aerodynamics :: AerodynamicCoefficientInterface :: getReferenceLengths , aerodynamicCoefficients ) , aerodynamicCoefficients -> getAreCoefficientsInNegativeAxisDirection ( ) ) ; }
Function to create an aerodynamic torque model.
Function to create an aerodynamic torque model .
// Check existence of required environment models // Retrieve flight conditions; create object if not yet extant. // Retrieve frame in which aerodynamic coefficients are defined. // Create function to transform from frame of aerodynamic coefficienrs to that of propagation. // Create torque model.