tudat-team / tudatpy-examples

Collection of examples showcasing Tudatpy functionalities. They can be run on mybinder.org as well.
https://tudat-space.readthedocs.io/en/latest/
4 stars 17 forks source link

coupled_translational_rotational_dynamics error #29

Closed spacefan closed 1 week ago

spacefan commented 11 months ago

When i run coupled_translational_rotational_dynamics.ipynb in JupyterLab, everything works fine until Cell In[5]:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], line 12
     10 body_settings.get('Phobos').rotation_model_settings = environment_setup.rotation_model.synchronous('Mars', 'J2000', 'Phobos_body_fixed')
     11 body_settings.get('Phobos').gravity_field_settings = get_gravitational_field('Phobos_body_fixed')
---> 12 body_settings.get('Phobos').gravity_field_settings.scaled_mean_moment_of_inertia = 0.43
     14 # AND NOW WE CREATE THE BODIES OBJECT
     15 bodies = environment_setup.create_system_of_bodies(body_settings)

AttributeError: 'tudatpy.kernel.numerical_simulation.environment_setup.gravity_field.SphericalHarmonicsGravityFieldSe' object has no attribute 'scaled_mean_moment_of_inertia'

When I commented out the code that reported the error, Cell In[10] reported another error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[10], line 2
      1 # DYNAMICS SIMULATION
----> 2 simulator = numerical_simulation.create_dynamics_simulator(bodies, combined_propagator_settings)
      3 state_history = simulator.state_history
      4 dependent_variable_history = simulator.dependent_variable_history

RuntimeError: Error when creating rotational state derivative model, inverse inertia tensor of body Phoboscontains NaN. 

Why tudatpy.kernel.numerical_simulation.environment_setup.gravity_field.SphericalHarmonicsGravityFieldSe object has no attribute scaled_mean_moment_of_inertia here? Please help!

>>> dir(body_settings.get('Phobos').gravity_field_settings)

['__class__',
 '__delattr__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'associated_reference_frame',
 'create_time_dependent_field',
 'gravitational_parameter',
 'gravity_field_type',
 'normalized_cosine_coefficients',
 'normalized_sine_coefficients',
 'reference_radius']
DominicDirkx commented 11 months ago

You may need to use the dev version of the conda package to run this example (for now)

spacefan commented 11 months ago

You may need to use the dev version of the conda package to run this example (for now)

Thanks for your fast and kind replay!

I'm updated tudatpy to 0.7.3.dev26 now, but another error exits:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[11], line 67
     65 normal_mode = get_longitudinal_normal_mode_from_inertia_tensor(bodies.get('Phobos').inertia_tensor, mean_motion)
     66 librations = bring_inside_bounds(dependents_array[:,8:10], -PI, PI, 'upper')
---> 67 lon_lib_freq, lon_lib_amp = get_fourier(np.hstack((np.atleast_2d(dependents_array[:,0]).T, np.atleast_2d(librations[:,1]).T)), [2.0*PI, 1])
     68 lat_lib_freq, lat_lib_amp = get_fourier(np.hstack((np.atleast_2d(dependents_array[:,0]).T, np.atleast_2d(librations[:,0]).T)), [2.0*PI, 1])
     69 plt.figure()

Cell In[4], line 219, in get_fourier(time_history, clean_signal)
    217 if clean_signal[1] != 0:
    218     coeffs = polyfit(sample_times, signal, clean_signal[1])
--> 219     for idx in len(coeffs):
    220         current_coeff = coeffs[idx]
    221         exponent = idx

TypeError: 'int' object is not iterable
spacefan commented 11 months ago

Error corrected as fellows:

for idx in range(len(coeffs)):

But another... error exits:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[21], line 5
      3 dissipation_times = list(np.array([4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0])*3600.0)  # In seconds. Here, we
      4 #"""
----> 5 damping_results = numerical_simulation.propagation.get_zero_proper_mode_rotational_state(bodies,
      6                                                                                          combined_propagator_settings,
      7                                                                                          phobos_mean_rotational_rate,
      8                                                                                          dissipation_times)
      9 #"""
     11 """
     12 damping_results = numerical_simulation.propagation.get_damped_proper_mode_initial_rotational_state(bodies,
     13                                                                                                    combined_propagator_settings,
     14                                                                                                    phobos_mean_rotational_rate,
     15                                                                                                    dissipation_times)
     16 """

AttributeError: module 'tudatpy.kernel.numerical_simulation.propagation' has no attribute 'get_zero_proper_mode_rotational_state'
> dir(numerical_simulation.propagation)

['AccelerationModel',
 'AerodynamicGuidance',
 'ConstantThrustMagnitudeWrapper',
 'CustomThrustMagnitudeWrapper',
 'DependentVariablesInterface',
 'HybridArcSimulationResults',
 'HybridArcVariationalSimulationResults',
 'MassRateModel',
 'MultiArcSimulationResults',
 'MultiArcVariationalSimulationResults',
 'PropagationTerminationDetails',
 'PropagationTerminationDetailsFromHybridCondition',
 'PropagationTerminationReason',
 'RotationalProperModeDampingResults',
 'SimulationResults',
 'SingleArcSimulationResults',
 'SingleArcVariationalSimulationResults',
 'ThrustMagnitudeWrapper',
 'TorqueModel',
 '__doc__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 'combine_initial_states',
 'get_damped_proper_mode_initial_rotational_state',
 'get_generalized_acceleration_size',
 'get_initial_rotational_state_of_body',
 'get_initial_state_of_bodies',
 'get_initial_state_of_body',
 'get_single_integration_differential_equation_order',
 'get_single_integration_size',
 'get_state_of_bodies',
 'nan_or_inf_detected_in_state',
 'propagation_never_run',
 'runtime_error_caught_in_propagation',
 'termination_condition_reached',
 'unknown_reason']

Wrong version of tudat or tudatpy?

> conda list

tudat                     2.12.1.dev25         h4dc84c1_0    tudat-team/label/dev
tudat-resources           2.1                  h802ae32_2    tudat-team
tudatpy                   0.7.3.dev26     py310hed3ccf5_1    tudat-team/label/dev