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

Mass propagation #49

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
50f6b7d
With personal code (unit tests not yet compiling/running)
DominicDirkx Mar 27, 2016
c9d90b5
Synced with master
DominicDirkx Apr 7, 2016
204c909
Variational equations unit test compiling, running and passing
DominicDirkx Apr 7, 2016
9700ab2
Unit test for acceleration partials compiling, running and passing
DominicDirkx Apr 7, 2016
297fde4
Updated error messages
DominicDirkx Apr 8, 2016
5a07eac
Synced with SimulationSetup;Propagators branches
DominicDirkx Apr 8, 2016
ccbff85
Going to make some optimization modifications
DominicDirkx Apr 8, 2016
398f072
Minor efficiency updates
DominicDirkx Apr 9, 2016
a21e8bc
Going to change state partials output to Eigen::Block
DominicDirkx Apr 9, 2016
f638993
State partial computation time reduced
DominicDirkx Apr 9, 2016
9c96560
Intermediate commit
DominicDirkx Apr 9, 2016
effd235
Some mroe performance updates
DominicDirkx Apr 9, 2016
178a610
Broke unit tests
DominicDirkx Apr 9, 2016
d77a2a3
Fixed error
DominicDirkx Apr 9, 2016
b0f1f05
Some minor modifications
DominicDirkx Apr 10, 2016
ba7d241
With modified LegendreCache stuff from personal code
DominicDirkx Apr 11, 2016
7d97b96
Merged with branch LegendreCalculationUpdate
DominicDirkx Apr 11, 2016
dea8512
With some optimizations of spherical harmonics computations
DominicDirkx Apr 11, 2016
637a209
With some optimizations of spherical harmonics computations
DominicDirkx Apr 11, 2016
ca4d2b1
Modularized caches for spherical harmonics
DominicDirkx Apr 11, 2016
6a311b8
Merged with update to LegendreCalculationUpdate
DominicDirkx Apr 11, 2016
864c47f
No longer using raw pointers for Legendre/SphericalHarmonicsCache
DominicDirkx Apr 11, 2016
715de84
Removed raw pointers to Caches
DominicDirkx Apr 11, 2016
6a46c58
Reorganization of code complete (comments are not)
DominicDirkx Apr 11, 2016
e3927ba
Reorganization of code complete (comments are not)
DominicDirkx Apr 12, 2016
ab5eace
Reorganization of code complete (comments are not)
DominicDirkx Apr 12, 2016
865b177
With comments
DominicDirkx May 12, 2016
f06eab4
With finalized comments
DominicDirkx May 13, 2016
c371473
With extended unit tests
DominicDirkx May 17, 2016
98e285a
Now consistent with Legendre polynomial/SH update
DominicDirkx May 17, 2016
3707860
With additional comments
DominicDirkx May 18, 2016
fe000d5
With first version
DominicDirkx May 18, 2016
bf63774
With added comments
DominicDirkx May 19, 2016
1b2fd28
Removing erroneuously added modifications (wrong branch)
DominicDirkx May 20, 2016
9dfb4db
Minor bug/comment fix
DominicDirkx May 26, 2016
ecdcb7e
Updated to new master
DominicDirkx Jun 1, 2016
00c3e1c
Removed conflict comments
DominicDirkx Jun 1, 2016
04cb154
Removed deprecated files
DominicDirkx Jun 1, 2016
817e280
Merge branch 'master' into AccelerationModifications
DominicDirkx Jun 6, 2016
a059a6f
Added some missing comments
DominicDirkx Jun 6, 2016
cd59351
With basic architecture for body mass propagation, and corrections fo…
DominicDirkx Jun 6, 2016
1255e74
Added unit tests for body mass propagation (with simple mass rate law)
DominicDirkx Jun 6, 2016
ff87e53
Updated to master
DominicDirkx Jun 6, 2016
84f1f2e
Added comments to most new code for mass propagation
DominicDirkx Jun 6, 2016
08eae0c
Added unit test for multitype propagation, and fixed small associated…
DominicDirkx Jun 8, 2016
1e7bcda
Updated error handling in Propagators (no more cerr for errors)
DominicDirkx Jun 10, 2016
ccb4b91
Update setNumericallyIntegratedStates.h
DominicDirkx Jun 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tudat/Astrodynamics/Aerodynamics/aerodynamicAcceleration.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class AerodynamicAcceleration : public basic_astrodynamics::AccelerationModel< E
return computeAerodynamicAcceleration(
0.5 * currentDensity_ * currentAirspeed_ * currentAirspeed_,
currentReferenceArea_, currentForceCoefficients_, currentMass_ );

}

