rocketPy package¶
Submodules¶
rocketPy.components module¶
Creates the components of a rocket. Base classes and the specific useful components are created.
All components inherit from Component
From here, it splits into
InternalComponent
or ExternalComponent
where the difference is used to help the drag model, and plotting.
-
class
rocketPy.components.
BodyTube
(name='Body Tube', mass=None, inertia=None, diameter=None, length=None, wall_thickness=<Quantity(2, 'millimeter')>, material=None)[source]¶ Bases:
rocketPy.components.ExternalComponent
-
estimate_inertia
()[source]¶ Generic method to estimate the mass of the component - assume inertia is 0. This method should be overridden for each component specified
-
-
class
rocketPy.components.
Component
(name='Component', mass=None, inertia=None)[source]¶ Bases:
object
Base class for all components
- Parameters
name (str) – Name of component. Defaults to ‘Component’.
mass (function or None or Quantity) – Mass of component. Defaults to None. If
None
: calls theself.estimate_mass()
method to assign mass. Iffunction
: calls the function and assigns mass IfPint.Quantity
: assigns mass directly.inertia (function or None or Quantity) – Assigns inertia of the rocket, in (I_xx, I_yy, I_zz). Rest of the components are assumed to be 0. Defaults to None. If
None
: calls theself.estimate_inertia()
method to assign inertia. Iffunction
: calls the function to assign the inertia. The function must return a tuple of (I_xx, I_yy, I_zz) Iftuple of Pint.Quantity
: assigns the inertia direction. The tuple must be (I_xx, I_yy, I_zz) with each being a Pint.Quantity of the right units.
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>>
-
I_xx
¶ Description of parameter I_xx.
- Type
type
-
I_yy
¶ Description of parameter I_yy.
- Type
type
-
I_zz
¶ Description of parameter I_zz.
- Type
type
-
x_ref
¶ Description of parameter x_ref.
- Type
type
-
y_ref
¶ Description of parameter y_ref.
- Type
type
-
z_ref
¶ Description of parameter z_ref.
- Type
type
-
A_ref
¶ Description of parameter A_ref.
- Type
type
-
name
¶
-
mass
¶
-
estimate_inertia
()[source] Generic method to estimate the mass of the component - assume inertia is 0. This method should be overridden for each component specified
-
estimate_mass
()[source] Generic method to estimate the mass of the component - assume mass is 0. This method should be overridden for each component specified
-
plot
(ax=None, rotation=<Quantity(0, 'degree')>, unit=<Unit('meter')>)[source]¶ Plots the component.
- Parameters
ax (type) – Description of parameter ax. Defaults to None.
rotation (type) – Description of parameter rotation. Defaults to 0*ureg.degree.
unit (type) – Description of parameter unit. Defaults to ureg.m.
- Returns
Description of returned object.
- Return type
type
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>>
-
set_position
(start_of=None, end_of=None, middle_of=None, after=None, offset=<Quantity(0, 'meter')>)[source]¶ Defines the x_ref of this component relative to other components.
- Parameters
start_of (Component) – If not None, aligns self with other. Defaults to None.
end_of (Component) – If not None, aligns end of self with other. Defaults to None.
middle_of (Component) – If not None, aligns midpoints of self and other. Defaults to None.
after (Component) – If not None, aligns start of self to end of other. Defaults to None.
offset (Pint.Quantity) – Follows rules as above, but adds
offset
to self.x_ref. Defaults to 0*ureg.m.
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>>
-
class
rocketPy.components.
Cylinder
(name='Internal Cylinder', mass=None, inertia=None, diameter=<Quantity(6, 'inch')>, length=<Quantity(6, 'inch')>, density=None)[source]¶
-
class
rocketPy.components.
ExternalComponent
(name='External Component', mass=None, inertia=None, A_ref=<Quantity(28.274333882308138, 'inch ** 2')>)[source]¶
-
class
rocketPy.components.
FinSet
(name='Fins', mass=None, inertia=None, n=None, span=None, root_chord=None, tip_chord=None, mid_sweep=None, tube_dia=None, thickness=None, material=None)[source]¶ Bases:
rocketPy.components.ExternalComponent
-
estimate_inertia
()[source]¶ Generic method to estimate the mass of the component - assume inertia is 0. This method should be overridden for each component specified
-
-
class
rocketPy.components.
InternalComponent
(name='Internal Component', mass=None, inertia=None)[source]¶
-
class
rocketPy.components.
NoseCone
(name='Nose Cone', mass=None, inertia=None, shape='Conical', diameter=None, length=None, fineness=None, wall_thickness=<Quantity(2, 'millimeter')>, material=None)[source]¶
-
class
rocketPy.components.
Transition
(name='Transition', mass=None, inertia=None, fore_dia=None, aft_dia=None, length=None, wall_thickness=<Quantity(2, 'millimeter')>, material=None)[source]¶ Bases:
rocketPy.components.ExternalComponent
-
estimate_inertia
()[source]¶ Generic method to estimate the mass of the component - assume inertia is 0. This method should be overridden for each component specified
-
rocketPy.materials module¶
Defines all the materials and their material properties. Base class Material allows for users to define a material, while some specific commonly used materials are predefined to help speed up the design process. Users should check that the right material properties are assumed for their parts.
-
class
rocketPy.materials.
Acrylic
(name='Acrylic')[source]¶ Bases:
rocketPy.materials.Material
-
class
rocketPy.materials.
Aluminium
(name='Al-6061-T6')[source]¶ Bases:
rocketPy.materials.Material
Defines a basic aluminium.
- Parameters
name (str) – Description of parameter name. Defaults to ‘Al-6061-T6’.
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>>
-
density
¶ Description of parameter density.
- Type
Pint.Quantity
-
tensile_modulus
¶ Description of parameter tensile_modulus.
- Type
Pint.Quantity
-
tensile_strength
¶ Description of parameter tensile_strength.
- Type
Pint.Quantity
-
max_temp
¶ Description of parameter max_temp.
- Type
Pint.Quantity
-
class
rocketPy.materials.
Material
(name)[source]¶ Bases:
object
Base class for defining material properties
- Parameters
name (str) – Name of material.
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>>
-
density
¶ Material Density.
- Type
Pint.Quantity
-
name
¶ name
- Type
str
-
class
rocketPy.materials.
PLA
(name='PLA')[source]¶ Bases:
rocketPy.materials.Material
-
class
rocketPy.materials.
Phenolic
(name='Phenolic')[source]¶ Bases:
rocketPy.materials.Material
-
class
rocketPy.materials.
Plywood
(name='Plywood')[source]¶ Bases:
rocketPy.materials.Material
-
class
rocketPy.materials.
Polycarbonate
(name='Polycarbonate')[source]¶ Bases:
rocketPy.materials.Material
rocketPy.rocket module¶
Module to describe the rocket
-
class
rocketPy.rocket.
Rocket
(name='Rocket')[source]¶ Bases:
object
-
CA
(alpha=<Quantity(0, 'radian')>, Re=1000000.0, Mach=0.3)[source]¶ Compute the axial drag force from the normal force and the axial force
-
CD
(alpha=<Quantity(0, 'radian')>, Re=1000000.0, Mach=0.3)[source]¶ Calculate the drag force at some angle of attack, including compressibility
-
CD0
(Re=1000000.0)[source]¶ Calcualte the zero angle-of-attack incompressible drag of the rocket. Generally uses DATCOM method (as specified by Box [1]) Reynolds number refers to the reynolds number by the length of the rocket.
-
CD0_f
(Re=1000000.0)[source]¶ Calcualte the zero-angle of attack drag due to the fins, including the effect of the interference
-
plot
(ax=None, unit=<Unit('meter')>, rotation=<Quantity(0, 'degree')>, plot_component_cp=True, plot_component_cg=True, alpha=<Quantity(0, 'degree')>, Re=1000000.0, Mach=0.3)[source]¶
-
rocketPy.util module¶
Utility functions for rocketPy
-
rocketPy.util.
angle_between
(va, vb)[source]¶ Return the angle between two column vectors using the dot product
-
rocketPy.util.
mach_correction
(Ma=0.0, method='default')[source]¶ Performs the Prandtl-Glauert compressibility correction, extended for supersonic region.
- Parameters
Ma (dimensionless float) – Mach Number. Defaults to 0.0.
method (str) – Choose the correction method (‘default’ or ‘Cambridge’). Defaults to ‘default’.
- Returns
Mach correction multiplier (float)
- Return type
dimensionless float
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>> mach_correction(0.5) 1.1547005383792517 >> mach_correction(1.5) 0.8944271909999159
-
rocketPy.util.
si
(v)[source]¶ Utility function to convert a Pint Quantity into a float in SI units.
- Parameters
v (Pint.Quantity or list/numpy.Array of Pint.Quantity) – quantity or list of quantities to convert.
- Returns
magnitudes in SI units.
- Return type
float or list of floats
- Examples
Examples should be written in doctest format, and should illustrate how to use the function/class. >>> si(5.0*ureg.meter) 5.0 >> si(6.0*ureg.inch) 0.1524
rocketPy.solution module¶
- class
rocketPy.solution.
Solution
(sol, stage)[source]¶Bases:
object
DOF
()[source]¶Returns the number of degrees of freedom in the state vector
- Returns
length of state vector
- Return type
int
__add__
(other)[source]¶Overloading the + operator to allow solutions to be ‘added’ together, essentially chaining them.
__init__
(sol, stage)[source]¶Wrapper for np.ODEresult to store extra information. Most importantly, allows multiple ODEresults to be chained together, with potential for storing extra information in them, and making it easy to access properties from each.
- Parameters
sol (ODEresult or List of ODEresult) – The ODEresult objects to be stored
stage (int or list of int) – Corresponding stage counters
- Returns
Solution object
- Return type
sol
(time, error='raise')[source]¶Returns the state at requested times. Assumes that scipy.integrate was called with dense_output=True and thus uses scipy’s interpolation method
- Parameters
time (float or np.array) – Float time to request the solution for, or list/array of times that the state is requested for.
error ('raise' or numeric) – if the requested time is outside the interpolations capabilities, if error=’raise’, will raise a warning, else will return error in the state. Maintains the shape of the state vector.
- Returns
state vector. If time is float, returns simple array of the right length. if time is a list of length n and state has length m, returns a shape of size (n x m).
- Return type
np.array
rocketPy.simulation module¶
- class
rocketPy.simulation.
Simulation
(object)[source]¶Bases:
object
full_solve
(t_span, y0, starting_stage, **kwargs)[source]¶Solves every single possible outcome.
#todo (low): add probability weighting
- Parameters
t_span ([float, float]) – Timespan for the solve
y0 (np.array) – Initial state vector
starting_stage (int) – Initial stage to start from
- Returns
list of possible outcomes
- Return type
list of rocketPy.Solution
nominal_solve
(t_span, y0, starting_stage, **kwargs)[source]¶Solves for a nominal flight
- Parameters
t_span ([float, float]) – Timespan to simulate over
y0 (np.array) – Initial state
starting_stage (int) – which stage to start in
- Returns
Solution object
- Return type
rocketPy.Solution
solve
(t_span, y0, stage, user_events=[], **kwargs)[source]¶Thin wrapper for scipy.solve_ivp to handle stages and events more intuitively. Arguments generally follow scipy.solve_ivp. The dynamics are picked up from object.dynamics, and dense_output=True to allow for solutions to be queried later Solve method uses scipy default, but can be specified using kwargs
- Parameters
t_span ([float, float]) – Simulation start and stop time.
y0 (np.array) – Initial state vector
stage (float) – stage number to use for the solve
user_events (list of functions) – each function is an event function. Defaults to [].
- Returns
solution object with the stage stored
- Return type
rocketPy.Solution
Module contents¶
Top-level package for rocketPy.