Skip to content

Commit 14937a7

Browse files
Merge pull request #466 from RocketPy-Team/docs/first-simulation-allinfo
DOC: first simulation allinfo
2 parents 4d17e4a + b4cb525 commit 14937a7

File tree

2 files changed

+248
-15
lines changed

2 files changed

+248
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ To learn more about RocketPy's requirements, visit our [Requirements Docs](https
123123

124124
## Running Your First Simulation
125125

126-
In order to run your first rocket trajectory simulation using RocketPy, you can start a Jupyter Notebook and navigate to the `docs/notebooks` folder. Open `getting_started.ipynb` and you are ready to go.
126+
In order to run your first rocket trajectory simulation using RocketPy, you can start a Jupyter Notebook and navigate to the `docs/notebooks` folder. Open `getting_started.ipynb` and you are ready to go. We recommend you reading the [First Simulation](https://docs.rocketpy.org/en/latest/user/first_simulation.html) page to get a complete description.
127127

128128
Otherwise, you may want to create your own script or your own notebook using RocketPy. To do this, let's see how to use RocketPy's four main classes:
129129

docs/user/first_simulation.rst

Lines changed: 247 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,35 +326,236 @@ rail.
326326
rocket=calisto, environment=env, rail_length=5.2, inclination=85, heading=0
327327
)
328328

329-
All simulation information will be saved in the ``test_flight``.
329+
All simulation information will be saved in the ``test_flight`` object.
330+
331+
RocketPy has two submodules to access the results of the simulation: ``prints``
332+
and ``plots``. Each class has its ``prints`` and ``plots`` submodule imported as
333+
an attribute. For example, to access the ``prints`` submodule of the ``Flight``
334+
object, we can use ``test_flight.prints``.
335+
336+
Also, each class has its own methods to quickly access all the information, for
337+
example, the ``test_flight.all_info()`` for visualizing all the plots and
338+
the ``test_flight.info()`` for a summary of the numerical results.
339+
340+
Bellow we describe how to access and manipulate the results of the simulation.
341+
342+
Accessing numerical results
343+
---------------------------
344+
345+
.. note::
346+
347+
All the methods that are used in this section can be accessed at once by
348+
running ``test_flight.info()``.
330349

331-
There are several methods to access the results. For example, we can plot the
332-
speed of the rocket until the first parachute is deployed:
350+
351+
You may want to start by checking the initial conditions of the simulation. This
352+
will allow you to check the state of the rocket at the time of ignition:
333353

334354
.. jupyter-execute::
335355

336-
test_flight.speed.plot(0, test_flight.apogee_time)
356+
test_flight.prints.initial_conditions()
337357

338-
Or get the array of the speed of the entire flight, in the form
339-
of ``[[time, speed], ...]``:
358+
Also important to check the surface wind conditions at launch site and the
359+
conditions of the launch rail:
340360

341361
.. jupyter-execute::
342362

