propagation_setup.acceleration.cannonball_radiation_pressure_type,
            SC_NAMES[i], "Sun"))

acceleration_models = propagation_setup.create_acceleration_models(
    bodies, acceleration_settings, bodies_to_propagate, central_bodies)

# Propagator settings
propagator_settings = propagation_setup.propagator.translational(
    central_bodies,
    acceleration_models,
    bodies_to_propagate,
    initial_state,
    simulation_end_epoch,
    output_variables=dependent_variables_to_save)

# Integrator settings
fixed_step_size = 10.0  #seconds

integrator_settings = propagation_setup.integrator.runge_kutta_4(
    simulation_start_epoch, fixed_step_size)

# Create dynamics simulator
dynamics_simulator = propagation_setup.SingleArcDynamicsSimulator(
    bodies, integrator_settings, propagator_settings)

# Retrieve Results

np.savetxt('AOP_Optimisation_Results.dat',
           result2array(dynamics_simulator.dependent_variable_history))
np.savetxt('AOP_Optimisation_AOPValues.dat', RAAN)
propagator_settings = create_propagator_settings(
    "Section 1", initial_inertial_state, 370, combined_termination_settings)

### Run the first section ascent
"""
With everything being now setup, we can finally run the ascent simulation of the first rocket section (containing both the first and the second stage). This is done by calling the `SingleArcSimulator()` function.

The state and dependent variables history is then extracted from the dynamics simulator, and converted to multi-dimensional numpy arrays, using the `result2array()` from tudatpy utils. Do mind that using `result2array` will shift all elements by 1 column to the right, since a first column will be added, containing the apochs.
"""

# Run the numerical simulation of the first rocket section
dynamics_simulator = numerical_simulation.SingleArcSimulator(
    bodies, integrator_settings, propagator_settings)
# Extract the propagated states and dependent variables and convert them to numpy arrays
states = dynamics_simulator.state_history
states_array_section_1 = result2array(states)
dep_vars = dynamics_simulator.dependent_variable_history
dep_vars_array_section_1 = result2array(dep_vars)

### Save section 1 final state
"""
Because we now want to simulate the second section from our rocket, we need to save what was the last state from the first section. This way, we can start a new propagation, simulating the remaining ascent of the second section (being the second stage) only, starting from where the first section ended.
"""

final_state_section_1 = states_array_section_1[-1, 1:7]
final_epoch_section_1 = states_array_section_1[-1, 0]

## Second section simulation
"""
With the first section simulation finished, the resulting states and dependant variables saved as the `states_array_section_1` and `dep_vars_array_section_1` arrays, and the final first section state saved as `final_state_section_1`, we can now propagate our second rocket section.
예제 #3
0
This function requires the `bodies`, `integrator_settings`, and `propagator_settings` that have all been defined earlier.

After this, the history of the propagated state over time, containing both the position and velocity history, is extracted.
This history, taking the form of a dictionary, is then converted to an array containing 7 columns:
- Column 0: Time history, in seconds since J2000.
- Columns 1 to 3: Position history, in meters, in the frame that was specified in the `body_settings`.
- Columns 4 to 6: Velocity history, in meters per second, in the frame that was specified in the `body_settings`.
"""

# Create simulation object and propagate the dynamics
dynamics_simulator = numerical_simulation.SingleArcSimulator(
    bodies, integrator_settings, propagator_settings)

# Extract the resulting state history and convert it to an ndarray
states = dynamics_simulator.state_history
states_array = result2array(states)

## Post-process the propagation results
"""
The results of the propagation are then processed to a more user-friendly form.
"""

### Print initial and final states
"""
First, let's print the initial and final position and velocity vector of `Delfi-C3`.
"""

