Skip to content

Commit

Permalink
Merge branch 'develop' into doc/environment-docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
phmbressan authored Mar 28, 2024
2 parents 27dd73d + 0a4d89b commit 32a28c1
Show file tree
Hide file tree
Showing 29 changed files with 1,226 additions and 2,441 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[report]
exclude_also=
; Don't complain about exceptions or warnings not being covered by tests
warnings.warn*
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- ENH: Add new stability margin properties to Flight class [#572](https://github.com/RocketPy-Team/RocketPy/pull/572)
- ENH: adds `Function.remove_outliers` method [#554](https://github.com/RocketPy-Team/RocketPy/pull/554)

### Changed

- MNT: Refactor flight prints module [#579](https://github.com/RocketPy-Team/RocketPy/pull/579)
- DOC: Convert CompareFlights example notebooks to .rst files [#576](https://github.com/RocketPy-Team/RocketPy/pull/576)
- MNT: Refactor inertia calculations using parallel axis theorem [#573] (https://github.com/RocketPy-Team/RocketPy/pull/573)
- ENH: Optional argument to show the plot in Function.compare_plots [#563](https://github.com/RocketPy-Team/RocketPy/pull/563)

### Fixed

- BUG: export_eng 'Motor' method would not work for liquid motors. [#559](https://github.com/RocketPy-Team/RocketPy/pull/559)

## [v1.2.2] - 2024-03-22

You can install this version by running `pip install rocketpy==1.2.2`

- BUG: wrong rocket mass in parachute u dot method [#569](https://github.com/RocketPy-Team/RocketPy/pull/569)

## [v1.2.1] - 2024-02-22

You can install this version by running `pip install rocketpy==1.2.1`
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author = "RocketPy Team"

# The full version, including alpha/beta/rc tags
release = "1.2.1"
release = "1.2.2"


# -- General configuration ---------------------------------------------------
Expand Down
940 changes: 0 additions & 940 deletions docs/notebooks/compare_flights_usage.ipynb

This file was deleted.

970 changes: 0 additions & 970 deletions docs/notebooks/deployable_payload_example.ipynb

This file was deleted.

3 changes: 2 additions & 1 deletion docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ This reference manual details functions, modules, methods and attributes include
AeroSurface Classes Plots and Prints <plots_prints/aero_surfaces/index>
Rocket Plots and Prints <plots_prints/Rocket/index>
Flight Plots and Prints <plots_prints/Flight/index>
EnvironmentAnalysis Plots and Prints <plots_prints/EnvironmentAnalysis/index>
EnvironmentAnalysis Plots and Prints <plots_prints/EnvironmentAnalysis/index>
CompareFlights Plots <plots_prints/compare_flights>
7 changes: 7 additions & 0 deletions docs/reference/plots_prints/compare_flights.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _compareflights:

CompareFlights
================

.. autoclass:: rocketpy.plots.compare.CompareFlights
:members:
229 changes: 229 additions & 0 deletions docs/user/compare_flights.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
Compare Flights
===============

This example demonstrates how to use the rocketpy ``CompareFlights`` class.
This class has many applications, including the comparison of different flight
setups for a single rocket, the simulation of deployable systems, and the
multi-stage rocket analysis.

Importing classes
-----------------

We will start by importing the necessary classes and modules:

.. jupyter-execute::

from rocketpy.plots.compare import CompareFlights
from rocketpy import Environment, Flight, Rocket, SolidMotor
from datetime import datetime, timedelta


Create Environment, Motor and Rocket
------------------------------------

First, let's create the environment, motor and rocket objects.
This is done following the same steps as in the :ref:`firstsimulation` example.

.. jupyter-execute::

after_tomorrow = datetime.now() + timedelta(days=2)
env = Environment(latitude=-23, longitude=-49, date=after_tomorrow)
env.set_atmospheric_model(type="Forecast", file="GFS")

cesaroni_motor = SolidMotor(
thrust_source="../data/motors/Cesaroni_M1670.eng",
dry_mass=1.815,
dry_inertia=(0.125, 0.125, 0.002),
nozzle_radius=33 / 1000,
grain_number=5,
grain_density=1815,
grain_outer_radius=33 / 1000,
grain_initial_inner_radius=15 / 1000,
grain_initial_height=120 / 1000,
grain_separation=5 / 1000,
grains_center_of_mass_position=0.397,
center_of_dry_mass_position=0.317,
nozzle_position=0,
burn_time=3.9,
throat_radius=11 / 1000,
coordinate_system_orientation="nozzle_to_combustion_chamber",
)

calisto = Rocket(
radius=127 / 2000,
mass=14.426,
inertia=(6.321, 6.321, 0.034),
power_off_drag="../data/calisto/powerOffDragCurve.csv",
power_on_drag="../data/calisto/powerOnDragCurve.csv",
center_of_mass_without_motor=0,
coordinate_system_orientation="tail_to_nose",
)

calisto.set_rail_buttons(
upper_button_position=0.0818,
lower_button_position=-0.618,
angular_position=45,
)

calisto.add_motor(cesaroni_motor, position=-1.255)

nosecone = calisto.add_nose(length=0.55829, kind="vonKarman", position=1.278)

fin_set = calisto.add_trapezoidal_fins(
n=4,
root_chord=0.120,
tip_chord=0.060,
span=0.110,
position=-1.04956,
cant_angle=0.5,
airfoil=("../data/calisto/NACA0012-radians.csv", "radians"),
)

tail = calisto.add_tail(
top_radius=0.0635, bottom_radius=0.0435, length=0.060, position=-1.194656
)

main_chute = calisto.add_parachute(
"Main",
cd_s=10.0,
trigger=800,
sampling_rate=105,
lag=1.5,
noise=(0, 8.3, 0.5),
)

drogue_chute = calisto.add_parachute(
"Drogue",
cd_s=1.0,
trigger="apogee",
sampling_rate=105,
lag=1.5,
noise=(0, 8.3, 0.5),
)

Creating the Flight objects
---------------------------

Now we can create different flights varying the launch angle and the rail inclination:

.. jupyter-execute::

inclinations = [85, 75]
headings = [90, 135]
flights = []

for heading in headings:
for inclination in inclinations:
flight = Flight(
environment=env,
rocket=calisto,
rail_length=5.2,
inclination=inclination,
heading=heading,
name=f"Incl {inclination} Head {heading}",
)
flights.append(flight)


We can easily visualize the number of flights created:

.. jupyter-execute::

print("Number of flights: ", len(flights))

Start the comparison
--------------------

It is easy to initialize the ``CompareFlights`` object:

.. jupyter-execute::

comparison = CompareFlights(flights)


After the initialization, we can use different methods to plot the results in a comparative way.
To see a full description of the available methods, you can check the :ref:`compareflights` documentation.

Plotting results one by one
----------------------------

The flights results are divided into different methods, so we can plot them one by one.
This is practical when we want to focus on a specific aspect of the flights.

.. jupyter-execute::

comparison.trajectories_3d(legend=True)

.. jupyter-execute::

comparison.positions()

.. jupyter-execute::

comparison.trajectories_2d(plane="xy", legend=True)

.. jupyter-execute::

comparison.velocities()

.. jupyter-execute::

comparison.stream_velocities()

.. jupyter-execute::

comparison.accelerations()

.. jupyter-execute::

comparison.angular_velocities()

.. jupyter-execute::

comparison.angular_accelerations()

.. jupyter-execute::

comparison.attitude_angles()

.. jupyter-execute::

comparison.euler_angles()

.. jupyter-execute::

comparison.quaternions()

.. jupyter-execute::

comparison.angles_of_attack()

.. jupyter-execute::

comparison.aerodynamic_forces()

.. jupyter-execute::

comparison.aerodynamic_moments()

.. jupyter-execute::

comparison.fluid_mechanics()

.. jupyter-execute::

comparison.energies()

.. jupyter-execute::

comparison.powers()


Plotting using the ``all`` method
---------------------------------

Alternatively, we can plot the results altogether by calling one simple method:

.. jupyter-execute::

comparison.all()
Loading

0 comments on commit 32a28c1

Please sign in to comment.