Tudat / tudatBundle

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
http://tudat.tudelft.nl
BSD 3-Clause "New" or "Revised" License
11 stars 113 forks source link

Implementation of Thrust and Mass Propagation #33

Closed carlosbislip closed 5 years ago

carlosbislip commented 5 years ago

The following error is produced when using FromFunctionThrustMagnitudeSettings and propagating mass through MultiTypePropagatorSettings.

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Error when making environment model update settings, could not find ephemeris of body Vehicle

If mass propagation if obviated, effectively passing only TranslationalStatePropagatorSettings , I am able to identify an additional issue through the declaration of various dependent variables.

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Error when getting acceleration between bodies, no translational dynamics models by acting on Vehicle are found Abort trap: 6

I traversed through the code and added some terminal printouts in various places in order to compare the problematic items.

spherical_harmonic_gravity acceleration:
nameOfBodyUndergoingAcceleration: Vehicle nameOfBodyExertingAcceleration: Earth aerodynamic acceleration:
nameOfBodyUndergoingAcceleration: Vehicle nameOfBodyExertingAcceleration: Earth thrust acceleration:
nameOfBodyUndergoingAcceleration: Vehicle bodyUndergoingAcceleration: Vehicle accelerationsForBody: Earth : 0x7fcb67c270a8 mach_number_dependent_variable bodyWithProperty: Vehicle > secondaryBody: <---------------- altitude_dependent_variable bodyWithProperty: Vehicle secondaryBody: Earth single_acceleration_norm_dependentvariable accelerationDependentVariableSettings->associatedBody: Vehicle accelerationDependentVariableSettings->secondaryBody_: Earth accelerationModelList.count( bodyUndergoingAcceleration ): 1 bodyUndergoingAcceleration: Vehicle bodyExertingAcceleration: Earth airspeed_dependent_variable bodyWithProperty: Vehicle > secondaryBody: <---------------- total_aerodynamic_g_load_variable bodyWithProperty: Vehicle > secondaryBody: <---------------- single_acceleration_dependentvariable accelerationDependentVariableSettings->associatedBody: Vehicle > accelerationDependentVariableSettings->secondaryBody_:
accelerationModelList.count( bodyUndergoingAcceleration ): 1 bodyUndergoingAcceleration: Vehicle > bodyExertingAcceleration: <----------------

You will see that various items are empty. For instance, the secondaryBody of both _mach_number_dependentvariable and _airspeed_dependentvariable. I am ignorant as to if this is by design within the code. However, I am certain that the accelerations all have to have a body that exerts an acceleration, field for which is empty.

My issues, however, could be due to improper settings. Especially due to the recent TUDAT updates.

EDIT #1: Per Dominic's comment, link to repository that generates this error: HERE

DominicDirkx commented 5 years ago

Hi Carlos,

Could you add a link to the Github repo with the code you are using to generate this?

carlosbislip commented 5 years ago

Hi Carlos,

Could you add a link to the Github repo with the code you are using to generate this?

Done! Added as edit #1. Thanks!

DominicDirkx commented 5 years ago

Hi Carlos,

Try removing all accelerations from your list of dependent variables, and run again. I know you want to save them, but this will help to track down the problem,

Dominic

carlosbislip commented 5 years ago

Followed your suggestion. Trying to propagate mass yields the following:

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Error when making environment model update settings, could not find ephemeris of body Vehicle Abort trap: 6

Without mass propagation, the simulation runs to completion. Similar to before, it seems as thrust does not occur.

DominicDirkx commented 5 years ago

Im not sure why you reach the conclusion that there is no thrust. I think the error is caused by the fact that the total_aerodynamic_g_load_variable dependnet variable does not have a secondary body, see:

http://tudat.tudelft.nl/tutorials/tudatFeatures/propagationSetup/propagatorSettingsDependentVariables.html?highlight=total_aerodynamic_g_load_variable#setting-up-dependent-variables

carlosbislip commented 5 years ago

Absolutely right! My thrust issue was elsewhere. However, I am still unable to propagate mass.

DominicDirkx commented 5 years ago

Thr problem with the mass propagation can be solved (-ish), by turning the throw.... of this error into a std::cerr (printing the error, but not terminating the program). Alternatively, it should also work if you use:

    bodyMap[ "Spaceplane" ]->setEphemeris(
                std::make_shared< ephemerides::TabulatedCartesianEphemeris< > >(
                    std::shared_ptr< interpolators::OneDimensionalInterpolator< double, Eigen::Vector6d  > >( ),   "Earth" ) );

What I think is going on is the following:

Either one of the fixes I give above should work. Let me know if it works out,

Best,

Dominic

carlosbislip commented 5 years ago

I implemented the code snippet you provided. I placed it AFTER setting the global frame.

setGlobalFrameBodyEphemerides( bodyMap, "SSB", "J2000" );

Mass is propagated and I can print out the mass-rate dependent variable.

Thanks!

DominicDirkx commented 5 years ago

Great!

For the record, I think I fixed the problem in a 'proper' way, see:

https://github.com/DominicDirkx/tudat/commit/120ad3fcf8e6ce322e2f7e4eda1c65e1cbf4861f

However, I'd suggest leaving well enough alone, and just using the code you have now :)