Skip to content

Commit 78ef92e

Browse files
committed
ENH: added new parameters into add_parachute method in Rocket class
1 parent f09a4b0 commit 78ef92e

2 files changed

Lines changed: 50 additions & 13 deletions

File tree

rocketpy/rocket/parachute.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ class Parachute:
9292
Function of noisy_pressure_signal.
9393
Parachute.clean_pressure_signal_function : Function
9494
Function of clean_pressure_signal.
95+
Parachute.parachute_radius : float
96+
Radius of the inflated parachute in meters.
97+
Parachute.parachute_height : float
98+
Height of the inflated parachute in meters.
99+
Parachute.porosity : float
100+
Porosity of the parachute material, which is a measure of how much air can
101+
pass through the parachute material.
95102
"""
96103

97104
def __init__(
@@ -158,26 +165,22 @@ def __init__(
158165
passed to the trigger function. Default value is ``(0, 0, 0)``.
159166
Units are in Pa.
160167
parachute_radius : float, optional
161-
Radius of the inflated parachute in meters. Default value is 1.5.
168+
Radius of the inflated parachute. Default value is 1.5.
162169
Units are in meters.
163170
parachute_height : float, optional
164-
Height of the inflated parachute in meters.
165-
Default value is the radius parachute. Units are in meters.
171+
Height of the inflated parachute. Default value is the radius parachute.
172+
Units are in meters.
166173
porosity : float, optional
167174
Porosity of the parachute material, which is a measure of how much air can
168-
pass through the parachute material. Default value is 0.0432.
175+
pass through the parachute material.
176+
Default value is 0.0432 (for consistency with previous versions).
169177
"""
170178
self.name = name
171179
self.cd_s = cd_s
172180
self.trigger = trigger
173181
self.sampling_rate = sampling_rate
174182
self.lag = lag
175183
self.noise = noise
176-
self.parachute_radius = parachute_radius
177-
if parachute_height is None:
178-
parachute_height = parachute_radius
179-
self.parachute_height = parachute_height
180-
self.porosity = porosity
181184
self.noise_signal = [[-1e-6, np.random.normal(noise[0], noise[1])]]
182185
self.noisy_pressure_signal = []
183186
self.clean_pressure_signal = []
@@ -187,6 +190,11 @@ def __init__(
187190
self.clean_pressure_signal_function = Function(0)
188191
self.noisy_pressure_signal_function = Function(0)
189192
self.noise_signal_function = Function(0)
193+
self.parachute_radius = parachute_radius
194+
if parachute_height is None:
195+
parachute_height = parachute_radius
196+
self.parachute_height = parachute_height
197+
self.porosity = porosity
190198

191199
alpha, beta = self.noise_corr
192200
self.noise_function = lambda: alpha * self.noise_signal[-1][

rocketpy/rocket/rocket.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,16 @@ def add_free_form_fins(
14341434
return fin_set
14351435

14361436
def add_parachute(
1437-
self, name, cd_s, trigger, sampling_rate=100, lag=0, noise=(0, 0, 0)
1437+
self,
1438+
name,
1439+
cd_s,
1440+
trigger,
1441+
sampling_rate=100,
1442+
lag=0,
1443+
noise=(0, 0, 0),
1444+
parachute_radius=1.5,
1445+
parachute_height=None,
1446+
porosity=0.0432,
14381447
):
14391448
"""Creates a new parachute, storing its parameters such as
14401449
opening delay, drag coefficients and trigger function.
@@ -1493,16 +1502,36 @@ def add_parachute(
14931502
The values are used to add noise to the pressure signal which is
14941503
passed to the trigger function. Default value is (0, 0, 0). Units
14951504
are in pascal.
1505+
parachute_radius : float, optional
1506+
Radius of the inflated parachute. Default value is 1.5.
1507+
Units are in meters.
1508+
parachute_height : float, optional
1509+
Height of the inflated parachute. Default value is the radius parachute.
1510+
Units are in meters.
1511+
porosity : float, optional
1512+
Porosity of the parachute material, which is a measure of how much air can
1513+
pass through the parachute material.
1514+
Default value is 0.0432 (for consistency with previous versions).
14961515
14971516
Returns
14981517
-------
14991518
parachute : Parachute
1500-
Parachute containing trigger, sampling_rate, lag, cd_s, noise
1501-
and name. Furthermore, it stores clean_pressure_signal,
1519+
Parachute containing trigger, sampling_rate, lag, cd_s, noise, radius,
1520+
height, porosity and name. Furthermore, it stores clean_pressure_signal,
15021521
noise_signal and noisyPressureSignal which are filled in during
15031522
Flight simulation.
15041523
"""
1505-
parachute = Parachute(name, cd_s, trigger, sampling_rate, lag, noise)
1524+
parachute = Parachute(
1525+
name,
1526+
cd_s,
1527+
trigger,
1528+
sampling_rate,
1529+
lag,
1530+
noise,
1531+
parachute_radius,
1532+
parachute_height,
1533+
porosity,
1534+
)
15061535
self.parachutes.append(parachute)
15071536
return self.parachutes[-1]
15081537

0 commit comments

Comments
 (0)