All Projects → bradleyjeck → epanet2toolkit

bradleyjeck / epanet2toolkit

Licence: other
An R package for calling the Epanet software for simulation of piping networks.

Programming Languages

c
50402 projects - #5 most used programming language
r
7636 projects

Projects that are alternatives of or similar to epanet2toolkit

epynet
Object-oriented wrapper for EPANET 2.1
Stars: ✭ 24 (+84.62%)
Mutual labels:  water, epanet
qgis-epanet
Project migrated to : https://gitlab.com/Oslandia/qgis/qgis-epanet
Stars: ✭ 36 (+176.92%)
Mutual labels:  water, epanet
epanetReader
Read text files in Epanet's .inp and .rpt formats into R
Stars: ✭ 18 (+38.46%)
Mutual labels:  water, epanet
rtide
R package to calculate tide heights
Stars: ✭ 14 (+7.69%)
Mutual labels:  cran
migraph
Tools for multimodal and multilevel network analysis
Stars: ✭ 25 (+92.31%)
Mutual labels:  cran
Gmisc
An R package for creating tables, some plots and other useful utilities too small to merit their own package
Stars: ✭ 45 (+246.15%)
Mutual labels:  cran
rcppsimdjson
Rcpp Bindings for the 'simdjson' Header Library
Stars: ✭ 103 (+692.31%)
Mutual labels:  cran
Reactr
React for R
Stars: ✭ 227 (+1646.15%)
Mutual labels:  cran
leaflet-velocity
Visualise velocity data on a leaflet layer
Stars: ✭ 467 (+3492.31%)
Mutual labels:  water
URPOcean
Ocean waves on URP for wide-range mobile devices (gles 3.0)
Stars: ✭ 98 (+653.85%)
Mutual labels:  water
nflreadr
Efficiently download nflverse data
Stars: ✭ 38 (+192.31%)
Mutual labels:  cran
SpatialPosition
R package for computing spatial position models
Stars: ✭ 30 (+130.77%)
Mutual labels:  cran
RJafroc
Artificial Intelligence: Evaluating AI, optimizing AI
Stars: ✭ 17 (+30.77%)
Mutual labels:  cran
MALDIquant
Quantitative Analysis of Mass Spectrometry Data
Stars: ✭ 48 (+269.23%)
Mutual labels:  cran
arulesViz
Visualizing Association Rules and Frequent Itemsets with R
Stars: ✭ 49 (+276.92%)
Mutual labels:  cran
Littler
A scripting and command-line front-end for GNU R
Stars: ✭ 238 (+1730.77%)
Mutual labels:  cran
QWAT
TEKSI Water module (project QWAT) - QGIS project
Stars: ✭ 52 (+300%)
Mutual labels:  water
ModelDeployment
CRAN Task View: Model Deployment with R
Stars: ✭ 19 (+46.15%)
Mutual labels:  cran
metacoder
Parsing, Manipulation, and Visualization of Metabarcoding/Taxonomic data
Stars: ✭ 120 (+823.08%)
Mutual labels:  cran
papeR
A toolbox for writing Sweave or other LaTeX-based papers and reports and to prettify the output of various estimated models.
Stars: ✭ 26 (+100%)
Mutual labels:  cran

Build Status Coverage Status CRAN RStudio mirror downloads CRAN version

epanet2toolkit

epanet2toolkit is an R package for simulating water networks using Epanet. The package provides functions from the Epanet programmer's toolkit as R functions so that basic or customized simulations can be carried out from R. The package uses Epanet version 2.2 from Open Water Analytics.

Although EPANET version 2.2 has substantial functionality beyond 2.1 this version of the R package provides the v2.1 functionality using the v2.2 code base. Only the "legacy" style functions of EPANET are supported.

In addition to this readme page and the package manual, the paper An R package for EPANET simulations is published in Environmental Modelling & Software and is also available as a preprint. The conference paper Water demand and network modelling with R gives some more in depth examples.

Installation

The package can be installed from CRAN.

install.packages("epanet2toolkit")

Especially for R<3.6.x on Windows, installation should work from MRAN.

install.packages("epanet2toolkit", repos="http://mran.revolutionanalytics.com/snapshot/2020-01-09") 

Or, install the development version from github.com

devtools::install_github("bradleyjeck\epanet2toolkit")

Getting Started

After installation, the package needs to be loaded for use.

library(epanet2toolkit)

A brief introduction is available in the package help and each function has its own help page. Functions provided by the package map directly to functions in Epanet's API and integrate with the R system for handling exceptions. Thus the function ENgetnodeindex( nodeID ) provides the index corresponding to a node ID, or raises an error if such a node ID does not exist.

?epanet2toolkit
?ENgetnodeindex

Running a Full Simulation

The function ENepanet() runs a full simulation and writes the results to a file. A file of simulation results can be analyzed using the package epanetReader.

ENepanet("Net1.inp", "Net1.rpt")

Querying Network Properties

Characteristics of a network can be examined using package functions. Note that Epanet needs to be opened for use and should be closed when the analysis finishes.

ENopen("Net1.inp", "Net1.rpt")
ENgetflowunits()
ENgetqualtype()
ENgetcount("EN_NODECOUNT") 
ENgetcount("EN_LINKCOUNT")
ENgetnodeid(1)
ENgetlinkid(1)
ENclose()

Example Programs

The US EPA website for Epanet includes example programs for a hydrant rating curve and chlorine dosage analysis. An implementation of those programs using R and epanet2toolkit are included with the package as tests:

Programming Notes for Package Developers

Epanet provides a collection of functions known as the programmer's toolkit or API for building customized simulations. epanet2toolkit makes these functions callable from R.

Functions in the Epanet API return an integer error code and provide requested values by reference.

int ENgetnodeindex(char *nodeID, int *nodeindex); 

A C toolkit function such as ENgetnodeindex takes two arguments: the node ID, and a pointer to an integer variable where the requested nodeindex is stored. The function returns an integer error code. Using the C function requires allocating an integer for storing the requested node index and passing a pointer to the storage location to the function. Checking the returned error code is optional, but is good practice.

epanet2toolkit integrates Epanet into R by providing two layers of wrapping. First, the existing functions of Epanet's C API are wrapped by new C functions with return type 'void' or 'SEXP' so that they can be called from R. Second, new R functions are provided to call these new C functions. The R functions provide some argument checking and also check the error codes returned by Epanet.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].