Skip to content

Commit d4dc989

Browse files
committed
MNT: lint cleanup and adding 3dof to init
-MNT: cleaned up PointMassRocket rocket.py for linters. -ENH: including PointMassMotor in motors and rocketpy __init__.py -MNT: adopting to structural changes in 3dof on the 3_DOF_TRIAL.ipynb -MNT: including pointmassmotor in settings.json as a spell word
1 parent e299a30 commit d4dc989

File tree

6 files changed

+24
-33
lines changed

6 files changed

+24
-33
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
"outerboundaryis",
240240
"overshootable",
241241
"planform",
242+
"pointmassmotor",
242243
"polystyle",
243244
"powerseries",
244245
"Prandtl",

docs/examples/3_DOF_TRIAL.ipynb

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"import numpy as np\n",
1212
"from scipy.signal import savgol_filter\n",
1313
"from rocketpy.rocket.rocket import PointMassRocket\n",
14-
"from rocketpy import Flight, Environment, Function\n"
14+
"from rocketpy import Flight, Environment, Function, PointMassMotor\n"
1515
]
1616
},
1717
{
@@ -106,21 +106,9 @@
106106
},
107107
{
108108
"cell_type": "code",
109-
"execution_count": 3,
109+
"execution_count": 5,
110110
"metadata": {},
111-
"outputs": [
112-
{
113-
"ename": "NameError",
114-
"evalue": "name 'PointMassMotor' is not defined",
115-
"output_type": "error",
116-
"traceback": [
117-
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
118-
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
119-
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 3\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mthrust_profile\u001b[39m(t):\n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[32m250\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[32m0\u001b[39m <= t <= \u001b[32m3\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m \u001b[32m0\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m motor = \u001b[43mPointMassMotor\u001b[49m(\n\u001b[32m 7\u001b[39m thrust_source=thrust_profile,\n\u001b[32m 8\u001b[39m dry_mass=\u001b[32m1.0\u001b[39m,\n\u001b[32m 9\u001b[39m thrust_curve=thrust_profile,\n\u001b[32m 10\u001b[39m propellant_initial_mass=\u001b[32m0.5\u001b[39m,\n\u001b[32m 11\u001b[39m propellant_final_mass=\u001b[32m0.0\u001b[39m,\n\u001b[32m 12\u001b[39m burn_time=\u001b[32m3.0\u001b[39m\n\u001b[32m 13\u001b[39m )\n",
120-
"\u001b[31mNameError\u001b[39m: name 'PointMassMotor' is not defined"
121-
]
122-
}
123-
],
111+
"outputs": [],
124112
"source": [
125113
"# Define Motor\n",
126114
"# Thrust profile: constant for 3 seconds\n",
@@ -130,7 +118,6 @@
130118
"motor = PointMassMotor(\n",
131119
" thrust_source=thrust_profile,\n",
132120
" dry_mass=1.0,\n",
133-
" thrust_curve=thrust_profile,\n",
134121
" propellant_initial_mass=0.5,\n",
135122
" propellant_final_mass=0.0,\n",
136123
" burn_time=3.0\n",
@@ -139,9 +126,21 @@
139126
},
140127
{
141128
"cell_type": "code",
142-
"execution_count": 4,
129+
"execution_count": 6,
143130
"metadata": {},
144-
"outputs": [],
131+
"outputs": [
132+
{
133+
"ename": "TypeError",
134+
"evalue": "PointMassRocket.__init__() got an unexpected keyword argument 'drag_coefficient'",
135+
"output_type": "error",
136+
"traceback": [
137+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
138+
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
139+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[6]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# Define Rocket\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m rocket = \u001b[43mPointMassRocket\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmass\u001b[49m\u001b[43m=\u001b[49m\u001b[32;43m2.0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdrag_coefficient\u001b[49m\u001b[43m=\u001b[49m\u001b[32;43m0.75\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 3\u001b[39m rocket.add_motor(motor)\n",
140+
"\u001b[31mTypeError\u001b[39m: PointMassRocket.__init__() got an unexpected keyword argument 'drag_coefficient'"
141+
]
142+
}
143+
],
145144
"source": [
146145
"# Define Rocket\n",
147146
"rocket = PointMassRocket(mass=2.0, drag_coefficient=0.75)\n",

rocketpy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
MassFlowRateBasedTank,
1919
Motor,
2020
SolidMotor,
21+
PointMassMotor,
2122
SphericalTank,
2223
Tank,
2324
TankGeometry,

rocketpy/motors/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .liquid_motor import LiquidMotor
55
from .motor import GenericMotor, Motor
66
from .solid_motor import SolidMotor
7+
from .pointmassmotor import PointMassMotor
78
from .tank import (
89
LevelBasedTank,
910
MassBasedTank,

rocketpy/motors/pointmassmotor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from functools import cached_property
2+
23
import numpy as np
3-
import csv
4-
import math
5-
from typing import Callable # Import Callable from the typing module
4+
5+
from typing import Callable
66

77
from rocketpy.mathutils.function import Function, funcify_method
88
from .motor import Motor

rocketpy/rocket/rocket.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,38 +2022,27 @@ def __init__(self, mass, radius=0.05):
20222022
power_off_drag=power_off_drag,
20232023
power_on_drag=power_on_drag,
20242024
)
2025-
@cached_property
2026-
@funcify_method("Time (s)", "I_xx (kg·m²)")
2025+
20272026
def I_11(self) -> Function:
20282027
"""Returns the moment of inertia around the x-axis for a point mass (always 0)."""
20292028
return Function(0)
20302029

2031-
@cached_property
2032-
@funcify_method("Time (s)", "I_22 (kg·m²)")
20332030
def I_22(self) -> Function:
20342031
"""Returns the moment of inertia around the y-axis for a point mass (always 0)."""
20352032
return Function(0)
20362033

2037-
@cached_property
2038-
@funcify_method("Time (s)", "I_33 (kg·m²)")
20392034
def I_33(self) -> Function:
20402035
"""Returns the moment of inertia around the z-axis for a point mass (always 0)."""
20412036
return Function(0)
20422037

2043-
@cached_property
2044-
@funcify_method("Time (s)", "I_12 (kg·m²)")
20452038
def I_12(self) -> Function:
20462039
"""Returns the product of inertia I_xy for a point mass (always 0)."""
20472040
return Function(0)
20482041

2049-
@cached_property
2050-
@funcify_method("Time (s)", "I_13 (kg·m²)")
20512042
def I_13(self) -> Function:
20522043
"""Returns the product of inertia I_xz for a point mass (always 0)."""
20532044
return Function(0)
20542045

2055-
@cached_property
2056-
@funcify_method("Time (s)", "I_23 (kg·m²)")
20572046
def I_23(self) -> Function:
20582047
"""Returns the product of inertia I_yz for a point mass (always 0)."""
20592048
return Function(0)

0 commit comments

Comments
 (0)