campyros package

Submodules

campyros.aero module

class campyros.aero.AeroData(CA_grid, CN_grid, COP_grid, Mach_grid, alpha_grid, ref_area, pitch_damping_coefficient=0.0, roll_damping_coefficient=0.0, error={'CA': 1.0, 'CN': 1.0, 'COP': 1.0})

Bases: object

Object holding aerodynamic data for the rocket.

Assumes an axially symmetric body. Uses scipy.interpolate.interp2d to interpolate data from arrays.

Parameters
  • CA_grid (array, 2D) – Axial force coefficient data.

  • CN_grid (array, 2D) – Normal force coefficient data.

  • COP_grid (array, 2D) – Centre of pressure data (m), containing distances between the nose tip and the centre of pressure.

  • Mach_grid (array, 1D or 2D) – Mach number data.

  • alpha_grid (array, 1D or 2D) – Angle of attack data (radians).

  • ref_area (float) – Referance area used to normalise coefficients (m^2).

  • pitch_damping_coefficient (float, optional) – Pitch damping coefficient, defined by moment = C * ρ * ω^2. Defaults to zero.

  • roll_damping_coefficient (float, optional) – Roll damping coefficient, defined by moment = C * ρ * ω^2. Defaults to zero.

  • error (dictionary, optional) – Used for running stochastic analyses. Defaults to {“CA”:1.0,”CN”:1.0,”COP”:1.0}.

CA_grid

Axial force coefficient data.

Type

array

CN_grid

Normal force coefficient data.

Type

array

COP_grid

Centre of pressure data, containing distances between the nose tip and the centre of pressure (m).

Type

array

Mach_grid

Mach number data.

Type

array

alpha_grid

Angle of attack data (rad).

Type

array

ref_area

Reference area used to normalise coefficients (m^2).

Type

float

pitch_damping_coefficient

Pitch damping coefficient, defined by moment = C * ρ * ω^2.

Type

float

roll_damping_coefficient

Roll damping coefficient, defined by moment = C * ρ * ω^2.

Type

float

error

Used for running stochastic analyses.

Type

dictionary

CA(Mach, alpha)
CN(Mach, alpha)
COP(Mach, alpha)
static from_lists(CA_list, CN_list, COP_list, Mach_list, alpha_list, ref_area, pitch_damping_coefficient=0, roll_damping_coefficient=0, error={'CA': 1.0, 'CN': 1.0, 'COP': 1.0})

Takes in 1D lists of data, and converts them into 2D arrays so they can be used for 2D interpolation.

Parameters
  • CA_list (array, 1D) – List of CA data at each Mach and alpha.

  • CN_list (array, 1D) – List of CN data at each Mach and alpha

  • COP_list (array, 1D) – List of COP data (m) at each mach and alph.

  • Mach_list (array, 1D) – List of Mach numbers for each data point.

  • alpha_list (array, 1D) – List of angles of attack (rad) for each data point.

  • ref_area (array, 1D) – Reference area used to normalise coefficients (m^2).

  • pitch_damping_coefficient (int, optional) – Pitch damping coefficient, defined by moment = C * ρ * ω^2. Defaults to 0.

  • roll_damping_coefficient (int, optional) – Roll damping coefficient, defined by moment = C * ρ * ω^2. Defaults to 0.

  • error (dict, optional) – Used for running stochastic analyses. Defaults to {“CA”:1.0,”CN”:1.0,”COP”:1.0}.

Returns

AeroData object.

Return type

AeroData

static from_rasaero(csv_directory, ref_area, pitch_damping_coefficient=0, roll_damping_coefficient=0, error={'CA': 1.0, 'CN': 1.0, 'COP': 1.0})

Convert an aerodynamic data .CSV file from RASAero II into an AeroData object.

Parameters
  • csv_directory (string) – Directory to .CSV file.

  • ref_area (float) – Referance area used to normalise coefficients (m^2).

  • pitch_damping_coefficient (float, optional) – Pitch damping coefficient, defined by moment = C * ρ * ω^2. Defaults to zero.

  • roll_damping_coefficient (float, optional) – Roll damping coefficient, defined by moment = C * ρ * ω^2. Defaults to zero.

  • error (dictionary, optional) – Used for running stochastic analyses.

Returns

AeroData object.

Return type

AeroData

