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 142 forks source link

Can't retrieve ephemeris data for 20 years or more #535

Closed ViktorJordanov closed 5 years ago

ViktorJordanov commented 5 years ago

Hi Dominic,

I try to retrieve ephemeris data for long periods of time (20 years and longer) (to use it for accelerations during the propagation), and put it into bodysettings. I get the following error however:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

After not specifying the begin- and end-time in "getDefaultBodySettings", it returns a message that insufficient ephemeris data has been loaded in.

How could I solve this problem? Thank you in advance,

Viktor

DominicDirkx commented 5 years ago

Hi Viktor,

Could you please also post the full Spice output that you get? If I recall, the problem was with the state of Mars. To solve this, you have to load kernels for the Martian system:

https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/satellites/

For instance, mar097,

Best,

Dominic

ViktorJordanov commented 5 years ago

Hi Dominic,

This was the output from spice:

SPICE(SPKINSUFFDATA) --

Insufficient ephemeris data has been loaded to compute the state of 499 (MARS) relative to 0 (SOLAR SYSTEM BARYCENTER) at the ephemeris epoch 2024 DEC 31 18:00:00.000.

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

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.

ViktorJordanov commented 5 years ago

Hi Dominic,

I have tried loading in the mar097 file, but it still gives the same output from spice. This is the way that I have done it:

std::vector< std::string > additionalKernels;
std::string path = input_output::getSpiceKernelPath( );
additionalKernels.push_back( path + "de435.bsp" );
additionalKernels.push_back( path + "mar097.bsp" );
spice_interface::loadStandardSpiceKernels( additionalKernels );

std::cout <<"Test 1" << std::endl;

// Set simulation time settings.
/*const*/ double simulationStartEpoch = 15.0 * tudat::physical_constants::JULIAN_YEAR;
const double simulationEndEpoch = 50.0 * tudat::physical_constants::JULIAN_YEAR;

// Define body settings for simulation.
std::vector< std::string > bodiesToCreate;
bodiesToCreate.push_back( "Sun" );
bodiesToCreate.push_back( "Earth" );
bodiesToCreate.push_back( "Moon" );
bodiesToCreate.push_back( "Mars" );
bodiesToCreate.push_back( "Venus" );

std::cout <<"Test 2" << std::endl;

// Create body objects.
std::map< std::string, std::shared_ptr< BodySettings > > bodySettings =
        getDefaultBodySettings( bodiesToCreate);
NamedBodyMap bodyMap = createBodies( bodySettings );

If I do define the 2 time inputs at "getDefaultBodySettings", it works for short periods of time, but again gives the 'std::bad_alloc' error with 20 years and longer. How could I solve this, to be able to propagate for long periods of time?

Thank you, Viktor

DominicDirkx commented 5 years ago

Hi Viktor,

Under Windows, the order of loading Spice kernels can matter. Try swapping the mar and de ephemerides, and see what happens. If this doesn't solve it, you have a couple of options:

Dominic