//! Update member variables used by the aerodynamic acceleration model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#ifndef TUDAT_AERODYNAMIC_COEFFICIENT_INTERFACE_H
#define TUDAT_AERODYNAMIC_COEFFICIENT_INTERFACE_H

#include <iostream>
#include <stdexcept>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions Tudat/Astrodynamics/BasicAstrodynamics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ set(BASICASTRODYNAMICS_HEADERS
"${SRCROOT}${BASICASTRODYNAMICSDIR}/bodyShapeModel.h"
"${SRCROOT}${BASICASTRODYNAMICSDIR}/oblateSpheroidBodyShapeModel.h"
"${SRCROOT}${BASICASTRODYNAMICSDIR}/sphericalBodyShapeModel.h"
"${SRCROOT}${BASICASTRODYNAMICSDIR}/massRateModel.h"
"${SRCROOT}${BASICASTRODYNAMICSDIR}/unifiedStateModelElementConversions.h"
)

Expand Down
18 changes: 13 additions & 5 deletions Tudat/Astrodynamics/BasicAstrodynamics/accelerationModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define TUDAT_ACCELERATION_MODEL_H

#include <map>
#include <vector>
#include <unordered_map>

#include <boost/shared_ptr.hpp>

Expand Down Expand Up @@ -103,13 +103,19 @@ class AccelerationModel
*/
virtual void updateMembers( const double currentTime = TUDAT_NAN ) = 0;

//! Function to reset the current time
/*!
* Function to reset the current time of the acceleration model.
* \param currentTime Current time (default NaN).
*/
virtual void resetTime( const double currentTime = TUDAT_NAN )
{
currentTime_ = currentTime;
}

protected:

//! Previous time to which acceleration model was updated.
double currentTime_;

protected:
Expand Down Expand Up @@ -137,29 +143,31 @@ typedef boost::shared_ptr< AccelerationModel2d > AccelerationModel2dPointer;
* \tparam AccelerationDataType Data type used to represent accelerations
* (default=Eigen::Vector3d).
* \param accelerationModel Acceleration model that is to be evaluated.
* \param currentTime Time at which acceleration model is to be updated.
* \return Acceleration that is obtained following the member update.
*/
template < typename AccelerationDataType >
AccelerationDataType updateAndGetAcceleration(
boost::shared_ptr< AccelerationModel< AccelerationDataType > > accelerationModel )
const boost::shared_ptr< AccelerationModel< AccelerationDataType > > accelerationModel,
const double currentTime = TUDAT_NAN )
{
// Update members.
accelerationModel->updateMembers( );
accelerationModel->updateMembers( currentTime );

// Evaluate and return acceleration.
return accelerationModel->getAcceleration( );
}

//! Typedef defining a list of accelerations acting on a single body, key is the name of each
//! body exerting a acceletation, value is a list of accelerations exerted by that body.
typedef std::map< std::string, std::vector<
typedef std::unordered_map< std::string, std::vector<
boost::shared_ptr< basic_astrodynamics::AccelerationModel< Eigen::Vector3d > > > >
SingleBodyAccelerationMap;

//! Typedef defining a list of accelerations acting on a set of bodies, key is the name of each
//! body undergoing a acceletation, value is SingleBodyAccelerationMap, defining all accelerations
//! acting on it.
typedef std::map< std::string, SingleBodyAccelerationMap > AccelerationMap;
typedef std::unordered_map< std::string, SingleBodyAccelerationMap > AccelerationMap;

} // namespace basic_astrodynamics
} // namespace tudat
Expand Down
21 changes: 21 additions & 0 deletions Tudat/Astrodynamics/BasicAstrodynamics/accelerationModelTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ AvailableAcceleration getAccelerationModelType(

}

//! Function to identify the type of a mass rate model.
AvailableMassRateModels getMassRateModelType(
const boost::shared_ptr< MassRateModel > massRateModel )
{
// Nominal type is undefined
AvailableMassRateModels massRateType = undefined_mass_rate_model;

// Check for each mass rate mdoel type implemented as AvailableMassRateModels.
if( boost::dynamic_pointer_cast< basic_astrodynamics::CustomMassRateModel >(
massRateModel ) != NULL )
{
massRateType = custom;
}
else
{
throw std::runtime_error(
"Error, mass rate model not identified when getting mass rate model type." );
}
return massRateType;
}


} // namespace basic_astrodynamics

Expand Down
22 changes: 22 additions & 0 deletions Tudat/Astrodynamics/BasicAstrodynamics/accelerationModelTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Tudat/Astrodynamics/Gravitation/sphericalHarmonicsGravityModel.h"
#include "Tudat/Astrodynamics/Gravitation/thirdBodyPerturbation.h"
#include "Tudat/Astrodynamics/Aerodynamics/aerodynamicAcceleration.h"
#include "Tudat/Astrodynamics/BasicAstrodynamics/massRateModel.h"


