---
title: "iemiscdata: Examples Using Manning&#8217;s n"
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{iemiscdata Examples Using Manning's n}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

\bigskip

# Examples

The following examples show how to locate Manning&#8217;s n using the nchannel, npartfull, nmetalpipe, and nsheetflow tables provided in this package.  

The examples make more sense if you have familiarized yourself with the nchannel, npartfull, and nmetalpipe tables. There are instructions to view the tables, as a .pdf, in the [View-PDF-table-vignette](https://CRAN.R-project.org/package=iemiscdata/vignettes/View-PDF-table-vignette.html).  

\bigskip
\bigskip

# Load the required packages

```{r, warning = FALSE, message = FALSE, tidy = TRUE}
install.load::load_package("iemiscdata", "data.table", "iemisc", "rivr", "units")
# load needed packages using the load_package function from the install.load package (it is assumed that you have already installed these packages)
```

\bigskip
\bigskip

# Example 1 (nchannel)

What is the maximum Manning&#8217;s n value for a channel that has the following classification: &ldquo;Natural streams - minor streams (top width at floodstage < 100 ft), Mountain streams, no vegetation in channel, banks usually steep, trees and brush along banks submerged at high stages and bottom: gravels, cobbles, and few boulders&rdquo;?  

\bigskip

```{r, warning = FALSE, message = FALSE, tidy = TRUE}
# Use grep to find the row number matching the given description
# Use nchannel$"Type of Channel and Description" to select the column to search through
# Use nchannel[nlocation, 4] to select the row number from nlocation and column 4
# Similar steps are performed for each of these examples


# The 1st heading is "Manning's n for Channels"
# The 2nd heading is "Natural streams - minor streams (top width at floodstage < 100 ft)"
# The 3rd heading is "Mountain streams, no vegetation in channel, banks usually steep, trees and brush along banks submerged at high stages"
# The 4th heading is "bottom: gravels, cobbles, and few boulders"

data(nchannel)

# locate the row where "Type of Channel and Description" == "bottom: gravels, cobbles, and few boulders"
nlocation1 <- nchannel[nchannel$"Type of Channel and Description" %like% "bottom: gravels, cobbles, and few boulders", ]


n1 <- nlocation1$"Maximum n"

n1
```

\bigskip
\bigskip

# Example 2 (npartfull)

What is the minimum Manning&#8217;s n value for a channel that has the following classification: &ldquo;Closed Conduits Flowing Partly Full, Wood and Stave&rdquo;?  

\bigskip

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


# The 1st heading is "Manning's n for Closed Conduits Flowing Partly Full"
# The 2nd heading is "Wood"
# The 3rd heading is "Stave"

data(npartfull)

# locate the row where "Type of Conduit and Description" %like% "Stave"
nlocation2 <- npartfull[npartfull$"Type of Conduit and Description" %like% "Stave", ]

n2 <- nlocation2$"Minimum n"

n2
```

\bigskip
\bigskip

# Example 3 (nmetalpipe)

What is the Manning&#8217;s n value for a channel that has the following classification: &ldquo;Corrugated Metal Pipe, Corrugations 6x2 inches and 60" diameter&rdquo;?  

\bigskip

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

# The 1st heading is "Manning's n for Corrugated Metal Pipe"
# The 2nd heading is "Corrugations 6x2 inches"
# The 3rd heading is "Corrugations 6x2 inches – 60\"\" diameter"

data(nmetalpipe)

# locate the row where "Type of Pipe and Diameter and Corrugation Dimension" %like% "Corrugations 6x2 inches – 60\"\" diameter"
nlocation3 <- nmetalpipe[nmetalpipe$"Type of Pipe and Diameter and Corrugation Dimension" %like% "Corrugations 6x2 inches – 60\"\" diameter", ]

n3 <- nlocation3$"n"

n3
```

\bigskip
\bigskip

# Example 4 (nchannel) -- From Reference 1 (compute_profile function)

Example to compute the &ldquo;gradually-varied flow profile of a prismatic channel&rdquo; with these channel conditions used to find Manning&#8217;s n (normal): &ldquo;Natural streams - minor streams (top width at floodstage < 100 ft), Excavated or Dredged Channels, Earth, straight, and uniform, & clean, recently completed&rdquo;.  

\bigskip

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

# The 1st heading is "Manning's n for Channels"
# The 2nd heading is "Natural streams - minor streams (top width at floodstage < 100 ft)"
# The 3rd heading is "Excavated or Dredged Channels"
# The 4th heading is "Earth, straight, and uniform"
# The 5th heading is "clean, recently completed"


# Using the data for the M1 profile example in rivr's compute_profile, except for the value of n to find the channel condition

# locate the row where "Type of Channel and Description" == "bottom: gravels, cobbles, and few boulders"
nlocation4 <- nchannel[nchannel$"Type of Channel and Description" %like% "clean, recently completed", ]


n4 <- nlocation4$"Maximum n"

n4


compute_profile(0.001, n4, 250, 2.7, 1.486, 32.2, 100, 0, stepdist = 50, totaldist = 3000)
```

\bigskip
\bigskip

# Example 5

What is the critical y (critical flow depth) for this cross-section (from Example 4)?  

\bigskip

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

# Let's assume that the channel from Example 4 has a trapezoidal shape with a
# slope of m (see below).

m <- 1 / 0.8390996

critical_y <- Manningtrap_critical(Q = 250, b = 100, m = m, Sf = 0.001, n = n4, units = "Eng",
type = "symmetrical", critical = "accurate", output = "data.table")
```

\bigskip

The critical flow depth is `r set_units(as.numeric(critical_y[Parameters == "Flow depth (y)", "Critical Value"][[1]]), ft)`.  

\bigskip
\bigskip

# Example 6 (nsheetflow) -- Modified from Example 3-1 of Reference 2

&ldquo;Segment AB: Sheet flow; dense grass; slope (s) = 0.01 ft/ft; and length (L) = 100 ft. Segment BC: Shallow concentrated flow; unpaved; s = 0.01 ft/ft; and L = 1,400 ft. Segment CD: Channel flow; Manning's n = .05; flow area (a) = 27 ft2; wetted perimeter (pw) = 28.2 ft; s = 0.005 ft/ft; and L = 7,300 ft.&rdquo;  

Obtain Manning&#8217;s n for Segment AB.  

\bigskip

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

# Given "dense grass", the table has "Dense grasses"

# locate the row where "Surface description" %like% "Dense grass"
nlocation5 <- nsheetflow[nsheetflow$"Surface description" %like% "Dense grass", ]


n5 <- nlocation5$"n *1"

n5
```

\bigskip
\bigskip

# References

Reference 1  
`rivr`: Steady and Unsteady Open-Channel Flow Computation, https://CRAN.R-project.org/package=rivr  

\bigskip

Reference 2  
United States Department of Agriculture Natural Resources Conservation Service Conservation Engineering Division, &ldquo;Urban Hydrology for Small Watersheds Technical Release 55 (TR-55)&rdquo;, June 1986, page 3-4, https://directives.sc.egov.usda.gov/OpenNonWebContent.aspx?content=22162.wba  

\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/).  
