for i in range(0, number_RAAN):
    bodies.create_empty_body(SC_NAMES[i])

    bodies.get_body(SC_NAMES[i]).set_constant_mass(4.874)

    environment_setup.add_radiation_pressure_interface(
        bodies, SC_NAMES[i], radiation_pressure_settings)

    central_bodies.append("Earth")

    acceleration_settings[SC_NAMES[i]] = accelerations_settings_chess

    initial_state_temp = conversion.keplerian_to_cartesian(
        gravitational_parameter=earth_gravitational_parameter,
        semi_major_axis=7078136,
        eccentricity=0.0424,
        inclination=np.deg2rad(97.5926),
        argument_of_periapsis=np.deg2rad(RAAN[i]),
        longitude_of_ascending_node=np.deg2rad(100.0),
        true_anomaly=np.deg2rad(0.0))
    if i == 0:
        initial_state = initial_state_temp
    else:
        initial_state = np.hstack([initial_state, initial_state_temp])

    dependent_variables_to_save.append(
        propagation_setup.dependent_variable.single_acceleration_norm(
            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)
Exemplo n.º 2
0
    Saturn=[propagation_setup.acceleration.point_mass_gravity()],
    Uranus=[propagation_setup.acceleration.point_mass_gravity()],
    Neptune=[propagation_setup.acceleration.point_mass_gravity()],
    Pluto=[propagation_setup.acceleration.point_mass_gravity()])

acceleration_settings = {"CubeSat": accelerations_settings_3u_cubesat}
acceleration_models = propagation_setup.create_acceleration_models(
    bodies, acceleration_settings, bodies_to_propagate, central_bodies)

# # Create propagation settings
# define initial conditions
sun_gravitational_parameter = bodies.get_body("Sun").gravitational_parameter
initial_state = conversion.keplerian_to_cartesian(
    gravitational_parameter=sun_gravitational_parameter,
    semi_major_axis=1.3 * 149597870700.0,
    eccentricity=0.1,
    inclination=np.deg2rad(1.0),
    argument_of_periapsis=np.deg2rad(235.7),
    longitude_of_ascending_node=np.deg2rad(23.4),
    true_anomaly=np.deg2rad(139.87))
# define the variables we need
dependent_variables_to_save = [
    propagation_setup.dependent_variable.total_acceleration("CubeSat"),
    propagation_setup.dependent_variable.keplerian_state("CubeSat", "Sun"),
]
# create propagation settings
propagator_settings = propagation_setup.propagator.translational(
    central_bodies,
    acceleration_models,
    bodies_to_propagate,
    initial_state,
    simulation_end_epoch,
Exemplo n.º 3
0
    def fitness(self,
                orbit_parameters: List[float]) -> List[float]:
        """
        Computes the fitness value for the problem.

        Parameters
        ----------
        orbit_parameters : List[float]
            Vector of decision variables of size n (for this problem, n = 4).

        Returns
        -------
        List[float]
            List of size p with the values for each objective (for this multi-objective optimization problem, p=2).
        """
        # Retrieves system of bodies
        current_bodies = self.bodies_function()
        # Retrieves Itokawa gravitational parameter
        itokawa_gravitational_parameter = current_bodies.get_body("Itokawa").gravitational_parameter
        # Reset the initial state from the decision variable vector
        new_initial_state = conversion.keplerian_to_cartesian(
            gravitational_parameter=itokawa_gravitational_parameter,
            semi_major_axis=orbit_parameters[0],
            eccentricity=orbit_parameters[1],
            inclination=np.deg2rad(orbit_parameters[2]),
            argument_of_periapsis=np.deg2rad(235.7),
            longitude_of_ascending_node=np.deg2rad(orbit_parameters[3]),
            true_anomaly=np.deg2rad(139.87))
        # Retrieves propagator settings object
        propagator_settings = self.propagator_settings_function()
        # Retrieves integrator settings object
        integrator_settings = self.integrator_settings_function()
        # Reset the initial state
        propagator_settings.reset_initial_states(new_initial_state)

        # Propagate orbit
        dynamics_simulator = propagation_setup.SingleArcDynamicsSimulator(current_bodies,
                                                                          integrator_settings,
                                                                          propagator_settings,
                                                                          print_dependent_variable_data=False)
        # Update dynamics simulator function
        self.dynamics_simulator_function = lambda: dynamics_simulator

        # Retrieve dependent variable history
        dependent_variables = dynamics_simulator.dependent_variable_history
        dependent_variables_list = np.vstack(list(dependent_variables.values()))
        # Retrieve distance
        distance = dependent_variables_list[:, 0]
        # Retrieve latitude
        latitudes = dependent_variables_list[:, 1]
        # Compute mean latitude
        mean_latitude = np.mean(np.absolute(latitudes))
        # Computes fitness as mean latitude
        current_fitness = 1.0 / mean_latitude

        # Exaggerate fitness value if the spacecraft has broken out of the selected distance range
        current_penalty = 0.0
        if (max(dynamics_simulator.dependent_variable_history.keys()) < self.mission_final_time):
            current_penalty += 1.0E4

        return [current_fitness + current_penalty, np.mean(distance) + current_penalty * 1.0E3]
accelerations_settings_chess = dict(
    Earth=[propagation_setup.acceleration.spherical_harmonic_gravity(4, 4)])

acceleration_settings = {"Spacecraft": accelerations_settings_chess}

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

# Initial System State
earth_gravitational_parameter = bodies.get_body(
    "Earth").gravitational_parameter

initial_state = conversion.keplerian_to_cartesian(
    gravitational_parameter=earth_gravitational_parameter,
    semi_major_axis=6928136,
    eccentricity=0.0,
    inclination=np.deg2rad(97.5919),
    argument_of_periapsis=np.deg2rad(0.0),
    longitude_of_ascending_node=np.deg2rad(90.0),
    true_anomaly=np.deg2rad(0.0))

# Variables to Export
dependent_variables_to_save = [
    propagation_setup.dependent_variable.relative_position(
        "Spacecraft", "Earth")
]

# Propagator settings
propagator_settings = propagation_setup.propagator.translational(
    central_bodies,
    acceleration_models,
    bodies_to_propagate,