343-
test_flight.speed.source
363+
test_flight.prints.surface_wind_conditions()
364+
365+
.. jupyter-execute::
366+
367+
test_flight.prints.launch_rail_conditions()
368+
369+
Once we have checked the initial conditions, we can check the conditions at the
370+
out of rail state, which is the first important moment of the flight. After this
371+
point, the rocket will start to fly freely:
372+
373+
.. jupyter-execute::
374+
375+
test_flight.prints.out_of_rail_conditions()
376+
377+
378+
Next, we can check at the burn out time, which is the moment when the motor
379+
stops burning. From this point on, the rocket will fly without any thrust:
380+
381+
.. jupyter-execute::
382+
383+
test_flight.prints.burn_out_conditions()
384+
385+
We can also check the apogee conditions, which is the moment when the rocket
386+
reaches its maximum altitude. The apogee will be displayed in both
387+
"Above Sea Level (ASL)" and "Above Ground Level (AGL)" formats.
388+
389+
.. jupyter-execute::
390+
391+
test_flight.prints.apogee_conditions()
392+
393+
To check for the ejection of any parachutes, we can use the following method:
394+
395+
.. jupyter-execute::
396+
397+
test_flight.prints.events_registered()
398+
399+
To understand the conditions at the end of the simulation, especially upon
400+
impact, we can use:
401+
402+
.. jupyter-execute::
403+
404+
test_flight.prints.impact_conditions()
405+
406+
Finally, the ``prints.maximum_values()`` provides a summary of the maximum
407+
values recorded during the flight for various parameters.
408+
409+
.. jupyter-execute::
410+
411+
test_flight.prints.maximum_values()
412+
413+
414+
Plotting the Results
415+
--------------------
416+
417+
.. note::
418+
419+
All the methods that are used in this section can be accessed at once by
420+
running ``test_flight.all_info()``. The output will be equivalent to
421+
running block by block the following methods.
422+
423+
Using the ``test_flight.plots`` module, we can access multiple results of the
424+
simulation. For example, we can plot the rocket's trajectory. Moreover, we can
425+
get plots of multiple data:
426+
427+
Full trajectory
428+
^^^^^^^^^^^^^^^^^^^^^^^^
429+
430+
.. jupyter-execute::
431+
432+
test_flight.plots.trajectory_3d()
433+
434+
435+
Velocity and acceleration
436+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
437+
438+
The velocity and acceleration in 3 directions can be accessed using the
439+
following method. The reference frame used for these plots is the absolute
440+
reference frame, which is the reference frame of the launch site.
441+
The acceleration might have a hard drop when the motor stops burning.
442+
443+
.. jupyter-execute::
444+
445+
test_flight.plots.linear_kinematics_data()
446+
447+
448+
Angular Positions
449+
^^^^^^^^^^^^^^^^^^^^^^^^^^
450+
451+
Here you can plot 3 different parameters of the rocket's angular position:
452+
453+
1. ``Flight Path Angle``: The angle between the rocket's velocity vector and the horizontal plane. This angle is 90° when the rocket is going straight up and 0° when the rocket is turned horizontally.
454+
2. ``Attitude Angle``: The angle between the axis of the rocket and the horizontal plane.
455+
3. ``Lateral Attitude Angle``: The angle between the rockets axis and the vertical plane that contains the launch rail. The bigger this angle, the larger is the deviation from the original heading of the rocket.
456+
457+
.. jupyter-execute::
458+
459+
test_flight.plots.flight_path_angle_data()
460+
461+
.. tip::
462+
463+
The ``Flight Path Angle`` and the ``Attitude Angle`` should be close to each
464+
other as long as the rocket is stable.
465+
466+
Rocket's Orientation or Attitude
467+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
468+
469+
Rocket's orientation in RocketPy is done through Euler Parameters or Quaternions.
470+
Additionally, RocketPy uses the quaternions to calculate the Euler Angles
471+
(Precession, nutation and spin) and their changes. All these information can be
472+
accessed through the following method:
473+
474+
.. jupyter-execute::
475+
476+
test_flight.plots.attitude_data()
344477

345478
.. seealso::
479+
Further information about Euler Parameters, or Quaternions, can be found
480+
in `Quaternions <https://en.wikipedia.org/wiki/Quaternion>`_, while
481+
further information about Euler Angles can be found in
482+
`Euler Angles <https://en.wikipedia.org/wiki/Euler_angles>`_.
346483

347-
The ``Flight`` object has several attributes containing every result of the
348-
simulation. To see all the attributes of the ``Flight`` object, see
349-
:class:`rocketpy.Flight`.
350484