print(f"""
Single Earth-Orbiting Satellite Example.
The initial position vector of Delfi-C3 is [km]: \n{
    states[simulation_start_epoch][:3] / 1E3} 
예제 #4
0
파일: main.py 프로젝트: tudat-team/tudatpy
# Create propagation settings.
propagator_settings = propagation_setup.TranslationalStatePropagatorSettings(
    central_bodies, acceleration_models, bodies_to_propagate,
    system_initial_state, simulation_end_epoch)
# Create numerical integrator settings.
integrator_settings = propagation_setup.IntegratorSettings(
    propagation_setup.AvailableIntegrators.rk4, simulation_start_epoch,
    fixed_step_size)

################################################################################
# PROPAGATE ####################################################################
################################################################################

# Instantiate the dynamics simulator.
dynamics_simulator = propagation_setup.SingleArcDynamicsSimulator(
    body_system, integrator_settings, propagator_settings, True)

# Propagate and store results to outer loop results dictionary.
result = dynamics_simulator.get_equations_of_motion_numerical_solution()

################################################################################
# VISUALISATION / OUTPUT / PRELIMINARY ANALYSIS ################################
################################################################################

import matplotlib.pyplot as plt
from tudatpy.util import result2array

array = result2array(result)

print(array)
# Compute the deviation in state due to each variation
for epoch in state_transition_matrices:
    delta_initial_state_dict[epoch] = np.dot(state_transition_matrices[epoch],
                                             initial_state_variation)
    earth_standard_param_dict[epoch] = np.dot(sensitivity_matrices[epoch],
                                              earth_standard_param_variation)
    delta_drag_coeff_dict[epoch] = np.dot(sensitivity_matrices[epoch],
                                          drag_coeff_variation)

## Post-process the results
"""
First, extract the time, and deviation in position and velocity associated with the system response to each variation.
"""

# Convert the dictionaries to numpy ndarrays
delta_initial_state_array = result2array(delta_initial_state_dict)
delta_earth_standard_param_array = result2array(earth_standard_param_dict)
delta_drag_coefficient_array = result2array(delta_drag_coeff_dict)

# Extract the time, and convert it to hours
time = delta_initial_state_array[:, 0]
time_hours = time / 3600

# Compute the deviation in position and velocity associated with the variation in initial state
delta_r1 = np.linalg.norm(delta_initial_state_array[:, 1:4], axis=1)
delta_v1 = np.linalg.norm(delta_initial_state_array[:, 4:8], axis=1)

# Compute the deviation in position and velocity associated with the variation in Earth gravitational parameter
delta_r2 = np.linalg.norm(delta_earth_standard_param_array[:, 1:4], axis=1)
delta_v2 = np.linalg.norm(delta_earth_standard_param_array[:, 4:8], axis=1)
Do mind that converting to an ndarray using the `result2array()` utility will shift these indexes, since the first column (index 0) will then be the times.
"""

# Instantiate the dynamics simulator and run the simulation
dynamics_simulator = numerical_simulation.SingleArcSimulator(
    system_of_bodies,
    integrator_settings,
    propagator_settings,
    print_dependent_variable_data=True)

# Extract the state and dependent variable history
state_history = dynamics_simulator.state_history
dependent_variable_history = dynamics_simulator.dependent_variable_history

# Convert the dictionaries to multi-dimensional arrays
vehicle_array = result2array(state_history)
dep_var_array = result2array(dependent_variable_history)

### Get Moon state from SPICE
"""
The state of the Moon at the epochs at which the propagation was run is now extracted from the SPICE kernel.
"""

# Retrieve the Moon trajectory over vehicle propagation epochs from spice
moon_states_from_spice = {
    epoch: spice.get_body_cartesian_state_at_epoch("Moon", "Earth", "J2000",
                                                   "None", epoch)
    for epoch in list(state_history.keys())
}
# Convert the dictionary to a mutli-dimensional array
moon_array = result2array(moon_states_from_spice)
예제 #7
0
- Column 0: Time history, in seconds since J2000.
- Columns 1 to 3: Position history, in meters, in the frame that was specified in the `body_settings`.
- Columns 4 to 6: Velocity history, in meters per second, in the frame that was specified in the `body_settings`.

The same is done with the dependent variable history. The column indexes corresponding to a given dependent variable in the `dep_vars` variable are printed when the simulation is run, when `SingleArcSimulator()` is called.
Do mind that converting to an ndarray using the `result2array()` utility will shift these indexes, since the first column (index 0) will then be the times.
"""

# Create simulation object and propagate the dynamics
dynamics_simulator = numerical_simulation.SingleArcSimulator(
    bodies, integrator_settings, propagator_settings
)

# Extract the resulting state and depedent variable history and convert it to an ndarray
states = dynamics_simulator.state_history
states_array = result2array(states)
dep_vars = dynamics_simulator.dependent_variable_history
dep_vars_array = result2array(dep_vars)


## Post-process the propagation results
"""
The results of the propagation are then processed to a more user-friendly form.
"""


### Total acceleration over time
"""
Let's first plot the total acceleration on the satellite over time. This can be done by taking the norm of the first three columns of the dependent variable list.
"""
        results_hierarchical = numerical_simulation.SingleArcSimulator(
            body_system, integrator_settings,
            propagator_settings_hierarchical).state_history

## Post-process the propagation results
"""
The results of the propagation are then processed to a more user-friendly form.
"""

### Plot the barycentric system evolution in 3D
"""
Let's first plot the trajectory of each of the bodies in 3 dimensions, with respect to the Solar System Barycenter.
"""

# Convert the state dictionnary to a multi-dimensional array
barycentric_system_state_array = result2array(results_barycentric)

fig1 = plt.figure(figsize=(8, 8))
ax1 = fig1.add_subplot(111, projection='3d')
ax1.set_title(f'System state evolution of all bodies w.r.t SSB.')

for i, body in enumerate(bodies_to_propagate):
    # Plot the 3D trajectory of each body
    ax1.plot(barycentric_system_state_array[:, 6 * i + 1],
             barycentric_system_state_array[:, 6 * i + 2],
             barycentric_system_state_array[:, 6 * i + 3],
             label=body)
    # Plot the initial position of each body
    ax1.scatter(barycentric_system_state_array[0, 6 * i + 1],
                barycentric_system_state_array[0, 6 * i + 2],
                barycentric_system_state_array[0, 6 * i + 3],
예제 #9
0
After this, the dependent variable history is extracted.
The column indexes corresponding to a given dependent variable in the `dep_vars` variable are printed when the simulation is run, when `SingleArcSimulator()` is called.
Do mind that converting to an ndarray using the `result2array()` utility will shift these indexes, since the first column (index 0) will then be the times.

In this example, we are not interested in analysing the state history. This can however be accessed in the `dynamics_simulator.state_history` variable.
"""

# Create the simulation objects and propagate the dynamics
dynamics_simulator = numerical_simulation.SingleArcSimulator(
    bodies, integrator_settings, propagator_settings
)

# Extract the resulting simulation dependent variables
dependent_variables = dynamics_simulator.dependent_variable_history
# Convert the dependent variables from a dictionary to a numpy array
dependent_variables_array = result2array(dependent_variables)


## Post-process the propagation results
"""
The results of the propagation are then processed to a more user-friendly form.
"""


### Altitude over time
"""
First, let's plot the altitude of the `STS` vehicle over time.
"""

# Extract the time from the dependent variables array (and convert from seconds to minutes)
time_min = dependent_variables_array[:,0] / 60
# Print transfer parameter definitions
print("Transfer parameter definitions:")
transfer_trajectory.print_parameter_definitions(transfer_leg_settings,
                                                transfer_node_settings)

#### Plot the transfer
"""
The state throughout the transfer can be retrieved from the transfer trajectory object, here at 500 instances per leg, to visualize the transfer.
"""

# Extract the state history
state_history = transfer_trajectory_object.states_along_trajectory(500)
fly_by_states = np.array(
    [state_history[node_times[i]] for i in range(len(node_times))])
state_history = result2array(state_history)
au = 1.5e11

# Plot the transfer
fig = plt.figure(figsize=(8, 5))
ax = fig.add_subplot(111, projection='3d')
# Plot the trajectory from the state history
ax.plot(state_history[:, 1] / au, state_history[:, 2] / au,
        state_history[:, 3] / au)
# Plot the position of the nodes
ax.scatter(fly_by_states[0, 0] / au,
           fly_by_states[0, 1] / au,
           fly_by_states[0, 2] / au,
           color='blue',
           label='Earth departure')
ax.scatter(fly_by_states[1, 0] / au,