Skip to content

Commit a1b1d1f

Browse files
committed
MNT: make format changes
- MNT: used make format to correct formatting mistakes on all the new classes.
1 parent 464212d commit a1b1d1f

File tree

6 files changed

+74
-51
lines changed

6 files changed

+74
-51
lines changed

rocketpy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
MassBasedTank,
1818
MassFlowRateBasedTank,
1919
Motor,
20-
SolidMotor,
2120
PointMassMotor,
21+
SolidMotor,
2222
SphericalTank,
2323
Tank,
2424
TankGeometry,
@@ -36,9 +36,9 @@
3636
LinearGenericSurface,
3737
NoseCone,
3838
Parachute,
39+
PointMassRocket,
3940
RailButtons,
4041
Rocket,
41-
PointMassRocket,
4242
Tail,
4343
TrapezoidalFins,
4444
)

rocketpy/motors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from .hybrid_motor import HybridMotor
44
from .liquid_motor import LiquidMotor
55
from .motor import GenericMotor, Motor
6+
from .point_mass_motor import PointMassMotor
67
from .solid_motor import SolidMotor
7-
from .pointmassmotor import PointMassMotor
88
from .tank import (
99
LevelBasedTank,
1010
MassBasedTank,

rocketpy/motors/pointmassmotor.py renamed to rocketpy/motors/point_mass_motor.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from functools import cached_property
2-
import numpy as np
32
from typing import Callable
3+
4+
import numpy as np
5+
46
from rocketpy.mathutils.function import Function, funcify_method
7+
58
from .motor import Motor
69

10+
711
class PointMassMotor(Motor):
812
"""Motor modeled as a point mass for 3-DOF simulations."""
913

@@ -78,14 +82,25 @@ def _zero_inertia_func(self):
7882
return Function(0.0)
7983

8084
@cached_property
81-
def propellant_I_11(self): return self._zero_inertia_func()
85+
def propellant_I_11(self):
86+
return self._zero_inertia_func()
87+
8288
@cached_property
83-
def propellant_I_12(self): return self._zero_inertia_func()
89+
def propellant_I_12(self):
90+
return self._zero_inertia_func()
91+
8492
@cached_property
85-
def propellant_I_13(self): return self._zero_inertia_func()
93+
def propellant_I_13(self):
94+
return self._zero_inertia_func()
95+
8696
@cached_property
87-
def propellant_I_22(self): return self._zero_inertia_func()
97+
def propellant_I_22(self):
98+
return self._zero_inertia_func()
99+
88100
@cached_property
89-
def propellant_I_23(self): return self._zero_inertia_func()
101+
def propellant_I_23(self):
102+
return self._zero_inertia_func()
103+
90104
@cached_property
91-
def propellant_I_33(self): return self._zero_inertia_func()
105+
def propellant_I_33(self):
106+
return self._zero_inertia_func()

rocketpy/rocket/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
)
1515
from rocketpy.rocket.components import Components
1616
from rocketpy.rocket.parachute import Parachute
17-
from rocketpy.rocket.rocket import Rocket
18-
from rocketpy.rocket.rocket import PointMassRocket
17+
from rocketpy.rocket.rocket import PointMassRocket, Rocket

rocketpy/rocket/rocket.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,7 @@ def from_dict(cls, data):
20042004

20052005
return rocket
20062006