show_plot(Mach=array([0.0, 0.0501002, 0.1002004, 0.1503006, 0.2004008, 0.250501, 0.3006012, 0.3507014, 0.4008016, 0.4509018, 0.501002, 0.5511022, 0.6012024, 0.65130261, 0.70140281, 0.75150301, 0.80160321, 0.85170341, 0.90180361, 0.95190381, 1.00200401, 1.05210421, 1.10220441, 1.15230461, 1.20240481, 1.25250501, 1.30260521, 1.35270541, 1.40280561, 1.45290581, 1.50300601, 1.55310621, 1.60320641, 1.65330661, 1.70340681, 1.75350701, 1.80360721, 1.85370741, 1.90380762, 1.95390782, 2.00400802, 2.05410822, 2.10420842, 2.15430862, 2.20440882, 2.25450902, 2.30460922, 2.35470942, 2.40480962, 2.45490982, 2.50501002, 2.55511022, 2.60521042, 2.65531062, 2.70541082, 2.75551102, 2.80561122, 2.85571142, 2.90581162, 2.95591182, 3.00601202, 3.05611222, 3.10621242, 3.15631263, 3.20641283, 3.25651303, 3.30661323, 3.35671343, 3.40681363, 3.45691383, 3.50701403, 3.55711423, 3.60721443, 3.65731463, 3.70741483, 3.75751503, 3.80761523, 3.85771543, 3.90781563, 3.95791583, 4.00801603, 4.05811623, 4.10821643, 4.15831663, 4.20841683, 4.25851703, 4.30861723, 4.35871743, 4.40881764, 4.45891784, 4.50901804, 4.55911824, 4.60921844, 4.65931864, 4.70941884, 4.75951904, 4.80961924, 4.85971944, 4.90981964, 4.95991984, 5.01002004, 5.06012024, 5.11022044, 5.16032064, 5.21042084, 5.26052104, 5.31062124, 5.36072144, 5.41082164, 5.46092184, 5.51102204, 5.56112224, 5.61122244, 5.66132265, 5.71142285, 5.76152305, 5.81162325, 5.86172345, 5.91182365, 5.96192385, 6.01202405, 6.06212425, 6.11222445, 6.16232465, 6.21242485, 6.26252505, 6.31262525, 6.36272545, 6.41282565, 6.46292585, 6.51302605, 6.56312625, 6.61322645, 6.66332665, 6.71342685, 6.76352705, 6.81362725, 6.86372745, 6.91382766, 6.96392786, 7.01402806, 7.06412826, 7.11422846, 7.16432866, 7.21442886, 7.26452906, 7.31462926, 7.36472946, 7.41482966, 7.46492986, 7.51503006, 7.56513026, 7.61523046, 7.66533066, 7.71543086, 7.76553106, 7.81563126, 7.86573146, 7.91583166, 7.96593186, 8.01603206, 8.06613226, 8.11623246, 8.16633267, 8.21643287, 8.26653307, 8.31663327, 8.36673347, 8.41683367, 8.46693387, 8.51703407, 8.56713427, 8.61723447, 8.66733467, 8.71743487, 8.76753507, 8.81763527, 8.86773547, 8.91783567, 8.96793587, 9.01803607, 9.06813627, 9.11823647, 9.16833667, 9.21843687, 9.26853707, 9.31863727, 9.36873747, 9.41883768, 9.46893788, 9.51903808, 9.56913828, 9.61923848, 9.66933868, 9.71943888, 9.76953908, 9.81963928, 9.86973948, 9.91983968, 9.96993988, 10.02004008, 10.07014028, 10.12024048, 10.17034068, 10.22044088, 10.27054108, 10.32064128, 10.37074148, 10.42084168, 10.47094188, 10.52104208, 10.57114228, 10.62124248, 10.67134269, 10.72144289, 10.77154309, 10.82164329, 10.87174349, 10.92184369, 10.97194389, 11.02204409, 11.07214429, 11.12224449, 11.17234469, 11.22244489, 11.27254509, 11.32264529, 11.37274549, 11.42284569, 11.47294589, 11.52304609, 11.57314629, 11.62324649, 11.67334669, 11.72344689, 11.77354709, 11.82364729, 11.87374749, 11.9238477, 11.9739479, 12.0240481, 12.0741483, 12.1242485, 12.1743487, 12.2244489, 12.2745491, 12.3246493, 12.3747495, 12.4248497, 12.4749499, 12.5250501, 12.5751503, 12.6252505, 12.6753507, 12.7254509, 12.7755511, 12.8256513, 12.8757515, 12.9258517, 12.9759519, 13.0260521, 13.0761523, 13.12625251, 13.17635271, 13.22645291, 13.27655311, 13.32665331, 13.37675351, 13.42685371, 13.47695391, 13.52705411, 13.57715431, 13.62725451, 13.67735471, 13.72745491, 13.77755511, 13.82765531, 13.87775551, 13.92785571, 13.97795591, 14.02805611, 14.07815631, 14.12825651, 14.17835671, 14.22845691, 14.27855711, 14.32865731, 14.37875752, 14.42885772, 14.47895792, 14.52905812, 14.57915832, 14.62925852, 14.67935872, 14.72945892, 14.77955912, 14.82965932, 14.87975952, 14.92985972, 14.97995992, 15.03006012, 15.08016032, 15.13026052, 15.18036072, 15.23046092, 15.28056112, 15.33066132, 15.38076152, 15.43086172, 15.48096192, 15.53106212, 15.58116232, 15.63126253, 15.68136273, 15.73146293, 15.78156313, 15.83166333, 15.88176353, 15.93186373, 15.98196393, 16.03206413, 16.08216433, 16.13226453, 16.18236473, 16.23246493, 16.28256513, 16.33266533, 16.38276553, 16.43286573, 16.48296593, 16.53306613, 16.58316633, 16.63326653, 16.68336673, 16.73346693, 16.78356713, 16.83366733, 16.88376754, 16.93386774, 16.98396794, 17.03406814, 17.08416834, 17.13426854, 17.18436874, 17.23446894, 17.28456914, 17.33466934, 17.38476954, 17.43486974, 17.48496994, 17.53507014, 17.58517034, 17.63527054, 17.68537074, 17.73547094, 17.78557114, 17.83567134, 17.88577154, 17.93587174, 17.98597194, 18.03607214, 18.08617234, 18.13627255, 18.18637275, 18.23647295, 18.28657315, 18.33667335, 18.38677355, 18.43687375, 18.48697395, 18.53707415, 18.58717435, 18.63727455, 18.68737475, 18.73747495, 18.78757515, 18.83767535, 18.88777555, 18.93787575, 18.98797595, 19.03807615, 19.08817635, 19.13827655, 19.18837675, 19.23847695, 19.28857715, 19.33867735, 19.38877756, 19.43887776, 19.48897796, 19.53907816, 19.58917836, 19.63927856, 19.68937876, 19.73947896, 19.78957916, 19.83967936, 19.88977956, 19.93987976, 19.98997996, 20.04008016, 20.09018036, 20.14028056, 20.19038076, 20.24048096, 20.29058116, 20.34068136, 20.39078156, 20.44088176, 20.49098196, 20.54108216, 20.59118236, 20.64128257, 20.69138277, 20.74148297, 20.79158317, 20.84168337, 20.89178357, 20.94188377, 20.99198397, 21.04208417, 21.09218437, 21.14228457, 21.19238477, 21.24248497, 21.29258517, 21.34268537, 21.39278557, 21.44288577, 21.49298597, 21.54308617, 21.59318637, 21.64328657, 21.69338677, 21.74348697, 21.79358717, 21.84368737, 21.89378758, 21.94388778, 21.99398798, 22.04408818, 22.09418838, 22.14428858, 22.19438878, 22.24448898, 22.29458918, 22.34468938, 22.39478958, 22.44488978, 22.49498998, 22.54509018, 22.59519038, 22.64529058, 22.69539078, 22.74549098, 22.79559118, 22.84569138, 22.89579158, 22.94589178, 22.99599198, 23.04609218, 23.09619238, 23.14629259, 23.19639279, 23.24649299, 23.29659319, 23.34669339, 23.39679359, 23.44689379, 23.49699399, 23.54709419, 23.59719439, 23.64729459, 23.69739479, 23.74749499, 23.79759519, 23.84769539, 23.89779559, 23.94789579, 23.99799599, 24.04809619, 24.09819639, 24.14829659, 24.19839679, 24.24849699, 24.29859719, 24.34869739, 24.3987976, 24.4488978, 24.498998, 24.5490982, 24.5991984, 24.6492986, 24.6993988, 24.749499, 24.7995992, 24.8496994, 24.8997996, 24.9498998, 25.0]), alpha=array([0.0, 0.01745329, 0.03490659, 0.05235988, 0.06981317]))

