Skip to content

Commit

Permalink
Modified torque name
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicDirkx committed Apr 19, 2024
1 parent b0ac008 commit cbe7b1d
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class RadiationPressureAcceleration: public basic_astrodynamics::AccelerationMod
return targetPositionFunction_;
}

std::function<Eigen::Quaterniond()> getTargetRotationFromLocalToGlobalFrameFunction( )
{
return targetRotationFromLocalToGlobalFrameFunction_;
}


double getCurrentRadiationPressure( )
{
return currentRadiationPressure_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class CannonballRadiationPressureTargetModel : public RadiationPressureTargetMod
area_(area), coefficientFunction_( nullptr ),
currentCoefficient_(coefficient)
{
this->currentRadiationPressureTorque_ = Eigen::Vector3d::Zero( );
}

CannonballRadiationPressureTargetModel(
Expand All @@ -153,7 +152,6 @@ class CannonballRadiationPressureTargetModel : public RadiationPressureTargetMod
area_(area), coefficientFunction_( coefficientFunction),
currentCoefficient_( TUDAT_NAN )
{
this->currentRadiationPressureTorque_ = Eigen::Vector3d::Zero( );
}

void enableTorqueComputation(
Expand Down
31 changes: 23 additions & 8 deletions include/tudat/astro/electromagnetism/radiationPressureTorque.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,40 @@ namespace electromagnetism
{

/*!
* Class modeling radiation pressure torque. Radiation pressure accelerates a target due to electromagnetic
* Class modeling radiation pressure torque. Radiation pressure torque a target due to electromagnetic
* radiation from a source.
*/
class RadiationPressureTorque: public basic_astrodynamics::TorqueModel
class IsotropicPointSourceRadiationPressureTorque: public basic_astrodynamics::TorqueModel
{
public:

RadiationPressureTorque(
const std::shared_ptr< RadiationPressureAcceleration > radiationPressureAcceleration,
IsotropicPointSourceRadiationPressureTorque(
const std::shared_ptr< IsotropicPointSourceRadiationPressureAcceleration > radiationPressureAcceleration,
const std::function< Eigen::Vector3d( ) > centerOfMassFunction ):
radiationPressureAcceleration_( radiationPressureAcceleration ),
centerOfMassFunction_( centerOfMassFunction )
{
radiationPressureAcceleration_->getTargetModel( )->enableTorqueComputation( centerOfMassFunction );
}

~RadiationPressureTorque( ){ }
~IsotropicPointSourceRadiationPressureTorque( ){ }

/*!
* Update class members.
*
* @param currentTime Current simulation time
*/
void updateMembers(double currentTime) override;
void updateMembers(double currentTime) override
{
radiationPressureAcceleration_->updateMembers( currentTime );
currentTorque_ = radiationPressureAcceleration_->getTargetModel( )->getCurrentRadiationPressureTorque( );
if( !radiationPressureAcceleration_->getTargetModel( )->forceFunctionRequiresLocalFrameInputs( ) )
{
currentTorque_ = radiationPressureAcceleration_->getTargetRotationFromLocalToGlobalFrameFunction( )( ).inverse( ) * currentTorque_;
}
}

void resetAccelerationModel( const std::shared_ptr< RadiationPressureAcceleration > radiationPressureAcceleration )
void resetAccelerationModel( const std::shared_ptr< IsotropicPointSourceRadiationPressureAcceleration > radiationPressureAcceleration )
{
radiationPressureAcceleration_ = radiationPressureAcceleration;
}
Expand All @@ -62,9 +70,16 @@ class RadiationPressureTorque: public basic_astrodynamics::TorqueModel
return currentTorque_;
}


virtual void resetCurrentTime( ) override
{
currentTime_ = TUDAT_NAN;
radiationPressureAcceleration_->resetCurrentTime( );
}

protected:

std::shared_ptr< RadiationPressureAcceleration > radiationPressureAcceleration_;
std::shared_ptr< IsotropicPointSourceRadiationPressureAcceleration > radiationPressureAcceleration_;

const std::function< Eigen::Vector3d( ) > centerOfMassFunction_;

Expand Down
2 changes: 1 addition & 1 deletion include/tudat/math/integrators/stepSizeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class PerBlockIntegratorStepSizeController: public IntegratorStepSizeController<
if( maximumColumn > state.cols( ) )
{
throw std::runtime_error( "Error when setting per-segment step-size control, block to check is out of bounds. Number of columns is " +
std::to_string( state.cols( ) ) + ", but control is requested on column segment" +
std::to_string( state.cols( ) ) + ", but control is requested on column segment " +
std::to_string( std::get< 1 >( blocksToCheck_.at( i ) ) ) + ", " +
std::to_string( std::get< 3 >( blocksToCheck_.at( i ) ) ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ bool checkMultiArcPropagatorSettingsAndParameterEstimationConsistency(
ArcWiseInitialTranslationalStateParameter< StateScalarType > >(
parameterIterator->second )->getArcStartTimes( );

//<<<<<<< HEAD
// Check that each arc has at least one body whose state is to be estimated.
for ( unsigned int i = 0 ; i < parameterArcStartTimes.size( ) ; i++ )
{
Expand All @@ -526,21 +525,6 @@ bool checkMultiArcPropagatorSettingsAndParameterEstimationConsistency(
{
if( std::fabs( arcStartTimes.at( j ) - parameterArcStartTimes.at( i ) ) <
std::max( 4.0 * parameterArcStartTimes.at( i ) * std::numeric_limits< double >::epsilon( ), 1.0E-12 ) )
//=======
// // Check if arc times are (almost) exactly the same
// if( propagatorSettings->getSingleArcSettings( ).size( ) != parameterArcStartTimes.size( ) )
// {
// isInputConsistent = false;
// throw std::runtime_error( "Error, arc times for " + parameterIterator->first + " have incompatible size with estimation" );
// }
// else
// {
// for( unsigned int i = 0; i < propagatorSettings->getSingleArcSettings( ).size( ); i++ )
// {
// if( std::fabs( propagatorSettings->getSingleArcSettings( ).at( i )->getInitialTime( ) - parameterArcStartTimes.at( i ) ) >
// std::max( 4.0 * parameterArcStartTimes.at( i ) * std::numeric_limits< double >::epsilon( ), 1.0E-12 ) )
//>>>>>>> feature/consistent_propagation_settings

{
detectedArc = true;
indexDetectedArc = j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ std::shared_ptr< gravitation::SphericalHarmonicGravitationalTorqueModel > create
const std::string& nameOfBodyUndergoingTorque,
const std::string& nameOfBodyExertingTorque );

std::shared_ptr< electromagnetism::RadiationPressureTorque > createRadiationPressureTorqueModel(
std::shared_ptr< electromagnetism::IsotropicPointSourceRadiationPressureTorque > createRadiationPressureTorqueModel(
const std::shared_ptr< simulation_setup::Body > bodyUndergoingTorque,
const std::shared_ptr< simulation_setup::Body > bodyExertingTorque,
const std::shared_ptr< TorqueSettings > torqueSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/astro/basic_astro/torqueModelTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AvailableTorque getTorqueModelType(
{
torqueType = spherical_harmonic_gravitational_torque;
}
else if( std::dynamic_pointer_cast< electromagnetism::RadiationPressureTorque >( torqueModel ) != nullptr )
else if( std::dynamic_pointer_cast< electromagnetism::IsotropicPointSourceRadiationPressureTorque >( torqueModel ) != nullptr )
{
torqueType = radiation_pressure_torque;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void IsotropicPointSourceRadiationPressureAcceleration::computeAcceleration()
else
{

if ( targetModel_->forceFunctionRequiresLocalFrameInputs( ))
if ( targetModel_->forceFunctionRequiresLocalFrameInputs( ) )
{
targetRotationFromLocalToGlobalFrame_ = targetRotationFromLocalToGlobalFrameFunction_( );
targetRotationFromGlobalToLocalFrame_ = targetRotationFromLocalToGlobalFrame_.inverse( );
Expand Down
4 changes: 4 additions & 0 deletions src/astro/electromagnetism/radiationPressureTargetModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ void CannonballRadiationPressureTargetModel::updateRadiationPressureForcing(
// From Montenbruck (2000), Sec. 3.4
radiationPressure_ = sourceIrradiance / physical_constants::SPEED_OF_LIGHT;
this->currentRadiationPressureForce_ = currentCoefficient_ * area_ * radiationPressure_ * sourceToTargetDirection;
if( computeTorques_ )
{
this->currentRadiationPressureTorque_ = -centerOfMassFunction_( ).cross( this->currentRadiationPressureForce_ );
}
}

void PaneledRadiationPressureTargetModel::updateRadiationPressureForcing(
Expand Down
13 changes: 9 additions & 4 deletions src/simulation/propagation_setup/createTorqueModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ std::shared_ptr< gravitation::SphericalHarmonicGravitationalTorqueModel > create


//! Function to create a spherical harmonic gravitational torque
std::shared_ptr< electromagnetism::RadiationPressureTorque > createRadiationPressureTorqueModel(
std::shared_ptr< electromagnetism::IsotropicPointSourceRadiationPressureTorque > createRadiationPressureTorqueModel(
const std::shared_ptr< simulation_setup::Body > bodyUndergoingTorque,
const std::shared_ptr< simulation_setup::Body > bodyExertingTorque,
const std::shared_ptr< TorqueSettings > torqueSettings,
Expand All @@ -197,12 +197,17 @@ std::shared_ptr< electromagnetism::RadiationPressureTorque > createRadiationPres
std::shared_ptr< AccelerationSettings > sphericalHarmonicAccelerationSettings =
std::make_shared< AccelerationSettings >( basic_astrodynamics::radiation_pressure );

std::shared_ptr< electromagnetism::RadiationPressureAcceleration > radiationPressureAcceleration =
std::dynamic_pointer_cast< electromagnetism::RadiationPressureAcceleration >(
std::shared_ptr< electromagnetism::IsotropicPointSourceRadiationPressureAcceleration > radiationPressureAcceleration =
std::dynamic_pointer_cast< electromagnetism::IsotropicPointSourceRadiationPressureAcceleration >(
createRadiationPressureAccelerationModel(
bodyExertingTorque, bodyUndergoingTorque, nameOfBodyExertingTorque, nameOfBodyUndergoingTorque,
bodies ) );

if( radiationPressureAcceleration == nullptr )
{
throw std::runtime_error( "Error when creating radiation pressure torque, only isotropic source is supported" );
}

std::function< Eigen::Vector3d( ) > centerOfMassFunction = nullptr;
std::shared_ptr< RigidBodyProperties > massProperties = bodyUndergoingTorque->getMassProperties( );
if( massProperties == nullptr )
Expand All @@ -214,7 +219,7 @@ std::shared_ptr< electromagnetism::RadiationPressureTorque > createRadiationPres
centerOfMassFunction = std::bind( &RigidBodyProperties::getCurrentCenterOfMass, massProperties );
}

return std::make_shared< electromagnetism::RadiationPressureTorque >(
return std::make_shared< electromagnetism::IsotropicPointSourceRadiationPressureTorque >(
radiationPressureAcceleration, centerOfMassFunction );
}

Expand Down
8 changes: 4 additions & 4 deletions tests/src/astro/aerodynamics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ TUDAT_ADD_TEST_CASE(AerodynamicCoefficientsFromFile
${Tudat_PROPAGATION_LIBRARIES}
)

TUDAT_ADD_TEST_CASE(RarefieldFlowGenerator
PRIVATE_LINKS
${Tudat_PROPAGATION_LIBRARIES}
)
#TUDAT_ADD_TEST_CASE(RarefieldFlowGenerator
# PRIVATE_LINKS
# ${Tudat_PROPAGATION_LIBRARIES}
#)

TUDAT_ADD_TEST_CASE(WindModel
PRIVATE_LINKS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ BOOST_AUTO_TEST_CASE( testRadiationPressureTargetModel_EquivalentSphere )
for( unsigned int i = 0; i < 3; i++ )
{
BOOST_CHECK_SMALL( std::fabs( paneledTorque( i ) - expectedPaneledTorque( i ) ), 1.0E-4 * paneledForce.norm( ) );
BOOST_CHECK_SMALL( std::fabs( cannonballTorque( i ) - expectedPaneledTorque( i ) ), 1.0E-4 * paneledForce.norm( ) );
}
}

Expand Down

0 comments on commit cbe7b1d

Please sign in to comment.