Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 80 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ RocketPy is the next-generation trajectory simulation solution for High-Power Ro
</details>

<details>
<summary>Solid motors models</summary>
<summary>Solid, Hybrid and Liquid motors models</summary>
<ul>
<li>Burn rate and mass variation properties from thrust curve</li>
<li>Define custom rocket tanks based on their flux data</li>
<li>CSV and ENG file support</li>
</ul>
</details>
Expand Down Expand Up @@ -156,12 +157,12 @@ To learn more about RocketPy's requirements, visit our [Requirements Docs](https

## Running Your First Simulation

In order to run your first rocket trajectory simulation using RocketPy, you can start a Jupyter Notebook and navigate to the _nbks_ folder. Open _Getting Started - Examples.ipynb_ and you are ready to go.
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.

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:

- Environment - Keeps data related to weather.
- SolidMotor - Keeps data related to solid motors. Hybrid motor support is coming in the next weeks.
- Motor - Subdivided into SolidMotor, HybridMotor and LiquidMotor. Keeps data related to rocket motors.
- Rocket - Keeps data related to a rocket.
- Flight - Runs the simulation and keeps the results.

Expand All @@ -175,6 +176,12 @@ A typical workflow starts with importing these classes from RocketPy:
from rocketpy import Environment, Rocket, SolidMotor, Flight
```

An optional step is to import datetime, which is used to define the date of the simulation:

```python
import datetime
```

Then create an Environment object. To learn more about it, you can use:

```python
Expand All @@ -188,9 +195,14 @@ env = Environment(
latitude=32.990254,
longitude=-106.974998,
elevation=1400,
date=(2020, 3, 4, 12) # Tomorrow's date in year, month, day, hour UTC format
)

tomorrow = datetime.date.today() + datetime.timedelta(days=1)

env.set_date(
(tomorrow.year, tomorrow.month, tomorrow.day, 12), timezone="America/Denver"
) # Tomorrow's date in year, month, day, hour UTC format

env.set_atmospheric_model(type='Forecast', file='GFS')
```

Expand All @@ -204,18 +216,23 @@ A sample Motor object can be created by the following code:

```python
Pro75M1670 = SolidMotor(
thrust_source="../data/motors/Cesaroni_M1670.eng",
thrust_source="data/motors/Cesaroni_M1670.eng",
dry_mass=1.815,
dry_inertia=(0.125, 0.125, 0.002),
center_of_dry_mass=0.317,
grains_center_of_mass_position=0.397,
burn_time=3.9,
grain_number=5,
grain_separation=5/1000,
grain_separation=0.005,
grain_density=1815,
grain_outer_radius=33/1000,
grain_initial_inner_radius=15/1000,
grain_initial_height=120/1000,
grains_center_of_mass_position=-0.85704,
nozzle_radius=33/1000,
throat_radius=11/1000,
interpolation_method='linear'
grain_outer_radius=0.033,
grain_initial_inner_radius=0.015,
grain_initial_height=0.12,
nozzle_radius=0.033,
throat_radius=0.011,
interpolation_method="linear",
nozzle_position=0,
coordinate_system_orientation="nozzle_to_combustion_chamber",
)
```

Expand All @@ -229,65 +246,62 @@ A sample code to create a Rocket is:

```python
calisto = Rocket(
radius=127 / 2000,
mass=19.197 - 2.956,
inertia_i=6.60,
inertia_z=0.0351,
power_off_drag="../../data/calisto/powerOffDragCurve.csv",
power_on_drag="../../data/calisto/powerOnDragCurve.csv",
center_of_dry_mass_position=0,
coordinate_system_orientation="tail_to_nose"
radius=0.0635,
mass=14.426, # without motor
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(0.2, -0.5)

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

calisto.add_motor(Pro75M1670, position=-1.255)
calisto.add_nose(length=0.55829, kind="vonKarman", position=1.278)
calisto.add_trapezoidal_fins(

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

fins = calisto.add_trapezoidal_fins(
n=4,
root_chord=0.120,
tip_chord=0.040,
span=0.100,
position=-1.04956,
sweep_length=None,
cant_angle=0,
radius=None,
airfoil=None
position=-1.04956,
)
calisto.add_tail(

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

You may want to add parachutes to your rocket as well:

```python
def drogue_trigger(p, h, y):
# p = pressure considering parachute noise signal
# h = height above ground level considering parachute noise signal
# y = [x, y, z, vx, vy, vz, e0, e1, e2, e3, w1, w2, w3]

# activate drogue when vz < 0 m/s.
return True if y[5] < 0 else False

def main_trigger(p, h, y):
# p = pressure considering parachute noise signal
# h = height above ground level considering parachute noise signal
# y = [x, y, z, vx, vy, vz, e0, e1, e2, e3, w1, w2, w3]

# activate main when vz < 0 m/s and z < 800 m
return True if y[5] < 0 and h < 800 else False

calisto.add_parachute('Main',
cd_s=10.0,
trigger=main_trigger,
sampling_rate=105,
lag=1.5,
noise=(0, 8.3, 0.5))

calisto.add_parachute('Drogue',
cd_s=1.0,
trigger=drogue_trigger,
sampling_rate=105,
lag=1.5,
noise=(0, 8.3, 0.5))
main = calisto.add_parachute(
name="main",
cd_s=10.0,
trigger=800, # ejection altitude in meters
sampling_rate=105,
lag=1.5,
noise=(0, 8.3, 0.5),
)

drogue = calisto.add_parachute(
name="drogue",
cd_s=1.0,
trigger="apogee", # ejection at apogee
sampling_rate=105,
lag=1.5,
noise=(0, 8.3, 0.5),
)
```

Finally, you can create a Flight object to simulate your trajectory. To get help on the Flight class, use:
Expand All @@ -299,7 +313,9 @@ help(Flight)
To actually create a Flight object, use:

```python
test_flight = Flight(rocket=calisto, environment=env, rail_length=5.2, inclination=85, heading=0)
test_flight = Flight(
rocket=calisto, environment=env, rail_length=5.2, inclination=85, heading=0
)
```

Once the Flight object is created, your simulation is done! Use the following code to get a summary of the results:
Expand All @@ -318,6 +334,12 @@ Here is just a quick taste of what RocketPy is able to calculate. There are hund

![6-DOF Trajectory Plot](https://raw.githubusercontent.com/RocketPy-Team/RocketPy/master/docs/static/rocketpy_example_trajectory.svg)

If you want to see the trajectory on Google Earth, RocketPy acn easily export a KML file for you:

```python
test_flight.export_kml(file_name="test_flight.kml")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will give a candy to whoever adds a good picture of trajectory plotted on Google Earth

extra candy if it is a GIF

```

<br>

# Authors and Contributors
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def set_atmospheric_model(
so information from virtual soundings such as GFS and NAM
can also be imported.

- 'WindyAtmosphere': sets pressure, temperature, wind-u and wind-v
- 'windy_atmosphere': sets pressure, temperature, wind-u and wind-v
profiles and surface elevation obtained from the Windy API. See file
argument to specify the model as either ECMWF, GFS or ICON.

Expand Down
2 changes: 1 addition & 1 deletion rocketpy/prints/environment_prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def launch_site_details(self):
"Launch Date:",
self.environment.datetime_date.strftime(time_format),
"UTC |",
self.environment.localDate.strftime(time_format),
self.environment.local_date.strftime(time_format),
self.environment.timezone,
)
elif self.environment.datetime_date != None:
Expand Down