“Shows plots of the CA, CN and COP functions, so you can visually check if the system has interpreted your data correctly.

Parameters
  • Mach (array) – Array of Mach numbers to plot over. Defaults to np.linspace(0, 25, 500).

  • alpha (array) – Array of angles of attack to plot over (rad). Defaults to np.linspace(0, 4, 5)*np.pi/180.

campyros.aero.pitch_damping_coefficient(length, radius, fin_number, area_per_fin)

Gives approximate values for the pitch damping coefficient. Uses equations (3.59) and (3.60) from the OpenRocket documentation.

Note

In this model we define the pitch damping coefficient as:

m = C * ρ * ω^2

Where:

m = moment ρ = free-stream density ω = pitch rate C = pitch damping coefficient.

Assumptions: - Fins are at the very bottom of the rocket - COG of the rocket is half way up the length

Parameters
  • length (float) – Length of the rocket (m)

  • radius (float) – Radius of the rocket (assuming it’s a cylinder) (m)

  • fin_number (int) – Number of fins on the rocket

  • area_per_fin (float) – Area of a single fin (m^2)

Returns

Return type

Pitch damping cofficient

campyros.constants module

Earth constants

campyros.gui module

campyros.heating module

campyros.main module

Contains the classes and functions for the core trajectory simulation. SI units unless stated otherwise. .. rubric:: Notes

Known issues: - Unsure about the use of “dx” in “scipy.misc.derivative(self.mass_model.mass, time, dx=1)” when calculating mdot - Possible inconsistency in the definition of the launch site coordinate system, and whether the origin is at alt=0 or alt=launch_site.alt. I haven’t thoroughly checked for this inconsistency yet. Coordinate systems: - Body (x_b, y_b, z_b)

  • Origin on rocket

  • Rotates with the rocket.

  • y points east and z north at take off (before rail alignment is accounted for) x up.

  • x is along the “long” axis of the rocket.

  • Launch site (x_l, y_l, z_l):
    • Origin has the launch site’s longitude and latitude, but is at altitude = 0.

    • Rotates with the Earth.

    • z points up (normal to the surface of the Earth).

    • y points East (tangentially to the surface of the Earth).

    • x points South (tangentially to the surface of the Earth).

  • Inertial (x_i, y_i, z_i):
    • Origin at centre of the Earth.

    • Does not rotate.

    • z points to North from the centre of Earth.

    • x aligned with launch site at start .

    • y defined from x and z (so it is a right hand coordinate system).

class campyros.main.LaunchSite(rail_length, rail_yaw, rail_pitch, alt, longi, lat, variable_wind=True, default_wind=[0, 0, 0], launch_datetime='20210428 00:00', cache_Wind=False)

Bases: object

