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
4 changes: 0 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ recursive=no
# source root.
source-roots=

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
Expand Down
24 changes: 14 additions & 10 deletions rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2434,22 +2434,26 @@ def add_wind_gust(self, wind_gust_x, wind_gust_y):

# Reset wind heading and velocity magnitude
self.wind_heading = Function(
lambda h: (180 / np.pi)
* np.arctan2(
self.wind_velocity_x.get_value_opt(h),
self.wind_velocity_y.get_value_opt(h),
)
% 360,
lambda h: (
(180 / np.pi)
* np.arctan2(
self.wind_velocity_x.get_value_opt(h),
self.wind_velocity_y.get_value_opt(h),
)
% 360
),
"Height (m)",
"Wind Heading (degrees)",
extrapolation="constant",
)
self.wind_speed = Function(
lambda h: (
self.wind_velocity_x.get_value_opt(h) ** 2
+ self.wind_velocity_y.get_value_opt(h) ** 2
)
** 0.5,
(
self.wind_velocity_x.get_value_opt(h) ** 2
+ self.wind_velocity_y.get_value_opt(h) ** 2
)
** 0.5
),
"Height (m)",
"Wind Speed (m/s)",
extrapolation="constant",
Expand Down
40 changes: 27 additions & 13 deletions rocketpy/rocket/aero_surface/nose_cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,16 @@ def theta(x):
return np.arccos(1 - 2 * max(min(x / self.length, 1), 0))

self.y_nosecone = Function(
lambda x: self.base_radius
* (theta(x) - np.sin(2 * theta(x)) / 2 + (np.sin(theta(x)) ** 3) / 3)
** (0.5)
/ (np.pi**0.5)
lambda x: (
self.base_radius
* (
theta(x)
- np.sin(2 * theta(x)) / 2
+ (np.sin(theta(x)) ** 3) / 3
)
** (0.5)
/ (np.pi**0.5)
)
)

elif value in ["tangent", "tangentogive", "ogive"]:
Expand All @@ -253,15 +259,19 @@ def theta(x):
area = np.pi * self.base_radius**2
self.k = 1 - volume / (area * self.length)
self.y_nosecone = Function(
lambda x: np.sqrt(rho**2 - (min(x - self.length, 0)) ** 2)
+ (self.base_radius - rho)
lambda x: (
np.sqrt(rho**2 - (min(x - self.length, 0)) ** 2)
+ (self.base_radius - rho)
)
)

elif value == "elliptical":
self.k = 1 / 3
self.y_nosecone = Function(
lambda x: self.base_radius
* np.sqrt(1 - ((x - self.length) / self.length) ** 2)
lambda x: (
self.base_radius
* np.sqrt(1 - ((x - self.length) / self.length) ** 2)
)
)

elif value == "vonkarman":
Expand All @@ -271,15 +281,19 @@ def theta(x):
return np.arccos(1 - 2 * max(min(x / self.length, 1), 0))

self.y_nosecone = Function(
lambda x: self.base_radius
* (theta(x) - np.sin(2 * theta(x)) / 2) ** (0.5)
/ (np.pi**0.5)
lambda x: (
self.base_radius
* (theta(x) - np.sin(2 * theta(x)) / 2) ** (0.5)
/ (np.pi**0.5)
)
)
elif value == "parabolic":
self.k = 0.5
self.y_nosecone = Function(
lambda x: self.base_radius
* ((2 * x / self.length - (x / self.length) ** 2) / (2 - 1))
lambda x: (
self.base_radius
* ((2 * x / self.length - (x / self.length) ** 2) / (2 - 1))
)
)
elif value == "powerseries":
self.k = (2 * self.power) / ((2 * self.power) + 1)
Expand Down
10 changes: 6 additions & 4 deletions rocketpy/rocket/aero_surface/tail.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ def evaluate_lift_coefficient(self):
"""
# Calculate clalpha
self.clalpha = Function(
lambda mach: 2
* (
(self.bottom_radius / self.rocket_radius) ** 2
- (self.top_radius / self.rocket_radius) ** 2
lambda mach: (
2
* (
(self.bottom_radius / self.rocket_radius) ** 2
- (self.top_radius / self.rocket_radius) ** 2
)
),
"Mach",
f"Lift coefficient derivative for {self.name}",
Expand Down
7 changes: 4 additions & 3 deletions rocketpy/rocket/parachute.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ def __init__(
)

alpha, beta = self.noise_corr
self.noise_function = lambda: alpha * self.noise_signal[-1][
1
] + beta * np.random.normal(noise[0], noise[1])
self.noise_function = lambda: (
alpha * self.noise_signal[-1][1]
+ beta * np.random.normal(noise[0], noise[1])
)

self.prints = _ParachutePrints(self)

Expand Down
18 changes: 11 additions & 7 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,14 @@ def evaluate_stability_margin(self):
self.stability_margin.set_source(
lambda mach, time: (
(
self.center_of_mass.get_value_opt(time)
- self.cp_position.get_value_opt(mach)
(
self.center_of_mass.get_value_opt(time)
- self.cp_position.get_value_opt(mach)
)
/ (2 * self.radius)
)
/ (2 * self.radius)
* self._csys
)
* self._csys
)
return self.stability_margin

Expand All @@ -647,10 +649,12 @@ def evaluate_static_margin(self):
# Calculate static margin
self.static_margin.set_source(
lambda time: (
self.center_of_mass.get_value_opt(time)
- self.cp_position.get_value_opt(0)
(
self.center_of_mass.get_value_opt(time)
- self.cp_position.get_value_opt(0)
)
/ (2 * self.radius)
)
/ (2 * self.radius)
)
# Change sign if coordinate system is upside down
self.static_margin *= self._csys
Expand Down
64 changes: 36 additions & 28 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,12 @@ def __simulate(self, verbose):
lambda self, parachute_porosity=parachute.porosity: setattr(
self, "parachute_porosity", parachute_porosity
),
lambda self,
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
self,
"parachute_added_mass_coefficient",
added_mass_coefficient,
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: (
setattr(
self,
"parachute_added_mass_coefficient",
added_mass_coefficient,
)
),
]
self.flight_phases.add_phase(
Expand Down Expand Up @@ -1020,33 +1021,40 @@ def __simulate(self, verbose):
i += 1
# Create flight phase for time after inflation
callbacks = [
lambda self,
parachute_cd_s=parachute.cd_s: setattr(
self, "parachute_cd_s", parachute_cd_s
lambda self, parachute_cd_s=parachute.cd_s: (
setattr(
self,
"parachute_cd_s",
parachute_cd_s,
)
),
lambda self,
parachute_radius=parachute.radius: setattr(
self,
"parachute_radius",
parachute_radius,
lambda self, parachute_radius=parachute.radius: (
setattr(
self,
"parachute_radius",
parachute_radius,
)
),
lambda self,
parachute_height=parachute.height: setattr(
self,
"parachute_height",
parachute_height,
lambda self, parachute_height=parachute.height: (
setattr(
self,
"parachute_height",
parachute_height,
)
),
lambda self,
parachute_porosity=parachute.porosity: setattr(
self,
"parachute_porosity",
parachute_porosity,
lambda self, parachute_porosity=parachute.porosity: (
setattr(
self,
"parachute_porosity",
parachute_porosity,
)
),
lambda self,
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
self,
"parachute_added_mass_coefficient",
added_mass_coefficient,
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: (
setattr(
self,
"parachute_added_mass_coefficient",
added_mass_coefficient,
)
),
]
self.flight_phases.add_phase(
Expand Down
Loading