Tudat / tudat

NOTE: This Tudat version is no longer supported. See https://docs.tudat.space/en/stable/ and https://github.com/tudat-team/tudat-bundle for the new version
BSD 3-Clause "New" or "Revised" License
87 stars 143 forks source link

Negative value for BEGIN address - Multiple Planets #658

Closed AlexBadauer closed 4 years ago

AlexBadauer commented 4 years ago

Hey everyone,

I'm working on an example of tudat, the "GalileoSimulator", but I get an error I need a hint to solve.

What I did:

I modified the example to account the accelerations of multiple planets.

  // Load Spice kernels.
    spice_interface::loadStandardSpiceKernels( );

    // Define body settings for simulation.
    unsigned int totalNumberOfBodies = 8;
    std::vector< std::string > bodiesToCreate;
    bodiesToCreate.resize( totalNumberOfBodies );

    bodiesToCreate[0] = "Earth";
    bodiesToCreate[1] = "Moon";
    bodiesToCreate[2] = "Mars";
    bodiesToCreate[3] = "Venus";
    bodiesToCreate[4] = "Mercury";
    bodiesToCreate[5] = "Sun";
    bodiesToCreate[6] = "Saturn";
    bodiesToCreate[7] = "Jupiter";

Added the use of DirectSpiceEphemeris

    std::string frameOrigin = "SSB";
std::string frameOrientation = "J2000";
std::string originalFrame = "J2000";
std::string targetFrame = "IAU_Earth";

bodySettings[ "Earth" ]->rotationModelSettings =std::make_shared< RotationModelSettings >( spice_rotation_model, originalFrame, targetFrame );

for( unsigned int i = 0; i < bodiesToCreate.size( ); i++ )  
    {
    bodySettings[ bodiesToCreate.at( i ) ]->ephemerisSettings = std::make_shared< DirectSpiceEphemerisSettings >( frameOrigin, frameOrientation );
    bodySettings[ bodiesToCreate.at( i ) ]->ephemerisSettings->resetFrameOrientation( "J2000" );
    bodySettings[ bodiesToCreate.at( i ) ]->rotationModelSettings->resetOriginalFrame( "J2000" );
    }

And increased the number and order of the spherical acceleration model

    std::map< std::string, std::vector< std::shared_ptr< AccelerationSettings > > > accelerationsOfCurrentSatellite;
    accelerationsOfCurrentSatellite[ "Earth" ].push_back(
                std::make_shared< SphericalHarmonicAccelerationSettings >( 300, 300 ) );

    accelerationsOfCurrentSatellite[ "Sun" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );
    accelerationsOfCurrentSatellite[ "Moon" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );
    accelerationsOfCurrentSatellite[ "Mars" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );
    accelerationsOfCurrentSatellite[ "Venus" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );
    accelerationsOfCurrentSatellite[ "Jupiter" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );
    accelerationsOfCurrentSatellite[ "Saturn" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );
    accelerationsOfCurrentSatellite[ "Mercury" ].push_back( std::make_shared< AccelerationSettings >( basic_astrodynamics::central_gravity ) );

The whole file is included in the following test2.zip

The Problem:

Everytime I try to run the simulation I get the following error message

================================================================================

Toolkit version: N0066

SPICE(DAFNEGADDR) --

Negative value for BEGIN address: -2147482983

A traceback follows.  The name of the highest level module is first.
spkezr_c --> SPKEZR --> SPKEZ --> SPKGEO --> SPKPVN --> SPKR02 --> DAFGDA

Oh, by the way:  The SPICELIB error handling actions are USER-TAILORABLE.  You
can choose whether the Toolkit aborts or continues when errors occur, which
error messages to output, and where to send the output.  Please read the ERROR
"Required Reading" file, or see the routines ERRACT, ERRDEV, and ERRPRT.

================================================================================

What I tried until now:

but

'convertdateStringToEphemerisTime' was not declared in this scope

What I would like to ask:

could someone please give me a hint

  1. why the spice error occurs?
  2. if there is a list what I have to import to use functions like convertdateStringToEphemerisTime or what I have to import specifically in this case?

Thank you for your time

Alex

DominicDirkx commented 4 years ago

Hi Alex,

The problem is that a 'NaN' value is occuring somewhere in your simulation, which results in Spice being queried at t=NaN, leading to this error.

The issue may be the degree 300 Earth gravity field you're using. I'm not sure the Earth gravity field in Tudat goes up to degree 300 (also, it is by no means a particularly accurate gravity field). But, I doubt very much that you need degree 300. You have a semi-major axis of 30000 km, so I'm pretty sure only the very low order terms will suffice.

Dominic

AlexBadauer commented 4 years ago

Hi Dominic,

thank you very much for your help!

Best Alex