2007+
20072008
class PointMassRocket(Rocket):
20082009
def __init__(
20092010
self,
@@ -2065,31 +2066,49 @@ def center_of_mass(self, value):
20652066
# Inertia Properties (always zero)
20662067
# ------------------------------------------------------------------
20672068
@property
2068-
def dry_I_11(self): return 0.0
2069+
def dry_I_11(self):
2070+
return 0.0
2071+
20692072
@dry_I_11.setter
2070-
def dry_I_11(self, value): self._dry_I_11 = 0.0
2073+
def dry_I_11(self, value):
2074+
self._dry_I_11 = 0.0
20712075

20722076
@property
2073-
def dry_I_22(self): return 0.0
2077+
def dry_I_22(self):
2078+
return 0.0
2079+
20742080
@dry_I_22.setter
2075-
def dry_I_22(self, value): self._dry_I_22 = 0.0
2081+
def dry_I_22(self, value):
2082+
self._dry_I_22 = 0.0
20762083

20772084
@property
2078-
def dry_I_33(self): return 0.0
2085+
def dry_I_33(self):
2086+
return 0.0
2087+
20792088
@dry_I_33.setter
2080-
def dry_I_33(self, value): self._dry_I_33 = 0.0
2089+
def dry_I_33(self, value):
2090+
self._dry_I_33 = 0.0
20812091

20822092
@property
2083-
def dry_I_12(self): return 0.0
2093+
def dry_I_12(self):
2094+
return 0.0
2095+
20842096
@dry_I_12.setter
2085-
def dry_I_12(self, value): self._dry_I_12 = 0.0
2097+
def dry_I_12(self, value):
2098+
self._dry_I_12 = 0.0
20862099

20872100
@property
2088-
def dry_I_13(self): return 0.0
2101+
def dry_I_13(self):
2102+
return 0.0
2103+
20892104
@dry_I_13.setter
2090-
def dry_I_13(self, value): self._dry_I_13 = 0.0
2105+
def dry_I_13(self, value):
2106+
self._dry_I_13 = 0.0
20912107

20922108
@property
2093-
def dry_I_23(self): return 0.0
2109+
def dry_I_23(self):
2110+
return 0.0
2111+
20942112
@dry_I_23.setter
2095-
def dry_I_23(self, value): self._dry_I_23 = 0.0
2113+
def dry_I_23(self, value):
2114+
self._dry_I_23 = 0.0

rocketpy/simulation/flight.py

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
import warnings
55
from copy import deepcopy
66
from functools import cached_property
7-
from ..motors.pointmassmotor import PointMassMotor
8-
from ..rocket import PointMassRocket
7+
98
import numpy as np
109
import simplekml
1110
from scipy.integrate import BDF, DOP853, LSODA, RK23, RK45, OdeSolver, Radau
1211

1312
from ..mathutils.function import Function, funcify_method
1413
from ..mathutils.vector_matrix import Matrix, Vector
14+
from ..motors.point_mass_motor import PointMassMotor
1515
from ..plots.flight_plots import _FlightPlots
1616
from ..prints.flight_prints import _FlightPrints
17+
from ..rocket import PointMassRocket
1718
from ..tools import (
1819
calculate_cubic_hermite_coefficients,
1920
euler313_to_quaternions,
@@ -1195,14 +1196,17 @@ def __init_solver_monitors(self):
11951196
def __init_equations_of_motion(self):
11961197
"""Initialize equations of motion."""
11971198
# Determine if a point-mass model is used.
1198-
is_point_mass = (
1199-
isinstance(self.rocket, PointMassRocket)
1200-
or (self.rocket._motors and isinstance(self.rocket._motors[0], PointMassMotor))
1199+
is_point_mass = isinstance(self.rocket, PointMassRocket) or (
1200+
hasattr(self.rocket, "motor")
1201+
and isinstance(self.rocket.motor, PointMassMotor)
12011202
)
12021203
# Set simulation mode based on model type.
12031204
if is_point_mass:
12041205
if self.simulation_mode != "3 DOF":
1205-
warnings.warn("A point-mass model was detected. Simulation mode should be '3 DOF'.", UserWarning)
1206+
warnings.warn(
1207+
"A point-mass model was detected. Simulation mode should be '3 DOF'.",
1208+
UserWarning,
1209+
)
12061210
self.simulation_mode = "3 DOF"
12071211
else:
12081212
self.simulation_mode = self.simulation_mode
@@ -1213,14 +1217,15 @@ def __init_equations_of_motion(self):
12131217
self.u_dot_generalized = self.u_dot_generalized_3dof
12141218
elif self.simulation_mode == "6 DOF":
12151219
if self.equations_of_motion == "solid_propulsion":
1216-
self.u_dot_generalized = self.u_dot_6dof
1220+
self.u_dot_generalized = self.u_dot
12171221
else:
1218-
self.u_dot_generalized = self.u_dot_generalized_6dof
1222+
self.u_dot_generalized = self.u_dot_generalized
12191223
else:
12201224
raise ValueError(
12211225
f"Invalid simulation_mode: {self.simulation_mode}. "
12221226
"Must be '3 DOF' or '6 DOF'."
12231227
)
1228+
12241229
def __init_controllers(self):
12251230
"""Initialize controllers and sensors"""
12261231
self._controllers = self.rocket._controllers[:]
@@ -1580,17 +1585,8 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals
15801585
R3 += Z
15811586
# Linear acceleration
15821587
L = [
1583-
(
1584-
R1
1585-
1586-
)
1587-
/ total_mass_at_t,
1588-
(
1589-
R2
1590-
1591-
)
1592-
/ total_mass_at_t,
1593-
1588+
(R1) / total_mass_at_t,
1589+
(R2) / total_mass_at_t,
15941590
(R3 - b * propellant_mass_at_t * (alpha2 - omega1 * omega3) + net_thrust)
15951591
/ total_mass_at_t,
15961592
]
@@ -1622,7 +1618,6 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals
16221618

16231619
if post_processing:
16241620
self.__post_processed_variables.append(
1625-
16261621
[
16271622
t,
16281623
ax,
@@ -1700,11 +1695,7 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False):
17001695
air_brake.deployment_level, mach
17011696
)
17021697
ab_force = (
1703-
-0.5
1704-
* rho
1705-
* free_stream_speed**2
1706-
* air_brake.reference_area
1707-
* ab_cd
1698+
-0.5 * rho * free_stream_speed**2 * air_brake.reference_area * ab_cd
17081699
)
17091700
if air_brake.override_rocket_drag:
17101701
R3 = ab_force
@@ -1759,7 +1750,6 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False):
17591750
if post_processing:
17601751
self.__post_processed_variables.append(
17611752
[t, *v_dot, *w_dot, R1, R2, R3, 0, 0, 0]
1762-
17631753
)
17641754

17651755
return u_dot
@@ -1769,7 +1759,7 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too
17691759
rocket is flying in 6 DOF motion in space and significant mass variation
17701760
effects exist. Typical flight phases include powered ascent after launch
17711761
rail.
1772-
1762+
17731763
Parameters
17741764
----------
17751765
t : float

0 commit comments

Comments
 (0)