Object for holding launch site information. :param rail_length: Length of the launch rail (m) :type rail_length: float :param rail_yaw: Yaw angle of the launch rail (deg), using a right-hand rotation rule out the launch frame z-axis. “rail_yaw = 0” points South, “rail_yaw = 90” points East. :type rail_yaw: float :param rail_pitch: Pitch angle of the launch rail (deg). “rail_pitch = 0” points up. :type rail_pitch: float :param alt: Launch site altitude (m) :type alt: float :param longi: Launch site longitude (deg) :type longi: float :param lat: Launch site latitude (deg) :type lat: float :param variable_wind: Whether to use real wind data or not. If True, wind data will be downloaded before use. Defaults to True. :type variable_wind: bool, optional :param default_wind: Wind vector to use if ‘variable_wind = False’, [x_l, y_l, z_l] (m/s). Defaults to [0,0,0]. :type default_wind: array, optional :param wind_data_loc: Directory to store wind data files in. Defaults to “data/wind/gfs”. :type wind_data_loc: str, optional :param run_date: Date to collect real wind data for, in the format “YYYYMMDD”. Defaults to the current date. :type run_date: str, optional :param forcast_time: Forcast run time, must be “00”, “06”, “12” or “18”. Defaults to “00”. :type forcast_time: str, optional :param forcast_plus_time: Hours forcast forward from forcast time, must be three digits between 000 and 123 (?). Defaults to “000”. :type forcast_plus_time: str, optional :param fast_wind: ???. Defaults to False. :type fast_wind: bool, optional

rail_length

Length of the launch rail (m)

Type

float

rail_yaw

Yaw angle of the launch rail (deg), using a right-hand rotation rule out the launch frame z-axis. “rail_yaw = 0” points South, “rail_yaw = 90” points East.

Type

float

rail_pitch

Pitch angle of the launch rail (deg). “rail_pitch = 0” points up.

Type

float

alt

Launch site altitude (m)

Type

float

longi

Launch site longitude (deg)

Type

float

lat

Launch site latitude (deg)

Type

float

wind

Wind object containing wind data.

Type

Wind

class campyros.main.Parachute(main_s, main_c_d, drogue_s, drogue_c_d, main_alt, attach_distance=0.0)

Bases: object

get(alt, mach)

Returns the drag coefficient and area of the parachute, given the current altitude and Mach Number. I.e., it checks if the main or drogue parachute is open, and returns the relevant values. :param alt: Current altitude (m) :type alt: float :param mach: Mach number :type mach: float

Returns

Drag coefficient, parachute area (m^2)

Return type

float, float

class campyros.main.Rocket(mass_model, motor, aero, launch_site, h=0.01, variable=True, rtol=1e-07, atol=1e-14, parachute=<campyros.main.Parachute object>, alt_poll_interval=1, thrust_vector=array([1, 0, 0]), errors={'density': 1.0, 'gravity': 1.0, 'pressure': 1.0, 'speed_of_sound': 1.0})

Bases: object

Rocket object to contain rocket data and run rocketry simulations. :param mass_model: MassModel object containing all the data on mass and moments of inertia. :type mass_model: MassModel :param motor: Motor object containing information on the rocket engine. :type motor: Motor :param aero: AeroData object containg data on aerodynamic coefficients and the centre of pressure. :type aero: AeroData :param launch_site: LaunchSite object contaning launch site and wind information. :type launch_site: LaunchSite :param h: Integration time step (if using a fixed time step by setting “variable = False”). Defaults to 0.01. :type h: float, optional :param variable: If True, a variable time step is use for the integration. If “False” then the input for “h” is used as the time step. Defaults to True. :type variable: bool, optional :param rtol: Relative error tolerance for integration. Defaults to 1e-7. :type rtol: float, optional :param atol: Absolute error tolerance for integration. Defaults to 1e-14. :type atol: float, optional :param parachute: Parachute object, containing parachute data. Defaults to Parachute(0,0,0,0,0,0). :type parachute: Parachute, optional :param alt_poll_interval: How often to check for parachute opening. Defaults to 1. :type alt_poll_interval: int, optional :param thrust_vector: Direction of thrust in body coordinates. Defaults to np.array([1,0,0]). :type thrust_vector: array, optional :param errors: Multiplication factors for the gravity, pressure, density and speed of sound. Used in the statistics model. Defaults to {“gravity”:1.0,”pressure”:1.0,”density”:1.0,”speed_of_sound”:1.0}. :type errors: dict, optional

mass_model

MassModel object containing all the data on mass and moments of inertia.

Type

MassModel

motor

Motor object containing information on the rocket engine.

Type

Motor

aero

AeroData object containg data on aerodynamic coefficients and the centre of pressure.

Type

AeroData

launch_site

LaunchSite object contaning launch site and wind information.

Type

LaunchSite

h

Integration time step (if using a fixed time step by setting “variable = False”).

Type

float

variable

If True, a variable time step is use for the integration. If “False” then the input for “h” is used as the time step.

Type

bool

rtol

Relative error tolerance for integration.

Type

float

atol

Absolute error tolerance for integration.

Type

float

parachute

Parachute object, containing parachute data.

Type

Parachute

alt_poll_interval

???. Defaults to 1.

Type

int

thrust_vector

Direction of thrust in body coordinates.

Type

array

env_vars

Multiplication factors for the gravity, pressure, density and speed of sound. Used in the statistics model.

Type

dict

time

Time since engine ignition (s).

Type

array

pos_i

Position in inertial coordinates [x_i, y_i, z_i] (m).

Type

array

vel_i

Velocity in inertial coordinates [x_i, y_i, z_i] (m/s).

Type

array

w_b

