A.6.4 Trajectory Code User’s Guide page 43

A.6.4 User’s Guide to Running the Trajectory Code

Compiled and Edited by Elizabeth Harkness

The trajectory code is a conglomeration of 27 MATLAB scripts and functions. The following document is meant to be a guide to anyone wishing to use the trajectory code. Each script or function in the trajectory code folder is briefly described here, with a listing of inputs needed and outputs generated. The first section, AAE450_Trajectory_run(_distribute).m, describes how to run the overall code, while the rest of the sections are more detailed descriptions of the separate components.

Index

AAE450_Trajectory_run(_distribute).m / E. Harkness / page 2
AAE450_Trajectory_Main.m / J. Kanehara / page 10
AAE450_Trajectory_Get_Inputs.m / J. Kanehara / page 11
AAE450_run_traj_Optimization_GB.m
(AAE450_run_traj_Optimization_AC.m) / D. Chua / page 12
AAE450_Trajectory_D2MP.m / D. Chua / page 13
AAE450_Trajectory_Calculations.m / J. Kanehara / page 14
AAE450_Trajectory_ODE.m / J. Kanehara / page 15
AAE450_Trajectory_ODE_AC_1st.m / J. Kanehara / page 17
AAE450_Trajectory_ODE_AC_2nd.m / J. Kanehara / page 19
AAE450_Trajectory_ODE_AC_linear.m / J. Kanehara / page 21
AAE450_Trajectory_ODE_steer.m / J. Kanehara / page 23
AAE450_Trajectory_ODE_coast.m / J. Kanehara / page 25
AAE450_Wind_Model.m / K. Donahue / page 27
atmosphere4.m / A. Guzik / page 28
solve_cd.m / B. Ferris / page 29
speedofsound.m / B. Ferris / page 30
thrustprofile.m / B. Ferris / page 31
AAE450_Trajectory_GSAC.m / A. Briden / page 32
AAE450_Trajectory_GSAC_2STO.m / A. Briden / page 33
AAE450_Trajectory_GSAC_Aircraft_2_3linear_sections.m / A. Briden / page 34
AAE450_Trajectory_GSAC_Aircraft_3.m / A. Briden / page 36
Delta_V.m / S. Breitengross / page 38
AAE450_orbit_param.m / A. Guzik / page 39
AAE450_Trajectory_outputs.m / J. Kanehara / page 40
AAE450_Trajectory_Plots.m / J. Kanehara / page 41
AAE450_Trajectory_Body2Inertial.m / J. Kanehara / page 42
Code Flowchart: Run Once / K. Donahue / page 43
Code Flowchart: Optimize / S. Breitengross / page 46


AAE450_Trajectory_run(_distribute).m

Written by Elizabeth Harkness

Revision 1.4 – 18 February 2008

Description:

The function AAE450_Trajectory_run.m interfaces between the output of the structures and propulsion codes and the input of the trajectory code while the function AAE450_Trajectory_run_distribute.m interfaces between the output of the structures and propulsion codes and the input of the trajectory code which uses AAE450_Trajectory_D2MP.m or AAE450_Trajectory_D2MP_ac.m to optimize steering angles (for ground/balloon or aircraft respectively). This document describes how AAE450_Trajectory_run.m and AAE450_Trajectory_run_distribute.m function, the required inputs and the expected outputs.

Input Section:

To get the inputs from the propulsion/structures code, the main_loop.m (MAT) code needs to be run with the following call line:

[ID,Trajectory_Input]= main_loop

Propulsion/Structures Inputs:

To make the input file for the AAE450_Trajectory_Main.m code, AAE450_Trajectory_run.m and AAE450_Trajectory_run_distribute.m need to be called with the call line:

AAE450_Trajectory_run(ID,Trajectory_Input)

or

AAE450_Trajectory_run_distribute(ID,Trajectory_Input)

All of the variables that are passed into the function from the propulsion/structures codes are described below:

