Skip to content

Commit

Permalink
ENH: improve clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano committed Nov 28, 2023
1 parent 085ad11 commit 7906efa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
18 changes: 11 additions & 7 deletions rocketpy/rocket/aero_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,11 @@ class AirBrakes(AeroSurface):
AirBrakes.reference_area : int, float
Reference area used to calculate the drag force of the air brakes
from the drag coefficient curve. Units of m^2.
AirBrakes.clamp : bool, optional
If True, the simulation will clamp the deployed level to 0 or 1 if
the deployed level is out of bounds. If False, the simulation will
not clamp the deployed level and will instead raise a warning if
the deployed level is out of bounds. Default is True.
AirBrakes.previous_state : list
List that stores the previous state of the air brakes. The state is
stored as a list with the following format:
Expand Down Expand Up @@ -1941,12 +1946,12 @@ def __init__(
If an array, it must be a 2D array where the first column is the
deployed level, the second column is the Mach number and the third
column is the drag coefficient. If a string, it must be the path to
a .csv or .txt file containing the drag coefficient curve. The file
must contain no headers and the first column must specify the
deployed level, the second column must specify the Mach number and
the third column must specify the drag coefficient. If a Function,
it must take as input the deployed level and the Mach number and
return the drag coefficient.
a .csv or .txt file containing the drag coefficient curve. The
file's first column must specify the deployed level, the second
column must specify the Mach number and the third column must
specify the drag coefficient. If a Function, it must take as input
the deployed level and the Mach number and return the drag
coefficient.
.. note:: At deployed level 0, the drag coefficient is assumed to
be 0, independent of the input drag coefficient curve. This
Expand Down Expand Up @@ -1978,7 +1983,6 @@ def __init__(
cd_curve,
inputs=["Deployed Level", "Mach"],
outputs="Cd",
extrapolation="zero",
)
self.reference_area = reference_area
self.clamp = clamp
Expand Down
7 changes: 7 additions & 0 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ def add_air_brakes(
cd_curve,
controller_function,
sampling_rate,
clamp=True,
reference_area=None,
name="AirBrakes",
controller_name="AirBrakes Controller",
Expand Down Expand Up @@ -1209,6 +1210,11 @@ def add_air_brakes(
The sampling rate of the controller function in Hertz (Hz). This
means that the controller function will be called every
`1/sampling_rate` seconds.
clamp : bool, optional
If True, the simulation will clamp the deployed level to 0 or 1 if
the deployed level is out of bounds. If False, the simulation will
not clamp the deployed level and will instead raise a warning if
the deployed level is out of bounds. Default is True.
reference_area : float, optional
Reference area used to calculate the drag force of the air brakes
from the drag coefficient curve. If None, which is default, use
Expand All @@ -1232,6 +1238,7 @@ def add_air_brakes(
air_brakes = AirBrakes(
cd_curve=cd_curve,
reference_area=reference_area,
clamp=clamp,
deployed_level=0,
name=name,
)
Expand Down

0 comments on commit 7906efa

Please sign in to comment.