Tudat/SimulationSetup/PropagationSetup/createMassRateModels.cpp
//! Function to create a mass rate model
Function to create a mass rate model
Function to create a mass rate model
std::shared_ptr< basic_astrodynamics::MassRateModel >
createMassRateModel(
        const std::string& bodyWithMassRate,
        const std::shared_ptr< MassRateModelSettings > massRateModelSettings,
        const NamedBodyMap& bodyMap,
        const basic_astrodynamics::AccelerationMap& accelerationModels )
{
    std::shared_ptr< basic_astrodynamics::MassRateModel > massRateModel;
    switch( massRateModelSettings->massRateType_ )
    {
    case basic_astrodynamics::custom_mass_rate_model:
    {
        std::shared_ptr< CustomMassRateModelSettings > customMassRateModelSettings =
                std::dynamic_pointer_cast< CustomMassRateModelSettings >( massRateModelSettings );
        if( customMassRateModelSettings == nullptr )
        {
            throw std::runtime_error( "Error when making cusom mass rate model, input is inconsistent" );
        }
        else
        {
            massRateModel = std::make_shared< basic_astrodynamics::CustomMassRateModel >(
                        customMassRateModelSettings->massRateFunction_ );
        }
        break;
    }
    case basic_astrodynamics::from_thrust_mass_rate_model:
    {
        std::shared_ptr< FromThrustMassModelSettings > fromThrustMassModelSettings =
                std::dynamic_pointer_cast< FromThrustMassModelSettings >( massRateModelSettings );
        if( fromThrustMassModelSettings == nullptr )
        {
            throw std::runtime_error( "Error when making from-engine mass rate model, input is inconsistent" );
        }
        else
        {
            std::vector< std::shared_ptr< basic_astrodynamics::AccelerationModel3d > >
                    thrustAccelerations;
            if( accelerationModels.count( bodyWithMassRate ) != 0 )
            {
                if( accelerationModels.at( bodyWithMassRate ).count( bodyWithMassRate ) != 0 )
                {
                    thrustAccelerations = basic_astrodynamics::getAccelerationModelsOfType(
                                accelerationModels.at( bodyWithMassRate ).at( bodyWithMassRate ),
                                basic_astrodynamics::thrust_acceleration );
                }
            }
            if( thrustAccelerations.size( ) == 0 )
            {
                std::cerr << "Warning when making from-thrust mass-rate model, no thrust model is found; no thust is used" << std::endl;
            }
            std::vector< std::shared_ptr< propulsion::ThrustAcceleration > >
                    explicitThrustAccelerations;
            if( fromThrustMassModelSettings->useAllThrustModels_ == 0 )
            {
                for( unsigned int i = 0; i < thrustAccelerations.size( ); i++ )
                {
                    if( std::dynamic_pointer_cast< propulsion::ThrustAcceleration >(
                                thrustAccelerations.at( i ) )->getAssociatedThrustSource( ) ==
                            fromThrustMassModelSettings->associatedThrustSource_ )
                    {
                        explicitThrustAccelerations.push_back( std::dynamic_pointer_cast< propulsion::ThrustAcceleration >(
                                                                   thrustAccelerations.at( i ) ) );
                    }
                }
                if( explicitThrustAccelerations.size( ) != 1 )
                {
                    std::cerr << "Warning when making from-thrust mass-rate model, did not find exactly 1 thrust model with correct identifier" << std::endl;
                }
            }
            else
            {
                for( unsigned int i = 0; i < thrustAccelerations.size( ); i++ )
                {
                    explicitThrustAccelerations.push_back( std::dynamic_pointer_cast< propulsion::ThrustAcceleration >(
                                                               thrustAccelerations.at( i ) ) );
                }
            }
            massRateModel = std::make_shared< propulsion::FromThrustMassRateModel >(
                        explicitThrustAccelerations );
        }
        break;
    }
    default:
        throw std::runtime_error( "Error when making mass rate model, type not recognized" );
    }
    return massRateModel;
}
std :: shared_ptr < basic_astrodynamics :: MassRateModel > createMassRateModel ( const std :: string & bodyWithMassRate , const std :: shared_ptr < MassRateModelSettings > massRateModelSettings , const NamedBodyMap & bodyMap , const basic_astrodynamics :: AccelerationMap & accelerationModels ) { std :: shared_ptr < basic_astrodynamics :: MassRateModel > massRateModel ; switch ( massRateModelSettings -> massRateType_ ) { case basic_astrodynamics :: custom_mass_rate_model : { std :: shared_ptr < CustomMassRateModelSettings > customMassRateModelSettings = std :: dynamic_pointer_cast < CustomMassRateModelSettings > ( massRateModelSettings ) ; if ( customMassRateModelSettings == nullptr ) { throw std :: runtime_error ( " " ) ; } else { massRateModel = std :: make_shared < basic_astrodynamics :: CustomMassRateModel > ( customMassRateModelSettings -> massRateFunction_ ) ; } break ; } case basic_astrodynamics :: from_thrust_mass_rate_model : { std :: shared_ptr < FromThrustMassModelSettings > fromThrustMassModelSettings = std :: dynamic_pointer_cast < FromThrustMassModelSettings > ( massRateModelSettings ) ; if ( fromThrustMassModelSettings == nullptr ) { throw std :: runtime_error ( " " ) ; } else { std :: vector < std :: shared_ptr < basic_astrodynamics :: AccelerationModel3d > > thrustAccelerations ; if ( accelerationModels . count ( bodyWithMassRate ) != 0 ) { if ( accelerationModels . at ( bodyWithMassRate ) . count ( bodyWithMassRate ) != 0 ) { thrustAccelerations = basic_astrodynamics :: getAccelerationModelsOfType ( accelerationModels . at ( bodyWithMassRate ) . at ( bodyWithMassRate ) , basic_astrodynamics :: thrust_acceleration ) ; } } if ( thrustAccelerations . size ( ) == 0 ) { std :: cerr << " " << std :: endl ; } std :: vector < std :: shared_ptr < propulsion :: ThrustAcceleration > > explicitThrustAccelerations ; if ( fromThrustMassModelSettings -> useAllThrustModels_ == 0 ) { for ( unsigned int i = 0 ; i < thrustAccelerations . size ( ) ; i ++ ) { if ( std :: dynamic_pointer_cast < propulsion :: ThrustAcceleration > ( thrustAccelerations . at ( i ) ) -> getAssociatedThrustSource ( ) == fromThrustMassModelSettings -> associatedThrustSource_ ) { explicitThrustAccelerations . push_back ( std :: dynamic_pointer_cast < propulsion :: ThrustAcceleration > ( thrustAccelerations . at ( i ) ) ) ; } } if ( explicitThrustAccelerations . size ( ) != 1 ) { std :: cerr << " " << std :: endl ; } } else { for ( unsigned int i = 0 ; i < thrustAccelerations . size ( ) ; i ++ ) { explicitThrustAccelerations . push_back ( std :: dynamic_pointer_cast < propulsion :: ThrustAcceleration > ( thrustAccelerations . at ( i ) ) ) ; } } massRateModel = std :: make_shared < propulsion :: FromThrustMassRateModel > ( explicitThrustAccelerations ) ; } break ; } default : throw std :: runtime_error ( " " ) ; } return massRateModel ; }
Function to create a mass rate model
Function to create a mass rate model
// Check type of mass rate model. // Check input consistency // Check input consistency // Retrieve thrust models with the correct id (should be 1) // Combine all thrust models into list // Create mass rate model