---
title: "iemisc: Comparing Other Hydraulic Software Output to iemisc&#8217;s Manningtrap for Critical Conditions"
author: "Irucka Embry, E.I.T. (EcoC²S)"
date: "`r Sys.Date()`"
lang: en-us
urlcolor: blue
output:
  rmarkdown::pdf_document:
    highlight: kate
    toc: true
    latex_engine: xelatex
vignette: >
  %\VignetteIndexEntry{iemisc Comparing Other Hydraulic Software Output to iemisc's Manningtrap for Critical Conditions}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

\bigskip

# Introduction

This document compares the results for 2 examples for a trapezoidal channel with a critical state for the FHWA Hydraulic Toolbox Version 4.4, Dr. Xing Fang&#8217;s open channel flow calculator, and Irucka Embry&#8217;s `iemisc` [https://CRAN.R-project.org/package=iemisc] Manningtrap_critical function.  

\bigskip
\bigskip

# Replicate the R code without the images

Note: If you wish to replicate the R code below, then you will need to copy and paste the following commands in R first (to make sure you have all the of the required packages):  

\medskip

```{r eval = FALSE, tidy = TRUE}

install.packages(c("install.load", "iemisc", "pander", "data.table"))
# install the packages and their dependencies
```

\bigskip
\bigskip

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

# load the required package
install.load::load_package("iemisc", "pander", "data.table")
```

\bigskip
\bigskip

# Critical State Description

> &ldquo;When F (Froude number) is equal to unity, ... the flow is said to be in a *critical* state. If F is less than unity, ... the flow is *subcritical*. If F is greater than unity, ... the flow is *supercritical*.  

> &ldquo;... the critical state of flow through a channel section is characterized by several important conditions. Recapitulating, they are (1) the specific energy is a minimum for a given discharge; (2) the discharge is a maximum for a given specific energy; (3) the specific force is a minimum for a given discharge; (4) the velocity head is equal to half the hydraulic depth in a channel of small slope; (5) the Froude number is equal to unity; and (6) the velocity of flow in a channel of small slope with uniform velocity distribution is equal to the celerity of small gravity waves in shallow water caused by local disturbances.  

> &ldquo;Discussions on critical state of flow have referred mainly to a particular section of a channel, known as the *critical section*. If the critical state of exists throughout the entire length of the channel or over a reach of the channel, the flow in the channel is a *critical flow*.&rdquo;  

–Ven Te Chow, Ph.D., *Open-Channel Hydraulics*, McGraw-Hill Classic Textbook Reissue, New York City, New York: McGraw-Hill Book Company, 1988, pages 13, 63.  

\bigskip
\bigskip

# Example 1

Given a trapezoidal channel with 3 ft symmetric side slopes, a channel width of 4 ft, a longitudinal slope of 0.02 ft/ft, Manning&#8217;s roughness coefficient of 0.0550, and a depth of 1.454 ft, calculate the missing parameters for a critical state.  

\bigskip
\bigskip

# FHWA Hydraulic Toolbox Example 1 (Image)

```{r, echo = FALSE, out.width = '100%'}

linguisticsdown::include_graphics2("compare.png")

```

\newpage

# FHWA Hydraulic Toolbox Example 1 (Text Table)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

fhwa_ex1 <- data.table(Parameter = c("Flow", "Depth", "Area of Flow", "Wetted Perimeter", "Hydraulic Radius", "Average Velocity", "Top Width (T)", "Side slope 1 (Z1)", "Side slope 2 (Z2)", "Channel width (B)", "Longitudinal slope", "Manning's roughness", "Froude Number", "Critical Depth", "Critical Velocity", "Critical Slope", "Critical Top Width", "Max Shear Stress", "Avg. Shear Stress"), Value = c(44.001, 1.454, 12.161, 13.197, 0.921, 3.618, 12.725, 3.0, 3.0, 4.0, 0.02, 0.0550, 0.652, 1.163, 5.052, 0.04979, 10.978, 1.815, 1.150), Unit = c("cfs", "ft", "sq ft", "ft", "ft", "fps", "ft", "", "", "ft", "ft/ft", "", "",  "ft", "fps", "ft/ft", "ft", "lb/ft^2", "lb/ft^2"))


pander(fhwa_ex1, missing = "")
```

\bigskip
\bigskip

# Dr. Xing Fang&#8217;s Open Channel Flow Calculator&#8217;s Solution of Example 1 (Image)

```{r, echo = FALSE, out.width = '100%'}

linguisticsdown::include_graphics2("trapezoid1.png")

```

\newpage

# Dr. Xing Fang&#8217;s Open Channel Flow Calculator&#8217;s Solution of Example 1 (Text Table)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

fang_ex1 <- data.table(Parameter = c("Flow", "Depth", "Area of Flow", "Wetted Perimeter", "Hydraulic Radius", "Average Velocity", "Top Width (T)", "Side slope 1 (Z1)", "Side slope 2 (Z2)", "Channel width (B)", "Longitudinal slope", "Manning's roughness", "Froude Number", "Critical Depth", "Critical Velocity", "Critical Slope", "Critical Top Width", "Max Shear Stress", "Avg. Shear Stress"), Value = c(43.9882, 1.454, 12.16, 13.2, "", 3.6179, 12.72, 3.0, 3.0, 4.0, 0.02, 0.0550, 0.65, 1.17, "", 0.0492, "", "", ""), Unit = c("cfs", "ft", "sq ft", "ft", "ft", "fps", "ft", "", "", "ft", "ft/ft", "", "", "ft", "fps", "ft/ft", "ft", "lb/ft^2", "lb/ft^2"))


pander(fang_ex1, missing = "")
```

\bigskip
\bigskip

# iemisc's Manningtrap Solution of Example 1

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

uuc1 <- Manningtrap_critical(y = 1.454, b = 4, m = 3, Sf = 0.02, n = 0.0550, units = "Eng", type = "symmetrical", critical = "accurate", output = "data.table")

pander(uuc1, missing = "")


uuc1a <- Manningtrap_critical(y = 1.454, b = 4, m = 3, Sf = 0.02, n = 0.0550, units = "Eng", type = "symmetrical", critical = "accurate", output = "list")

uuc1b <- Manningtrap_critical(y = 1.454, b = 4, m = 3, Sf = 0.02, n = 0.0550, units = "Eng", type = "symmetrical", critical = "approximate", output = "list")
```

\bigskip
\bigskip

# Comparing All 3 Solutions for Example 1

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

compare_ex1 <- data.table(Parameter = c("Flow", "Depth", "Area of Flow", "Wetted Perimeter", "Hydraulic Radius", "Average Velocity", "Top Width (T)", "Side slope 1 (Z1)", "Side slope 2 (Z2)", "Channel width (B)", "Longitudinal slope", "Manning's roughness", "Normal Froude Number", "Critical Froude Number", "Critical Depth", "Critical Velocity", "Critical Slope", "Critical Top Width", "Max Shear Stress", "Avg. Shear Stress"), `FHWA Value` = c(44.001, 1.454, 12.161, 13.197, 0.921, 3.618, 12.725, 3.0, 3.0, 4.0, 0.02, 0.0550, 0.652, "", 1.163, 5.052, 0.04979, 10.978, 1.815, 1.150), `Wang Value` = c(43.9882, 1.454, 12.16, 13.2, "", 3.6179, 12.72, 3.0, 3.0, 4.0, 0.02, 0.0550, 0.65, "", 1.17, "", 0.0492, "", "", ""), `iemisc Value (Accurate Critical Froude)` = c(uuc1a$Q, uuc1a$y, uuc1a$A, uuc1a$P, uuc1a$R, uuc1a$V, uuc1a$B, uuc1a$m, uuc1a$m, uuc1a$b, uuc1a$Sf, uuc1a$n, uuc1a$Fr, uuc1a$Frc, uuc1a$yc, uuc1a$Vc, uuc1a$Sfc, uuc1a$Bc, uuc1a$taud, uuc1a$tau0), `iemisc Value (Approximate Critical Froude)` = c(uuc1b$Q, uuc1b$y, uuc1b$A, uuc1b$P, uuc1b$R, uuc1b$V, uuc1b$B, uuc1b$m, uuc1b$m, uuc1b$b, uuc1b$Sf, uuc1b$n, uuc1b$Fr, uuc1b$Frc, uuc1b$yc, uuc1b$Vc, uuc1b$Sfc, uuc1b$Bc, uuc1b$taud, uuc1b$tau0), Unit = c("cfs", "ft", "sq ft", "ft", "ft", "fps", "ft", "", "", "ft", "ft/ft", "", "", "", "ft", "fps", "ft/ft", "ft", "lb/ft^2", "lb/ft^2"))


pander(compare_ex1, missing = "")
```

\bigskip
\bigskip
\bigskip
\bigskip

# Example 2

Given a trapezoidal channel with 2 ft and 1.5 ft non-symmetric side slopes, a channel width of 8 ft, a longitudinal slope of 0.01 ft/ft, Manning&#8217;s roughness coefficient of 0.0150, and a flow of 745 cfs, calculate the missing parameters for a critical state.  

\bigskip
\bigskip

# FHWA Hydraulic Toolbox Example 2

```{r, echo = FALSE, out.width = '100%'}

linguisticsdown::include_graphics2("2019-05-22_08_24_13-ChannelAnalysis.png")

```

\bigskip

# FHWA Hydraulic Toolbox Example 2 (Text Table)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

fhwa_ex2 <- data.table(Parameter = c("Flow", "Depth", "Area of Flow", "Wetted Perimeter", "Hydraulic Radius", "Average Velocity", "Top Width (T)", "Side slope 1 (Z1)", "Side slope 2 (Z2)", "Channel width (B)", "Longitudinal slope", "Manning's roughness", "Froude Number", "Critical Depth", "Critical Velocity", "Critical Slope", "Critical Top Width", "Max Shear Stress", "Avg. Shear Stress"), Value = c(745.000, 3.298, 45.419, 21.320, 2.130, 16.408, 19.543, 2.0, 1.5, 8.0, 0.01, 0.0150, 1.896, 4.639, 9.965, 0.0257, 24.235, 2.058, 1.329), Unit = c("cfs", "ft", "sq ft", "ft", "ft", "fps", "ft", "", "", "ft", "ft/ft", "", "", "ft", "fps", "ft/ft", "ft", "lb/ft^2", "lb/ft^2"))



pander(fhwa_ex2, missing = "")
```

\bigskip
\bigskip

# Dr. Xing Fang&#8217;s Open Channel Flow Calculator&#8217;s Solution of Example 2

```{r, echo = FALSE, out.width = '100%'}

linguisticsdown::include_graphics2("trapezoid2.png")

```

\newpage

# Dr. Xing Fang&#8217;s Open Channel Flow Calculator&#8217;s Solution of Example 2 (Text Table)

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

fang_ex2 <- data.table(Parameter = c("Flow", "Depth", "Area of Flow", "Wetted Perimeter", "Hydraulic Radius", "Average Velocity", "Top Width (T)", "Side slope 1 (Z1)", "Side slope 2 (Z2)", "Channel width (B)", "Longitudinal slope", "Manning's roughness", "Froude Number", "Critical Depth", "Critical Velocity", "Critical Slope", "Critical Top Width", "Max Shear Stress", "Avg. Shear Stress"), Value = c(745, 3.3, 45.51, 21.34, "", 16.371, 19.56, 2.0, 1.5, 8.0, 0.01, 0.0150, 1.89, 4.64, "", 0.0026, "",  "", ""), Unit = c("cfs", "ft", "sq ft", "ft", "ft", "fps", "ft", "", "", "ft", "ft/ft", "", "", "", "ft", "fps", "ft/ft", "ft", "lb/ft^2", "lb/ft^2"))


pander(fang_ex1, missing = "")
```

\bigskip
\bigskip

# iemisc&#8217;s Manningtrap Solution of Example 2

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

uuc2 <- Manningtrap_critical(Q = 745, b = 8, m1 = 2, m2 = 1.5, Sf = 0.01, n = 0.0150, units = "Eng", type = "non-symmetrical", critical = "accurate", output = "data.table")

pander(uuc2, missing = "")



uuc2a <- Manningtrap_critical(Q = 745, b = 8, m1 = 2, m2 = 1.5, Sf = 0.01, n = 0.0150, units = "Eng", type = "non-symmetrical", critical = "accurate", output = "list")

uuc2b <- Manningtrap_critical(Q = 745, b = 8, m1 = 2, m2 = 1.5, Sf = 0.01, n = 0.0150, units = "Eng", type = "non-symmetrical", critical = "approximate", output = "list")
```

\bigskip
\bigskip

# Comparing All 3 Solutions for Example 2

```{r, warning = FALSE, message = FALSE, tidy = TRUE}

compare_ex2 <- data.table(Parameter = c("Flow", "Depth", "Area of Flow", "Wetted Perimeter", "Hydraulic Radius", "Average Velocity", "Top Width (T)", "Side slope 1 (Z1)", "Side slope 2 (Z2)", "Channel width (B)", "Longitudinal slope", "Manning's roughness", "Normal Froude Number", "Critical Froude Number", "Critical Depth", "Critical Velocity", "Critical Slope", "Critical Top Width", "Max Shear Stress", "Avg. Shear Stress"), `FHWA Value` =  c(745.000, 3.298, 45.419, 21.320, 2.130, 16.408, 19.543, 2.0, 1.5, 8.0, 0.01, 0.0150, 1.896, "", 4.639, 9.965, 0.0257, 24.235, 2.058, 1.329), `Wang Value` = c(745, 3.3, 45.51, 21.34, "", 16.371, 19.56, 2.0, 1.5, 8.0, 0.01, 0.0150, 1.89, "", 4.64, "", 0.0026, "",  "", ""), `iemisc Value (Accurate Critical Froude)` = c(uuc2a$Q, uuc2a$y, uuc2a$A, uuc2a$P, uuc2a$R, uuc2a$V, uuc2a$B, uuc2a$m1, uuc2a$m2, uuc2a$b, uuc2a$Sf, uuc2a$n, uuc2a$Fr, uuc2a$Frc, uuc2a$yc, uuc2a$Vc, uuc2a$Sfc, uuc2a$Bc, uuc2a$taud, uuc2a$tau0), `iemisc Value (Approximate Critical Froude)` = c(uuc2b$Q, uuc2b$y, uuc2b$A, uuc2b$P, uuc2b$R, uuc2b$V, uuc2b$B, uuc2b$m1, uuc2b$m2, uuc2b$b, uuc2b$Sf, uuc2b$n, uuc2b$Fr, uuc2b$Frc, uuc2b$yc, uuc2b$Vc, uuc2b$Sfc, uuc2b$Bc, uuc2b$taud, uuc2b$tau0), Unit = c("cfs", "ft", "sq ft", "ft", "ft", "fps", "ft", "", "", "ft", "ft/ft", "", "", "", "ft", "fps", "ft/ft", "ft", "lb/ft^2", "lb/ft^2"))



pander(compare_ex2, missing = "")
```

\bigskip
\bigskip
\bigskip
\bigskip

# Works Cited

FHWA Hydraulic Toolbox Version 4.4. https://www.fhwa.dot.gov/engineering/hydraulics/software/toolbox404.cfm  

The open channel flow calculator. Dr. Xing Fang, Department of Civil Engineering, Lamar University, 2000. https://eng.auburn.edu/~xzf0001/Handbook/Channels.html  

\bigskip
\bigskip

# EcoC²S Links

EcoC²S Home -- https://www.ecoccs.com/  
About EcoC²S -- https://www.ecoccs.com/about_ecoc2s.html  
Services -- https://www.ecoccs.com/services.html  
1 Stop Shop -- https://www.ecoccs.com/other_biz.html  
Products -- https://www.questionuniverse.com/products.html  
Media -- https://www.ecoccs.com/media.html  
Resources -- https://www.ecoccs.com/resources.html  
R Trainings and Resources provided by EcoC²S (Irucka Embry, E.I.T.) -- https://www.ecoccs.com/rtraining.html  

\bigskip
\bigskip

# Copyright and License

All R code written by Irucka Embry is distributed under the GPL-3 (or later) license, see the [GNU General Public License {GPL} page](https://www.gnu.org/licenses/gpl-3.0.html).  

All written content originally created by Irucka Embry is copyrighted under the Creative Commons Attribution-ShareAlike 4.0 International License. All other written content retains the copyright of the original author(s).  

This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).  