Angular velocity in body coordiates [x_b, y_b, z_b] (rad/s).

Type

array

b2i

Body-to-inertial coordinate rotation matrix.

Type

scipy.spatial.transform.Rotation

i2b

Inertial-to-body coordinate rotation matrix.

Type

scipy.spatial.transform.Rotation

alt

Rocket altitude (m).

Type

float

on_rail

True if the rocket is still on the rail, False if the rocket is off the rail.

Type

bool

burn_out

False if engine is still firing, True if the engine has finished firing.

Type

bool

alt_record

“Current” altitude of the rocket used to check for parahute opening.

Type

float

alt_poll_watch_interval

How often to check if the parachute needs to be openes (s).

Type

float

alt_poll_watch

Last polled time.

Type

float

check_phase(debug=False)

Check what phase of flight the rocket is in, e.g. on the rail, off the rail, or with the parachute open. .. rubric:: Notes

  • Since this only checks after each time step, there may be a very short period where the rocket is orientated as if it is still on the rail, when it shouldn’t be.

  • For this reason, it may look like the rocket leaves the rail at an altitude greater than the rail length.

Parameters

debug (bool, optional) – If True, a message is printed when the rocket leaves the rail. Defaults to False.

Returns

List of events that happened in this step, for the data log.

Return type

list

fdot(time, fn)

Returns the rate of change of the rocket’s state array, ‘fn’. :param time: Time since ignition (s). :type time: float :param fn: Rocket’s current state, [pos_i[0], pos_i[1], pos_i[2], vel_i[0], vel_i[1], vel_i[2], w_b[0], w_b[1], w_b[2], xb_i[0], xb_i[1], xb_i[2], yb_i[0], yb_i[1], yb_i[2], zb_i[0],zb_i[1],zb_i[2]] :type fn: array

Returns

Rate of change of fdot, i.e. [vel_i[0], vel_i[1], vel_i[2], acc_i[0], acc_i[1], acc_i[2], wdot_b[0], wdot_b[1], wdot_b[2], xbdot[0], xbdot[1], xbdot[2], ybdot[0], ybdot[1], ybdot[2], zbdot[0], zbdot[1], zbdot[2]]

Return type

array

run(max_time=1000, debug=False, to_json=False)

Runs the rocket trajectory simulation. Uses the SciPy DOP853 O(h^8) integrator. :param max_time: Maximum time to run the simulation for (s). Defaults to 1000. :type max_time: float, optional :param debug: If True, data will be printed to the console to aid with debugging. Defaults to False. :type debug: bool, optional :param to_json: Directory to export a .json file to, containing the results of the simulation. If False, no .json file will be produced. Defaults to False. :type to_json: str, optional

Returns

pandas DataFrame containing the fundamental trajectory results. Most information can be derived from this in post processing.

”time” (array): List of times that all the data corresponds to (s). “pos_i” (array): List of position vectors in inertial coordinates [x_i, y_i, z_i] (m). “vel_i” (array): List of velocity vectors in inertial coordinates [x_i, y_i, z_i] (m/s). “b2imat” (array): List of rotation matrices for going from the body to inertial coordinate system (i.e. a record of rocket orientation). “w_b” (array): List of angular velocity vectors, in body coordinates [x_b, y_b, z_b] (rad/s). “events” (array): List of useful events.

Return type

pandas.DataFrame

campyros.main.from_json(directory)

Extract trajectory data from a .json file produced by campyros.Rocket.run(), and convert it into a pandas DataFrame. :param directory: .json file directory. :type directory: str

Returns

pandas DataFrame containing the fundamental trajectory results. Most information can be derived from this in post processing.

”time” (array): List of times that all the data corresponds to (s). “pos_i” (array): List of position vectors in inertial coordinates [x_i, y_i, z_i] (m). “vel_i” (array): List of velocity vectors in inertial coordinates [x_i, y_i, z_i] (m/s). “b2imat” (array): List of rotation matrices for going from the body to inertial coordinate system (i.e. a record of rocket orientation). “w_b” (array): List of angular velocity vectors, in body coordinates [x_b, y_b, z_b] (rad/s). “events” (array): List of useful events.

Return type

pandas.DataFrame

campyros.main.warning_on_one_line(message, category, filename, lineno, file=None, line=None)

A one line warning format :param message: [description] :type message: [type] :param category: [description] :type category: [type] :param filename: [description] :type filename: [type] :param lineno: [description] :type lineno: [type] :param file: [description]. Defaults to None. :type file: [type], optional :param line: [description]. Defaults to None. :type line: [type], optional

Returns

[description]

Return type

[type]

campyros.mass module

Notes

  • All “positions” are relative to the tip of the rocket’s nose

  • All “times” are from the moment of ignition

class campyros.mass.CylindricalApproximation(mass_array, time_array, r, l)

Bases: object

Solid cylinder approxiation for the rocket.

Notes

Assumes: - The entire rocket is a solid cylinder. It’s volume is constant, but it’s density decreases with time according to how the mass decreases as fuel is burnt.

cog(time)
ixx(time)
iyy(time)
izz(time)
mass(time)
class campyros.mass.DryMass(mass, ixx, iyy, izz, cog)

Bases: object

Class for adding custom dry mass values.

class campyros.mass.HollowCylinder(mass, r_out, r_in, l, cog)

Bases: object

Class for getting moment of inertia properties for a solid hollow cylinder that does not vary with time.