351-
To see a very large summary of the results, we can call the ``all_info`` method:
485+
Angular Velocity and Acceleration
486+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
487+
488+
The angular velocity and acceleration are particularly important to check the
489+
stability of the rocket. You may expect a sudden change in the angular velocity
490+
and acceleration when the motor stops burning, for example:
491+
492+
.. jupyter-execute::
493+
494+
test_flight.plots.angular_kinematics_data()
495+
496+
497+
Aerodynamic forces and moments
498+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
499+
500+
The aerodynamic forces and moments are also important to check the flight
501+
behavior of the rocket. The drag (axial) and lift forces are made available,
502+
as well as the bending and spin moments. The lift is decomposed in two
503+
directions orthogonal to the drag force.
504+
505+
.. jupyter-execute::
506+
507+
test_flight.plots.aerodynamic_forces()
508+
509+
510+
Forces Applied to the Rail Buttons
511+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
512+
513+
RocketPy can also plot the forces applied to the rail buttons before the rocket
514+
leaves the rail. This information may be useful when designing the rail buttons
515+
and the launch rail.
516+
517+
.. jupyter-execute::
518+
519+
test_flight.plots.rail_buttons_forces()
520+
521+
Energies and Power
522+
^^^^^^^^^^^^^^^^^^^^^^^^
523+
524+
RocketPy also calculates the kinetic and potential energy of the rocket during
525+
the flight, as well as the thrust and drag power:
526+
527+
.. jupyter-execute::
528+
529+
test_flight.plots.energy_data()
530+
531+
532+
Fluid Mechanics Related Parameters
533+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
534+
535+
RocketPy computes the Mach Number, Reynolds Number, total and dynamic pressure
536+
felt by the rocket and the rocket's angle of attack, all available through the
537+
following method:
352538

353539
.. jupyter-execute::
354540

355-
test_flight.all_info()
541+
test_flight.plots.fluid_mechanics_data()
356542

357-
| At last, we can export the trajectory to ``.kml`` to visualize it in Google Earth:
543+
544+
Stability Margin and Frequency Response
545+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
546+
547+
The Stability margin can be checked along with the frequency response of the
548+
rocket:
549+
550+
.. jupyter-execute::
551+
552+
test_flight.plots.stability_and_control_data()
553+
554+
555+
Visualizing the Trajectory in Google Earth
556+
------------------------------------------
557+
558+
We can export the trajectory to ``.kml`` to visualize it in Google Earth:
358559

359560
.. jupyter-input::
360561

@@ -364,10 +565,42 @@ To see a very large summary of the results, we can call the ``all_info`` method:
364565
altitude_mode="relative_to_ground",
365566
)
366567

568+
.. note::
569+
570+
To learn more about the ``.kml`` format, see
571+
`KML Reference <https://developers.google.com/kml/documentation/kmlreference>`_.
572+
573+
574+
Manipulating results
575+
--------------------
576+
577+
There are several methods to access the results. For example, we can plot the
578+
speed of the rocket until the first parachute is deployed:
579+
580+
.. jupyter-execute::
581+
582+
test_flight.speed.plot(0, test_flight.apogee_time)
583+
584+
Or get the array of the speed of the entire flight, in the form
585+
of ``[[time, speed], ...]``:
586+
587+
.. jupyter-execute::
588+
589+
test_flight.speed.source
590+
591+
.. seealso::
592+
593+
The ``Flight`` object has several attributes containing every result of the
594+
simulation. To see all the attributes of the ``Flight`` object, see
595+
:class:`rocketpy.Flight`. These attributes are usually instances of the
596+
:class:`rocketpy.Function` class, see the :ref:`Function Class Usage <functionusage>` for more information.
597+
367598
Exporting Flight Data
368599
---------------------
369600

370-
In this section, we will explore how to export specific data from your RocketPy simulations to CSV files. This is particularly useful if you want to insert the data into spreadsheets or other software for further analysis.
601+
In this section, we will explore how to export specific data from your RocketPy
602+
simulations to CSV files. This is particularly useful if you want to insert the
603+
data into spreadsheets or other software for further analysis.
371604

372605
The main method that is used to export data is the :meth:`rocketpy.Flight.export_data` method. This method exports selected flight attributes to a CSV file. In this first example, we will export the rocket angle of attack (see :meth:`rocketpy.Flight.angle_of_attack`) and the rocket mach number (see :meth:`rocketpy.Flight.mach_number`) to the file ``calisto_flight_data.csv``.
373606

0 commit comments

Comments
 (0)