def create_hodographic_shaping_object(trajectory_parameters: list,
                                      bodies: tudatpy.kernel.simulation.environment_setup.SystemOfBodies) \
        -> tudatpy.kernel.simulation.shape_based_thrust.HodographicShaping:
    """
    It creates and returns the hodographic shaping object, based on the trajectory parameters.

    Parameters
    ----------
    trajectory_parameters : list
        List of trajectory parameters to be optimized.
    bodies : tudatpy.kernel.simulation.environment_setup.SystemOfBodies
        System of bodies present in the simulation.

    Returns
    -------
    hodographic_shaping_object : tudatpy.kernel.simulation.shape_based_thrust.HodographicShaping
        Hodographic shaping object.
    """
    # Time settings
    initial_time = get_trajectory_initial_time(trajectory_parameters)
    time_of_flight = get_trajectory_time_of_flight(trajectory_parameters)
    final_time = get_trajectory_final_time(trajectory_parameters)
    # Number of revolutions
    number_of_revolutions = int(trajectory_parameters[2])
    # Compute relevant frequency and scale factor for shaping functions
    frequency = 2.0 * np.pi / time_of_flight
    scale_factor = 1.0 / time_of_flight
    # Retrieve shaping functions and free parameters
    radial_velocity_shaping_functions, radial_free_coefficients = get_radial_velocity_shaping_functions(
        trajectory_parameters, frequency, scale_factor, time_of_flight,
        number_of_revolutions)
    normal_velocity_shaping_functions, normal_free_coefficients = get_normal_velocity_shaping_functions(
        trajectory_parameters, frequency, scale_factor, time_of_flight,
        number_of_revolutions)
    axial_velocity_shaping_functions, axial_free_coefficients = get_axial_velocity_shaping_functions(
        trajectory_parameters, frequency, scale_factor, time_of_flight,
        number_of_revolutions)
    # Retrieve boundary conditions and central body gravitational parameter
    initial_state = bodies.get_body(
        'Earth').get_state_in_based_frame_from_ephemeris(initial_time)
    final_state = bodies.get_body(
        'Mars').get_state_in_based_frame_from_ephemeris(final_time)
    gravitational_parameter = bodies.get_body('Sun').gravitational_parameter
    # Create and return shape-based method
    hodographic_shaping_object = shape_based_thrust.HodographicShaping(
        initial_state, final_state, time_of_flight, gravitational_parameter,
        number_of_revolutions, radial_velocity_shaping_functions,
        normal_velocity_shaping_functions, axial_velocity_shaping_functions,
        radial_free_coefficients, normal_free_coefficients,
        axial_free_coefficients)
    return hodographic_shaping_object
Exemplo n.º 2
0
def set_capsule_shape_parameters(
        shape_parameters: list,
        bodies: tudatpy.kernel.simulation.environment_setup.SystemOfBodies,
        capsule_density: float):
    """
    It computes and creates the properties of the capsule (shape, mass, aerodynamic coefficient interface...).

    Parameters
    ----------
    shape_parameters : list of floats
        List of shape parameters to be optimized.
    bodies : tudatpy.kernel.simulation.environment_setup.SystemOfBodies
        System of bodies present in the simulation.
    capsule_density : float
        Constant density of the vehicle.

    Returns
    -------
    none
    """
    # Compute shape constraint
    length_limit = shape_parameters[1] - shape_parameters[4] * (
        1 - np.cos(shape_parameters[3]))
    length_limit /= np.tan(-shape_parameters[3])
    # Add safety factor
    length_limit -= 0.01
    # Apply constraint
    if shape_parameters[2] >= length_limit:
        shape_parameters[2] = length_limit

    # Create capsule
    new_capsule = geometry.Capsule(*shape_parameters[0:5])
    # Compute new body mass
    new_capsule_mass = capsule_density * new_capsule.volume
    # Set capsule mass
    bodies.get_body('Capsule').set_constant_mass(new_capsule_mass)
    # Create aerodynamic interface from shape parameters (this calls the local inclination analysis)
    new_aerodynamic_coefficient_interface = get_capsule_coefficient_interface(
        new_capsule)
    # Update the Capsule's aerodynamic coefficient interface
    bodies.get_body('Capsule').set_aerodynamic_coefficient_interface(
        new_aerodynamic_coefficient_interface)
