---
title: "Gas Inflow Overbalanced"
author: "Alfonso R. Reyes"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Gas Inflow Overbalanced}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

This vignette show the search of papers that are about gas influx in an overbalanced well where a long section of exposed shale was shut in for many hours. While gas influx was not expected because the well was in an overbalanced condition while shut in, the gas influx may have been caused by a [desorption][desorption] mechanism. To explain the flow, a differential equation was written using a concentration gradient, not pressure gradient.


```{r, rows.print=25}
library(petro.One)

major <- c("gas influx")
minor <- c("overbalanced", "shut in")
lesser <- c("shale", "drilling")
more <- c("gas diffusion", "concentration gradient")


paper_results <- run_papers_search(major, minor, lesser, more,
                                   get_papers = TRUE,       # return with papers
                                   verbose = FALSE,         # show progress
                                   len_keywords = 4,        # naming the data file
                                   allow_duplicates = FALSE) # by paper title and id

(papers <- paper_results$papers)
```

## Providing the author or company
Now, we want to reduce the number of papers that might be authored by BP.

```{r}
library(petro.One)

major <- c("gas influx")
minor <- c("overbalanced", "shut in", "shut-in")
lesser <- c("shale", "drilling", "logging")
more <- c("desorption", "concentration gradient")
author <- c("British Petroleum", "BP")

paper_results <- run_papers_search(major, minor, lesser, more, author,
                                   get_papers = TRUE,       # return with papers
                                   verbose = FALSE,         # show progress
                                   len_keywords = 4,        # naming the data file
                                   allow_duplicates = FALSE) # by paper title and id

(papers <- paper_results$papers)

# returns "no non-missing arguments to max; returning -Inf"
```

```{r}
# library(xlsx)
# write.xlsx2(papers <- paper_results$papers, file = "gas_influx_gas_difusion.xlsx")
```


[desorption]: https://en.wikipedia.org/wiki/Desorption
