Skip to content

Commit

Permalink
init commit to methods branch
Browse files Browse the repository at this point in the history
  • Loading branch information
BMasinde committed Sep 15, 2019
1 parent 1775133 commit a816024
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 69 deletions.
1 change: 0 additions & 1 deletion R/birds_documentation.R
Expand Up @@ -19,4 +19,3 @@
#' }
#'
"birds"

2 changes: 1 addition & 1 deletion R/flight_simulation.R
Expand Up @@ -40,7 +40,7 @@ flysim <- function(data, method, ctrl) {
}

if (is.data.frame(data) == TRUE &&
sum(levels(data[ ,5]) == levels(factor(c(1, 2)))) != 2) {
sum(levels(data[, 5]) == levels(factor(c(1, 2)))) != 2) {
stop("Order column should be a factor with levels 1 or 2")
}

Expand Down
1 change: 0 additions & 1 deletion R/method_1.R
@@ -1,6 +1,5 @@
#' Method 1 on practical range calculation based on Breguets equations
#'
#' @name .breguet
#' @author Brian Masinde
#' @param bodyMass all up mass
#' @param wingSpan wing span of bird in metres
Expand Down
1 change: 0 additions & 1 deletion R/method_2.R
@@ -1,6 +1,5 @@
#' Method 2 practical range calculation based on Breguets equations with mean
#' of effective lift: drag ratio
#' @name .breguet_adj
#' @author Brian Masinde
#' @param bodyMass All up mass. Including fuel, crop contents and equipment in Kg
#' @param wingSpan Wing span in metres
Expand Down
9 changes: 1 addition & 8 deletions R/misc_functions.R
Expand Up @@ -306,11 +306,4 @@
return(list(Vmp, Vmr))
}

################################################################################







###############################################################################
107 changes: 51 additions & 56 deletions R/time_march.R
@@ -1,59 +1,54 @@
#' An attempt at range estimation using time marching
#'
#' @author Brian Masinde
#'
#'
#'


time_march <- function(body_mass, wing_span, wing_area) {

# default constants
cons <- list(
# profile power constant
ppcons = 8.4,

# eneryg content of fuel per kg
energy = 4 * 10 ^ 7,

# accelaration due to gravity
g = 9.81,
# mechanical efficiency [0,1]
n = 0.23,

# induced power factor
k = 1.20,

# ventilation and circulation power (Tucker's data)
R = 1.10,

# air density at fligh height
air_dens = 1.00,

# body drag coefficient
bdc = 0.10,

# constant varies btw passerines and non-passerines
alpha = c(6.25, 3.79),
delta = c(0.724, 0.723)
)

# start with power curve

# flight calculates mechanical power first then estimates chemical power (pg 47, 53)

# Estimating the minimum power speed pg 66------------------------------------------------


# Sb = bfa = body frontal area
min_pow_speed <-
((0.807 * cons$k ^ 0.25 * body_mass ^ 0.5 * cons$g ^ 0.5) /
(cons$air_dens ^ 0.5 * wing_span ^ 0.5 * bfa(body_mass) ^ 0.25 * cons$bdc ^
0.25)) - 0.9 # speed slightly lower

# induced power in horizontal flight Box 3.1 eqn 16




}
# time_march <- function(body_mass, wing_span, wing_area) {
#
# # default constants
# cons <- list(
# # profile power constant
# ppcons = 8.4,
#
# # eneryg content of fuel per kg
# energy = 4 * 10 ^ 7,
#
# # accelaration due to gravity
# g = 9.81,
# # mechanical efficiency [0,1]
# n = 0.23,
#
# # induced power factor
# k = 1.20,
#
# # ventilation and circulation power (Tucker's data)
# R = 1.10,
#
# # air density at fligh height
# air_dens = 1.00,
#
# # body drag coefficient
# bdc = 0.10,
#
# # constant varies btw passerines and non-passerines
# alpha = c(6.25, 3.79),
# delta = c(0.724, 0.723)
# )
#
# # start with power curve
#
# # flight calculates mechanical power first then estimates chemical power (pg 47, 53)
#
# # Estimating the minimum power speed pg 66------------------------------------------------
#
#
# # Sb = bfa = body frontal area
# min_pow_speed <-
# ((0.807 * cons$k ^ 0.25 * body_mass ^ 0.5 * cons$g ^ 0.5) /
# (cons$air_dens ^ 0.5 * wing_span ^ 0.5 * bfa(body_mass) ^ 0.25 * cons$bdc ^
# 0.25)) - 0.9 # speed slightly lower
#
# # induced power in horizontal flight Box 3.1 eqn 16
#
#
#
#
# }
1 change: 1 addition & 0 deletions flying.Rproj
Expand Up @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,namespace
2 changes: 1 addition & 1 deletion tests/testthat/test_flysim.R
Expand Up @@ -3,7 +3,7 @@ context("data input in flysim")

data("birds")

vec_data <- c(5,4,7,8,9,10)
vec_data <- c(5, 4, 7, 8, 9, 10)

test_that("vector input is not allowed", {
expect_error(flysim(vec_data))
Expand Down

0 comments on commit a816024

Please sign in to comment.