class campyros.mass.LiquidTank(lmass_array, lden_array, time_array, r, pos_bottom, vmass_array=None, vden_array=None)

Bases: object

Liquid fuel tank.

Notes

Assumes: - Cylindrical fuel tank - Inviscid liquid, so the liquid does not contribute to ixx - Vapour does not contribute to moments of inertia

cog(time)
ixx(time)
iyy(time)
izz(time)
lden(time)
lheight(time)
lmass(time)
lvol(time)
mass(time)
vden(time)
vheight(time)
vmass(time)
vvol(time)
class campyros.mass.MassModel

Bases: object

Notes

Assumes: - All centres of mass lie on the x-x axis.

add_cylindricalapproximation(mass_array, time_array, r, l)
add_drymass(mass, ixx, iyy, izz, cog)
add_hollowcylinder(mass, r_out, r_in, l, cog)
add_liquidtank(lmass_array, lden_array, time_array, r, pos_bottom, vmass_array=None, vden_array=None)
add_solidfuel(mass_array, time_array, den, r_out, l, pos_bottom)
cog(time)
ixx(time)
iyy(time)
izz(time)
mass(time)
class campyros.mass.SolidFuel(mass_array, time_array, den, r_out, l, pos_bottom)

Bases: object

Solid fuel grain.

Notes

Assumes: - Fuel grain is shaped like an annular cylinder - Burning the fuel simply increases the inner radius of the cylinder, uniformly

cog(time)
ixx(time)
iyy(time)
izz(time)
mass(time)
r_in(time)

campyros.motor module

class campyros.motor.Motor(thrust_array, time_array, exit_area, pos, ambient_pressure=100000.0)

Bases: object

Object for holding rocket engine data.

Assumes constant nozzle exit area.

Parameters
  • thrust_array (list) – Thrust data (N).

  • time_array (list) – Times corresponding to thrust_array data points (s).

  • exit_area (float) – Nozzle exit area (m^2).

  • pos (float) – Distance between the nose tip and the point at which the thrust acts (m).

  • ambient_pressure (float, optional) – Ambient pressure used to obtain the thrust_array data (Pa). Defaults to 1e5.

thrust_array

Thrust data (N).

Type

list

time_array

Times corresponding to thrust_array data points (s).

Type

list

exit_area

Nozzle exit area (m^2).

Type

float

pos

Distance between the nose tip and the point at which the thrust acts (m).

Type

float

ambient_pressure

Ambient pressure used to obtain the thrust_array data (Pa).

Type

float, optional

static from_novus(csv_directory, pos)

Generate Motor object from a novus_sim_6 output csv file. Modified from Joe Hunt’s NOVUS simulator.

Parameters
  • csv_directory (string) – Directory of the .CSV file.

  • pos (float) – Distance between the nose tip and the point at which the thrust acts (m).

Returns

The Motor object.

Return type

Motor

thrust(time)

Function for calculating the thrust at a given time, with an ambient pressure of self.ambient_pressure.

Parameters

time (float) – Time since ignition (s).

Returns

Thrust (N).

Return type

float

campyros.motor.load_motor(file)

Legacy requirment for statistical models

Parameters

file (string) – Location of novus output file

Returns

Motor data - “motor_time”,”prop_mass”,

”cham_pres”,”throat”,”gamma”, “nozzle_efficiency”, “exit_pres”,”area_ratio”,”vmass”,”lden”,”lmass”, “fuel_mass”,”density_fuel”,”dia_fuel”,”length_port”

Return type

dict

campyros.plot module

6DOF Trajectory Simulator

Various useful plots of the outputted data

campyros.plot.animate_orientation(simulation_output, frames=500)

Shows an animation of the orientation against time, alongside an animation of altitude against time for reference

Parameters

simulation_output (pandas array) – Simulation output from a Rocket.run() method. Should contain the following data:

campyros.plot.elipse(u, v, a, b, c)
campyros.plot.fix_ypr(point)
campyros.plot.get_velocity_magnitude(df)
campyros.plot.inertial_position(simulation_output)
campyros.plot.plot_aero(simulation_output, rocket)

Plots the following: - Aerodynamic forces against time - COG and COP against time - Angles of attack against time

Parameters
  • simulation_output (pandas array) – Simulation output from a Rocket.run() method. Should contain the following data:

  • rocket (trajectory.Rocket object) – The rocket object that was used to produce the simulation data. Is needed to calculate coordinate system changes.

campyros.plot.plot_altitude_time(simulation_output, rocket)

Plots the following, against time where applicable: ground track, altitude, speed (in the launch frame) and vertical velocity (in the launch frame)

Parameters
  • simulation_output (pandas array) – Simulation output from a Rocket.run() method. Should contain the following data:

  • rocket (trajectory.Rocket object) – The rocket object that was used to produce the simulation data. Is needed to calculate coordinate system changes.

campyros.plot.plot_launch_trajectory_3d(simulation_output, rocket, show_orientation=False, arrow_frequency=0.02)

Plots the trajectory in 3D, given the simulation_output and the rocket

Parameters
  • simulation_output (pandas array) – Simulation output from a Rocket.run() method. Should contain the following data:

  • rocket (trajectory.Rocket object) – The rocket object that was used to produce the simulation data. Is needed to calculate coordinate system changes.

campyros.plot.plot_mass(simulation_output, rocket)