namespace tudat
Expand All @@ -65,6 +66,17 @@ enum AvailableAcceleration
third_body_spherical_harmonic_gravity
};

//! List of model types for body mass rates.
/*!
* List of model types for body mass rates available in simulations. Mass rate models not defined by this
* given enum cannot be used for automatic mass rate model setup.
*/
enum AvailableMassRateModels
{
undefined_mass_rate_model,
custom
};

//! Function to identify the derived class type of an acceleration model.
/*!
* Function to identify the derived class type of an acceleration model. The type must be defined
Expand All @@ -76,6 +88,16 @@ AvailableAcceleration getAccelerationModelType(
const boost::shared_ptr< basic_astrodynamics::AccelerationModel< Eigen::Vector3d > >
accelerationModel );

//! Function to identify the type of a mass rate model.
/*!
* Function to identify the type of a mass rate model. The type must be defined
* in the AvailableMassRateModels enum to be recognized by this function.
* \param massRateModel Mass rate model of which the type is to be identified.
* \return Type of the massRateModel, as identified by AvailableMassRateModels enum.
*/
AvailableMassRateModels getMassRateModelType(
const boost::shared_ptr< MassRateModel > massRateModel );


} // namespace basic_astrodynamics

Expand Down
136 changes: 136 additions & 0 deletions Tudat/Astrodynamics/BasicAstrodynamics/massRateModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/* Copyright (c) 2010-2016, Delft University of Technology
* All rigths reserved
*
* This file is part of the Tudat. Redistribution and use in source and
* binary forms, with or without modification, are permitted exclusively
* under the terms of the Modified BSD license. You should have received
* a copy of the license with this file. If not, please or visit:
* http://tudat.tudelft.nl/LICENSE.
*/

#ifndef TUDAT_MASSRATEMODEL_H
#define TUDAT_MASSRATEMODEL_H

#include <map>
#include <vector>
#include <iostream>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>

#include <Eigen/Core>

#include "Tudat/Mathematics/BasicMathematics/mathematicalConstants.h"

namespace tudat
{
namespace basic_astrodynamics
{

//! Base class for determining the rate of change of a body's mass, to be used in numerical integration.
/*!
* Base class for determining the rate of change of a body's mass, to be used in numerical integration. Specific types
* of mass rate models are to be implemented in derived classes
*/
class MassRateModel
{
public:

//! Constructor
MassRateModel( ):
currentTime_( TUDAT_NAN ), currentMassRate_( TUDAT_NAN ){ }

//! Destructor
virtual ~MassRateModel( ) { }

//! Function to retrieve current mass rate
/*!
* Function to retrieve current mass rate, as set by last call to updateMembers (implemented in derived class)
* \return Current mass rate
*/
virtual double getMassRate( )
{
return currentMassRate_;
}

//! Update member variables used by the mass rate model, and internally compute mass rate.
/*!
* Updates member variables used by the mass rate model, and internally compute mass rate. In the case of mass rate
* models containing varying parameters, function-pointers returning such a parameter (for instance
* the Cartesian state of a body) will be set as a member variable.
* This function evaluates such function-pointers and updates member variables to the 'current'
* values of these parameters. Only these current values, not the function-pointers are then
* used for the actual computation function.
* \param currentTime Time at which acceleration model is to be updated.
*/
virtual void updateMembers( const double currentTime = TUDAT_NAN ) = 0;

//! Function to reset the current time
/*!
* Function to reset the current time of the acceleration model.
* \param currentTime Current time (default NaN).
*/
virtual void resetTime( const double currentTime = TUDAT_NAN )
{
currentTime_ = currentTime;
}

protected:

//! Previous time to which mass rate model was updated.
double currentTime_;

//! Current mass rate, as set by last call to updateMembers (implemented in derived class)
double currentMassRate_;

private:
};

//! Derived class for determining the rate of change of a body's mass, user-defined by a function pointer.
/*!
* Derived class for determining the rate of change of a body's mass, user-defined by a function pointer.
* This class can be used for any kind of mass rate model for which the user can define the dependency as a function
* of time.
*/
class CustomMassRateModel: public MassRateModel
{
public:

//! Constructor.
/*!
* Constructor
* \param massRateFunction Function returning mass rate as a function of time.
*/
CustomMassRateModel(
const boost::function< double( const double ) > massRateFunction ):
massRateFunction_( massRateFunction ){ }

//! Destructor.
~CustomMassRateModel( ){ }

//! Update member variables used by the mass rate model and compute the mass rate
/*!
* Update member variables used by the mass rate model and compute the mass rate
* \param currentTime Time at which acceleration model is to be updated.
*/
void updateMembers( const double currentTime = TUDAT_NAN )
{
// Check if update is needed.
if( !( currentTime_ == currentTime ) )
{
currentMassRate_ = massRateFunction_( currentTime );
}
}

private:

//! Function returning mass rate as a function of time.
boost::function< double( const double ) > massRateFunction_;

};


} // namespace basic_astrodynamics

} // namespace tudat