Variable Name / Description
ID / Run Identifier. This is the code for each case being run.
E.g. ‘XX-XX-XX’
type / If the case is running an air launch or ground launch.
E.g. Ground: 1, Balloon: 2, Aircraft: 3.
N / Number of stages. E.g 1, 2, 3
payload_mass / Mass of Payload [kg] E.g. 0.2, 1, 5
m1 / Mass of the 1st Stage [kg]
m2 / Mass of the 2nd Stage [kg]
m3 / Mass of the 3rd Stage [kg]
T1 / Average Thrust of first stage. [N]
T2 / Average Thrust of second stage. [N]
T3 / Average Thrust of third stage. [N]
t_vertical / Time of vertical flight [s]
t_burn_1 / First stage burn time. [s]
t_burn_2 / Second stage burn time. [s]
t_burn_3 / Third stage burn time. [s]
m_dot_1 / Mass flow rate of 1st Stage. [kg/s]
m_dot_2 / Mass flow rate of 2nd Stage. [kg/s]
m_dot_3 / Mass flow rate of 3rd Stage. [kg/s]
diam_1 / Diameter of first stage. [m]
diam_2 / Diameter of second stage. [m]
diam_3 / Diameter of third stage. [m]
diam_4 / Diameter of fourth (payload) stage. [m]
Pe_1 / Exit pressure of 1st stage engine. [Pa]
Pe_2 / Exit pressure of 2nd stage engine. [Pa]
Pe_3 / Exit pressure of 3rd stage engine. [Pa]
Ae_1 / Exit area of 1st stage engine. [m^2]
Ae_2 / Exit area of 2nd stage engine. [m^2]
Ae_3 / Exit area of 3rd stage engine. [m^2]

User Inputs:

AAE450_Trajectory_run.m

For Ground and Balloon Launch

After the propulsion/structures data has been loaded, the function will then prompt the user to input the steering angles:

Variable Name / Description
psi1_0 / Angle at the end of 1st stage vertical [deg]
psi1_1 / Starting angle for end of first stage variation [deg]
psi1_2 / Final angle for end of first stage variation [deg]
psi_increment / Number of increments between psi1_1 and psi1_2
psi2 / Angle at the end of 2nd stage [deg]
psi3 / Angle at the end of 3rd stage [deg]

Note: To run only one steering angle, make psi1_1 equal to psi1_2 and set psi_increment to one. E.g. psi1_1 = 10, psi1_2 = 10, psi_increment = 1.

For Aircraft Launch

After the propulsion/structures data has been loaded, the function will then prompt the user to input the steering angles:

Variable Name / Description
angle_tclimb / Steering angle at the end of climb [deg]
tb2sec1_percent_tb2 / Percent of first steering law for stage two [s]
psi2 / Angle at the end of 2nd stage [deg]
psi3 / Angle at the end of 3rd stage [deg]

AAE450_Trajectory_run_distribute.m

For All Launch Types

There are no user generated inputs for AAE450_Trajectory_run_distribute.m, the steering angles are all varied by the program AAE450_Trajectory_D2MP.m (or AAE450_Trajectory_D2MP_ac.m for an aircraft launch).

Internal Inputs:

The following inputs are defined internally in AAE450_Trajectory_run.m and AAE450_Trajectory_run_distribute.m. These values should not need altering by the casual user (if ever). They include all initial conditions (these are set to vary with the type of launch), as well as some placeholder variables (labeled 4) for the orbit propagation stage.

Variable Name / Description
h_i / Initial altitude [m]
psi1_0 / ***Initial launch angle [deg]
r_dot_i_1 / Initial radial velocity [m/s]
theta_dot_i_1 / Initial tangential velocity [rad/s]
launch_lat / Launch latitude [deg]
launch_long / Launch longitude [deg]
phi_dot_i_1 / Initial phi velocity [rad/sec]
b_1 / Coefficient of angle at the end of 1st vertical stage.
R_Earth / Radius of the Earth [m]
t_vertical / Time of vertical flight to clear launch tower. [sec]

*** Note: For AAE450_Trajectory_run_distribute.m only.

The values for these variables are shown below:

%% User non-variable inputs.

R_Earth = 6376*1000;

launch_lat = 28; %[deg]

launch_long = -80;

t_vertical = 10; %[sec]

(psi1_0 = 88;)

......

% Set initial conditions for different launches

if type == 1 % Ground

h_i = 0;

r_i_1=R_Earth+h_i; % [m]

r_dot_i_1 = 0; % [m/sec]

theta_i_1=launch_long*pi/180; % [rad]

theta_dot_i_1 = 0; % [rad]

phi_i_1=(90-launch_lat)*pi/180; % [rad]

phi_dot_i_1=0; % [rad/s]

b_1=tan(psi1_0*pi/180);

end

if type == 2 % Balloon

h_i = 30000;

r_i_1=R_Earth+h_i; % [m]

r_dot_i_1 = 0; % [m/sec]

theta_i_1=launch_long*pi/180; % [rad]

theta_dot_i_1 = 0; % [rad]

phi_i_1=(90-launch_lat)*pi/180; % [rad]

phi_dot_i_1=0; % [rad/s]

b_1=tan(psi1_0*pi/180);

end

if type == 3 % Airplane

h_i = 15000; % Launch Altitude (from MSL) [m] {Pegasus deployment Altitude}

r_i_1=R_Earth+h_i;

r_dot_i_1 = 0; % [m/sec]

theta_i_1=launch_long*pi/180;