Plots the following: - Total mass against time - Moments of inertia against time - Angles of attack against time

Parameters
  • simulation_output (pandas array) – Simulation output from a Rocket.run() method. Should contain the following data:

  • rocket (trajectory.Rocket object) – The rocket object that was used to produce the simulation data. Is needed to calculate coordinate system changes.

campyros.plot.plot_thrust(simulation_output, rocket)

Plots the following: - Thrust against time - Jet damping moment against time - Propellant mass flow rate against time

Parameters
  • simulation_output (pandas array) – Simulation output from a Rocket.run() method. Should contain the following data:

  • rocket (trajectory.Rocket object) – The rocket object that was used to produce the simulation data. Is needed to calculate coordinate system changes.

campyros.plot.plot_ypr(simulation_output, rocket)
campyros.plot.set_axes_equal_3d(ax)

Makes the scaling the same on the axes of 3D plot. The in-built functions that come with matplotlib only seem to be able to do this for 2D axes.

Parameters

ax (matplotlib.pyplot.axes) – The 3D axis that you want to have equal axis scaling, e.g. could have been created with ax = matplotlib.pyplot.axes(projection=”3d”).

campyros.plot.stats_alt(z, t, show_means=False, sigma=3)
campyros.plot.stats_apogee(apogee_mu, apogee_cov, apogee=Empty DataFrame Columns: [] Index: [], sigma=3, landing_mu=array([], dtype=float64), landing_cov=array([], dtype=float64), landing=Empty DataFrame Columns: [] Index: [])
campyros.plot.stats_landing(mu, cov, data=Empty DataFrame Columns: [] Index: [], sigma=3)
campyros.plot.stats_trajectories(x, y, z, apogee_mu=array([], dtype=float64), apogee_cov=array([], dtype=float64), sigma=3, landing_mu=array([], dtype=float64), landing_cov=array([], dtype=float64))

campyros.post module

Useful functions for post-processing of the trajectory data, e.g. when imported from a .JSON file.

The trajectory data is usually stored in a minimalistic format, so only contains: - time - pos_i - vel_i - b2imat - w_b

So things like the altitude, yaw, pitch, and roll, etc… need to be obtained from only this data.

campyros.post.ypr_i(simulation_output)

Get yaw, pitch and roll data (relative to inertial axes).

simulation_output : pandas DataFrame

Returns

  • yaw (list)

  • pitch (list)

  • roll (list)

campyros.ray_alt module

class campyros.ray_alt.remote(f)

Bases: object

campyros.slosh module

Liquid fuel slosh modelling tools

References

[1] - The Dynamic Behavior of Liquids in Moving Containers, with Applications to Space Vehicle Technology Hyperlink - https://ntrs.nasa.gov/citations/19670006555

class campyros.slosh.CylindricalFuelTank(h, d, rho)

Bases: object

pendulum_analogy()
spring_analogy()
w_pendulum()
w_spring()

campyros.statistical module

class campyros.statistical.StatisticalModel(run_file)

Bases: object

Stochastic model for the rocket flight

Notes

Every variable specified has a value and a standard deviation in a list (i.e. [mean,st_dev]) Currenrly only supports aero import from rasaero file. Wind will currently not vary

Parameters

run_file (string) – json file containing config, see stats_settings.json

launch_site_vars

Dictionary of variables for launch site object. Must contain: rail_length, rail_yaw, rail_pitch, alt, longi, lat

Type

dict

mass_model_vars

Dictionary of variables for mass model object. Must contain: dry_mass, prop_mass, time_data, length, radius

Type

dict

aero_file

Location of RASAero data file

Type

string

aero_error

Standard deviaiton for the aero coefficients in format COP, CN and CA

Type

dict

motor_base

Unpeterbed motor object

Type

MotorObject

h

Default timestep /s, defaults to 0.05 - this doesn’t really do anything

Type

float, optional

variable_time

Vary timesteps?, defaults to True

Type

bool, optional

alt_poll_interval

Parachute altitude polling interval /s defaults to 1

Type

, optional

run_date

Date for forcast data in format YYYYMMDD, defaults to current date

Type

string, optional

forcast_time

Forcast run time, must be 00,06,12 or 18, defaults to 00

Type

string, optional

forcast_plus_time

Hours forcast forward from forcast time, must be three digits between 000 and 123 (?), defaults to 000

Type

string, optional

thrust_error

Standard deviation of thrust magnitude error /%

Type

float

thrust_alignment

Standard deviation of thrust alignment vector error

Type

float

parachute_vars

Dictionary of variables for parachute object. Must contain: main_s, main_c_d, drogue_s, drogue_c_d, main_alt, attatch_distance

Type

dict

env_vars

Multiplied factor for the gravity, pressure, density and speed of sound used in the model, defaults to {“gravity”:1.0,”pressure”:1.0,”density”:1.0,”speed_of_sound”:1.0}

Type

dictionary

type_name

The different types of errors to itterate over later

Type

list

wind_base

Unpeterbed wind model

Type

wind object

run_itteration = <ray_alt.remote object>
run_model(test_mode=False, debug=False, num_cpus=False)

Runs the stochastic model

Parameters
  • itters (int) – Number of times to run the rocket

  • save_loc (string, optional) – Folder to store results, defaults to None (is generated based on date if None)

Returns

save location, if not specified is generated so needs to be returned to be known

Return type

string

