Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cc439b7
ENH: change of variables between rocket and motor
ompro07 Jun 2, 2022
5a5f6b4
Fix code style issues with Black
lint-action Jun 2, 2022
77b0c72
initializing distanceNozzlePropellant parameter
Gui-FernandesBR Jun 5, 2022
326ef16
Fix code style issues with Black
lint-action Jun 5, 2022
f78fa73
ENH: change variable name and notebooks adjustments
ompro07 Jun 8, 2022
6c94e26
Fix code style issues with Black
lint-action Jun 8, 2022
3009a86
adding missed variable to notebook
Gui-FernandesBR Jun 9, 2022
494c934
update parachute_drop_from_helicopter
Gui-FernandesBR Jun 9, 2022
9b12588
simple update on environment_class_usage
Gui-FernandesBR Jun 9, 2022
161eff4
adding missed variables to getting_started
Gui-FernandesBR Jun 9, 2022
b5a58b9
adding missed variable to test.py
Gui-FernandesBR Jun 9, 2022
06af77a
remove unused libraries
Gui-FernandesBR Jun 9, 2022
d7743a3
added missed variable to test_flight.py
Gui-FernandesBR Jun 9, 2022
c536f51
adding missed variable to test_rocket.py
Gui-FernandesBR Jun 9, 2022
e443b82
missed variable to test_solidmotor
Gui-FernandesBR Jun 9, 2022
7223987
modify variables test_acceptance
Gui-FernandesBR Jun 9, 2022
4f9b556
Fix code style issues with Black
lint-action Jun 9, 2022
a3c8e1b
adjust distanceNozzleMotorReference on test files
Gui-FernandesBR Jun 9, 2022
a9765d6
Fix code style issues with Black
lint-action Jun 9, 2022
8d99403
BUG: add missing dimensions to distanceNozzleMotorReference in dimens…
giovaniceotto Jun 15, 2022
1c05fe3
FIX: correct distanceNozzleMotorReference value and remove old comments
giovaniceotto Jun 16, 2022
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
59 changes: 44 additions & 15 deletions rocketpy/Motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(
self,
thrustSource,
burnOut,
distanceNozzlePropellant,
Comment thread
Gui-FernandesBR marked this conversation as resolved.
Outdated
nozzleRadius=0.0335,
throatRadius=0.0114,
reshapeThrustCurve=False,
Expand All @@ -137,6 +138,12 @@ def __init__(
Function. See help(Function). Thrust units are Newtons.
burnOut : int, float
Motor burn out time in seconds.
distanceNozzlePropellant : int, float
Distance from nozzle outlet to the motor reference point, which
for Solids and Hybrids is the center of mass of the solid propellant,
in meters. Generally positive, meaning a positive position in the
z axis which has an origin in the rocket's center of mass (without
propellant) and points towards the nose cone.
Comment thread
Gui-FernandesBR marked this conversation as resolved.
Outdated
nozzleRadius : int, float, optional
Motor's nozzle outlet radius in meters. Used to calculate Kn curve.
Optional if the Kn curve is not interesting. Its value does not impact
Expand Down Expand Up @@ -166,6 +173,9 @@ def __init__(
self.interpolate = interpolationMethod
self.burnOutTime = burnOut

# Geometric parameters
self.distanceNozzlePropellant = distanceNozzlePropellant

# Check if thrustSource is csv, eng, function or other
if isinstance(thrustSource, str):
# Determine if csv or eng
Expand Down Expand Up @@ -275,7 +285,8 @@ def reshapeThrustCurve(
# Reshape thrust - set total impulse
if oldTotalImpulse is None:
oldTotalImpulse = self.evaluateTotalImpulse()
self.thrust.source[:, 1] = (totalImpulse / oldTotalImpulse) * thrustArray
self.thrust.source[:, 1] = (
totalImpulse / oldTotalImpulse) * thrustArray
self.thrust.setInterpolation(self.interpolate)

# Store total impulse
Expand Down Expand Up @@ -472,7 +483,8 @@ def importEng(self, fileName):
description = line.strip().split(" ")
else:
# Extract thrust curve data points
time, thrust = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", line)
time, thrust = re.findall(
r"[-+]?\d*\.\d+|[-+]?\d+", line)
dataPoints.append([float(time), float(thrust)])

# Return all extract content
Expand Down Expand Up @@ -589,7 +601,8 @@ def allInfo(self):
print("Grain Outer Radius: " + str(self.grainOuterRadius) + " m")
print("Grain Inner Radius: " + str(self.grainInitialInnerRadius) + " m")
print("Grain Height: " + str(self.grainInitialHeight) + " m")
print("Grain Volume: " + "{:.3f}".format(self.grainInitialVolume) + " m3")
print("Grain Volume: " +
"{:.3f}".format(self.grainInitialVolume) + " m3")
print("Grain Mass: " + "{:.3f}".format(self.grainInitialMass) + " kg")

# Print motor details
Expand Down Expand Up @@ -724,6 +737,7 @@ def __init__(
self,
thrustSource,
burnOut,
distanceNozzlePropellant,
grainNumber,
grainDensity,
grainOuterRadius,
Expand Down Expand Up @@ -793,6 +807,9 @@ def __init__(
self.interpolate = interpolationMethod
self.burnOutTime = burnOut

# Geometric parameters
self.distanceNozzlePropellant = distanceNozzlePropellant

# Check if thrustSource is csv, eng, function or other
if isinstance(thrustSource, str):
# Determine if csv or eng
Expand Down Expand Up @@ -973,9 +990,11 @@ def geometryDot(y, t):
grainMassDot = self.massDot(t) / self.grainNumber
rI, h = y
rIDot = (
-0.5 * grainMassDot / (density * np.pi * (rO**2 - rI**2 + rI * h))
-0.5 * grainMassDot /
(density * np.pi * (rO**2 - rI**2 + rI * h))
)
hDot = 1.0 * grainMassDot / (density * np.pi * (rO**2 - rI**2 + rI * h))
hDot = 1.0 * grainMassDot / \
(density * np.pi * (rO**2 - rI**2 + rI * h))
return [rIDot, hDot]

# Solve the system of differential equations
Expand Down Expand Up @@ -1045,7 +1064,8 @@ def evaluateBurnRate(self):
burnRate : Function
Rate of progression of the inner radius during the combustion.
"""
self.burnRate = (-1) * self.massDot / (self.burnArea * self.grainDensity)
self.burnRate = (-1) * self.massDot / \
(self.burnArea * self.grainDensity)
self.burnRate.setOutputs("Burn Rate (m/s)")
return self.burnRate

Expand Down Expand Up @@ -1253,7 +1273,8 @@ def allInfo(self):
print("Grain Outer Radius: " + str(self.grainOuterRadius) + " m")
print("Grain Inner Radius: " + str(self.grainInitialInnerRadius) + " m")
print("Grain Height: " + str(self.grainInitialHeight) + " m")
print("Grain Volume: " + "{:.3f}".format(self.grainInitialVolume) + " m3")
print("Grain Volume: " +
"{:.3f}".format(self.grainInitialVolume) + " m3")
print("Grain Mass: " + "{:.3f}".format(self.grainInitialMass) + " kg")

# Print motor details
Expand Down Expand Up @@ -1388,14 +1409,15 @@ def __init__(
self,
thrustSource,
burnOut,
distanceNozzlePropellant,
grainNumber,
grainDensity,
grainOuterRadius,
grainInitialInnerRadius,
grainInitialHeight,
oxidizerTankRadius,
oxidizerTankHeight,
oxidizerInitialPresure,
oxidizerInitialPressure,
oxidizerDensity,
oxidizerMolarMass,
oxidizerInitialVolume,
Expand Down Expand Up @@ -1438,10 +1460,10 @@ def __init__(
Oxidizer Tank inner radius.
oxidizerTankHeight :
Oxidizer Tank Height.
oxidizerInitialPresure :
Initial presure of the oxidizer tank, could be equal to the pressure of the source cylinder in atm.
oxidizerInitialPressure :
Initial pressure of the oxidizer tank, could be equal to the pressure of the source cylinder in atm.
oxidizerDensity :
Oxidizer theoretical density in liquit state, for N2O is equal to 1.98 (Kg/m^3).
Oxidizer theoretical density in liquid state, for N2O is equal to 1.98 (Kg/m^3).
oxidizerMolarMass :
Oxidizer molar mass, for the N2O is equal to 44.01 (g/mol).
oxidizerInitialVolume :
Expand Down Expand Up @@ -1481,6 +1503,9 @@ def __init__(
self.interpolate = interpolationMethod
self.burnOutTime = burnOut

# Geometric parameters
self.distanceNozzlePropellant = distanceNozzlePropellant

# Check if thrustSource is csv, eng, function or other
if isinstance(thrustSource, str):
# Determine if csv or eng
Expand Down Expand Up @@ -1519,6 +1544,7 @@ def __init__(
# Grain and nozzle parameters
self.nozzleRadius = nozzleRadius
self.throatRadius = throatRadius
# Propellant parameters
self.grainNumber = grainNumber
self.grainSeparation = grainSeparation
self.grainDensity = grainDensity
Expand All @@ -1527,7 +1553,7 @@ def __init__(
self.grainInitialHeight = grainInitialHeight
self.oxidizerTankRadius = oxidizerTankRadius
self.oxidizerTankHeight = oxidizerTankHeight
self.oxidizerInitialPresure = oxidizerInitialPresure
self.oxidizerInitialPressure = oxidizerInitialPressure
self.oxidizerDensity = oxidizerDensity
self.oxidizerMolarMass = oxidizerMolarMass
self.oxidizerInitialVolume = oxidizerInitialVolume
Expand Down Expand Up @@ -1675,9 +1701,11 @@ def geometryDot(y, t):
grainMassDot = self.massDot(t) / self.grainNumber
rI, h = y
rIDot = (
-0.5 * grainMassDot / (density * np.pi * (rO**2 - rI**2 + rI * h))
-0.5 * grainMassDot /
(density * np.pi * (rO**2 - rI**2 + rI * h))
)
hDot = 1.0 * grainMassDot / (density * np.pi * (rO**2 - rI**2 + rI * h))
hDot = 1.0 * grainMassDot / \
(density * np.pi * (rO**2 - rI**2 + rI * h))
return [rIDot, hDot]

# Solve the system of differential equations
Expand Down Expand Up @@ -1747,7 +1775,8 @@ def evaluateBurnRate(self):
burnRate : Function
Rate of progression of the inner radius during the combustion.
"""
self.burnRate = (-1) * self.massDot / (self.burnArea * self.grainDensity)
self.burnRate = (-1) * self.massDot / \
(self.burnArea * self.grainDensity)
self.burnRate.setOutputs("Burn Rate (m/s)")
return self.burnRate

Expand Down
47 changes: 26 additions & 21 deletions rocketpy/Rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class Rocket:
Rocket.distanceRocketNozzle : float
Distance between rocket's center of mass, without propellant,
to the exit face of the nozzle, in meters. Always positive.
Rocket.distanceRocketPropellant : float
Rocket.distanceRocketMotorReference : float
Distance between rocket's center of mass, without propellant,
to the motor reference point, which for solid and hybrid motors
is the center of mass of solid propellant, in meters. Always positive.
to the motor reference point, for solid and hybrid motor
the reference point is the center of mass of solid propellant,
in meters. Always positive.

Mass and Inertia attributes:
Rocket.mass : float
Expand Down Expand Up @@ -113,7 +114,6 @@ def __init__(
inertiaZ,
radius,
distanceRocketNozzle,
distanceRocketPropellant,
powerOffDrag,
powerOnDrag,
):
Expand All @@ -125,12 +125,12 @@ def __init__(
motor : Motor
Motor used in the rocket. See Motor class for more information.
mass : int, float
Unloaded rocket total mass (without propelant) in kg.
Unloaded rocket total mass (without propellant) in kg.
inertiaI : int, float
Unloaded rocket lateral (perpendicular to axis of symmetry)
moment of inertia (without propelant) in kg m^2.
moment of inertia (without propellant) in kg m^2.
inertiaZ : int, float
Unloaded rocket axial moment of inertia (without propelant)
Unloaded rocket axial moment of inertia (without propellant)
in kg m^2.
radius : int, float
Rocket biggest outer radius in meters.
Expand All @@ -139,12 +139,12 @@ def __init__(
in meters. Generally negative, meaning a negative position in the
z axis which has an origin in the rocket's center of mass (without
propellant) and points towards the nose cone.
distanceRocketPropellant : int, float
distanceRocketMotorReference : int, float
Comment thread
Gui-FernandesBR marked this conversation as resolved.
Distance from rocket's unloaded center of mass to the motor reference
point, which for solid and hybrid motor the is the center of mass of
solid propellant, in meters. Generally negative, meaning a negative
position in the z axis which has an origin in the rocket's center of
mass (with out propellant) and points towards the nose cone.
point, for solid and hybrid motor the reference point is the center
of mass of solid propellant, in meters. Generally negative, meaning a negative
position in the z axis which has an origin in the rocket's center
of mass (with out propellant) and points towards the nose cone.
powerOffDrag : int, float, callable, string, array
Rocket's drag coefficient when the motor is off. Can be given as an
entry to the Function class. See help(Function) for more
Expand All @@ -162,22 +162,30 @@ def __init__(
-------
None
"""
# Define motor to be used
self.motor = motor

# Center of mass distance to points of interest
self.distanceRocketNozzle = distanceRocketNozzle
self.distanceRocketMotorReference = (
self.distanceRocketNozzle + self.motor.distanceNozzlePropellant
)

# Define rocket inertia attributes in SI units
self.mass = mass
self.inertiaI = inertiaI
self.inertiaZ = inertiaZ

self.centerOfMass = (
(distanceRocketPropellant - motor.yCM) * motor.mass / (mass + motor.mass)
(self.distanceRocketMotorReference - self.motor.yCM)
* motor.mass
/ (mass + motor.mass)
)

# Define rocket geometrical parameters in SI units
self.radius = radius
self.area = np.pi * self.radius**2

# Center of mass distance to points of interest
self.distanceRocketNozzle = distanceRocketNozzle
self.distanceRocketPropellant = distanceRocketPropellant

# Eccentricity data initialization
self.cpEccentricityX = 0
self.cpEccentricityY = 0
Expand Down Expand Up @@ -213,9 +221,6 @@ def __init__(
"constant",
)

# Define motor to be used
self.motor = motor

# Important dynamic inertial quantities
self.reducedMass = None
self.totalMass = None
Expand Down Expand Up @@ -963,7 +968,7 @@ def allInfo(self):
)
print(
"Rocket Center of Mass - Motor reference point: "
+ str(self.distanceRocketPropellant)
+ str(self.distanceRocketMotorReference)
+ " m"
)
print(
Expand Down