theta_dot_i_1=59.72/r_i_1; % [rad/s]

phi_i_1=(90-launch_lat)*pi/180;

phi_dot_i_1=0;

b_1=tan(angle_tclimb*pi/180);

end

% Coasting Orbit Propagation Parameters

m4=0;

T4 = 0; % Zero thrust for coasting.

t_burn_4=3*60^2; % [s] for orbit trajectory

m_dot_4=0; % Mass flow rate of coasting Stage [kg/s]

Pe_4=0; % Exit pressure, 4th stage engine [Pa]

Ae_4=0; % Exit area, 4th stage engine [m^2]

diam_4=0;

......

if N==2

t_burn_3=0;

m_dot_3=0;

T3 = 0;

End

Output Section:

The function creates an input file called AAE450_Trajectory_Inputs.m this is the input file used by AAE450_Trajectory_Main.m. After writing the input file, the main trajectory code needs to be run to generate the solution. The call line is simply:

AAE450_Trajectory_Main

for AAE450_Trajectory_run.m and

AAE450_Trajectory_D2MP

for AAE450_Trajectory_run_distribute.m.

Or, for an aircraft launch,

AAE450_Trajectory_D2MP_ac

Note: Before running AAE450_Trajectory_Main.m, make sure that the script AAE450_Get_Inputs.m has the script AAE450_Trajectory_Inputs.m as the only uncommented line. Otherwise, AAE450_Trajectory_Main.m will not load the correct inputs.

Once AAE450_Trajectory_Main.m has been run, an output file will be written. This output file is a copy of what has been printed to the MATLAB Command Window and is named with the Case ID number that was assigned to it. (E.g. MG-CA-DS-DC)


AAE450_Trajectory_run.m Sample Output:

The output of AAE450_Trajectory_run(_distribute).m is the input file for the AAE450_Trajectory_Main.m.

File: AAE450_Trajectory_Inputs.m:

ID = 'SB-HA-DA-DA.txt';

type = 2.0000000000;

airplane = 0.0000000000;

N = 3.0000000000;

h_i = 30000.0000000000;

r_i_1 = 6406000.0000000000;

r_dot_i_1 = 0.0000000000;

theta_dot_i_1 = 0.0000000000;

payload_mass = 0.2000000000;

t_vertical = 10.0000000000;

t_burn_1 = 147.7675026979;

t_burn_2 = 160.8812170075;

t_burn_3 = 206.2408603065;

psi1_1 = psi1orig;

psi2 = psi2orig;

psi3 = psi3orig;

psi1_0 = 88.0000000000;

m1 = 437.8415091229;

m2 = 91.5734691245;

m3 = 31.2258015670;

T1 = 6606.1670069556;

T2 = 1392.5576461998;

T3 = 355.7926808351;

m_dot_1 = 2.0741303114;

m_dot_2 = 0.4325914350;

m_dot_3 = 0.1105253106;

diam_1 = 0.7731278821;

diam_2 = 0.3350953988;

diam_3 = 0.2309862864;

diam_4 = 0.0000000000;

Pe_1 = 2821.1669372331;

Pe_2 = 11453.6603989692;

Pe_3 = 11453.6603989692;

Ae_1 = 0.1054496676;

Ae_2 = 0.0064027858;

Ae_3 = 0.0016358851;

launch_lat = 28.0000000000;

launch_long = -80.0000000000;

theta_i_1 = -1.3962634016;

phi_i_1 = 1.0821041362;

phi_dot_i_1 = 0.0000000000;

b_1 = 28.6362532829;

phi_i_1 = 1.0821041362;

m4 = 8.4309664231;

T4 = 0.0000000000;

t_burn_4 = 32400.0000000000;

m_dot_4 = 0.0000000000;

Pe_4 = 0.0000000000;

Ae_4 = 0.0000000000;

m0_1 = 560.8407798144;

m0_2 = 122.9992706915;

m0_3 = 31.4258015670;

m0_4 = 8.6309664231;
Sample Output for Entire Trajectory Code:

The following is a sample output of the entire trajectory code (this is the output of the code AAE450_Trajectory_outputs.m). This is output to both the MATLAB command window as well as to a text file that has the same name as the case ID:

Currently running 24 deg case.

***************************************

Output from AAE450_Trajectory_outputs.m

***************************************

Case ID: LB_HA_DA_DA

Orbital Parameters

Period: 6038.7878 [s]

Semi-major axis: 7167.36 [km]

eccentricity: 0.0025

periapsis: 773.14 [km](from the surface of the Earth)

apoapsis: 809.57 [km](from the surface of the Earth)

Linear Tangent Steering Parameters:

a1 = -0.16117 b1 = 28.6363