campyros.statistical.abs_stdev(value, percentage)
campyros.statistical.analyse(results_path, itterations, full_results=True, velocity=False)

Loads stats model results to put them in a more useful form for use, see stats_analysis_example notebook for example use

Parameters
  • results_path (string) – Folder containing results

  • itterations (int) – Number of runs used for the model

  • full_results (bool, optional) – Return the full x,y,z,t for every run of the model

  • velocity (bool, optional) – Return velocity analys, defaults to False - currently not implimented

Returns

  • if full_results=True

    numpy array

    landing position mean

    numpy array

    landing position covariant matrix

    numpy array

    apogee position mean

    numpy array

    apogee position covariant matrix

    pandas dataframe

    positions of all apogees (columns x,y,z, row for each run)

    pandas dataframe

    positions of all landings (columns x,y,z, row for each run)

    pandas dataframe

    x position throughout flight (row for each run)

    pandas dataframe

    y position throughout flight (row for each run)

    pandas dataframe

    z position throughout flight (row for each run)

    andas dataframe

    time throughout flight (row for each run)

  • else

    numpy array

    landing position mean

    numpy array

    landing position covariant matrix

    numpy array

    apogee position mean

    numpy array

    apogee position covariant matrix

campyros.statistical.variable_name(**variables)

campyros.transforms module

campyros.transforms.direction_i2l(vector, launch_site, time)

Converts position in launch frame to position in inertial frame. .. note:: -Problem in the yaw pitch conversions, unexplained negative sign needed

Parameters
  • vector (numpy array) – Vector in the inertial frame [x,y,z] /m/s

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Vector in the launch frame

Return type

numpy array

campyros.transforms.direction_l2i(vector, launch_site, time)

Converts position in launch frame to position in inertial frame. .. note:: -Problem in the yaw pitch conversions, unexplained negative sign needed

Parameters
  • vector (numpy array) – Vector in the launch frame [x,y,z] /m/s

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Vector in the launch frame

Return type

numpy array

campyros.transforms.i2airspeed(pos_i, vel_i, launch_site, time)

Converts velocity in the inertial frame to airspeed (before wind is taken into account) using site launch coordinates

Note

Assumes that the atmosphere moves at the same angular velocity as the Earth. Hence, at a given altitude, v_atmosphere = w_earth x r_i

Parameters
  • vel_i (numpy array) – Velocity in the inertial frame [x,y,z] /m/s

  • pos_i (numpy array) – Position in the intertial frame [x,y,z] /m

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Airspeed (assuming no wind), given using launch site coordinates

Return type

numpy array

campyros.transforms.i2lla(pos_i, time)
campyros.transforms.lla2i(lat, lon, alt, time)
campyros.transforms.pos_i2alt(pos_i, time)

Returns the altitude (height from surface in launch frame) from pos_i

Note

-Uses a spherical Earth model

Parameters

pos_i (numpy array) – Position of the rocket in the inertial coordinate system [x,y,z] /m

Returns

Altitude /m

Return type

float

campyros.transforms.pos_i2l(position, launch_site, time)

Converts position in launch frame to position in inertial frame. .. note:

-Converting spherical coordinates to Cartesian
-https://math.libretexts.org/Bookshelves/Calculus/Book%3A_Calculus_(OpenStax)/12%3A_Vectors_in_Space/12.7%3A_Cylindrical_and_Spherical_Coordinates#:~:text=To%20convert%20a%20point%20from,y2%2Bz2)
Parameters
  • position (numpy array) – Position in the inertial frame [x,y,z] /m

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Position in the launch frame

Return type

numpy array

campyros.transforms.pos_l2i(pos_l, launch_site, time)

Converts position in launch frame to position in inertial frame. .. note:

-Converting spherical coordinates to Cartesian
-https://math.libretexts.org/Bookshelves/Calculus/Book%3A_Calculus_(OpenStax)/12%3A_Vectors_in_Space/12.7%3A_Cylindrical_and_Spherical_Coordinates#:~:text=To%20convert%20a%20point%20from,y2%2Bz2)
Parameters
  • pos_l (numpy array) – Position in the launch site frame [x,y,z] /m

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Position in the inertial frame

Return type

numpy array

campyros.transforms.vel_i2l(vel_i, launch_site, time)

Converts velocity in inertial frame to velocity in launch frame. .. note:: -v = w x r for a rigid body, where v, w and r are vectors

Parameters
  • vel_i (numpy array) – Velocity in the inertial frame [x,y,z] /m/s

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Velocity in the launch frame

Return type

numpy array

campyros.transforms.vel_l2i(vel_l, launch_site, time)

Converts position in launch frame to position in inertial frame. .. note:: -v = w x r for a rigid body, where v, w and r are vectors

Parameters
  • vel_i (numpy array) – Velocity in the launch frame [x,y,z] /m/s

  • launch_site (LaunchSite object) – Holds the launch site parameters

  • time (float) – Time since ignition /s

Returns

Velocity in the inertial frame

Return type

numpy array

campyros.wind module

class campyros.wind.Wind(datetime='20210428 00:00', default=array([0, 0, 0]), variable=True, cache=False)

Bases: object

get_wind(lat, long, alt, flight_time=0)

[summary]

Parameters
  • lat (float) – latitude

  • long (float) – longitude

  • alt (float) – altitude

  • flight_time (float, optional) – time into flight. Defaults to 0.

Returns

returns u and v components of wind

Return type

tuple

Module contents