Exemplo n.º 3
0
def get_initial_state(simulation_start_epoch: float,
                      bodies: tudatpy.kernel.simulation.environment_setup.SystemOfBodies) -> np.ndarray:
    """
    Converts the initial state to inertial coordinates.

    The initial state is expressed in Earth-centered spherical coordinates.
    These are first converted into Earth-centered cartesian coordinates,
    then they are finally converted in the global (inertial) coordinate
    system.

    Parameters
    ----------
    simulation_start_epoch : float
        Start of the simulation [s] with t=0 at J2000.
    bodies : tudatpy.kernel.simulation.environment_setup.SystemOfBodies
        System of bodies present in the simulation.

    Returns
    -------
    initial_state_inertial_coordinates : np.ndarray
        The initial state of the vehicle expressed in inertial coordinates.
    """
    # Set initial spherical elements
    # position vector (m)
    radial_distance = spice_interface.get_average_radius('Earth') + 120.0E3
    # latitude (rad)
    latitude = np.deg2rad(0.0)
    # longitude (rad)
    longitude = np.deg2rad(68.75)
    # velocity (m/s)
    speed = 7.83E3
    # flight path angle (rad)
    flight_path_angle = np.deg2rad(-1.5)
    # heading angle (rad)
    heading_angle = np.deg2rad(34.37)

    # Convert spherical elements to body-fixed cartesian coordinates
    initial_cartesian_state_body_fixed = conversion.spherical_to_cartesian(radial_distance,
                                                                latitude,
                                                                longitude,
                                                                speed,
                                                                flight_path_angle,
                                                                heading_angle)
    # Get rotational ephemerides of the Earth
    earth_rotational_model = bodies.get_body('Earth').rotation_model
    # Transform the state to the global (inertial) frame
    initial_cartesian_state_inertial = conversion.transform_to_inertial_orientation(initial_cartesian_state_body_fixed,
                                                                                      simulation_start_epoch,
                                                                                      earth_rotational_model)
    return initial_cartesian_state_inertial
Exemplo n.º 4
0
def add_capsule_to_body_system(
        bodies: tudatpy.kernel.simulation.environment_setup.SystemOfBodies,
        shape_parameters: list, capsule_density: float):
    """
    It creates the capsule body object and adds it to the body system, setting its shape based on the shape parameters
    provided.

    Parameters
    ----------
    bodies : tudatpy.kernel.simulation.environment_setup.SystemOfBodies
        System of bodies present in the simulation.
    shape_parameters : list of floats
        List of shape parameters to be optimized.
    capsule_density : float
        Constant density of the vehicle.

    Returns
    -------
    none
    """
    # Create new vehicle object and add it to the existing system of bodies
    bodies.create_empty_body('Capsule')
    # Update the capsule shape parameters
    set_capsule_shape_parameters(shape_parameters, bodies, capsule_density)
Exemplo n.º 5
0
def get_thrust_acceleration_model_from_parameters(thrust_parameters: list,
                                                  bodies: tudatpy.kernel.simulation.environment_setup.SystemOfBodies,
                                                  initial_time: float,
                                                  specific_impulse: float) -> \
        tudatpy.kernel.simulation.propagation_setup.acceleration.ThrustAccelerationSettings:
    """
    Creates the thrust acceleration models from the LunarAscentThrustGuidance class and sets it in the propagator.

    Parameters
    ----------
    thrust_parameters : list of floats
        List of thrust parameters.
    bodies : tudatpy.kernel.simulation.environment_setup.SystemOfBodies
        System of bodies present in the simulation.
    initial_time : float
        The start time of the simulation in seconds.
    specific_impulse : float
        Specific impulse of the vehicle.

    Returns
    -------
    tudatpy.kernel.simulation.propagation_setup.acceleration.ThrustAccelerationSettings
        Thrust acceleration settings object.
    """
    # Create Thrust Guidance object
    thrust_guidance = LunarAscentThrustGuidance(bodies.get_body('Vehicle'),
                                                initial_time,
                                                thrust_parameters)
    # Retrieves thrust functions
    thrust_direction_function = thrust_guidance.get_current_thrust_direction
    thrust_magnitude_function = thrust_guidance.get_current_thrust_magnitude
    # Set thrust functions in the acceleration model
    thrust_direction_settings = propagation_setup.acceleration.custom_thrust_direction(
        thrust_direction_function)
    thrust_magnitude_settings = propagation_setup.acceleration.custom_thrust_magnitude(
        thrust_magnitude_function, lambda time: specific_impulse)
    # Create and return thrust acceleration settings
    return propagation_setup.acceleration.ThrustAccelerationSettings(
        thrust_direction_settings, thrust_magnitude_settings)