Summaries of LV3 OpenRocket Simulation

Interpreter Version

This notebook was last run with the interpreter shown below.
It is known to work with output from OpenRocket 15.03.
(It will probably work with any version of R.)


In [1]:
data.frame(R.Version())


platformarchossystemstatusmajorminoryearmonthdaysvn.revlanguageversion.stringnickname
x86_64-pc-linux-gnu x86_64 linux-gnu x86_64, linux-gnu 3 2.3 2015 12 10 69752 R R version 3.2.3 (2015-12-10)Wooden Christmas-Tree

Data Input

When creating a CSV file from OpenRocket, take the "kitchen sink" approach. If it gives you an option to include something, include it. Missing data may cause this script to break or give misleading/unexpected output.

The comment character should be an octothorpe (#). The CSV should include commented lines for when certain events occur, such as the apogee.


In [2]:
# CSV file you want to look at
#csvName <- 'simData/LV3_L13_O3400_2018-02-06.csv'
csvName <- 'simData/LV3_L13_N2501_2018-02-06.csv'
cat('This cell DOES auto-complete parens and quotes. (awful!)')

In [ ]:
cat('This cell doesn\'t auto-complete my parens or quotes. (nice!)')
cat('And, now that I\'ve restarted the server and the kernel, it DOES!)

In [ ]:
cat('This cell was created after the kernel was started, and it doesn\'t.')
cat('After re-opening the cell, it still behaves correctly.')

In [3]:
#### parse the CSV file ####
simStringLines <- readLines(csvName)#read the CSV as a vector of the lines
dat <- read.csv(#load the simulation from a CSV into a data frame
	csvName, 
	comment.char= "#",#ignore commented lines
	nrows= grep("APOGEE", simStringLines)#stop reading [slightly] after apogee
	)
if (!exists("dat")) stop("Couldn't find ", csvName) # check that we sucessfully read the CSV
datNames <- simStringLines[grep("Time", simStringLines)] # extract the column names
datNames <- sub(pattern= "# ", replacement= "", x= datNames) # remove comment char
datNames <- strsplit(datNames, split= ",")[[1]] # break apart into a vector
datNames <- gsub("[^[:alnum:]///' ]", "", datNames)#regex black magic (remove weird chars)
datNames <- sub(pattern= " ", replacement= "_", datNames)#replace spaces with underscores
datNames <- sub(pattern= " ", replacement= "_", datNames)#nonbreaking spaces?
datNames <- sub(pattern= " ", replacement= "_", datNames)#other magical spaces?!
colnames(dat) <- datNames # name the columns
head(dat)


Time_sAltitude_mVertical_velocity_m/sVertical_acceleration_m/sTotal_velocity_m/sTotal_acceleration_m/sPosition_East_of_launch mPosition_North_of_launch mLateral_distance_mLateral_direction_Reference_length_cmReference_area_cmVertical_orientation_zenith_Lateral_orientation_azimuth_Wind_velocity_m/sAir_temperature_CAir_pressure_mbarSpeed_of_sound_m/sSimulation_time_step_sComputation_time_s
0.002 0.0000e+000.00000000-5.46770 0.000000005.46770 0 0 0 0 16.764 220.72 90 0 NaN 6.03 858.32 334.95 0.002 0.0062884
0.004 0.0000e+000.00000000-2.57890 0.000000002.57890 0 0 0 0 16.764 220.72 90 0 NaN 6.03 858.32 334.95 0.002 0.0072761
0.006 0.0000e+000.00000000 0.31011 0.000000000.31011 0 0 0 0 16.764 220.72 90 0 NaN 6.03 858.32 334.95 0.002 0.0084689
0.008 6.2066e-070.00062077 3.19930 0.000620773.19930 0 0 0 0 16.764 220.72 90 0 NaN 6.03 858.32 334.95 0.002 0.0095215
0.010 8.2613e-060.00702000 6.08860 0.007020006.08860 0 0 0 0 16.764 220.72 90 0 NaN 6.03 858.32 334.95 0.002 0.0109910
0.012 3.4479e-050.01919800 8.97820 0.019198008.97820 0 0 0 0 16.764 220.72 90 0 NaN 6.03 858.32 334.95 0.002 0.0120030

Summary


In [4]:
flightMaximums <- sapply(1:ncol(dat), function(i) max(dat[,i], na.rm = T))
names(flightMaximums) <- names(dat)


Warning message in max(dat[, i], na.rm = T):
“no non-missing arguments to max; returning -Inf”

In [5]:
cat('Maximum values:\n')
flightMaximums


Maximum values:
Time_s
31.82
Altitude_m
5490.7
Vertical_velocity_m/s
425.23
Vertical_acceleration_m/s
105.33
Total_velocity_m/s
426.28
Total_acceleration_m/s
105.33
Position_East_of_launch m
509.62
Position_North_of_launch m
0.69201
Lateral_distance_m
509.62
Lateral_direction_
0.077803
Lateral_velocity_m/s
30.005
Lateral_acceleration_m/s
13.129
Latitude_
43.4
Longitude_
-120.39
Gravitational_acceleration_m/s
9.8005
Angle_of_attack_
90
Roll_rate_/s
0
Pitch_rate_/s
19.573
Yaw_rate_/s
0.51697
Mass_g
30457
Propellant_mass_g
8703.5
Longitudinal_moment_of_inertia kgm
30.452
Rotational_moment_of_inertia kgm
0.070951
CP_location_cm
254.95
CG_location_cm
213.74
Stability_margin_calibers_
4.137
Mach_number_
1.2948
Reynolds_number_
77150000
Thrust_N
3485.5
Drag_force_N
859.73
Drag_coefficient_
0.51304
Axial_drag_coefficient_
0.58408
Friction_drag_coefficient_
0.38881
Pressure_drag_coefficient_
0.069704
Base_drag_coefficient_
0.2499
Normal_force_coefficient_
9.4933
Pitch_moment_coefficient_
8.35
Yaw_moment_coefficient_
0.00049972
Side_force_coefficient_
0
Roll_moment_coefficient_
0
Roll_forcing_coefficient_
0
Roll_damping_coefficient_
0
Pitch_damping_coefficient_
2.628
Coriolis_acceleration_m/s
0.045269
Reference_length_cm
16.764
Reference_area_cm
220.72
Vertical_orientation_zenith_
90
Lateral_orientation_azimuth_
0.13639
Wind_velocity_m/s
-Inf
Air_temperature_C
6.03
Air_pressure_mbar
858.32
Speed_of_sound_m/s
334.95
Simulation_time_step_s
0.01
Computation_time_s
2.2362

In [6]:
par.old <- par()
layout(matrix(c(1,2), nrow=2), heights = c(1,1))
par(mar=c(0,5,2,2))
plot(
    dat$Time_s, dat$Stability_margin_calibers_, 
    type='l', ylim=c(0, max(dat$Stab, na.rm=T)),
    xlab='time (s)', ylab=NA, xaxt='n',
    main='Characterizing Plots'
    )
lines(dat$Time_s, dat$Angle_of_attack_, col='gray')
grid(col='darkgray')
legend(
    'center', 
    legend=c(
        'stability margin calibers',
        'angle of attack (degrees)',
        paste('SMC off rail = ', na.omit(dat$Stability)[1])
    ),
    col=c('black', 'gray', NA),
    lty=1
)
par(mar=c(5,5,0,2))
plot(
    dat$Time, dat$Vertical_orientation_zenith_,
    xlab='time (s)', ylab= 'vertical orientation\n(degrees)',
    type='l'
)
grid(col='gray')
suppressWarnings(par(par.old))