a2 = -0.00502483 b2 = 1.32415

a3 = 2.86231e-019 b3 = -0.624869

Flight Path Angle = 0.1 [deg].

at t=0[s]:

Altitude: h=30000 [m] (Initial Condition)

Radial(Vertical) Speed: Vr=0 [m/s] (Initial Condition)

Payload Mass= 5.000 [kg]

GLOW= 6294.7686 [kg]

Thrust

1st stage: 75.073 [kN]

2nd stage: 15.257 [kN]

3rd stage: 0.692 [kN]

Max Acceleration

Max a @1st Stage= 28.5 [m/s^2]

Max a @1st Stage= 2.90 G

Max a @2nd Stage= 51.2 [m/s^2]

Max a @2nd Stage= 5.22 G

Max a @3rd Stage= 39.0 [m/s^2]

Max a @3rd Stage= 3.97 G

Max a @Coasting Stage= 3.8 [m/s^2]

Max a @Coasting Stage= 0.38 G

Burn Times

1st Stage: 175[s]

(first 10.00 [s] is vertical flight)

2nd Stage: 212.96[s]

3rd Stage: 178.40[s]

Times at the end of each stage

End of first stage: 174.00[s]

End of second stage: 386.00[s]

End of third stage: 564.00[s]

Constant Mass Flow Rates

1st Stage: 23.571[kg/s]

2nd Stage: 4.739[kg/s]

3rd Stage: 0.215[kg/s]

Constant Exit Pressures

1st Stage: 2.82[kPa]

2nd Stage: 11.45[kPa]

3rd Stage: 11.45[kPa]

Altitudes

at the end of the vertical part of flight: 30112.44[m]

at t= 0 [s] : 30.00[km]

at the end of the first stage: 131.57[km]

at the end of the second stage: 560.08[km]

at the end of the third stage: 801.62[km]

from AAE450_Delta_V.m

Delta_V_Thrust_1st= 3486 [m/s] (29.4 percent)

Delta_V_Thrust_2nd= 4775 [m/s] (40.3 percent)

Delta_V_Thrust_3rd= 3592 [m/s] (30.3 percent)

Delta_V_Thrust_Total (what we get)= 11853 [m/s]

Delta_V_Leo= 7727 [m/s]

Delta_V_Grav= 2034 [m/s]

DeltaV_drag= 4 [m/s]

Delta_V_Earth_assist= 411 [m/s]

Delta_V_Total (what we need)= 9354 [m/s]

Delta V required to circularize: 568 [m/s]

************************************************************

Note: it takes approximately 20[s] to produce all the plots.

Please wait until you get the three figures of 3-D plots.

There are six plots that are output:

Figure 1: Distance from the ground versus time

Figure 3: Radial speed versus time

Figure 5: Tangential speed versus time

Figure 6: Three views of the 3D orbit and trajectory

Figure 7: One view of the orbit (with wireframe Earth)

Figure 8: One view of the orbit (with solid sphere Earth)

Written and Compiled by Elizabeth Harkness

A.6.4 Trajectory Code User’s Guide page 43

AAE450_Trajectory_Main.m

Written by Junichi Kanehara

Revision 1.0 – 16 March 2008

Description:

AAE450_Trajectory_Main.m is the main script of the trajectory code. This code calls all the necessary scripts and functions in order to compute and output the numerical results and produce plots for one particular set of input.

Assumptions:

All necessary inputs are assumed to be given by the input file, AAE450_Trajectory_Inputs.m, which has either been created by AAE450_Trajectory_run.m or AAE450_Trajectory_run_distribute.m as described above.

Important Notes:

The log section of this main script addresses the modifications in every component of the entire trajectory code.

Input Section:

The call line of the script is:

AAE450_Trajectory_Main

Output Section:

There is no “output” in the way a function does since this is a script.

Written by Junichi Kanehara and Compiled by Elizabeth Harkness

A.6.4 Trajectory Code User’s Guide page 43

AAE450_Get_Inputs.m

Written by Junichi Kanehara

Revision 1.0 – 16 March 2008

Description:

This is a simple script that chooses which input file to call.

Important Notes:

In the early version of the codes, AAE450_Trajectory_default_inputs was usually called.

In the later version of the codes, AAE450_Trajectory_Inputs was usually called.

In the final version of the codes, the winners of each case such as LB_HA_DA_DA_v125_Inputs should be called.

Input Section:

The call line of the function is:

AAE450_Get_Inputs

Output Section:

All the necessary input variables should be obtained by this script, as it calls an input file.


AAE450_run_traj_Optimization_GB.m (AAE450_run_traj_Optimization_AC.m)

Written by Daniel Chua

Revision 1.0 – 10 March 2008