#endif // TUDAT_MASSRATEMODEL_H
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,5 @@ Eigen::Vector3d computeCannonBallRadiationPressureAcceleration(
radiationPressure, vectorToSource, area, radiationPressureCoefficient ) / mass;
}

//! Get radiation pressure acceleration.
Eigen::Vector3d CannonBallRadiationPressureAcceleration::getAcceleration( )
{
return computeCannonBallRadiationPressureAcceleration(
currentRadiationPressure_, currentVectorToSource_, currentArea_,
currentRadiationPressureCoefficient_, currentMass_ );
}

//! Update member variables used by the radiation pressure acceleration model.
void CannonBallRadiationPressureAcceleration::updateMembers( const double currentTime )
{
if( !( this->currentTime_ == currentTime ) )
{
currentVectorToSource_ = ( sourcePositionFunction_( )
- acceleratedBodyPositionFunction_( ) ).normalized( );
currentRadiationPressure_ = radiationPressureFunction_( );
currentRadiationPressureCoefficient_ = radiationPressureCoefficientFunction_( );
currentArea_ = areaFunction_( );
currentMass_ = massFunction_( );
}
}

} // namespace electro_magnetism
} // namespace tudat
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ class CannonBallRadiationPressureAcceleration: public basic_astrodynamics::Accel
* \return Radiation pressure acceleration.
* \sa computeCannonBallRadiationPressureAcceleration().
*/
Eigen::Vector3d getAcceleration( );
Eigen::Vector3d getAcceleration( )
{
return computeCannonBallRadiationPressureAcceleration(
currentRadiationPressure_, currentVectorToSource_, currentArea_,
currentRadiationPressureCoefficient_, currentMass_ );
}

//! Update member variables used by the radiation pressure acceleration model.
/*!
Expand All @@ -181,7 +186,28 @@ class CannonBallRadiationPressureAcceleration: public basic_astrodynamics::Accel
* not the function-pointers are then used by the getAcceleration( ) function.
* \param currentTime Time at which acceleration model is to be updated.
*/
void updateMembers( const double currentTime = TUDAT_NAN );
void updateMembers( const double currentTime = TUDAT_NAN )
{
if( !( this->currentTime_ == currentTime ) )
{
currentVectorToSource_ = ( sourcePositionFunction_( )
- acceleratedBodyPositionFunction_( ) ).normalized( );
currentRadiationPressure_ = radiationPressureFunction_( );
currentRadiationPressureCoefficient_ = radiationPressureCoefficientFunction_( );
currentArea_ = areaFunction_( );
currentMass_ = massFunction_( );
}
}

//! Function to retrieve the function pointer returning mass of accelerated body.
/*!
* Function to retrieve the function pointer returning mass of accelerated body.
* \return Function pointer returning mass of accelerated body.
*/
boost::function< double( ) > getMassFunction( )
{
return massFunction_;
}

private:

Expand Down
10 changes: 10 additions & 0 deletions Tudat/Astrodynamics/ElectroMagnetism/radiationPressureInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ class RadiationPressureInterface{
return radiationPressureCoefficient_;
}

//! Function to reset the radiation pressure coefficient of the target body.
/*!
* Function to reset the radiation pressure coefficient of the target body.
* \param radiationPressureCoefficient The new radiation pressure coefficient of the target body.
*/
void resetRadiationPressureCoefficient( const double radiationPressureCoefficient )
{
radiationPressureCoefficient_ = radiationPressureCoefficient;
}

//! Function to return the function returning the current total power (in W) emitted by the
//! source body.
/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE( testCompositeEphemeris )
double buffer = 5.0 * maximumTimeStep;

// Create bodies needed in simulation
std::map< std::string, boost::shared_ptr< Body > > bodyMap = createBodies(
NamedBodyMap bodyMap = createBodies(
getDefaultBodySettings( bodyNames,initialEphemerisTime - buffer, finalEphemerisTime + buffer ) );
setGlobalFrameBodyEphemerides( bodyMap, "SSB", "ECLIPJ2000" );

Expand Down
Loading