Tudat/SimulationSetup/EnvironmentSetup/createAtmosphereModel.cpp
//! Function to create an atmosphere model.
Function to create an atmosphere model.
Function to create an atmosphere model .
std::shared_ptr< aerodynamics::AtmosphereModel > createAtmosphereModel(
        const std::shared_ptr< AtmosphereSettings > atmosphereSettings,
        const std::string& body )
{
    using namespace tudat::aerodynamics;
    std::shared_ptr< AtmosphereModel > atmosphereModel;
    switch( atmosphereSettings->getAtmosphereType( ) )
    {
    case exponential_atmosphere:
    {
        std::shared_ptr< ExponentialAtmosphereSettings > exponentialAtmosphereSettings =
                std::dynamic_pointer_cast< ExponentialAtmosphereSettings >( atmosphereSettings );
        if( exponentialAtmosphereSettings == nullptr )
        {
            throw std::runtime_error( "Error, expected exponential atmosphere settings for body " + body );
        }
        else
        {
            std::shared_ptr< ExponentialAtmosphere > exponentialAtmosphereModel;
            if ( exponentialAtmosphereSettings->getBodyName( ) == undefined_body )
            {
                exponentialAtmosphereModel = std::make_shared< ExponentialAtmosphere >(
                            exponentialAtmosphereSettings->getDensityScaleHeight( ) ,
                            exponentialAtmosphereSettings->getConstantTemperature( ),
                            exponentialAtmosphereSettings->getDensityAtZeroAltitude( ),
                            exponentialAtmosphereSettings->getSpecificGasConstant( ),
                            exponentialAtmosphereSettings->getRatioOfSpecificHeats( ) );
            }
            else
            {
                exponentialAtmosphereModel = std::make_shared< ExponentialAtmosphere >(
                            exponentialAtmosphereSettings->getBodyName( ) );
            }
            atmosphereModel = exponentialAtmosphereModel;
        }
        break;
    }
    case custom_constant_temperature_atmosphere:
    {
        std::shared_ptr< CustomConstantTemperatureAtmosphereSettings > customConstantTemperatureAtmosphereSettings =
                std::dynamic_pointer_cast< CustomConstantTemperatureAtmosphereSettings >( atmosphereSettings );
        if( customConstantTemperatureAtmosphereSettings == nullptr )
        {
            throw std::runtime_error( "Error, expected exponential atmosphere settings for body " + body );
        }
        else
        {
            std::shared_ptr< CustomConstantTemperatureAtmosphere > customConstantTemperatureAtmosphereModel;
            if ( customConstantTemperatureAtmosphereSettings->getModelSpecificParameters( ).empty( ) )
            {
                customConstantTemperatureAtmosphereModel = std::make_shared< CustomConstantTemperatureAtmosphere >(
                            customConstantTemperatureAtmosphereSettings->getDensityFunction( ) ,
                            customConstantTemperatureAtmosphereSettings->getConstantTemperature( ),
                            customConstantTemperatureAtmosphereSettings->getSpecificGasConstant( ),
                            customConstantTemperatureAtmosphereSettings->getRatioOfSpecificHeats( ) );
            }
            else
            {
                customConstantTemperatureAtmosphereModel = std::make_shared< CustomConstantTemperatureAtmosphere >(
                            customConstantTemperatureAtmosphereSettings->getDensityFunctionType( ),
                            customConstantTemperatureAtmosphereSettings->getConstantTemperature( ),
                            customConstantTemperatureAtmosphereSettings->getSpecificGasConstant( ),
                            customConstantTemperatureAtmosphereSettings->getRatioOfSpecificHeats( ),
                            customConstantTemperatureAtmosphereSettings->getModelSpecificParameters( ) );
            }
            atmosphereModel = customConstantTemperatureAtmosphereModel;
        }
        break;
    }
    case tabulated_atmosphere:
    {
        std::shared_ptr< TabulatedAtmosphereSettings > tabulatedAtmosphereSettings =
                std::dynamic_pointer_cast< TabulatedAtmosphereSettings >( atmosphereSettings );
        if( tabulatedAtmosphereSettings == nullptr )
        {
            throw std::runtime_error( "Error, expected tabulated atmosphere settings for body " + body );
        }
        else
        {
            atmosphereModel = std::make_shared< TabulatedAtmosphere >(
                        tabulatedAtmosphereSettings->getAtmosphereFile( ),
                        tabulatedAtmosphereSettings->getIndependentVariables( ),
                        tabulatedAtmosphereSettings->getDependentVariables( ),
                        tabulatedAtmosphereSettings->getSpecificGasConstant( ),
                        tabulatedAtmosphereSettings->getRatioOfSpecificHeats( ),
                        tabulatedAtmosphereSettings->getBoundaryHandling( ),
                        tabulatedAtmosphereSettings->getDefaultExtrapolationValue( ) );
        }
        break;
    }
#if USE_NRLMSISE00
    case nrlmsise00:
    {
        std::string spaceWeatherFilePath;
        std::shared_ptr< NRLMSISE00AtmosphereSettings > nrlmsise00AtmosphereSettings =
                std::dynamic_pointer_cast< NRLMSISE00AtmosphereSettings >( atmosphereSettings );
        if( nrlmsise00AtmosphereSettings == nullptr )
        {
            spaceWeatherFilePath = input_output::getSpaceWeatherDataPath( ) + "sw19571001.txt";
        }
        else
        {
            spaceWeatherFilePath = nrlmsise00AtmosphereSettings->getSpaceWeatherFile( );
        }
        tudat::input_output::solar_activity::SolarActivityDataMap solarActivityData =
                tudat::input_output::solar_activity::readSolarActivityData( spaceWeatherFilePath ) ;
        std::function< tudat::aerodynamics::NRLMSISE00Input( double, double, double, double ) > inputFunction =
                std::bind( &tudat::aerodynamics::nrlmsiseInputFunction,
                           std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4,
                           solarActivityData, false, TUDAT_NAN );
        atmosphereModel = std::make_shared< aerodynamics::NRLMSISE00Atmosphere >( inputFunction );
        break;
    }
#endif
    default:
        throw std::runtime_error( "Error, did not recognize atmosphere model settings type " +
                                  std::to_string( atmosphereSettings->getAtmosphereType( ) ) );
    }
    if( atmosphereSettings->getWindSettings( ) != nullptr )
    {
        atmosphereModel->setWindModel( createWindModel( atmosphereSettings->getWindSettings( ), body ) );
    }
    return atmosphereModel;
}
std :: shared_ptr < aerodynamics :: AtmosphereModel > createAtmosphereModel ( const std :: shared_ptr < AtmosphereSettings > atmosphereSettings , const std :: string & body ) { using namespace tudat :: aerodynamics ; std :: shared_ptr < AtmosphereModel > atmosphereModel ; switch ( atmosphereSettings -> getAtmosphereType ( ) ) { case exponential_atmosphere : { std :: shared_ptr < ExponentialAtmosphereSettings > exponentialAtmosphereSettings = std :: dynamic_pointer_cast < ExponentialAtmosphereSettings > ( atmosphereSettings ) ; if ( exponentialAtmosphereSettings == nullptr ) { throw std :: runtime_error ( " " + body ) ; } else { std :: shared_ptr < ExponentialAtmosphere > exponentialAtmosphereModel ; if ( exponentialAtmosphereSettings -> getBodyName ( ) == undefined_body ) { exponentialAtmosphereModel = std :: make_shared < ExponentialAtmosphere > ( exponentialAtmosphereSettings -> getDensityScaleHeight ( ) , exponentialAtmosphereSettings -> getConstantTemperature ( ) , exponentialAtmosphereSettings -> getDensityAtZeroAltitude ( ) , exponentialAtmosphereSettings -> getSpecificGasConstant ( ) , exponentialAtmosphereSettings -> getRatioOfSpecificHeats ( ) ) ; } else { exponentialAtmosphereModel = std :: make_shared < ExponentialAtmosphere > ( exponentialAtmosphereSettings -> getBodyName ( ) ) ; } atmosphereModel = exponentialAtmosphereModel ; } break ; } case custom_constant_temperature_atmosphere : { std :: shared_ptr < CustomConstantTemperatureAtmosphereSettings > customConstantTemperatureAtmosphereSettings = std :: dynamic_pointer_cast < CustomConstantTemperatureAtmosphereSettings > ( atmosphereSettings ) ; if ( customConstantTemperatureAtmosphereSettings == nullptr ) { throw std :: runtime_error ( " " + body ) ; } else { std :: shared_ptr < CustomConstantTemperatureAtmosphere > customConstantTemperatureAtmosphereModel ; if ( customConstantTemperatureAtmosphereSettings -> getModelSpecificParameters ( ) . empty ( ) ) { customConstantTemperatureAtmosphereModel = std :: make_shared < CustomConstantTemperatureAtmosphere > ( customConstantTemperatureAtmosphereSettings -> getDensityFunction ( ) , customConstantTemperatureAtmosphereSettings -> getConstantTemperature ( ) , customConstantTemperatureAtmosphereSettings -> getSpecificGasConstant ( ) , customConstantTemperatureAtmosphereSettings -> getRatioOfSpecificHeats ( ) ) ; } else { customConstantTemperatureAtmosphereModel = std :: make_shared < CustomConstantTemperatureAtmosphere > ( customConstantTemperatureAtmosphereSettings -> getDensityFunctionType ( ) , customConstantTemperatureAtmosphereSettings -> getConstantTemperature ( ) , customConstantTemperatureAtmosphereSettings -> getSpecificGasConstant ( ) , customConstantTemperatureAtmosphereSettings -> getRatioOfSpecificHeats ( ) , customConstantTemperatureAtmosphereSettings -> getModelSpecificParameters ( ) ) ; } atmosphereModel = customConstantTemperatureAtmosphereModel ; } break ; } case tabulated_atmosphere : { std :: shared_ptr < TabulatedAtmosphereSettings > tabulatedAtmosphereSettings = std :: dynamic_pointer_cast < TabulatedAtmosphereSettings > ( atmosphereSettings ) ; if ( tabulatedAtmosphereSettings == nullptr ) { throw std :: runtime_error ( " " + body ) ; } else { atmosphereModel = std :: make_shared < TabulatedAtmosphere > ( tabulatedAtmosphereSettings -> getAtmosphereFile ( ) , tabulatedAtmosphereSettings -> getIndependentVariables ( ) , tabulatedAtmosphereSettings -> getDependentVariables ( ) , tabulatedAtmosphereSettings -> getSpecificGasConstant ( ) , tabulatedAtmosphereSettings -> getRatioOfSpecificHeats ( ) , tabulatedAtmosphereSettings -> getBoundaryHandling ( ) , tabulatedAtmosphereSettings -> getDefaultExtrapolationValue ( ) ) ; } break ; } #if USE_NRLMSISE00 case nrlmsise00 : { std :: string spaceWeatherFilePath ; std :: shared_ptr < NRLMSISE00AtmosphereSettings > nrlmsise00AtmosphereSettings = std :: dynamic_pointer_cast < NRLMSISE00AtmosphereSettings > ( atmosphereSettings ) ; if ( nrlmsise00AtmosphereSettings == nullptr ) { spaceWeatherFilePath = input_output :: getSpaceWeatherDataPath ( ) + " " ; } else { spaceWeatherFilePath = nrlmsise00AtmosphereSettings -> getSpaceWeatherFile ( ) ; } tudat :: input_output :: solar_activity :: SolarActivityDataMap solarActivityData = tudat :: input_output :: solar_activity :: readSolarActivityData ( spaceWeatherFilePath ) ; std :: function < tudat :: aerodynamics :: NRLMSISE00Input ( double , double , double , double ) > inputFunction = std :: bind ( & tudat :: aerodynamics :: nrlmsiseInputFunction , std :: placeholders :: _1 , std :: placeholders :: _2 , std :: placeholders :: _3 , std :: placeholders :: _4 , solarActivityData , false , TUDAT_NAN ) ; atmosphereModel = std :: make_shared < aerodynamics :: NRLMSISE00Atmosphere > ( inputFunction ) ; break ; } #endif default : throw std :: runtime_error ( " " + std :: to_string ( atmosphereSettings -> getAtmosphereType ( ) ) ) ; } if ( atmosphereSettings -> getWindSettings ( ) != nullptr ) { atmosphereModel -> setWindModel ( createWindModel ( atmosphereSettings -> getWindSettings ( ) , body ) ) ; } return atmosphereModel ; }
Function to create an atmosphere model.
Function to create an atmosphere model .
// Declare return object. // Check which type of atmosphere model is to be created. // Check whether settings for atmosphere are consistent with its type. // Create and initialize exponential atmosphere model. // Check whether settings for atmosphere are consistent with its type. // Create and initialize exponential atmosphere model. // Check whether settings for atmosphere are consistent with its type // Create and initialize tabulated atmosphere model. // Use default space weather file stored in tudatBundle. // Use space weather file specified by user. // Create atmosphere model using NRLMISE00 input function