183
.github/BuildAndTest.md
vendored
Normal file
183
.github/BuildAndTest.md
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
## Building OWA EPANET From Source on Windows
|
||||
by Michael E. Tryby
|
||||
|
||||
Created on: March 13, 2018
|
||||
|
||||
|
||||
### Introduction
|
||||
|
||||
Building OWA's fork of EPANET from source is a basic skill that all developers
|
||||
interested in contributing to the project should know how to perform. This
|
||||
document describes the build process step-by-step. You will learn 1) how to
|
||||
configure your machine to build the project locally; 2) how to obtain the
|
||||
project files using git; 3) how to use cmake to generate build files and build
|
||||
the project; and 4) how to use ctest and nrtest to perform unit and regression
|
||||
testing on the build artifacts produced. Be advised, you will need local admin
|
||||
privileges on your machine to follow this tutorial. Let’s begin!
|
||||
|
||||
### Dependencies
|
||||
|
||||
Before the project can be built the required tools must be installed. The OWA
|
||||
EPANET project adheres to a platform compiler policy - for each platform there
|
||||
is a designated compiler. The platform compiler for Windows is Visual
|
||||
Studio cl, for Linux gcc, and for Mac OS clang. These instructions describe how
|
||||
to build EPANET on Windows. CMake is a cross platform build, testing, and packaging
|
||||
tool that is used to automate the EPANET build workflow. Boost is a free portable
|
||||
peer-reviewed C++ library. Unit tests are linked with Boost unit test libraries.
|
||||
Lastly, git is a free and open source distributed version control system. Git must
|
||||
be installed to obtain the project source code from the OWA EPANET repository
|
||||
found on GitHub.
|
||||
|
||||
### Summary of Build Dependencies
|
||||
- Platform Compiler
|
||||
- Windows: Visual Studio 10.0 32-bit cl (version 16.00.40219.01 for 80x86)
|
||||
- CMake (version 3.0.0 or greater)
|
||||
- Boost Libraries (version 1.58 or greater)
|
||||
- git (version 2.6.0 or greater)
|
||||
|
||||
### Build Procedure
|
||||
1. Install Dependencies
|
||||
* A. Install Visual Studio 2010 Express and SP1
|
||||
Our current benchmark platform and compiler is Windows 32-bit Visual Studio 10
|
||||
2010. Older versions of Visual Studio are available for download here:
|
||||
|
||||
https://www.visualstudio.com/vs/older-downloads/
|
||||
|
||||
A service pack for Visual Studio 10 2010 is available here:
|
||||
|
||||
https://www.microsoft.com/en-us/download/details.aspx?id=34677
|
||||
|
||||
* B. Install Boost
|
||||
Boost binaries for Windows offer a convenient installation solution. Be sure to
|
||||
select for download the boost installer exe that corresponds to the version of Visual Studio you have installed.
|
||||
|
||||
https://sourceforge.net/projects/boost/files/boost-binaries/1.58.0/
|
||||
|
||||
Although newer version of Boost are available, a link to Boost 1.58 is provided. This is the library version that the unit tests have been written against. Older versions of Boost may not work. The default install location for the Boost
|
||||
Libraries is C:\local\boost_1_58_0
|
||||
|
||||
* C. Install Chocolatey, CMake, and git
|
||||
Chocolatey is a Windows package manager that makes installing some of these
|
||||
dependencies a little easier. When working with Chocolatey it is useful to have
|
||||
local admin privileges. Chocolatey is available here:
|
||||
|
||||
https://chocolatey.org/install
|
||||
|
||||
Once Chocolately is installed, from a command prompt running with admin privileges
|
||||
issue the following commands
|
||||
```
|
||||
\>choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=User'
|
||||
\>choco install -y git --installargs /GitOnlyOnPath
|
||||
\>refreshenv
|
||||
```
|
||||
|
||||
* D. Common Problems
|
||||
Using chocolatey requires a command prompt with admin privileges.
|
||||
Check to make sure installed applications are on the command path.
|
||||
Make note of the Boost Library install location.
|
||||
|
||||
|
||||
2. Build The Project
|
||||
As administrator open a Visual Studio 2010 Command Prompt. Change directories to
|
||||
the location where you wish to build the EPANET project. Now we will issue a series
|
||||
of commands to create a parent directory for the project root and clone the project
|
||||
from OWA's GitHub repository.
|
||||
|
||||
* A. Clone the EPANET Repository
|
||||
```
|
||||
\>mkdir OWA
|
||||
\>cd OWA
|
||||
\>git clone --branch=dev https://github.com/OpenWaterAnalytics/EPANET.git
|
||||
\>cd EPANET
|
||||
```
|
||||
The present working directory is now the project root EPANET. The directory contains
|
||||
the same files that are visibly present in the GitHub Repo by browsing to the URL
|
||||
https://github.com/OpenWaterAnalytics/EPANET/tree/dev.
|
||||
|
||||
Now we will create a build products directory and generate the platform build
|
||||
file using cmake.
|
||||
|
||||
* B. Generate the build files
|
||||
```
|
||||
\>mkdir buildprod
|
||||
\>cd buildprod
|
||||
\>set BOOST_ROOT=C:\local\boost_1_58_0
|
||||
\>cmake -G "Visual Studio 10 2010" -DBOOST_ROOT="%BOOST_ROOT%" -DBoost_USE_STATIC_LIBS="ON" ..
|
||||
```
|
||||
|
||||
Now that the dependencies have been installed and the build system has been
|
||||
generated, building EPANET is a simple CMake command.
|
||||
|
||||
* C. Build EPANET
|
||||
\>cmake --build . --config Debug
|
||||
|
||||
* D. Common Problems
|
||||
CMake may not be able to find the project CMakeLists.txt file or the Boost
|
||||
library install location.
|
||||
|
||||
|
||||
3. Testing
|
||||
Unit Testing uses Boost Unit Test library and CMake ctest as the test runner.
|
||||
Cmake has been configured to register tests with ctest as part of the build process.
|
||||
|
||||
* A. Unit Testing
|
||||
```
|
||||
\>cd tests
|
||||
\>ctest -C Debug
|
||||
```
|
||||
The unit tests run quietly. Ctest redirects stdout to a log file which can be
|
||||
found in the "tests\Testing\Temporary" folder. This is useful when a test fails.
|
||||
|
||||
Regression testing is somewhat more complicated because it relies on Python
|
||||
to execute EPANET for each test and compare the binary files and report files.
|
||||
To run regression tests first python and any required packages must be installed.
|
||||
If Python is already installed on your local machine the installation of
|
||||
miniconda can be skipped.
|
||||
|
||||
* B. Installing Regression Testing Dependencies
|
||||
```
|
||||
cd ..\..
|
||||
\>choco install -y miniconda --installargs '/AddToPath=1'
|
||||
\>choco install -y curl
|
||||
\>choco install -y 7zip
|
||||
\>refreshenv
|
||||
\>pip install -r tools/requirements-appveyor.txt
|
||||
```
|
||||
|
||||
With Python and the necessary dependencies installed, regression testing can be run
|
||||
using the before-test and run-nrtest helper scripts found in the tools folder. The script
|
||||
before-test stages the test and benchmark files for nrtest. The script run-nrtest calls
|
||||
nrtest execute and nrtest compare to perform the regression test.
|
||||
|
||||
To run the executable under test, nrtest needs the absolute path to it and a
|
||||
unique identifier for it such as the version number. The project cmake build places build
|
||||
artifacts in the buildprod\bin\ folder. On Windows the build configuration "Debug" or
|
||||
"Release" must also be indicated. On Windows it is also necessary to specify the path to
|
||||
the Python Scripts folder so the nrtest execute and compare commands can be found. You
|
||||
need to substitute bracketed fields below like "<build identifier>" with the values for
|
||||
your setup.
|
||||
|
||||
* C. Regression Testing
|
||||
```
|
||||
\>tools\before-test.cmd <relative path to regression test location> <absolute path to exe under test> <build identifier>
|
||||
\>tools\run-nrtest.cmd <absolute path to python scripts> <relative path to regression test location> <build identifier>
|
||||
```
|
||||
|
||||
* D. Common Problems
|
||||
The batch file before-test.cmd needs to run with admin privileges. The nrtest script complains when it can't find manifest files.
|
||||
|
||||
That concludes this tutorial on building OWA EPANET from source on Windows.
|
||||
You have learned how to configure your machine satisfying project dependencies
|
||||
and how to acquire, build, and test EPANET on your local machine. To be sure,
|
||||
there is a lot more to learn, but this is a good start! Learn more about project
|
||||
build and testing dependencies by following the links provided below.
|
||||
|
||||
### Further Reading
|
||||
* Visual Studio - https://msdn.microsoft.com/en-us/library/dd831853(v=vs.100).aspx
|
||||
* CMake - https://cmake.org/documentation/
|
||||
* Boost - http://www.boost.org/doc/
|
||||
* git - https://git-scm.com/doc
|
||||
* Miniconda - https://conda.io/docs/user-guide/index.html
|
||||
* curl - https://curl.haxx.se/
|
||||
* 7zip - https://www.7-zip.org/
|
||||
* nrtest - https://nrtest.readthedocs.io/en/latest/
|
||||
220
.gitignore
vendored
Normal file → Executable file
220
.gitignore
vendored
Normal file → Executable file
@@ -2,14 +2,14 @@
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
*.map
|
||||
*.exp
|
||||
*.lib
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
# Compiled Dynamic libraries and executables
|
||||
*.so
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
@@ -19,16 +19,218 @@
|
||||
# Doxygen output
|
||||
doxygen_out/
|
||||
|
||||
# Mac Stuff
|
||||
# OS X Finder
|
||||
.DS_Store
|
||||
|
||||
# Xcode per-user config
|
||||
*.mode1
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspective
|
||||
*.perspectivev3
|
||||
*.pbxuser
|
||||
*.xcworkspace
|
||||
xcuserdata
|
||||
|
||||
# Build products
|
||||
*.o
|
||||
*.LinkFileList
|
||||
*.hmap
|
||||
|
||||
# Automatic backup files
|
||||
*~.nib/
|
||||
*.swp
|
||||
*~.nib
|
||||
*.build/
|
||||
DerivedData/
|
||||
Debug/
|
||||
*~
|
||||
*.dep
|
||||
|
||||
*.xcodeproj/
|
||||
!*.xcodeproj/project.pbxproj
|
||||
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.idb
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
# =========================
|
||||
# Windows detritus
|
||||
# =========================
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
|
||||
*.xcuserstate
|
||||
|
||||
# WindSDK compiled folders
|
||||
build/WinSDK/32bit/
|
||||
build/WinSDK/64bit/
|
||||
=======
|
||||
|
||||
|
||||
# Python compiler files
|
||||
*.py[c]
|
||||
|
||||
# Python distribution and packaging
|
||||
dist/
|
||||
temp/
|
||||
*.cfg
|
||||
*.egg-info/
|
||||
|
||||
# Eclipse Stuff
|
||||
.metadata/
|
||||
.settings/
|
||||
.project
|
||||
.cproject
|
||||
.pydevproject
|
||||
|
||||
# Testing Stuff
|
||||
nrtestsuite/
|
||||
tests/data/
|
||||
tests/outfile/data/en*
|
||||
|
||||
|
||||
#Cmake stuff
|
||||
__cmake_systeminformation/
|
||||
buildprod*/
|
||||
*_export.h
|
||||
|
||||
|
||||
# git merge
|
||||
*.orig
|
||||
|
||||
13
.mailmap
Normal file
13
.mailmap
Normal file
@@ -0,0 +1,13 @@
|
||||
Sam Hatchett <samhatchett@gmail.com>
|
||||
James Uber <jim@citilogics.com>
|
||||
Demetrios Eliades <eldemet@gmail.com>
|
||||
Hyoungmin Woo <hyoungmin.woo@gmail.com>
|
||||
Hyoungmin Woo <hyoungmin.woo@gmail.com> <woohn@mail.uc.edu>
|
||||
Yunier Soad <yunier.soad@gmail.com>
|
||||
Jinduan Chen <jinduan.uc@gmail.com>
|
||||
Maurizio Cingi <mrzcng2@gmail.com>
|
||||
Elad Salomons <selad@optiwater.com> <elad.salomons@gmail.com>
|
||||
Angela Marchi <angela.marchi@adelaide.edu.au>
|
||||
Angela Marchi <angela.marchi@adelaide.edu.au> <a1219261@adelaide.edu.au>
|
||||
Bryant McDonnell <bemcdonnell@gmail.com>
|
||||
Marios Kyriakou <mariosmsk@gmail.com>
|
||||
58
.travis.yml
Normal file
58
.travis.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
language: python
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# works on Precise and Trusty
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:mhier/libboost-latest'
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
- boost1.67
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
- PLATFORM="linux"
|
||||
- REF_BUILD_ID="220dev1"
|
||||
|
||||
python:
|
||||
- "3.6"
|
||||
|
||||
env:
|
||||
global:
|
||||
- SUT_BUILD_ID=$TRAVIS_JOB_NUMBER
|
||||
- EPANET_HOME=`pwd`
|
||||
- BUILD_HOME=buildprod
|
||||
- TEST_HOME=nrtestsuite
|
||||
|
||||
before_install:
|
||||
# - sudo apt-get -qq update
|
||||
- eval "${MATRIX_EVAL}"
|
||||
|
||||
#install:
|
||||
# - sudo apt-get install -y libboost-test-dev
|
||||
# - sudo apt-get install -y libboost-thread-dev
|
||||
|
||||
before_script:
|
||||
- mkdir -p $BUILD_HOME
|
||||
- cd $BUILD_HOME
|
||||
- cmake -DCMAKE_C_COMPILER=${CC}
|
||||
-DCMAKE_CXX_COMPILER=${CXX}
|
||||
-DBUILD_TESTS=ON
|
||||
-DBUILD_COVERAGE=ON ..
|
||||
|
||||
script:
|
||||
- cmake --build .
|
||||
# run unit tests
|
||||
- cd tests
|
||||
- ctest --output-on-failure
|
||||
# run regression tests
|
||||
- cd $EPANET_HOME
|
||||
- pip install -r tools/requirements.txt
|
||||
- tools/before-test.sh $PLATFORM $REF_BUILD_ID $SUT_BUILD_ID $TRAVIS_COMMIT
|
||||
- tools/run-nrtest.sh -c -s $SUT_BUILD_ID
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
22
AUTHORS
Normal file
22
AUTHORS
Normal file
@@ -0,0 +1,22 @@
|
||||
# Authors ordered by first contribution.
|
||||
# Generated by tools/update-authors.sh
|
||||
# and modified to reflect works in the public domain (denoted by ***)
|
||||
|
||||
Lew Rossman <LRossman@cinci.rr.com> ***
|
||||
Michael Tryby <tryby.michael@epa.gov> ***
|
||||
Sam Hatchett <samhatchett@gmail.com>
|
||||
Feng Shang <fshang>
|
||||
James Uber <jim@citilogics.com>
|
||||
Tom Taxon <tntaxon@anl.gov>
|
||||
Hyoungmin Woo <hyoungmin.woo@gmail.com>
|
||||
Jinduan Chen <jinduan.uc@gmail.com>
|
||||
Yunier Soad <yunier.soad@gmail.com>
|
||||
Mike Kane <muke195@gmail.com>
|
||||
Demetrios Eliades <eldemet@gmail.com>
|
||||
Will Furnass <will@thearete.co.uk>
|
||||
Steffen Macke <sdteffen@sdteffen.de>
|
||||
Marios Kyriakou <mariosmsk@gmail.com>
|
||||
Elad Salomons <selad@optiwater.com>
|
||||
Maurizio Cingi <mrzcng2@gmail.com>
|
||||
Bryant McDonnell <bemcdonnell@gmail.com>
|
||||
Angela Marchi <angela.marchi@adelaide.edu.au>
|
||||
137
CMakeLists.txt
Normal file
137
CMakeLists.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
# CMakeLists.txt - CMake configuration file for EPANET 2.0
|
||||
#
|
||||
# CMake is a cross-platform build tool. CMake generates platform native
|
||||
# build systems that can be used with your compiler of choice. CMake uses a
|
||||
# generator concept to represent different build tooling. CMake automatically
|
||||
# detects the platform it is running on and generates the appropriate makefiles
|
||||
# for the platform default compiler. Different generators can also be specified.
|
||||
#
|
||||
# Note: CMake requires that your platform build system and compiler are
|
||||
# properly installed. Build using Visual Studio requires msbuild shell.
|
||||
#
|
||||
# Build Options:
|
||||
# BUILD_TESTS = ON/OFF
|
||||
# BUILD_PY_LIB = ON/OFF
|
||||
#
|
||||
# Generic Invocation:
|
||||
# cmake -E make_directory buildprod
|
||||
# cd build
|
||||
# cmake -G GENERATOR -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON ..
|
||||
# cmake --build . --target SOME_TARGET --config Release
|
||||
#
|
||||
# More information:
|
||||
# cmake --help
|
||||
#
|
||||
# CMake is available at https://cmake.org/download/
|
||||
#
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.8)
|
||||
|
||||
project(EPANET)
|
||||
|
||||
# Append local dir to module search path
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||
|
||||
option(BUILD_TESTS "Build tests (requires Boost)" OFF)
|
||||
option(BUILD_PY_LIB "Build library for Python wrapper" OFF)
|
||||
option(BUILD_COVERAGE "Build library for coverage" OFF)
|
||||
|
||||
|
||||
IF (NOT BUILD_PY_LIB)
|
||||
add_subdirectory(run)
|
||||
ENDIF (NOT BUILD_PY_LIB)
|
||||
add_subdirectory(src/outfile)
|
||||
|
||||
IF (BUILD_TESTS)
|
||||
#Prep ourselves for compiling with boost
|
||||
IF(WIN32)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
ELSE(TRUE)
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||
ENDIF(WIN32)
|
||||
|
||||
find_package(Boost COMPONENTS unit_test_framework system thread filesystem)
|
||||
include_directories (${Boost_INCLUDE_DIRS})
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(tests/outfile)
|
||||
add_subdirectory(tests/util)
|
||||
ENDIF (BUILD_TESTS)
|
||||
|
||||
|
||||
# Sets for output directory for executables and libraries.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
|
||||
# Sets the position independent code property for all targets
|
||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
|
||||
IF (APPLE)
|
||||
set(INSTALL_NAME_DIR @executable_path/../lib)
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
ENDIF (APPLE)
|
||||
|
||||
IF (MSVC)
|
||||
set(CMAKE_C_FLAGS_RELEASE "/GL")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
ENDIF (MSVC)
|
||||
|
||||
|
||||
# configure file groups
|
||||
file(GLOB EPANET_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} src/*.c src/util/*.c)
|
||||
file(GLOB EPANET_LIB_ALL RELATIVE ${PROJECT_SOURCE_DIR} src/* src/util/*)
|
||||
# exclude epanet python API from the default build
|
||||
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet_py.c")
|
||||
source_group("Library" FILES ${EPANET_LIB_ALL})
|
||||
|
||||
|
||||
# create build target for epanet library with python API
|
||||
IF (BUILD_PY_LIB)
|
||||
|
||||
# exclude legacy epanet 2.0 API and include epanet py API
|
||||
list(REMOVE_ITEM EPANET_LIB_ALL "src/epanet2.c")
|
||||
add_library(epanet_py SHARED ${EPANET_LIB_ALL} src/epanet_py.c src/util/errormanager.c)
|
||||
target_include_directories(epanet_py PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
include(GenerateExportHeader)
|
||||
GENERATE_EXPORT_HEADER(epanet_py
|
||||
BASE_NAME epanet_py
|
||||
EXPORT_MACRO_NAME EXPORT_PY_API
|
||||
EXPORT_FILE_NAME epanet_py_export.h
|
||||
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_py_export.h
|
||||
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
|
||||
# create build target for code coverage
|
||||
ELSEIF (BUILD_COVERAGE)
|
||||
|
||||
include(CodeCoverage)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
APPEND_COVERAGE_COMPILER_FLAGS()
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0")
|
||||
|
||||
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
|
||||
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
|
||||
# create build target for default epanet library with 2.0 and 2.2 API
|
||||
ELSE (BUILD_PY_LIB)
|
||||
|
||||
# the shared library
|
||||
IF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
|
||||
add_library(epanet2 SHARED ${EPANET_LIB_ALL})
|
||||
ELSE(TRUE)
|
||||
add_library(epanet2 SHARED ${EPANET_LIB_ALL} ${PROJECT_SOURCE_DIR}/include/epanet2.def)
|
||||
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/epanet2.def PROPERTIES_HEADER_FILE_ONLY TRUE)
|
||||
ENDIF("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" OR NOT MSVC)
|
||||
|
||||
target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
ENDIF (BUILD_PY_LIB)
|
||||
26
LICENSE
Normal file
26
LICENSE
Normal file
@@ -0,0 +1,26 @@
|
||||
MIT License
|
||||
|
||||
<<<<<<< HEAD
|
||||
Works are copyright (c) 2018 their respective AUTHORS,
|
||||
unless such work is in the Public Domain (again, see AUTHORS)
|
||||
=======
|
||||
Copyright (c) 2017 Open Water Analytics
|
||||
>>>>>>> master
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
23
README.md
Normal file → Executable file
23
README.md
Normal file → Executable file
@@ -1,8 +1,23 @@
|
||||
EPANET
|
||||
EPANET {#epanet-readme}
|
||||
======
|
||||
|
||||
The EPANET Library is a pressurized pipe network hydraulic and water quality analysis toolkit written in C.
|
||||
## Build Status
|
||||
[](https://ci.appveyor.com/project/OpenWaterAnalytics/epanet/branch/dev)
|
||||
[](https://travis-ci.org/OpenWaterAnalytics/EPANET)
|
||||
|
||||
__Note:__ This is not the "official" release of EPANET -- for that, please go to [the USEPA website](http://www2.epa.gov/water-research/epanet).
|
||||
[](https://codecov.io/gh/OpenWaterAnalytics/EPANET)
|
||||
|
||||
However, if you are interested in extending EPANET for academic, personal, or commercial use, then this is probably a good place to be.
|
||||
|
||||
## For EPANET-related questions and discussion
|
||||
For community discussion, FAQ, and roadmapping of the project, go to the [Community Forum](http://community.wateranalytics.org/category/epanet).
|
||||
|
||||
## What is on this Repository?
|
||||
The EPANET Library is a pressurized pipe network hydraulic and water quality analysis toolkit written in C. If you are interested in using/extending EPANET for academic, personal, or commercial use, then you've come to the right place.
|
||||
|
||||
Please see the [`version 2.1` Release Notes](https://github.com/OpenWaterAnalytics/EPANET/blob/master/ReleaseNotes2_1.md) for information relevant to users of the previous official version (2.00.12). If you would like to contribute by addressing any of the outstanding [Issues](https://github.com/OpenWaterAnalytics/EPANET/issues), then please comment on the Issue, then Fork this repo to your own account and base your commits on the [`dev` branch](https://github.com/OpenWaterAnalytics/EPANET/tree/dev). Once you are finished, you can open a Pull Request to test the code and discuss merging your changes back into the community respository.
|
||||
|
||||
A step-by-step tutorial on how to contribute to EPANET using GitHub is also [available](http://www.slideshare.net/demetriseliades/contributing-to-epanet-using-github-in-windows).
|
||||
|
||||
__Note:__ This repository is not affiliated with, or endorsed by, the USEPA. For the last "official" release of EPANET (2.00.12 UI and Toolkit) please go to the [EPA's GitHub repo](https://github.com/USEPA/Water-Distribution-Network-Model) or [the USEPA website](http://www2.epa.gov/water-research/epanet). It is also not the graphical user interface version. This is the hydraulic and water quality solver engine.
|
||||
|
||||
However, if you are interested in extending EPANET for academic, personal, or commercial use, then you've come to the right place. For community discussion, FAQ, and roadmapping of the project, go to the [Community Forum](http://community.wateranalytics.org/category/epanet).
|
||||
|
||||
104
ReleaseNotes2_1.md
Normal file
104
ReleaseNotes2_1.md
Normal file
@@ -0,0 +1,104 @@
|
||||
Release Notes for EPANET 2.1 {#release_2_1}
|
||||
============================
|
||||
|
||||
The last update to the EPANET engine was "Build 2.00.12" in February of 2008. Since that time, a community effort to update and extend the open-source code has emerged. This group has made a number of bug-fixes and API additions that help to improve the EPANET engine for everyone. Version 2.1 was released in July 2016, after 8.5 years.
|
||||
|
||||
Contributors to this version (listed in order of first contribution):
|
||||
|
||||
- Lew Rossman
|
||||
- Michael Tryby
|
||||
- Feng Shang
|
||||
- James Uber
|
||||
- Tom Taxon
|
||||
- Sam Hatchett
|
||||
- Hyoungmin Woo
|
||||
- Jinduan Chen
|
||||
- Yunier Soad
|
||||
- Mike Kane
|
||||
- Demetrios Eliades
|
||||
- Will Furnass
|
||||
- Steffen Macke
|
||||
- Mariosmsk
|
||||
- Elad Salomons
|
||||
- Maurizio Cingi
|
||||
- Bryant McDonnell
|
||||
|
||||
##API Additions (new functions):
|
||||
- `ENgetaveragepatternvalue`
|
||||
- `ENgetstatistic`
|
||||
- `ENgetcoord / ENsetcoord`
|
||||
- `ENgetpumptype`
|
||||
- `ENgetqualinfo`
|
||||
|
||||
###Demands
|
||||
- `ENgetnumdemands`
|
||||
- `ENgetbasedemand / ENsetbasedemand`
|
||||
- `ENgetdemandpattern`
|
||||
|
||||
###Curves
|
||||
- `ENgetcurve`
|
||||
- `ENgetcurveid`
|
||||
- `ENgetcurvelen`
|
||||
- `ENgetcurvevalue`
|
||||
- `ENsetcurvevalue`
|
||||
- `ENsetcurve`
|
||||
- `ENaddcurve`
|
||||
- `ENgetheadcurveindex`
|
||||
- `ENgetcurveindex`
|
||||
|
||||
|
||||
##API Extensions (additional parameters)
|
||||
###node value types:
|
||||
- `EN_TANKVOLUME`
|
||||
- `EN_MAXVOLUME`
|
||||
|
||||
###link value types:
|
||||
- `EN_LINKQUAL`
|
||||
- `EN_LINKPATTERN`
|
||||
|
||||
###time parameters:
|
||||
- `EN_STARTTIME`
|
||||
- `EN_HTIME`
|
||||
- `EN_QTIME`
|
||||
- `EN_HALTFLAG`
|
||||
- `EN_NEXTEVENT`
|
||||
|
||||
###(new) statistic values:
|
||||
- `EN_ITERATIONS`
|
||||
- `EN_RELATIVEERROR`
|
||||
|
||||
###pump types
|
||||
- `EN_CONST_HP`
|
||||
- `EN_POWER_FUNC`
|
||||
- `EN_CUSTOM`
|
||||
|
||||
##Notable Performance Improvements, Bug Fixes, Usage Features, and other notes
|
||||
- API float type is a compile-time option with the `EN_API_FLOAT_TYPE` definition. Use either `float` or `double` - default if left undefined is `float` to maintain compatibility with 2.0.x
|
||||
- updated hash table algorithm
|
||||
- fixed memory leak when saving output
|
||||
- enables interleaved hydraulic and water quality analysis steps:
|
||||
|
||||
```
|
||||
ENopenH();
|
||||
ENopenQ();
|
||||
ENinitH(0);
|
||||
ENinitQ(EN_NOSAVE);
|
||||
do {
|
||||
ENrunH(&t);
|
||||
ENrunQ(&qt);
|
||||
// collect results
|
||||
ENnextH(&tstep);
|
||||
ENnextQ(&qstep);
|
||||
} while (tstep > 0);
|
||||
ENcloseQ();
|
||||
ENcloseH();
|
||||
```
|
||||
|
||||
- engine code and command-line executable are now in separate implementation files
|
||||
- parameter `#define` directives are now enumerated values
|
||||
- main header now contains doxygen-compatible comment blocks for auto-generated documentation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
253
ReleaseNotes2_2.md
Normal file
253
ReleaseNotes2_2.md
Normal file
@@ -0,0 +1,253 @@
|
||||
Release Notes for EPANET 2.2 (Draft)
|
||||
============================
|
||||
This document describes the changes and updates that have been made in version 2.2 of EPANET.
|
||||
|
||||
## Thread-Safe API Functions
|
||||
|
||||
A duplicate set of API functions has been provided that allow multiple EPANET projects to be analyzed concurrently in a thread-safe manner. These functions maintain the same name as the original but use a `EN_` prefix instead of `EN`. In addition, the first argument to each of these functions is a handle that identifies the particular project being analyzed. For example, instead of writing:
|
||||
|
||||
`ENgetnodevalue(nodeIndex, EN_ELEVATION, &elev)`
|
||||
|
||||
one would use:
|
||||
|
||||
`EN_getnodevalue(ph, nodeIndex, EN_ELEVATION, &elev)`
|
||||
|
||||
where `ph` is the handle assigned to the project.
|
||||
|
||||
Two new functions have been added to the API to manage the creation and deletion of project handles. `EN_createproject` creates a new project along with its handle, while `EN_deleteproject` deletes a project. An example of using the thread-safe version of the API is shown below:
|
||||
```
|
||||
#include "epanet2_2.h"
|
||||
int runEpanet(char *finp, char *frpt)
|
||||
{
|
||||
EN_Project ph = 0;
|
||||
int err;
|
||||
err = EN_createproject(&ph);
|
||||
if (err) return err;
|
||||
err = EN_open(ph, finp, frpt, "");
|
||||
if (!err) err = EN_solveH(ph);
|
||||
if (!err) err = EN_report(ph);
|
||||
EN_close(ph);
|
||||
EN_deleteproject(&ph);
|
||||
return err;
|
||||
}
|
||||
```
|
||||
Prototypes of the thread-safe functions appear in the `epanet2_2.h` header file while `epanet2.h` contains prototypes of the legacy-style API functions. The enumerated constants used with both types of functions have been moved to `epanet2_enums.h`.
|
||||
|
||||
## Network Building By Code
|
||||
|
||||
API users now have the ability to build a complete EPANET network model using just function calls, without the need to open an EPANET-formatted input file. All types of network objects can be created and have their properties set using these calls, including both simple and rule-based controls. Here is an example of building a simple 2-node, 1-pipe network just through code:
|
||||
```
|
||||
#include "epanet2_2.h"
|
||||
int buildandrunEpanet(char *frpt)
|
||||
{
|
||||
EN_Project ph = 0;
|
||||
int err;
|
||||
err = EN_createproject(&ph);
|
||||
if (err) return err;
|
||||
EN_init(ph, frpt, "", EN_GPM, EN_HW);
|
||||
EN_addnode(ph, "J1, EN_JUNCTION);
|
||||
EN_setjuncdata(ph, 1, 710, 500, ""); //elev, demand
|
||||
EN_addnode(ph, "R1", EN_RESERVOIR);
|
||||
EN_setnodevalue(ph, 2, EN_ELEVATION, 800);
|
||||
EN_addlink(ph, "P1", EN_PIPE, "R1", "J1");
|
||||
EN_setpipedata(ph, 1, 5280, 14, 100, 0); // length, diam, C-factor
|
||||
EN_setreport(ph, "NODES ALL");
|
||||
err = EN_solveH(ph);
|
||||
if (!err) err = EN_report(ph);
|
||||
EN_close(ph);
|
||||
EN_deleteproject(&ph);
|
||||
return err;
|
||||
}
|
||||
```
|
||||
Instead of using `EN_open` to load data from a file, `EN_init` is used to initialize a project with the names of its report and binary files, and its flow units and head loss formula. The legacy-style API has a complementary set of functions for building networks from code.
|
||||
|
||||
## Additional Convergence Parameters
|
||||
|
||||
Two new analysis options have been added to provide more rigorous convergence criteria for EPANET's hydraulic solver. In the API they are named `EN_HEADERROR` and `EN_FLOWCHANGE` while in the `[OPTIONS]` section of an EPANET input file they are named `HEADERROR` and `FLOWCHANGE`, respectively.
|
||||
|
||||
`EN_HEADERROR` is the maximum head loss error that any network link can have for hydraulic convergence to occur. A link's head loss error is the difference between the head loss found as a function of computed flow in the link (such as by the Hazen-Williams equation for a pipe) and the difference in computed heads for the link's end nodes. The units of this parameter are feet (or meters for SI units). The default value of 0 indicates that no head error limit applies.
|
||||
|
||||
`EN_FLOWCHANGE` is the largest change in flow that any network element (link, emitter, or pressure-dependent demand) can have for hydraulic convergence to occur. It is specified in whatever flow units the project is using. The default value of 0 indicates that no flow change limit applies.
|
||||
|
||||
These new parameters augment the current `EN_ACCURACY` option which always remains in effect. In addition, both `EN_HEADERROR` and `EN_FLOWCHANGE` can be used as parameters in the `ENgetstatistic` (or `EN_getstatistic`) function to retrieve their computed values (even when their option values are 0) after a hydraulic solution has been completed.
|
||||
|
||||
## Improved Linear Solver Routine
|
||||
|
||||
EPANET's hydraulic solver requires solving a system of linear equations over a series of iterations until a set of convergence criteria are met. The coefficient matrix of this linear system is square and symmetric. It has a row for each network node and a non-zero off-diagonal coefficient for each link. The numerical effort needed to solve the linear system can be reduced if the nodes are re-ordered so that the non-zero coefficients cluster more tightly around the diagonal.
|
||||
|
||||
EPANET's original node re-ordering scheme has been replaced by the more powerful **Multiple Minimum Degree (MMD)** algorithm. On a series of eight networks ranging in size from 7,700 to 100,000 nodes **MMD** reduced the solution time for a single period (steady state) hydraulic analysis by an average of 58%.
|
||||
|
||||
## Improved Handling of Near-Zero Flows
|
||||
|
||||
EPANET's hydraulic solver can generate an ill-conditioned solution matrix when pipe flows approach zero unless some adjustment is made (i.e., as a pipe's flow approaches 0 its head loss gradient also approaches 0 causing its reciprocal, which is used to form the solution matrix's coefficients, to approach infinity). EPANET 2.0 used an arbitrary cutoff on head loss gradient to prevent it from becoming 0. This approach doesn't allow a pipe to follow any head loss v. flow relation in the region below the cutoff and can produce incorrect solutions for some networks (see [Estrada et al., 2009](https://ascelibrary.org/doi/full/10.1061/%28ASCE%29IR.1943-4774.0000100)).
|
||||
|
||||
The hydraulic solver has been modified to use a linear head loss v. flow relation for flows approaching zero. For the Darcy-Weisbach equation, the linear Hagen-Poiseuille formula is used for laminar flow where the Reynolds Number is <= 2000. For the Hazen-Williams and Chezy-Manning equations, a flow limit `Qa` is established for each pipe, equal to the flow that produces the EPANET 2 gradient cutoff. For flows below this a linear head loss relation is used between 0 and the head loss at `Qa` and the gradient always equals the cutoff. EPANET 2.2 is now able to correctly solve the examples presented in Estrada et al. (2009) as well as those in [Gorev et al., (2013)](https://ascelibrary.org/doi/10.1061/%28ASCE%29HY.1943-7900.0000694) and [Elhay and Simpson (2011)](https://ascelibrary.org/doi/10.1061/%28ASCE%29HY.1943-7900.0000411).
|
||||
|
||||
## Pressure Dependent Demands
|
||||
|
||||
EPANET has always employed a Demand Driven Analysis (**DDA**) when modeling network hydraulics. Under this approach nodal demands at a given point in time are fixed values that must be delivered no matter what nodal heads and link flows are produced by a hydraulic solution. This can result in situations where required demands are satisfied at nodes that have negative pressures - a physical impossibility.
|
||||
|
||||
To address this issue EPANET has been extended to use a Pressure Driven Analysis (**PDA**) if so desired. Under **PDA**, the demand *D* delivered at a node depends on the node's available pressure *P* according to:
|
||||
|
||||
*D = D<sub>f</sub> [ (P - P<sub>min</sub>) / (P<sub>req</sub> - P<sub>min</sub>) ]<sup>P<sub>exp</sub></sup>*
|
||||
|
||||
where *D<sub>f</sub>* is the full demand required, *P<sub>min</sub>* is the pressure below which demand is zero, *P<sub>req</sub>* is the pressure required to deliver the full required demand and *P<sub>exp</sub>* is an exponent. When *P < P<sub>min</sub>* demand is 0 and when *P > P<sub>req</sub>* demand equals *D<sub>f</sub>*.
|
||||
|
||||
To implement pressure driven analysis four new parameters have been added to the [OPTIONS] section of the EPANET input file:
|
||||
|
||||
| Parameter | Description | Default |
|
||||
|--|--|--|
|
||||
| DEMAND MODEL | either DDA or PDA | DDA |
|
||||
| MINIMUM PRESSURE | value for *P<sub>min</sub>* | 0
|
||||
| REQUIRED PRESSURE | value for *P<sub>req</sub>* | 0
|
||||
| PRESSURE EXPONENT | value for *P<sub>exp</sub>* | 0.5 |
|
||||
|
||||
These parameters can also be set and retrieved in code using the following API functions
|
||||
```
|
||||
int ENsetdemandmodel(int modelType, double pMin, double pReq, double pExp);
|
||||
int ENgetdemandmodel(int *modelType, double *pMin, double *pReq, double *pExp);
|
||||
```
|
||||
for the legacy API and
|
||||
```
|
||||
int EN_setdemandmodel(EN_Project ph, int modelType, double pMin, double pReq, double pExp);
|
||||
int EN_getdemandmodel(EN_Project ph, int *modelType, double *pMin, double *pReq, double *pExp);
|
||||
```
|
||||
for the thread-safe API. Some additional points regarding the new **PDA** option are:
|
||||
|
||||
- If no DEMAND MODEL and its parameters are specified then the analysis defaults to being demand driven (**DDA**).
|
||||
- This implementation of **PDA** assumes that the same parameters apply to all nodes in the network. Extending the framework to allow different parameters for specific nodes is left as a future feature to implement.
|
||||
- *P<sub>min</sub>* is allowed to equal to *P<sub>req</sub>*. This condition can be used to find a solution that results in the smallest amount of demand reductions needed to insure that no node delivers positive demand at a pressure below *P<sub>min</min>*.
|
||||
|
||||
## Improved Water Quality Mass Balance
|
||||
|
||||
As described by [Davis et al. (2018)](https://www.drink-water-eng-sci.net/11/25/2018/dwes-11-25-2018.pdf) EPANET's water quality simulations can result in some significant mass balance errors when modeling short term mass injections (errors are much smaller for continuous source flows). The entire water quality engine has been re-written to eliminate these errors. It still uses the Lagrangian Time Driven transport method but now analyzes each network node in topologically sorted order rather than in arbitrary order.
|
||||
|
||||
A Mass Balance Report now appears the end of a simulation's Status Report that lists the various components (inflow, outflow, reaction) that comprise the network's overall mass balance. In addition `EN_MASSBALANCE` can be used as a parameter in the `ENgetstatistic` (or `EN_getstatistic`) function to retrieve the Mass Balance Ratio (Total Outflow Mass / Total Inflow Mass) at any point during a water quality simulation.
|
||||
|
||||
Mass balance ratio (MBR) results for two of the networks analyzed by Davis et al. (2018) are shown in the following table. MBR-2.0 is for EPANET 2.0.012 as reported by Davis et al. while MBR-2.2 is for the re-written quality engine.
|
||||
|
||||
| Network | Time Step (s) | MBR-2.0 | MBR-2.2 |
|
||||
|--|--|--|--|
|
||||
| N2 | 900 | 16.63 | 1.00 |
|
||||
| | 300 | 23.45 | 1.00 |
|
||||
| | 60 | 6.49 | 1.00 |
|
||||
| N4 | 900 | 0.09 | 1.00 |
|
||||
| | 300 | 0.70 | 1.00 |
|
||||
| | 60 | 0.98 | 1.00 |
|
||||
|
||||
Both network files are available [here](https://doi.org/10.23719/1375314).
|
||||
|
||||
## New API functions
|
||||
|Function|Description|
|
||||
|--|--|
|
||||
|`EN_createproject` | Creates a new EPANET project |
|
||||
|`EN_deleteproject` | Deletes an EPANET project |
|
||||
|`EN_init`|Initializes an EPANET project|
|
||||
|`EN_setflowunits`|Sets the project's flow units|
|
||||
|`EN_addnode`|Adds a new node to a project|
|
||||
|`EN_addlink`|Adds a new link to a project|
|
||||
|`EN_addcontrol`|Adds a new simple control to a project|
|
||||
|`EN_addrule`|Adds a new control rule to a project|
|
||||
|`EN_deletenode`|Deletes a node from the project|
|
||||
|`EN_deletelink`|Deletes a link from the project|
|
||||
|`EN_deletepattern`|Deletes a time pattern from the project|
|
||||
|`EN_deletecurve`|Deletes a data curve from the project|
|
||||
|`EN_deletecontrol`|Deletes a simple control from the project|
|
||||
|`EN_deleterule`|Deletes a rule-based control from the project|
|
||||
|`EN_setnodeid`|Changes the ID name for a node|
|
||||
|`EN_setjuncdata` |Sets values for a junction's parameters |
|
||||
|`EN_settankdata` |Sets values for a tank's parameters|
|
||||
|`EN_setlinkid`|Changes the ID name for a link|
|
||||
|`EN_setlinknodes`|Sets a link's start- and end-nodes|
|
||||
|`EN_setlinktype`|Changes the type of a specific link|
|
||||
|`EN_setpipedata`|Sets values for a pipe's parameters|
|
||||
|`EN_getdemandmodel`|Retrieves the type of demand model in use |
|
||||
|`EN_setdemandmodel`|Sets the type of demand model to use|
|
||||
|`EN_getdemandname`|Gets the name of a node's demand category|
|
||||
|`EN_setdemandname`|Sets the name of a node's demand category|
|
||||
|`EN_setdemandpattern`|Assigns a time pattern to a node's demand category |
|
||||
|`EN_setpatternid`|Changes the ID name of a time pattern|
|
||||
|`EN_setcurveid`|Changes the ID name of a data curve|
|
||||
|`EN_getcurvetype`|Gets a curve's type|
|
||||
|`EN_setheadcurveindex`|Sets the index of a head curve used by a pump |
|
||||
|`EN_getrule`|Gets the number of elements in a rule-based control |
|
||||
|`EN_getruleid` | Gets the name assigned to a rule-based control |
|
||||
|`EN_getpremise`|Gets the contents of a premise in a rule-based control|
|
||||
|`EN_setpremise`|Sets the contents of a premise in a rule-based control|
|
||||
|`EN_setpremiseindex`|Sets the index of an object in a premise of a rule-based control|
|
||||
|`EN_setpremisestatus`|Sets the status of an object in a premise of a rule-based control|
|
||||
|`EN_setpremisevalue`|Sets the value of a property in a premise of a rule-based control|
|
||||
|`EN_getthenaction`|Gets the contents of a THEN action in a rule-based control|
|
||||
|`EN_setthenaction`|Sets the contents of a THEN action in a rule-based control|
|
||||
|`EN_getelseaction`|Gets the contents of an ELSE action in a rule-based control|
|
||||
|`EN_setelseaction`|Sets the contents of an ELSE action in a rule-based control|
|
||||
|`EN_setrulepriority`|Sets the priority of a rule-based control|
|
||||
|`EN_gettitle` |Gets a project's title |
|
||||
|`EN_settitle` |Sets a project's title |
|
||||
|`EN_clearreport` |Clears the contents of a project's report file |
|
||||
|`EN_copyreport` | Copies the contents of a project's report file |
|
||||
In addition to these new functions, a tank's volume curve `EN_VOLCURVE` can be set using `EN_setnodevalue` and `EN_setlinkvalue` can now be used to set the following pump properties:
|
||||
- `EN_PUMP_POWER` (constant power rating)
|
||||
- `EN_PUMP_HCURVE` (head characteristic curve)
|
||||
- `EN_PUMP_ECURVE` (efficiency curve)
|
||||
- `EN_PUMP_ECOST` (average energy price)
|
||||
- `EN_PUMP_EPAT` (energy pricing pattern)
|
||||
- `EN_LINKPATTERN` (speed setting pattern)
|
||||
|
||||
Access to the following global energy options have been added to `EN_getoption` and `EN_setoption`:
|
||||
- `EN_GLOBALEFFIC` (global pump efficiency)
|
||||
- `EN_GLOBALPRICE` (global average energy price per kW-Hour)
|
||||
- `EN_GLOBALPATTERN` (global energy price pattern)
|
||||
- `EN_DEMANDCHARGE` (price per maximum kW of energy consumption)
|
||||
|
||||
## New API Constants
|
||||
|
||||
### Link value types:
|
||||
- `EN_PUMP_STATE`
|
||||
- `EN_PUMP_EFFIC`
|
||||
- `EN_PUMP_POWER`
|
||||
- `EN_PUMP_HCURVE`
|
||||
- `EN_PUMP_ECURVE`
|
||||
- `EN_PUMP_ECOST`
|
||||
- `EN_PUMP_EPAT`
|
||||
|
||||
### Count types:
|
||||
- `EN_RULECOUNT`
|
||||
|
||||
### Head loss formula:
|
||||
- `EN_HW`
|
||||
- `EN_DW`
|
||||
- `EN_CM`
|
||||
|
||||
### Hydraulic option types:
|
||||
- `EN_HEADERROR`
|
||||
- `EN_FLOWCHANGE`
|
||||
- `EN_DEFDEMANDPAT`
|
||||
- `EN_HEADLOSSFORM`
|
||||
- `EN_GLOBALEFFIC`
|
||||
- `EN_GLOBALPRICE`
|
||||
- `EN_GLOBALPATTERN`
|
||||
- `EN_DEMANDCHARGE`
|
||||
|
||||
### Simulation statistic types:
|
||||
- `EN_MAXHEADERROR`
|
||||
- `EN_MAXFLOWCHANGE`
|
||||
- `EN_MASSBALANCE`
|
||||
|
||||
### Action code types:
|
||||
- `EN_UNCONDITIONAL`
|
||||
- `EN_CONDITIONAL`
|
||||
|
||||
### Curve types:
|
||||
- `EN_VOLUME_CURVE`
|
||||
- `EN_PUMP_CURVE`
|
||||
- `EN_EFFIC_CURVE`
|
||||
- `EN_HLOSS_CURVE`
|
||||
- `EN_GENERIC_CURVE`
|
||||
|
||||
### Demand model types:
|
||||
- `EN_DDA`
|
||||
- `EN_PDA`
|
||||
|
||||
## Authors contributing to this release:
|
||||
- List item
|
||||
85
appveyor.yml
Normal file
85
appveyor.yml
Normal file
@@ -0,0 +1,85 @@
|
||||
#
|
||||
# appveyor.yml - Appveyor CI configuration for OWA EPANET
|
||||
#
|
||||
# Date created: 01/09/2018
|
||||
#
|
||||
# Author: Michael E. Tryby
|
||||
# US EPA - ORD/NRMRL
|
||||
#
|
||||
|
||||
version: 2.0.{build}
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
#GROUP: (SUPPORTED/EXPERIMENTAL)
|
||||
#EXPERIMENTAL is allowed to fail under build matrix
|
||||
- GROUP: "EXPERIMENTAL"
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
GENERATOR: "Visual Studio 15 2017"
|
||||
GROUP: "SUPPORTED"
|
||||
BOOST_ROOT: "C:/Libraries/boost_1_67_0"
|
||||
PLATFORM: "win32"
|
||||
REF_BUILD_ID: "538_1"
|
||||
# New build on Visual Studio 15 2017
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
GENERATOR: "Visual Studio 15 2017 Win64"
|
||||
GROUP: "EXPERIMENTAL"
|
||||
BOOST_ROOT: "C:/Libraries/boost_1_67_0"
|
||||
PLATFORM: "win64"
|
||||
REF_BUILD_ID: "538_2"
|
||||
|
||||
# called before repo cloning
|
||||
init:
|
||||
- set SUT_BUILD_ID=%APPVEYOR_BUILD_NUMBER%_%APPVEYOR_JOB_NUMBER%
|
||||
- set EPANET_HOME=%APPVEYOR_BUILD_FOLDER%
|
||||
- set BUILD_HOME=buildprod
|
||||
- set TEST_HOME=nrtestsuite
|
||||
- set PATH=%PATH%;%BOOST_ROOT%/
|
||||
|
||||
# See values set
|
||||
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
|
||||
- echo %BUILD_HOME%
|
||||
- echo %GENERATOR%
|
||||
- echo %BOOST_ROOT%
|
||||
|
||||
# called after repo clone
|
||||
install:
|
||||
- python -m pip install -r tools\requirements-appveyor.txt
|
||||
|
||||
# called before build
|
||||
before_build:
|
||||
- mkdir %BUILD_HOME%
|
||||
- cd %BUILD_HOME%
|
||||
- cmake -G "%GENERATOR%"
|
||||
-DBUILD_TESTS=ON
|
||||
-DBOOST_ROOT="%BOOST_ROOT%" ..
|
||||
|
||||
# run custom build script
|
||||
build_script:
|
||||
- cmake --build . --config Release
|
||||
|
||||
before_test:
|
||||
- cd %EPANET_HOME%
|
||||
- tools\before-test.cmd %PLATFORM% %REF_BUILD_ID% %SUT_BUILD_ID% %APPVEYOR_REPO_COMMIT%
|
||||
|
||||
# run custom test script
|
||||
test_script:
|
||||
# run unit tests
|
||||
- cd %BUILD_HOME%\tests
|
||||
- ctest -C Release --output-on-failure
|
||||
# run regression tests
|
||||
- cd %EPANET_HOME%
|
||||
- tools\run-nrtest.cmd %REF_BUILD_ID% %SUT_BUILD_ID%
|
||||
|
||||
on_success:
|
||||
- cd %TEST_HOME%\benchmark
|
||||
- appveyor PushArtifact receipt.json
|
||||
|
||||
on_failure:
|
||||
- cd %TEST_HOME%\benchmark
|
||||
# zip up the SUT benchmarks
|
||||
- 7z a benchmark-%PLATFORM%-%SUT_BUILD_ID%.zip .\epanet-%SUT_BUILD_ID%
|
||||
- appveyor PushArtifact benchmark-%PLATFORM%-%SUT_BUILD_ID%.zip
|
||||
@@ -1,125 +0,0 @@
|
||||
# Cygwin Makefile for EPANET
|
||||
|
||||
# This will build EPANET as a cygwin DLL and import
|
||||
# library (cygepanet.dll/libcygepanet.dll.a) under Cygwin/gcc,
|
||||
# and a standalone executable (cygepanet.exe).
|
||||
# The current release of the Cygwin environment can be
|
||||
# obtained from http://www.cygwin.com
|
||||
|
||||
# The following targets are defined (for execution in
|
||||
# the build directory under the Cygwin environment):
|
||||
# make
|
||||
# -Builds cygepanet2.dll, cygepanet2.def, libcygepanet2.dll.a,
|
||||
# cygepanet2.exe
|
||||
# make install
|
||||
# -Creates shell wrapper runcygepanet2.sh that
|
||||
# executes cygepanet2.exe.
|
||||
# The runcygepanet2.sh wrapper simply exports
|
||||
# environment variables so that the DLL is found at runtime,
|
||||
# allowing you to specify your own locations for installing
|
||||
# the DLL.
|
||||
# -Installs cygepanet2.dll, cygepanet2.exe, and runcygepanet2.sh
|
||||
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
||||
# below to something different - see "Install directories")
|
||||
# -Installs libcygepanet2.dll.a (import library), and cygepanet2.def,
|
||||
# in <prefix>/lib
|
||||
# -Installs epanet2.h in <prefix>/include. This is the required
|
||||
# header file for the EPANET programmer's toolkit, and thus
|
||||
# <prefix>/include should be on your CPP include search path
|
||||
# for subsequent use of the toolkit and linking with the import
|
||||
# library libcygepanet2.dll.a.
|
||||
# make clean
|
||||
# -Removes object and library files, returning the build directory
|
||||
# to its pristine state.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# C H A N G E H E R E A S N E E D E D
|
||||
# You may wish to change the install path 'prefix',
|
||||
# or the compiler flags, but these defaults should be fine.
|
||||
|
||||
# Target filenames
|
||||
epanetrootname := cygepanet2
|
||||
dllname := $(epanetrootname).dll
|
||||
defname := $(epanetrootname).def
|
||||
implibname = lib$(dllname).a
|
||||
exename := $(epanetrootname)
|
||||
# Shell wrapper
|
||||
runcmdtemplate = runepanet.sh.template
|
||||
runcmdname = runcygepanet2.sh
|
||||
# Location of EPANET toolkit includes
|
||||
epanetincludedir = ../../include
|
||||
# Search path for sources
|
||||
epanetsrcdir = ../../src
|
||||
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
||||
|
||||
# Install directories
|
||||
prefix = ~
|
||||
exec_prefix = $(prefix)
|
||||
srcdir = .
|
||||
libdir = $(exec_prefix)/lib
|
||||
bindir = $(exec_prefix)/bin
|
||||
includedir = $(prefix)/include
|
||||
datarootdir = $(prefix)/share
|
||||
docdir = $(datarootdir)/doc/epanet
|
||||
|
||||
# Compiler and flags
|
||||
CC = /bin/gcc
|
||||
dlltool = /bin/dlltool
|
||||
CFLAGS = -g -O3
|
||||
CPPFLAGS = -I $(srcdir) -I $(epanetincludedir)
|
||||
LDFLAGS = -L . -W1,-rpath,$(libdir) -lm
|
||||
|
||||
# Installer
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# EPANET object files
|
||||
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
||||
input3.o mempool.o output.o quality.o report.o \
|
||||
rules.o smatrix.o
|
||||
# Epanet header files
|
||||
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
||||
epanet_main_heads=epanet2.h
|
||||
# Epanet main program
|
||||
epanet_main=epanet
|
||||
|
||||
.PHONY: all
|
||||
all: $(dllname) $(exename)
|
||||
|
||||
$(dllname): $(epanet_objs)
|
||||
# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^
|
||||
# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--output-def,$(defname)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--kill-at
|
||||
$(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at
|
||||
|
||||
$(exename): $(epanet_objs)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS)
|
||||
|
||||
$(epanet_objs): $(epanet_heads)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \
|
||||
| sed 's|exename|$(bindir)/$(exename)|' \
|
||||
> $(runcmdname)
|
||||
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
||||
$(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname)
|
||||
$(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname)
|
||||
$(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname)
|
||||
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
||||
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname)
|
||||
@@ -1,130 +0,0 @@
|
||||
# Cygwin Makefile for EPANET
|
||||
|
||||
# This will build EPANET as a cygwin DLL and import
|
||||
# library (cygepanet_gcc_<Rev>.dll/libcygepanet_gcc_<Rev>.dll.a) under Cygwin/gcc,
|
||||
# and a standalone executable (cygepanet_gcc_<Rev>.exe).
|
||||
# <Rev> is the atomic revision number of the EPANET SVN repo,
|
||||
# so the results of each build can be unambiguously tracked to a repo Rev.
|
||||
# The current release of the Cygwin environment can be
|
||||
# obtained from http://www.cygwin.com
|
||||
|
||||
# The following targets are defined (for execution in
|
||||
# the build directory under the Cygwin environment):
|
||||
# make
|
||||
# -Builds cygepanet_gcc_<Rev>.dll, cygepanet_gcc_<Rev>.def, libcygepanet_gcc_<Rev>.dll.a,
|
||||
# cygepanet_gcc_<Rev>.exe
|
||||
# make install
|
||||
# -Creates shell wrapper runcygepanet_<Rev>.sh that
|
||||
# executes cygepanet_gcc_<Rev>.exe.
|
||||
# The runcygepanet_<Rev>.sh wrapper simply exports
|
||||
# environment variables so that the DLL is found at runtime,
|
||||
# allowing you to specify your own locations for installing
|
||||
# the DLL.
|
||||
# -Installs cygepanet_gcc_<Rev>.dll, cygepanet_gcc_<Rev>.exe, and runcygepanet_<Rev>.sh
|
||||
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
||||
# below to something different - see "Install directories")
|
||||
# -Installs libcygepanet_gcc_<Rev>.dll.a (import library), and cygepanet_gcc_<Rev>.def,
|
||||
# in <prefix>/lib
|
||||
# -Installs epanet2.h in <prefix>/include. This is the required
|
||||
# header file for the EPANET programmer's toolkit, and thus
|
||||
# <prefix>/include should be on your CPP include search path
|
||||
# for subsequent use of the toolkit and linking with the import
|
||||
# library libcygepanet_gcc_<Rev>.dll.a.
|
||||
# make clean
|
||||
# -Removes object and library files, returning the build directory
|
||||
# to its pristine state.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# C H A N G E H E R E A S N E E D E D
|
||||
# You may wish to change the install path 'prefix',
|
||||
# or the compiler flags, but these defaults should be fine.
|
||||
|
||||
# Target filenames
|
||||
# svnname.sh constructs a name: <prefix><root><Rev><postfix>
|
||||
# where <Rev> is the atomic revision number of the svn repo.
|
||||
epanetsvnpath = ../../..
|
||||
epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" cygepanet_gcc_ "")
|
||||
dllname := $(epanetrootname).dll
|
||||
defname := $(epanetrootname).def
|
||||
implibname = lib$(dllname).a
|
||||
exename := $(epanetrootname)
|
||||
# Shell wrapper
|
||||
runcmdtemplate = runepanet.sh.template
|
||||
runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runcygepanet_ .sh)
|
||||
# Location of EPANET toolkit includes
|
||||
epanetincludedir = ../../include
|
||||
# Search path for sources
|
||||
epanetsrcdir = ../../src
|
||||
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
||||
|
||||
# Install directories
|
||||
prefix = ~
|
||||
exec_prefix = $(prefix)
|
||||
srcdir = .
|
||||
libdir = $(exec_prefix)/lib
|
||||
bindir = $(exec_prefix)/bin
|
||||
includedir = $(prefix)/include
|
||||
datarootdir = $(prefix)/share
|
||||
docdir = $(datarootdir)/doc/epanet
|
||||
|
||||
# Compiler and flags
|
||||
CC = /bin/gcc
|
||||
dlltool = /bin/dlltool
|
||||
CFLAGS = -g -O3
|
||||
CPPFLAGS = -I $(srcdir) -I $(epanetincludedir)
|
||||
LDFLAGS = -L . -W1,-rpath,$(libdir) -lm
|
||||
|
||||
# Installer
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# EPANET object files
|
||||
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
||||
input3.o mempool.o output.o quality.o report.o \
|
||||
rules.o smatrix.o
|
||||
# Epanet header files
|
||||
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
||||
epanet_main_heads=epanet2.h
|
||||
# Epanet main program
|
||||
epanet_main=epanet
|
||||
|
||||
.PHONY: all
|
||||
all: $(dllname) $(exename)
|
||||
|
||||
$(dllname): $(epanet_objs)
|
||||
# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^
|
||||
# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--output-def,$(defname)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--kill-at
|
||||
$(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at
|
||||
|
||||
$(exename): $(epanet_objs)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS)
|
||||
|
||||
$(epanet_objs): $(epanet_heads)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \
|
||||
| sed 's|exename|$(bindir)/$(exename)|' \
|
||||
> $(runcmdname)
|
||||
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
||||
$(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname)
|
||||
$(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname)
|
||||
$(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname)
|
||||
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
||||
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname)
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
export PATH=libdir:$PATH
|
||||
export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH
|
||||
exec exename "$@"
|
||||
@@ -1,108 +0,0 @@
|
||||
# Linux Makefile for EPANET
|
||||
|
||||
# This will build EPANET as a shared object library
|
||||
# (libepanet2.so) under Linux/Unix, and a standalone
|
||||
# executable (epanet2).
|
||||
|
||||
# The following targets are defined:
|
||||
# make
|
||||
# -Builds libepanet2.so, epanet2
|
||||
# make install
|
||||
# -Creates shell wrapper runepanet2.sh that executes epanet2.
|
||||
# The runepanet2.sh wrapper simply exports
|
||||
# environment variables that help locate the runtime library,
|
||||
# allowing you to specify your own library locations.
|
||||
# -Installs epanet2 and runepanet2.sh
|
||||
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
||||
# below to something different - see "Install directories")
|
||||
# -Installs libepanet2.so in <prefix>/lib
|
||||
# -Installs epanet2.h in <prefix>/include. This is the required
|
||||
# header file for the EPANET programmer's toolkit, and thus
|
||||
# <prefix>/include should be on your CPP include search path
|
||||
# for subsequent use of the toolkit and linking with the
|
||||
# library libepanet2.so
|
||||
# make clean
|
||||
# -Removes object and library files, returning the build directory
|
||||
# to its pristine state.
|
||||
|
||||
# You may wish to change the install path 'prefix',
|
||||
# or the compiler flags, but these defaults should be fine.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# Target filenames
|
||||
epanetrootname := epanet2
|
||||
libname := lib$(epanetrootname).so
|
||||
exename := $(epanetrootname)
|
||||
# Shell wrapper
|
||||
runcmdtemplate = runepanet.sh.template
|
||||
runcmdname = runepanet2.sh
|
||||
# Location of EPANET toolkit includes
|
||||
epanetincludedir = ../../include
|
||||
# Search path for sources
|
||||
epanetsrcdir = ../../src
|
||||
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
||||
|
||||
# Install directories
|
||||
prefix = ~
|
||||
exec_prefix = $(prefix)
|
||||
libdir = $(exec_prefix)/lib
|
||||
bindir = $(exec_prefix)/bin
|
||||
includedir = $(prefix)/include
|
||||
datarootdir = $(prefix)/share
|
||||
docdir = $(datarootdir)/doc/epanet
|
||||
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CFLAGS = -g -O3 -fPIC
|
||||
CPPFLAGS = -I $(epanetincludedir)
|
||||
LDFLAGS = -L . -Wl,-rpath,$(libdir) -lm
|
||||
|
||||
# Installer
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# Files for the shared object library
|
||||
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
||||
input3.o mempool.o output.o quality.o report.o \
|
||||
rules.o smatrix.o
|
||||
# Epanet header files
|
||||
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
||||
# Epanet main program
|
||||
epanet_main=epanet
|
||||
# Epanet main program header files
|
||||
epanet_main_heads=epanet2.h
|
||||
|
||||
.PHONY: all
|
||||
all: $(libname) $(exename)
|
||||
|
||||
$(libname): $(epanet_objs)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^
|
||||
|
||||
$(exename): $(libname) $(epanet_main_heads)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS)
|
||||
|
||||
$(epanet_objs): $(epanet_heads)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cat $(runcmdtemplate) | sed 's|libdir|$(libdir)|' \
|
||||
| sed 's|exename|$(bindir)/$(exename)|' \
|
||||
> $(runcmdname)
|
||||
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
||||
$(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname)
|
||||
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
||||
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-/bin/rm *.o $(libname) $(exename) $(runcmdname)
|
||||
@@ -1,111 +0,0 @@
|
||||
# Linux Makefile for EPANET
|
||||
|
||||
# This will build EPANET as a shared object library
|
||||
# (libepanet_gcc_<Rev>.so) under Linux/Unix, and a standalone
|
||||
# executable (epanet_gcc_<Rev>).
|
||||
|
||||
# The following targets are defined:
|
||||
# make
|
||||
# -Builds libepanet_gcc_<Rev>.so, epanet_gcc_<Rev>
|
||||
# make install
|
||||
# -Creates shell wrapper runepanet_<Rev>.sh that executes epanet_gcc_<Rev>.exe.
|
||||
# The runepanet_<Rev>.sh wrapper simply exports
|
||||
# environment variables that help locate the runtime library,
|
||||
# allowing you to specify your own library locations.
|
||||
# -Installs epanet_gcc_<Rev> and runepanet_<Rev>.sh
|
||||
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
||||
# below to something different - see "Install directories")
|
||||
# -Installs libepanet_gcc_<Rev>.so in <prefix>/lib
|
||||
# -Installs epanet2.h in <prefix>/include. This is the required
|
||||
# header file for the EPANET programmer's toolkit, and thus
|
||||
# <prefix>/include should be on your CPP include search path
|
||||
# for subsequent use of the toolkit and linking with the
|
||||
# library libepanet_gcc_<Rev>.so
|
||||
# make clean
|
||||
# -Removes object and library files, returning the build directory
|
||||
# to its pristine state.
|
||||
|
||||
# You may wish to change the install path 'prefix',
|
||||
# or the compiler flags, but these defaults should be fine.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# Target filenames
|
||||
# svnname.sh constructs a name: <prefix><root><Rev><postfix>
|
||||
# where <Rev> is the atomic revision number of the svn repo.
|
||||
epanetsvnpath = ../../..
|
||||
epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" epanet_gcc_ "")
|
||||
libname := lib$(epanetrootname).so
|
||||
exename := $(epanetrootname)
|
||||
# Shell wrapper
|
||||
runcmdtemplate = runepanet.sh.template
|
||||
runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runepanet_ .sh)
|
||||
# Location of EPANET toolkit includes
|
||||
epanetincludedir = ../../include
|
||||
# Search path for sources
|
||||
epanetsrcdir = ../../src
|
||||
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
||||
|
||||
# Install directories
|
||||
prefix = ~
|
||||
exec_prefix = $(prefix)
|
||||
libdir = $(exec_prefix)/lib
|
||||
bindir = $(exec_prefix)/bin
|
||||
includedir = $(prefix)/include
|
||||
datarootdir = $(prefix)/share
|
||||
docdir = $(datarootdir)/doc/epanet
|
||||
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CFLAGS = -g -O3 -fPIC
|
||||
CPPFLAGS = -I $(epanetincludedir)
|
||||
LDFLAGS = -L . -Wl,-rpath,$(libdir) -lm
|
||||
|
||||
# Installer
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# Files for the shared object library
|
||||
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
||||
input3.o mempool.o output.o quality.o report.o \
|
||||
rules.o smatrix.o
|
||||
# Epanet header files
|
||||
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
||||
# Epanet main program
|
||||
epanet_main=epanet
|
||||
# Epanet main program header files
|
||||
epanet_main_heads=epanet2.h
|
||||
|
||||
.PHONY: all
|
||||
all: $(libname) $(exename)
|
||||
|
||||
$(libname): $(epanet_objs)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^
|
||||
|
||||
$(exename): $(libname) $(epanet_main_heads)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS)
|
||||
|
||||
$(epanet_objs): $(epanet_heads)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cat $(runcmdtemplate) | sed 's|libdir|$(libdir)|' \
|
||||
| sed 's|exename|$(bindir)/$(exename)|' \
|
||||
> $(runcmdname)
|
||||
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
||||
$(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname)
|
||||
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
||||
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-/bin/rm *.o $(libname) $(exename) $(runcmdname)
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
export PATH=libdir:$PATH
|
||||
export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH
|
||||
exec exename "$@"
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "epanet-dll", "epanet-dll.vcproj", "{3646F046-B542-4712-929F-E6A4F0C1F835}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3646F046-B542-4712-929F-E6A4F0C1F835}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3646F046-B542-4712-929F-E6A4F0C1F835}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3646F046-B542-4712-929F-E6A4F0C1F835}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3646F046-B542-4712-929F-E6A4F0C1F835}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,282 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="epanet-dll"
|
||||
ProjectGUID="{3646F046-B542-4712-929F-E6A4F0C1F835}"
|
||||
RootNamespace="epanetdll"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="DLL;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
DisableLanguageExtensions="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\epanet2.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy .\Debug\epanet2.dll "%HOME%"\bin
copy .\Debug\epanet2.lib "%HOME%"\lib
copy ..\..\..\include\epanet2.h "%HOME%"\include
"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="DLL;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
DisableLanguageExtensions="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\epanet2.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Installing Library Files..."
|
||||
CommandLine="copy .\Release\epanet2.dll "%HOME%"\bin
copy .\Release\epanet2.lib "%HOME%"\lib
copy ..\..\..\include\epanet2.h "%HOME%"\include
"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\src\epanet.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\hash.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\hydraul.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\inpfile.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\input1.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\input2.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\input3.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\mempool.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\output.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\quality.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\report.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\rules.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\smatrix.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\src\enumstxt.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\funcs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\hash.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\mempool.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\text.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\toolkit.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\types.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\vars.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "epanet-exe", "epanet-exe.vcproj", "{67C47E99-8BA3-4597-AFA8-566C26FF9C78}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,284 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="epanet-exe"
|
||||
ProjectGUID="{67C47E99-8BA3-4597-AFA8-566C26FF9C78}"
|
||||
RootNamespace="epanetexe"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="CLE;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
DisableLanguageExtensions="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
UseLibraryDependencyInputs="false"
|
||||
OutputFile="$(OutDir)\epanet2.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy .\Debug\epanet2.exe "%HOME%"\bin
"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="CLE;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
DisableLanguageExtensions="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\epanet2.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Installing Executable file..."
|
||||
CommandLine="copy .\Release\epanet2.exe "%HOME%"\bin
"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\src\epanet.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\hash.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\hydraul.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\inpfile.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\input1.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\input2.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\input3.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\mempool.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\output.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\quality.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\report.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\rules.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\smatrix.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\..\src\enumstxt.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\funcs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\hash.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\mempool.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\text.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\toolkit.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\types.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\vars.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,213 +0,0 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on epanet2.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=epanet2 - Win32 Release
|
||||
!MESSAGE No configuration specified. Defaulting to epanet2 - Win32 Release.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "epanet2 - Win32 Release"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "epanet2.mak" CFG="epanet2 - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "epanet2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\epanet2.dll"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\epanet.obj"
|
||||
-@erase "$(INTDIR)\hash.obj"
|
||||
-@erase "$(INTDIR)\hydraul.obj"
|
||||
-@erase "$(INTDIR)\inpfile.obj"
|
||||
-@erase "$(INTDIR)\input1.obj"
|
||||
-@erase "$(INTDIR)\input2.obj"
|
||||
-@erase "$(INTDIR)\input3.obj"
|
||||
-@erase "$(INTDIR)\mempool.obj"
|
||||
-@erase "$(INTDIR)\output.obj"
|
||||
-@erase "$(INTDIR)\quality.obj"
|
||||
-@erase "$(INTDIR)\report.obj"
|
||||
-@erase "$(INTDIR)\rules.obj"
|
||||
-@erase "$(INTDIR)\smatrix.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\epanet2.dll"
|
||||
-@erase "$(OUTDIR)\epanet2.exp"
|
||||
-@erase "$(OUTDIR)\epanet2.lib"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EPANET2_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\epanet2.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\epanet2.pdb" /machine:I386 /def:"..\epanet2.def" /out:"$(OUTDIR)\epanet2.dll" /implib:"$(OUTDIR)\epanet2.lib"
|
||||
DEF_FILE= \
|
||||
"..\epanet2.def"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\epanet.obj" \
|
||||
"$(INTDIR)\hash.obj" \
|
||||
"$(INTDIR)\hydraul.obj" \
|
||||
"$(INTDIR)\inpfile.obj" \
|
||||
"$(INTDIR)\input1.obj" \
|
||||
"$(INTDIR)\input2.obj" \
|
||||
"$(INTDIR)\input3.obj" \
|
||||
"$(INTDIR)\mempool.obj" \
|
||||
"$(INTDIR)\output.obj" \
|
||||
"$(INTDIR)\quality.obj" \
|
||||
"$(INTDIR)\report.obj" \
|
||||
"$(INTDIR)\rules.obj" \
|
||||
"$(INTDIR)\smatrix.obj"
|
||||
|
||||
"$(OUTDIR)\epanet2.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("epanet2.dep")
|
||||
!INCLUDE "epanet2.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "epanet2.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "epanet2 - Win32 Release"
|
||||
SOURCE=..\epanet.c
|
||||
|
||||
"$(INTDIR)\epanet.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\hash.c
|
||||
|
||||
"$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\hydraul.c
|
||||
|
||||
"$(INTDIR)\hydraul.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\inpfile.c
|
||||
|
||||
"$(INTDIR)\inpfile.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\input1.c
|
||||
|
||||
"$(INTDIR)\input1.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\input2.c
|
||||
|
||||
"$(INTDIR)\input2.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\input3.c
|
||||
|
||||
"$(INTDIR)\input3.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\mempool.c
|
||||
|
||||
"$(INTDIR)\mempool.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\output.c
|
||||
|
||||
"$(INTDIR)\output.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\quality.c
|
||||
|
||||
"$(INTDIR)\quality.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\report.c
|
||||
|
||||
"$(INTDIR)\report.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\rules.c
|
||||
|
||||
"$(INTDIR)\rules.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\smatrix.c
|
||||
|
||||
"$(INTDIR)\smatrix.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
"MSVClibexe" /machine:i386 /def:defname
|
||||
@@ -1,161 +0,0 @@
|
||||
# MinGW Makefile for EPANET
|
||||
|
||||
# Note: This makefile usese MinGW to produce native windows
|
||||
# libraries and executables. The dll/import library, and
|
||||
# executable files will have the same names as those produced
|
||||
# using other Windows compilers, e.g. MSVC++. So be aware that
|
||||
# there is no way to reliably distinguish between these two compiler
|
||||
# sources based on output filenames.
|
||||
|
||||
# This will build EPANET as a native windows DLL and import
|
||||
# library (epanet2.dll/libepanet2.dll.a) using MinGW/gcc,
|
||||
# and a standalone executable (epanet2.exe).
|
||||
# This makefile also creates a windows batch file
|
||||
# (see MScmdname below) that can be run to produce an import
|
||||
# library for linking the DLL using MSVC.
|
||||
# This makefile assumes a minimum
|
||||
# MinGW installation, and uses the MinGW gcc compiler from
|
||||
# the MinGW install directory.
|
||||
# The current release of MinGW can be obtained from
|
||||
# http://www.mingw.org/wiki/Getting_Started -- the easiest
|
||||
# approach is to download the latest MingW installer and
|
||||
# accept all of the defaults.
|
||||
|
||||
# The following targets are defined (for execution in
|
||||
# the build directory):
|
||||
# make
|
||||
# -Builds epanet2.dll, epanet2.def, libepanet2.dll.a,
|
||||
# epanet2.exe
|
||||
# make install
|
||||
# -Creates scripts runepanet2.sh and CreateEpanet2Lib.bat that
|
||||
# execute epanet2.exe, and MSVC 'lib' (to create an MSVC
|
||||
# import library). The runepanet2.sh wrapper simply exports
|
||||
# environment variables so that the DLL is found at runtime,
|
||||
# allowing you to specify your own locations for installing
|
||||
# the DLL.
|
||||
# -Installs epanet2.dll, epanet2.exe, and runepanet2.sh
|
||||
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
||||
# below to something different - see "Install directories")
|
||||
# -Installs libepanet2.dll.a (import library), epanet2.def,
|
||||
# and CreateEpanet2Lib.bat in <prefix>/lib
|
||||
# -Installs epanet2.h in <prefix>/include. This is the required
|
||||
# header file for the EPANET programmer's toolkit, and thus
|
||||
# <prefix>/include should be on your CPP include search path
|
||||
# for subsequent use of the toolkit and linking with the import
|
||||
# library libepanet2.dll.a or epanet2.lib.
|
||||
# make clean
|
||||
# -Removes object and library files, returning the build directory
|
||||
# to its pristine state.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# C H A N G E H E R E A S N E E D E D
|
||||
# Change (as needed) the MinGW install directory below.
|
||||
# Change (as needed) the location off the MS LIB tool.
|
||||
# You may also wish to change the install path 'prefix',
|
||||
# or the compiler flags, but these defaults should be fine.
|
||||
|
||||
# MinGW top level install directory, accessible from build environment
|
||||
MinGWdir = /cygdrive/c/MinGW
|
||||
# Microsoft lib tool directory (for creating an MS import library)
|
||||
MSVClibexe = c:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\lib
|
||||
|
||||
# Target filenames
|
||||
# svnname.sh constructs a name: <prefix><root><Rev><postfix>
|
||||
# where <Rev> is the atomic revision number of the svn repo.
|
||||
epanetrootname := epanet2
|
||||
dllname := $(epanetrootname).dll
|
||||
defname := $(epanetrootname).def
|
||||
implibname = lib$(dllname).a
|
||||
exename := $(epanetrootname)
|
||||
# Shell wrapper
|
||||
runcmdtemplate = runepanet.sh.template
|
||||
runcmdname = runepanet2.sh
|
||||
# MSVC import lib batch file
|
||||
MScmdtemplate = CreateMSLib.bat.template
|
||||
MScmdname = CreateEpanet2Lib.bat
|
||||
# Location of EPANET toolkit includes
|
||||
epanetincludedir = ../../include
|
||||
# Search path for sources
|
||||
epanetsrcdir = ../../src
|
||||
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
||||
|
||||
# Install directories
|
||||
winprefix = $(shell cygpath -w $$HOME)
|
||||
prefix = ~
|
||||
exec_prefix = $(prefix)
|
||||
srcdir = .
|
||||
libdir = $(exec_prefix)/lib
|
||||
winlibdir = "$(winprefix)\lib"
|
||||
bindir = $(exec_prefix)/bin
|
||||
includedir = $(prefix)/include
|
||||
winincludedir = "$(winprefix)\include"
|
||||
datarootdir = $(prefix)/share
|
||||
docdir = $(datarootdir)/doc/epanet
|
||||
|
||||
# Compiler and flags
|
||||
# MinGW gcc
|
||||
CC = $(MinGWdir)/bin/gcc
|
||||
dlltool = $(MinGWdir)/bin/dlltool
|
||||
CFLAGS = -g -O3
|
||||
CPPFLAGS = -I $(srcdir) -I $(epanetincludedir)
|
||||
LDFLAGS = -L . -W1,-rpath,$(libdir) -lm
|
||||
|
||||
# Installer
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# EPANET object files
|
||||
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
||||
input3.o mempool.o output.o quality.o report.o \
|
||||
rules.o smatrix.o
|
||||
# Epanet header files
|
||||
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
||||
epanet_main_heads=epanet2.h
|
||||
# Epanet main program
|
||||
epanet_main=epanet
|
||||
|
||||
.PHONY: all
|
||||
all: $(dllname) $(exename)
|
||||
|
||||
$(dllname): $(epanet_objs)
|
||||
# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^
|
||||
# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D DLL -c $(epanetsrcdir)/epanet.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--output-def,$(defname)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--kill-at
|
||||
$(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at
|
||||
|
||||
$(exename): $(epanet_objs)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS)
|
||||
|
||||
$(epanet_objs): $(epanet_heads)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \
|
||||
| sed 's|exename|$(bindir)/$(exename)|' \
|
||||
> $(runcmdname)
|
||||
cat $(MScmdtemplate) | sed 's|MSVClibexe|$(MSVClibexe)|' \
|
||||
| sed 's|defname|$(defname)|' \
|
||||
| sed 's|libdir|$(libdir)|' \
|
||||
> $(MScmdname)
|
||||
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
||||
$(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname)
|
||||
$(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname)
|
||||
$(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname)
|
||||
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
||||
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
||||
$(INSTALL_PROGRAM) -D $(MScmdname) $(libdir)/$(MScmdname)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname) $(MScmdname)
|
||||
@@ -1,159 +0,0 @@
|
||||
# Cygwin/MinGW Makefile for EPANET
|
||||
|
||||
# This will build EPANET as a native windows DLL and import
|
||||
# library (epanet_gcc_<Rev>.dll/libepanet_gcc_<Rev>.dll.a) under Cygwin/MinGW,
|
||||
# and a standalone executable (epanet_gcc_<Rev>.exe).
|
||||
# <Rev> is the atomic revision number of the EPANET SVN repo,
|
||||
# so the results of each build can be unambiguously tracked to a repo Rev.
|
||||
# This makefile also creates a windows batch file
|
||||
# (see MScmdname below) that will produce an import
|
||||
# library for linking the DLL using MSVC.
|
||||
# This makefile assumes a Cygwin environment with minimal
|
||||
# MinGW installation, and uses the MinGW gcc compiler from
|
||||
# the MinGW install directory.
|
||||
# The current release of MinGW can be obtained from
|
||||
# http://www.mingw.org/wiki/Getting_Started -- the easiest
|
||||
# approach is to download the latest MingW installer and
|
||||
# accept all of the defaults.
|
||||
# The current release of the Cygwin environment can be
|
||||
# obtained from http://www.cygwin.com
|
||||
|
||||
# The following targets are defined (for execution in
|
||||
# the build directory under the Cygwin environment):
|
||||
# make
|
||||
# -Builds epanet_gcc_<Rev>.dll, epanet_gcc_<Rev>.def, libepanet_gcc_<Rev>.dll.a,
|
||||
# epanet_gcc_<Rev>.exe
|
||||
# make install
|
||||
# -Creates shell wrappers runepanet_<Rev>.sh and CreateMSLib_<Rev>.bat that
|
||||
# execute epanet_gcc_<Rev>.exe, and MSVC 'lib' (to create an MSVC
|
||||
# import library). The runepanet_<Rev>.sh wrapper simply exports
|
||||
# environment variables so that the DLL is found at runtime,
|
||||
# allowing you to specify your own locations for installing
|
||||
# the DLL.
|
||||
# -Installs epanet_gcc_<Rev>.dll, epanet_gcc_<Rev>.exe, and runepanet_<Rev>.sh
|
||||
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set
|
||||
# below to something different - see "Install directories")
|
||||
# -Installs libepanet_gcc_<Rev>.dll.a (import library), epanet_gcc_<Rev>.def,
|
||||
# and CreateMSLib-<Rev>.bat in <prefix>/lib
|
||||
# -Installs epanet2.h in <prefix>/include. This is the required
|
||||
# header file for the EPANET programmer's toolkit, and thus
|
||||
# <prefix>/include should be on your CPP include search path
|
||||
# for subsequent use of the toolkit and linking with the import
|
||||
# library libepanet_gcc_<Rev>.dll.a.
|
||||
# make clean
|
||||
# -Removes object and library files, returning the build directory
|
||||
# to its pristine state.
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# C H A N G E H E R E A S N E E D E D
|
||||
# Change (as needed) the MinGW install directory below.
|
||||
# Change (as needed) the location off the MS LIB tool.
|
||||
# You may also wish to change the install path 'prefix',
|
||||
# or the compiler flags, but these defaults should be fine.
|
||||
|
||||
# MinGW top level install directory, accessible from build environment
|
||||
MinGWdir = /cygdrive/c/MinGW
|
||||
# Microsoft lib tool directory (for creating an MS import library)
|
||||
MSVClibexe = c:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\lib
|
||||
|
||||
# Target filenames
|
||||
# svnname.sh constructs a name: <prefix><root><Rev><postfix>
|
||||
# where <Rev> is the atomic revision number of the svn repo.
|
||||
epanetsvnpath = ../../..
|
||||
epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" epanet_gcc_ "")
|
||||
dllname := $(epanetrootname).dll
|
||||
defname := $(epanetrootname).def
|
||||
implibname = lib$(dllname).a
|
||||
exename := $(epanetrootname)
|
||||
# Shell wrapper
|
||||
runcmdtemplate = runepanet.sh.template
|
||||
runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runepanet_ .sh)
|
||||
# MSVC import lib batch file
|
||||
MScmdtemplate = CreateMSLib.bat.template
|
||||
MScmdname = $(shell ../svnname.sh $(epanetsvnpath) "" CreateEpanetLib_ .bat)
|
||||
# Location of EPANET toolkit includes
|
||||
epanetincludedir = ../../include
|
||||
# Search path for sources
|
||||
epanetsrcdir = ../../src
|
||||
VPATH = $(epanetsrcdir):$(epanetincludedir)
|
||||
|
||||
# Install directories
|
||||
winprefix = $(shell cygpath -w $$HOME)
|
||||
prefix = ~
|
||||
exec_prefix = $(prefix)
|
||||
srcdir = .
|
||||
libdir = $(exec_prefix)/lib
|
||||
winlibdir = "$(winprefix)\lib"
|
||||
bindir = $(exec_prefix)/bin
|
||||
includedir = $(prefix)/include
|
||||
winincludedir = "$(winprefix)\include"
|
||||
datarootdir = $(prefix)/share
|
||||
docdir = $(datarootdir)/doc/epanet
|
||||
|
||||
# Compiler and flags
|
||||
# MinGW gcc
|
||||
CC = $(MinGWdir)/bin/gcc
|
||||
dlltool = $(MinGWdir)/bin/dlltool
|
||||
CFLAGS = -g -O3
|
||||
CPPFLAGS = -I $(srcdir) -I $(epanetincludedir)
|
||||
LDFLAGS = -L . -W1,-rpath,$(libdir) -lm
|
||||
|
||||
# Installer
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# EPANET object files
|
||||
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
|
||||
input3.o mempool.o output.o quality.o report.o \
|
||||
rules.o smatrix.o
|
||||
# Epanet header files
|
||||
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
|
||||
epanet_main_heads=epanet2.h
|
||||
# Epanet main program
|
||||
epanet_main=epanet
|
||||
|
||||
.PHONY: all
|
||||
all: $(dllname) $(exename)
|
||||
|
||||
$(dllname): $(epanet_objs)
|
||||
# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^
|
||||
# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D DLL -c $(epanetsrcdir)/epanet.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--output-def,$(defname)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--kill-at
|
||||
$(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at
|
||||
|
||||
$(exename): $(epanet_objs)
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
|
||||
$(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS)
|
||||
|
||||
$(epanet_objs): $(epanet_heads)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \
|
||||
| sed 's|exename|$(bindir)/$(exename)|' \
|
||||
> $(runcmdname)
|
||||
cat $(MScmdtemplate) | sed 's|MSVClibexe|$(MSVClibexe)|' \
|
||||
| sed 's|defname|$(defname)|' \
|
||||
| sed 's|libdir|$(libdir)|' \
|
||||
> $(MScmdname)
|
||||
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
|
||||
$(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname)
|
||||
$(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname)
|
||||
$(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname)
|
||||
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
|
||||
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
|
||||
$(INSTALL_PROGRAM) -D $(MScmdname) $(libdir)/$(MScmdname)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname) $(MScmdname)
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
export PATH=libdir:$PATH
|
||||
export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH
|
||||
exec exename "$@"
|
||||
@@ -1,424 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
22322F851068369500641384 /* enumstxt.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F701068369500641384 /* enumstxt.h */; };
|
||||
22322F861068369500641384 /* epanet.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F711068369500641384 /* epanet.c */; };
|
||||
22322F871068369500641384 /* funcs.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F721068369500641384 /* funcs.h */; };
|
||||
22322F881068369500641384 /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F731068369500641384 /* hash.c */; };
|
||||
22322F891068369500641384 /* hash.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F741068369500641384 /* hash.h */; };
|
||||
22322F8A1068369500641384 /* hydraul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F751068369500641384 /* hydraul.c */; };
|
||||
22322F8B1068369500641384 /* inpfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F761068369500641384 /* inpfile.c */; };
|
||||
22322F8C1068369500641384 /* input1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F771068369500641384 /* input1.c */; };
|
||||
22322F8D1068369500641384 /* input2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F781068369500641384 /* input2.c */; };
|
||||
22322F8E1068369500641384 /* input3.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F791068369500641384 /* input3.c */; };
|
||||
22322F8F1068369500641384 /* mempool.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7A1068369500641384 /* mempool.c */; };
|
||||
22322F901068369500641384 /* mempool.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F7B1068369500641384 /* mempool.h */; };
|
||||
22322F911068369500641384 /* output.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7C1068369500641384 /* output.c */; };
|
||||
22322F921068369500641384 /* quality.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7D1068369500641384 /* quality.c */; };
|
||||
22322F931068369500641384 /* report.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7E1068369500641384 /* report.c */; };
|
||||
22322F941068369500641384 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; };
|
||||
22322F951068369500641384 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; };
|
||||
22322F961068369500641384 /* text.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F811068369500641384 /* text.h */; };
|
||||
22322F971068369500641384 /* toolkit.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F821068369500641384 /* toolkit.h */; };
|
||||
22322F981068369500641384 /* types.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F831068369500641384 /* types.h */; };
|
||||
22322F991068369500641384 /* vars.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F841068369500641384 /* vars.h */; };
|
||||
22322F9A1068369500641384 /* epanet.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F711068369500641384 /* epanet.c */; };
|
||||
22322F9B1068369500641384 /* hash.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F731068369500641384 /* hash.c */; };
|
||||
22322F9C1068369500641384 /* hydraul.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F751068369500641384 /* hydraul.c */; };
|
||||
22322F9D1068369500641384 /* inpfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F761068369500641384 /* inpfile.c */; };
|
||||
22322F9E1068369500641384 /* input1.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F771068369500641384 /* input1.c */; };
|
||||
22322F9F1068369500641384 /* input2.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F781068369500641384 /* input2.c */; };
|
||||
22322FA01068369500641384 /* input3.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F791068369500641384 /* input3.c */; };
|
||||
22322FA11068369500641384 /* mempool.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7A1068369500641384 /* mempool.c */; };
|
||||
22322FA21068369500641384 /* output.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7C1068369500641384 /* output.c */; };
|
||||
22322FA31068369500641384 /* quality.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7D1068369500641384 /* quality.c */; };
|
||||
22322FA41068369500641384 /* report.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7E1068369500641384 /* report.c */; };
|
||||
22322FA51068369500641384 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; };
|
||||
22322FA61068369500641384 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; };
|
||||
22322FAA106836BC00641384 /* epanet2.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322FA9106836B000641384 /* epanet2.h */; };
|
||||
22322FAE106836D900641384 /* malloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322FAD106836D900641384 /* malloc.h */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
22322FAF1068370B00641384 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = D2AAC0620554660B00DB518D;
|
||||
remoteInfo = epanet;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
22322F66106833BB00641384 /* runepanet */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runepanet; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
22322F701068369500641384 /* enumstxt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = enumstxt.h; path = ../../../src/enumstxt.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F711068369500641384 /* epanet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = epanet.c; path = ../../../src/epanet.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F721068369500641384 /* funcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = funcs.h; path = ../../../src/funcs.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F731068369500641384 /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hash.c; path = ../../../src/hash.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F741068369500641384 /* hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hash.h; path = ../../../src/hash.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F751068369500641384 /* hydraul.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hydraul.c; path = ../../../src/hydraul.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F761068369500641384 /* inpfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = inpfile.c; path = ../../../src/inpfile.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F771068369500641384 /* input1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = input1.c; path = ../../../src/input1.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F781068369500641384 /* input2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = input2.c; path = ../../../src/input2.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F791068369500641384 /* input3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = input3.c; path = ../../../src/input3.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F7A1068369500641384 /* mempool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mempool.c; path = ../../../src/mempool.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F7B1068369500641384 /* mempool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mempool.h; path = ../../../src/mempool.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F7C1068369500641384 /* output.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = output.c; path = ../../../src/output.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F7D1068369500641384 /* quality.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = quality.c; path = ../../../src/quality.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F7E1068369500641384 /* report.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = report.c; path = ../../../src/report.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F7F1068369500641384 /* rules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rules.c; path = ../../../src/rules.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F801068369500641384 /* smatrix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = smatrix.c; path = ../../../src/smatrix.c; sourceTree = SOURCE_ROOT; };
|
||||
22322F811068369500641384 /* text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = text.h; path = ../../../src/text.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F821068369500641384 /* toolkit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = toolkit.h; path = ../../../src/toolkit.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F831068369500641384 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = types.h; path = ../../../src/types.h; sourceTree = SOURCE_ROOT; };
|
||||
22322F841068369500641384 /* vars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vars.h; path = ../../../src/vars.h; sourceTree = SOURCE_ROOT; };
|
||||
22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; };
|
||||
22322FAD106836D900641384 /* malloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = malloc.h; path = macinclude/malloc.h; sourceTree = "<group>"; };
|
||||
D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
22322F64106833BB00641384 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D289988505E68E00004EDB86 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
08FB7794FE84155DC02AAC07 /* epanet */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22322FA8106836A000641384 /* Include */,
|
||||
08FB7795FE84155DC02AAC07 /* Source */,
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */,
|
||||
);
|
||||
name = epanet;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
08FB7795FE84155DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22322F701068369500641384 /* enumstxt.h */,
|
||||
22322F711068369500641384 /* epanet.c */,
|
||||
22322F721068369500641384 /* funcs.h */,
|
||||
22322F731068369500641384 /* hash.c */,
|
||||
22322F741068369500641384 /* hash.h */,
|
||||
22322F751068369500641384 /* hydraul.c */,
|
||||
22322F761068369500641384 /* inpfile.c */,
|
||||
22322F771068369500641384 /* input1.c */,
|
||||
22322F781068369500641384 /* input2.c */,
|
||||
22322F791068369500641384 /* input3.c */,
|
||||
22322F7A1068369500641384 /* mempool.c */,
|
||||
22322F7B1068369500641384 /* mempool.h */,
|
||||
22322F7C1068369500641384 /* output.c */,
|
||||
22322F7D1068369500641384 /* quality.c */,
|
||||
22322F7E1068369500641384 /* report.c */,
|
||||
22322F7F1068369500641384 /* rules.c */,
|
||||
22322F801068369500641384 /* smatrix.c */,
|
||||
22322F811068369500641384 /* text.h */,
|
||||
22322F821068369500641384 /* toolkit.h */,
|
||||
22322F831068369500641384 /* types.h */,
|
||||
22322F841068369500641384 /* vars.h */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AB674ADFE9D54B511CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D2AAC0630554660B00DB518D /* libepanet.dylib */,
|
||||
22322F66106833BB00641384 /* runepanet */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22322FA8106836A000641384 /* Include */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22322FAD106836D900641384 /* malloc.h */,
|
||||
22322FA9106836B000641384 /* epanet2.h */,
|
||||
);
|
||||
name = Include;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
D2AAC0600554660B00DB518D /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22322FAA106836BC00641384 /* epanet2.h in Headers */,
|
||||
22322F851068369500641384 /* enumstxt.h in Headers */,
|
||||
22322F871068369500641384 /* funcs.h in Headers */,
|
||||
22322F891068369500641384 /* hash.h in Headers */,
|
||||
22322F901068369500641384 /* mempool.h in Headers */,
|
||||
22322F961068369500641384 /* text.h in Headers */,
|
||||
22322F971068369500641384 /* toolkit.h in Headers */,
|
||||
22322F981068369500641384 /* types.h in Headers */,
|
||||
22322F991068369500641384 /* vars.h in Headers */,
|
||||
22322FAE106836D900641384 /* malloc.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
22322F65106833BB00641384 /* runepanet */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 22322F6A106833E600641384 /* Build configuration list for PBXNativeTarget "runepanet" */;
|
||||
buildPhases = (
|
||||
22322F63106833BB00641384 /* Sources */,
|
||||
22322F64106833BB00641384 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
22322FB01068370B00641384 /* PBXTargetDependency */,
|
||||
);
|
||||
name = runepanet;
|
||||
productName = runepanet;
|
||||
productReference = 22322F66106833BB00641384 /* runepanet */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
D2AAC0620554660B00DB518D /* epanet */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1DEB914A08733D8E0010E9CD /* Build configuration list for PBXNativeTarget "epanet" */;
|
||||
buildPhases = (
|
||||
D2AAC0600554660B00DB518D /* Headers */,
|
||||
D2AAC0610554660B00DB518D /* Sources */,
|
||||
D289988505E68E00004EDB86 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = epanet;
|
||||
productName = epanet;
|
||||
productReference = D2AAC0630554660B00DB518D /* libepanet.dylib */;
|
||||
productType = "com.apple.product-type.library.dynamic";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "epanet" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 08FB7794FE84155DC02AAC07 /* epanet */;
|
||||
projectDirPath = "";
|
||||
projectRoot = ../../..;
|
||||
targets = (
|
||||
D2AAC0620554660B00DB518D /* epanet */,
|
||||
22322F65106833BB00641384 /* runepanet */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
22322F63106833BB00641384 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22322F9A1068369500641384 /* epanet.c in Sources */,
|
||||
22322F9B1068369500641384 /* hash.c in Sources */,
|
||||
22322F9C1068369500641384 /* hydraul.c in Sources */,
|
||||
22322F9D1068369500641384 /* inpfile.c in Sources */,
|
||||
22322F9E1068369500641384 /* input1.c in Sources */,
|
||||
22322F9F1068369500641384 /* input2.c in Sources */,
|
||||
22322FA01068369500641384 /* input3.c in Sources */,
|
||||
22322FA11068369500641384 /* mempool.c in Sources */,
|
||||
22322FA21068369500641384 /* output.c in Sources */,
|
||||
22322FA31068369500641384 /* quality.c in Sources */,
|
||||
22322FA41068369500641384 /* report.c in Sources */,
|
||||
22322FA51068369500641384 /* rules.c in Sources */,
|
||||
22322FA61068369500641384 /* smatrix.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
D2AAC0610554660B00DB518D /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22322F861068369500641384 /* epanet.c in Sources */,
|
||||
22322F881068369500641384 /* hash.c in Sources */,
|
||||
22322F8A1068369500641384 /* hydraul.c in Sources */,
|
||||
22322F8B1068369500641384 /* inpfile.c in Sources */,
|
||||
22322F8C1068369500641384 /* input1.c in Sources */,
|
||||
22322F8D1068369500641384 /* input2.c in Sources */,
|
||||
22322F8E1068369500641384 /* input3.c in Sources */,
|
||||
22322F8F1068369500641384 /* mempool.c in Sources */,
|
||||
22322F911068369500641384 /* output.c in Sources */,
|
||||
22322F921068369500641384 /* quality.c in Sources */,
|
||||
22322F931068369500641384 /* report.c in Sources */,
|
||||
22322F941068369500641384 /* rules.c in Sources */,
|
||||
22322F951068369500641384 /* smatrix.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
22322FB01068370B00641384 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = D2AAC0620554660B00DB518D /* epanet */;
|
||||
targetProxy = 22322FAF1068370B00641384 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1DEB914B08733D8E0010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
PRODUCT_NAME = epanet;
|
||||
SDKROOT = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB914C08733D8E0010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
INSTALL_PATH = /usr/local/lib;
|
||||
PRODUCT_NAME = epanet;
|
||||
SDKROOT = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
1DEB914F08733D8E0010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = macinclude;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB915008733D8E0010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = macinclude;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
22322F68106833BC00641384 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = CLE;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = runepanet;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
22322F69106833BC00641384 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = CLE;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = runepanet;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1DEB914A08733D8E0010E9CD /* Build configuration list for PBXNativeTarget "epanet" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB914B08733D8E0010E9CD /* Debug */,
|
||||
1DEB914C08733D8E0010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "epanet" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1DEB914F08733D8E0010E9CD /* Debug */,
|
||||
1DEB915008733D8E0010E9CD /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
22322F6A106833E600641384 /* Build configuration list for PBXNativeTarget "runepanet" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
22322F68106833BC00641384 /* Debug */,
|
||||
22322F69106833BC00641384 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* malloc.h
|
||||
* epanet
|
||||
*
|
||||
* Created by Sam Hatchett on 9/21/09.
|
||||
* Copyright 2009 __MyCompanyName__. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
SVNREV=`svn info "$1" | grep Revision | awk -F": " '{print $2}'`
|
||||
echo $2$3${SVNREV}$4
|
||||
305
cmake/CodeCoverage.cmake
Normal file
305
cmake/CodeCoverage.cmake
Normal file
@@ -0,0 +1,305 @@
|
||||
# Copyright (c) 2012 - 2017, Lars Bilke
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# CHANGES:
|
||||
#
|
||||
# 2012-01-31, Lars Bilke
|
||||
# - Enable Code Coverage
|
||||
#
|
||||
# 2013-09-17, Joakim Söderberg
|
||||
# - Added support for Clang.
|
||||
# - Some additional usage instructions.
|
||||
#
|
||||
# 2016-02-03, Lars Bilke
|
||||
# - Refactored functions to use named parameters
|
||||
#
|
||||
# 2017-06-02, Lars Bilke
|
||||
# - Merged with modified version from github.com/ufz/ogs
|
||||
#
|
||||
#
|
||||
# USAGE:
|
||||
#
|
||||
# 1. Copy this file into your cmake modules path.
|
||||
#
|
||||
# 2. Add the following line to your CMakeLists.txt:
|
||||
# include(CodeCoverage)
|
||||
#
|
||||
# 3. Append necessary compiler flags:
|
||||
# APPEND_COVERAGE_COMPILER_FLAGS()
|
||||
#
|
||||
# 3.a (OPTIONAL) Set appropriate optimization flags, e.g. -O0, -O1 or -Og
|
||||
#
|
||||
# 4. If you need to exclude additional directories from the report, specify them
|
||||
# using the COVERAGE_LCOV_EXCLUDES variable before calling SETUP_TARGET_FOR_COVERAGE_LCOV.
|
||||
# Example:
|
||||
# set(COVERAGE_LCOV_EXCLUDES 'dir1/*' 'dir2/*')
|
||||
#
|
||||
# 5. Use the functions described below to create a custom make target which
|
||||
# runs your test executable and produces a code coverage report.
|
||||
#
|
||||
# 6. Build a Debug build:
|
||||
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
# make
|
||||
# make my_coverage_target
|
||||
#
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# Check prereqs
|
||||
find_program( GCOV_PATH gcov )
|
||||
find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl)
|
||||
find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat )
|
||||
find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
|
||||
find_program( SIMPLE_PYTHON_EXECUTABLE python )
|
||||
|
||||
if(NOT GCOV_PATH)
|
||||
message(FATAL_ERROR "gcov not found! Aborting...")
|
||||
endif() # NOT GCOV_PATH
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
|
||||
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
|
||||
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
|
||||
endif()
|
||||
elseif(NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
|
||||
endif()
|
||||
|
||||
set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage"
|
||||
CACHE INTERNAL "")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE
|
||||
${COVERAGE_COMPILER_FLAGS}
|
||||
CACHE STRING "Flags used by the C++ compiler during coverage builds."
|
||||
FORCE )
|
||||
set(CMAKE_C_FLAGS_COVERAGE
|
||||
${COVERAGE_COMPILER_FLAGS}
|
||||
CACHE STRING "Flags used by the C compiler during coverage builds."
|
||||
FORCE )
|
||||
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
""
|
||||
CACHE STRING "Flags used for linking binaries during coverage builds."
|
||||
FORCE )
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
|
||||
""
|
||||
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
|
||||
FORCE )
|
||||
mark_as_advanced(
|
||||
CMAKE_CXX_FLAGS_COVERAGE
|
||||
CMAKE_C_FLAGS_COVERAGE
|
||||
CMAKE_EXE_LINKER_FLAGS_COVERAGE
|
||||
CMAKE_SHARED_LINKER_FLAGS_COVERAGE )
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
|
||||
endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
link_libraries(gcov)
|
||||
else()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
# Defines a target for running and collection code coverage information
|
||||
# Builds dependencies, runs the given executable and outputs reports.
|
||||
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||
# the coverage generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_LCOV(
|
||||
# NAME testrunner_coverage # New target name
|
||||
# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||
# DEPENDENCIES testrunner # Dependencies to build first
|
||||
# )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_LCOV)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES LCOV_ARGS GENHTML_ARGS)
|
||||
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT LCOV_PATH)
|
||||
message(FATAL_ERROR "lcov not found! Aborting...")
|
||||
endif() # NOT LCOV_PATH
|
||||
|
||||
if(NOT GENHTML_PATH)
|
||||
message(FATAL_ERROR "genhtml not found! Aborting...")
|
||||
endif() # NOT GENHTML_PATH
|
||||
|
||||
# Setup target
|
||||
add_custom_target(${Coverage_NAME}
|
||||
|
||||
# Cleanup lcov
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -directory . --zerocounters
|
||||
# Create baseline to make sure untouched files show up in the report
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -c -i -d . -o ${Coverage_NAME}.base
|
||||
|
||||
# Run tests
|
||||
COMMAND ${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
|
||||
# Capturing lcov counters and generating report
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info
|
||||
# add baseline counters
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -a ${Coverage_NAME}.base -a ${Coverage_NAME}.info --output-file ${Coverage_NAME}.total
|
||||
COMMAND ${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --remove ${Coverage_NAME}.total ${COVERAGE_LCOV_EXCLUDES} --output-file ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
|
||||
COMMAND ${GENHTML_PATH} ${Coverage_GENHTML_ARGS} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
|
||||
COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
|
||||
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."
|
||||
)
|
||||
|
||||
# Show where to find the lcov info report
|
||||
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT "Lcov code coverage info report saved in ${Coverage_NAME}.info."
|
||||
)
|
||||
|
||||
# Show info where to find the report
|
||||
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
|
||||
)
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_LCOV
|
||||
|
||||
# Defines a target for running and collection code coverage information
|
||||
# Builds dependencies, runs the given executable and outputs reports.
|
||||
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||
# the coverage generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_GCOVR_XML(
|
||||
# NAME ctest_coverage # New target name
|
||||
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||
# DEPENDENCIES executable_target # Dependencies to build first
|
||||
# )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_GCOVR_XML)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
|
||||
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT SIMPLE_PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "python not found! Aborting...")
|
||||
endif() # NOT SIMPLE_PYTHON_EXECUTABLE
|
||||
|
||||
if(NOT GCOVR_PATH)
|
||||
message(FATAL_ERROR "gcovr not found! Aborting...")
|
||||
endif() # NOT GCOVR_PATH
|
||||
|
||||
# Combine excludes to several -e arguments
|
||||
set(GCOVR_EXCLUDES "")
|
||||
foreach(EXCLUDE ${COVERAGE_GCOVR_EXCLUDES})
|
||||
list(APPEND GCOVR_EXCLUDES "-e")
|
||||
list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
|
||||
endforeach()
|
||||
|
||||
add_custom_target(${Coverage_NAME}
|
||||
# Run tests
|
||||
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
|
||||
# Running gcovr
|
||||
COMMAND ${GCOVR_PATH} --xml
|
||||
-r ${PROJECT_SOURCE_DIR} ${GCOVR_EXCLUDES}
|
||||
--object-directory=${PROJECT_BINARY_DIR}
|
||||
-o ${Coverage_NAME}.xml
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT "Running gcovr to produce Cobertura code coverage report."
|
||||
)
|
||||
|
||||
# Show info where to find the report
|
||||
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml."
|
||||
)
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_GCOVR_XML
|
||||
|
||||
# Defines a target for running and collection code coverage information
|
||||
# Builds dependencies, runs the given executable and outputs reports.
|
||||
# NOTE! The executable should always have a ZERO as exit code otherwise
|
||||
# the coverage generation will not complete.
|
||||
#
|
||||
# SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML(
|
||||
# NAME ctest_coverage # New target name
|
||||
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
|
||||
# DEPENDENCIES executable_target # Dependencies to build first
|
||||
# )
|
||||
function(SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML)
|
||||
|
||||
set(options NONE)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
|
||||
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT SIMPLE_PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "python not found! Aborting...")
|
||||
endif() # NOT SIMPLE_PYTHON_EXECUTABLE
|
||||
|
||||
if(NOT GCOVR_PATH)
|
||||
message(FATAL_ERROR "gcovr not found! Aborting...")
|
||||
endif() # NOT GCOVR_PATH
|
||||
|
||||
# Combine excludes to several -e arguments
|
||||
set(GCOVR_EXCLUDES "")
|
||||
foreach(EXCLUDE ${COVERAGE_GCOVR_EXCLUDES})
|
||||
list(APPEND GCOVR_EXCLUDES "-e")
|
||||
list(APPEND GCOVR_EXCLUDES "${EXCLUDE}")
|
||||
endforeach()
|
||||
|
||||
add_custom_target(${Coverage_NAME}
|
||||
# Run tests
|
||||
${Coverage_EXECUTABLE} ${Coverage_EXECUTABLE_ARGS}
|
||||
|
||||
# Create folder
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/${Coverage_NAME}
|
||||
|
||||
# Running gcovr
|
||||
COMMAND ${GCOVR_PATH} --html --html-details
|
||||
-r ${PROJECT_SOURCE_DIR} ${GCOVR_EXCLUDES}
|
||||
--object-directory=${PROJECT_BINARY_DIR}
|
||||
-o ${Coverage_NAME}/index.html
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${Coverage_DEPENDENCIES}
|
||||
COMMENT "Running gcovr to produce HTML code coverage report."
|
||||
)
|
||||
|
||||
# Show info where to find the report
|
||||
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
|
||||
COMMAND ;
|
||||
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
|
||||
)
|
||||
|
||||
endfunction() # SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML
|
||||
|
||||
function(APPEND_COVERAGE_COMPILER_FLAGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
|
||||
endfunction() # APPEND_COVERAGE_COMPILER_FLAGS
|
||||
15958
doc/DataFlow.eps
Normal file
15958
doc/DataFlow.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
doc/DataFlow.png
Normal file
BIN
doc/DataFlow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
195
doc/DoxygenLayout.xml
Normal file
195
doc/DoxygenLayout.xml
Normal file
@@ -0,0 +1,195 @@
|
||||
<doxygenlayout version="1.0">
|
||||
<!-- Generated by doxygen 1.8.10 -->
|
||||
<!-- Navigation index tabs for HTML output -->
|
||||
<navindex>
|
||||
<tab type="mainpage" visible="yes" title=""/>
|
||||
<tab type="pages" visible="yes" title="" intro=""/>
|
||||
<tab type="modules" visible="yes" title="Reference"
|
||||
intro="These topics describe the Toolkit's functions, symbolic constants, and other details related to its usage."/>
|
||||
<tab type="namespaces" visible="yes" title="">
|
||||
<tab type="namespacelist" visible="yes" title="" intro=""/>
|
||||
<tab type="namespacemembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="classes" visible="yes" title="">
|
||||
<tab type="classlist" visible="yes" title="" intro=""/>
|
||||
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
|
||||
<tab type="hierarchy" visible="yes" title="" intro=""/>
|
||||
<tab type="classmembers" visible="yes" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="files" visible="no" title="">
|
||||
<tab type="filelist" visible="no" title="" intro=""/>
|
||||
<tab type="globals" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="examples" visible="yes" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
<!-- Layout definition for a class page -->
|
||||
<class>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<inheritancegraph visible="$CLASS_GRAPH"/>
|
||||
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
|
||||
<memberdecl>
|
||||
<nestedclasses visible="yes" title=""/>
|
||||
<publictypes title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<publicslots title=""/>
|
||||
<signals title=""/>
|
||||
<publicmethods title=""/>
|
||||
<publicstaticmethods title=""/>
|
||||
<publicattributes title=""/>
|
||||
<publicstaticattributes title=""/>
|
||||
<protectedtypes title=""/>
|
||||
<protectedslots title=""/>
|
||||
<protectedmethods title=""/>
|
||||
<protectedstaticmethods title=""/>
|
||||
<protectedattributes title=""/>
|
||||
<protectedstaticattributes title=""/>
|
||||
<packagetypes title=""/>
|
||||
<packagemethods title=""/>
|
||||
<packagestaticmethods title=""/>
|
||||
<packageattributes title=""/>
|
||||
<packagestaticattributes title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
<privatetypes title=""/>
|
||||
<privateslots title=""/>
|
||||
<privatemethods title=""/>
|
||||
<privatestaticmethods title=""/>
|
||||
<privateattributes title=""/>
|
||||
<privatestaticattributes title=""/>
|
||||
<friends title=""/>
|
||||
<related title="" subtitle=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<services title=""/>
|
||||
<interfaces title=""/>
|
||||
<constructors title=""/>
|
||||
<functions title=""/>
|
||||
<related title=""/>
|
||||
<variables title=""/>
|
||||
<properties title=""/>
|
||||
<events title=""/>
|
||||
</memberdef>
|
||||
<allmemberslink visible="yes"/>
|
||||
<usedfiles visible="$SHOW_USED_FILES"/>
|
||||
<authorsection visible="yes"/>
|
||||
</class>
|
||||
|
||||
<!-- Layout definition for a namespace page -->
|
||||
<namespace>
|
||||
<briefdescription visible="yes"/>
|
||||
<memberdecl>
|
||||
<nestednamespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</namespace>
|
||||
|
||||
<!-- Layout definition for a file page -->
|
||||
<file>
|
||||
<briefdescription visible="yes"/>
|
||||
<includes visible="$SHOW_INCLUDE_FILES"/>
|
||||
<includegraph visible="$INCLUDE_GRAPH"/>
|
||||
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
|
||||
<sourcelink visible="yes"/>
|
||||
<memberdecl>
|
||||
<classes visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<constantgroups visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
<memberdef>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
</memberdef>
|
||||
<authorsection/>
|
||||
</file>
|
||||
|
||||
<!-- Layout definition for a group page -->
|
||||
<group>
|
||||
<briefdescription visible="yes"/>
|
||||
<groupgraph visible="$GROUP_GRAPHS"/>
|
||||
<memberdecl>
|
||||
<nestedgroups visible="yes" title="File Sections"/>
|
||||
<dirs visible="yes" title=""/>
|
||||
<files visible="yes" title=""/>
|
||||
<namespaces visible="yes" title=""/>
|
||||
<classes visible="yes" title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
<membergroups visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title="Overview"/>
|
||||
<memberdef>
|
||||
<pagedocs/>
|
||||
<inlineclasses title=""/>
|
||||
<defines title=""/>
|
||||
<typedefs title=""/>
|
||||
<enums title=""/>
|
||||
<enumvalues title=""/>
|
||||
<functions title=""/>
|
||||
<variables title=""/>
|
||||
<signals title=""/>
|
||||
<publicslots title=""/>
|
||||
<protectedslots title=""/>
|
||||
<privateslots title=""/>
|
||||
<events title=""/>
|
||||
<properties title=""/>
|
||||
<friends title=""/>
|
||||
</memberdef>
|
||||
<authorsection visible="yes"/>
|
||||
</group>
|
||||
|
||||
<!-- Layout definition for a directory page -->
|
||||
<directory>
|
||||
<briefdescription visible="yes"/>
|
||||
<directorygraph visible="yes"/>
|
||||
<memberdecl>
|
||||
<dirs visible="yes"/>
|
||||
<files visible="yes"/>
|
||||
</memberdecl>
|
||||
<detaileddescription title=""/>
|
||||
</directory>
|
||||
</doxygenlayout>
|
||||
5118
doc/Example2.eps
Normal file
5118
doc/Example2.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
doc/Example2.png
Normal file
BIN
doc/Example2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
@@ -1,9 +0,0 @@
|
||||
The EPANET software was developed by Lewis Rossman (US-EPA).
|
||||
|
||||
This public-domain software developed by the U.S. EPA,
|
||||
National Risk Management Research Laboratory in Cincinnati, Ohio.
|
||||
Although these programs have been used by the U.S. EPA, no warranty,
|
||||
expressed or implied, is made by the U.S. EPA as to the accuracy and
|
||||
functioning of the programs and related program material, nor shall the
|
||||
fact of distribution constitute any such warranty, and no responsibility
|
||||
is assumed by the U.S. EPA in connection therewith.
|
||||
8420
doc/Network.eps
Normal file
8420
doc/Network.eps
Normal file
File diff suppressed because it is too large
Load Diff
BIN
doc/Network.png
Normal file
BIN
doc/Network.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -1,54 +0,0 @@
|
||||
Contents of EPANET2.ZIP
|
||||
=======================
|
||||
This archive contains the source code for the EPANET 2
|
||||
network hydraulic and water quality solver. The solver
|
||||
provides functions for simulating the extended period
|
||||
hydraulic and water quality behavior of water distribution
|
||||
system pipe networks. It is written in ANSI-compatible C
|
||||
and can be compiled into either a Windows Dynamic Link
|
||||
Library of functions or into a command-line executable.
|
||||
|
||||
The archived code is set up for compilation as a DLL.
|
||||
To compile it as a command line (or console) application
|
||||
simply comment out the "#define DLL" macro statement at
|
||||
the top of EPANET.C and un-comment the "#define CLE" macro.
|
||||
|
||||
The DLL version of the solver (epanet2.dll) is used with
|
||||
the EPANET 2 user interface executable (epanet2w.exe) to
|
||||
form a complete Windows modeling package. It also serves
|
||||
as the function library for the EPANET Programmer's Toolkit,
|
||||
allowing developers to construct their own customized pipe
|
||||
network analysis applications.
|
||||
|
||||
The following C-code files are included in this archive:
|
||||
EPANET.C -- main module providing supervisory control
|
||||
INPUT1.C -- controls processing of input data
|
||||
INPUT2.C -- reads data from input file
|
||||
INPUT3.C -- parses individual lines of input data
|
||||
INPFILE.C -- saves modified input data to a text file
|
||||
RULES.C -- implements rule-based control of piping system
|
||||
HYDRAUL.C -- computes extended period hydraulic behavior
|
||||
QUALITY.C -- tracks transport & fate of water quality
|
||||
OUTPUT.C -- handles transfer of data to and from binary files
|
||||
REPORT.C -- handles reporting of results to text file
|
||||
SMATRIX.C -- sparse matrix linear equation solver routines
|
||||
MEMPOOL.C -- memory pool management routines
|
||||
HASH.C -- hash table routines
|
||||
|
||||
Also included are the following header files:
|
||||
TOOLKIT.H -- function prototypes of exported DLL functions
|
||||
FUNCS.H -- prototypes of all other functions
|
||||
TYPES.H -- declaration of global constants and data structures
|
||||
VARS.H -- declaration of global variables
|
||||
HASH.H -- header file for hash table routines
|
||||
MEMPOOL.H -- header file for memory pool routines
|
||||
ENUMSTXT.H -- string constants for enumerated types
|
||||
TEXT.H -- declaration of all other string constants
|
||||
|
||||
The comments at the top of each file lists the date when the latest
|
||||
update was made, and these updates can be located in the code by
|
||||
searching for comments with the phrase "/*** Updated" or with the
|
||||
release number (e.g., 2.00.12) in them.
|
||||
|
||||
Other useful documentation that can be consulted includes the EPANET
|
||||
Programmers Toolkit Help file and the EPANET Version 2 Users Manual.
|
||||
@@ -1,57 +0,0 @@
|
||||
-----------------------
|
||||
Build 2.00.12 (2/25/08)
|
||||
-----------------------
|
||||
|
||||
Computational Engine Changes (epanet2.dll and epanet2d.exe):
|
||||
===============================================================================
|
||||
CODE MODULES CHANGES
|
||||
===============================================================================
|
||||
EPANET.C Temporary files are now written to the users's current working
|
||||
INPUT1.C directory or to the designated Temporary Directory when running
|
||||
VARS.H the Windows GUI, thus avoiding file access problems for users
|
||||
FUNCS.H who do not have administrative privileges on their machine.
|
||||
-------------------------------------------------------------------------------
|
||||
EPANET.C The following tank parameters were made available for retrieval
|
||||
TOOLKIT.H using the Toolkit's ENgetnodevalue function: tank diameter,
|
||||
EPANET2.H minimum volume, index of the tank's volume curve, the initial,
|
||||
minimum, and maximum water levels, the fraction of a 2-compart-
|
||||
ment tank devoted to the mixing zone, and the tank's bulk
|
||||
reaction rate coefficient. These same parameters (with the
|
||||
exception of the volume curve) were made modifiable using the
|
||||
ENsetnodevalue function, as was the choice of mixing model.
|
||||
See the Toolkit Help file for details.
|
||||
-------------------------------------------------------------------------------
|
||||
EPANET.C A new Toolkit function, ENaddpattern, was added that allows
|
||||
TOOLKIT.C programmers to add a new time pattern to the network in any
|
||||
EPANET2.H custom code that they write.
|
||||
-------------------------------------------------------------------------------
|
||||
HYDRAUL.C A DAMPLIMIT parameter was added to control at what point during
|
||||
INPUT1.C the hydraulic solution iterations status checks on PRVs and PSVs
|
||||
INPUT3.C begin and subsequent flow changes are dampened.
|
||||
REPORT.C
|
||||
VARS.H
|
||||
TEXT.H
|
||||
-------------------------------------------------------------------------------
|
||||
HYDRAUL.C Demands for tanks (net inflows/outflows) were not always being
|
||||
set to zero when the tank was full or empty which was causing
|
||||
problems in the water quality routing solutions.
|
||||
-------------------------------------------------------------------------------
|
||||
QUALITY.C The water quality functions for all of the tank mixing models
|
||||
were modified so as to produce more robust results for cases
|
||||
where there is a significant amount of volume exchange over a
|
||||
water quality time step.
|
||||
-------------------------------------------------------------------------------
|
||||
EPANET.C A problem with the system not recognizing that water quality
|
||||
QUALITY.C reactions could begin after some initial period of time when
|
||||
VARS.H the Toolkit was used to modify reaction rate coefficients was
|
||||
fixed.
|
||||
-------------------------------------------------------------------------------
|
||||
INPFILE.C A problem with extraneous lines being written to the [REPORT]
|
||||
section of an EPANET input file created with the ENsaveinpfile
|
||||
function was fixed. Also the number of decimal places for some
|
||||
items written to the saved file, such as nodal demands, was
|
||||
increased.
|
||||
-------------------------------------------------------------------------------
|
||||
TYPES.H The code version was changed to 20012 and INT4 was explicitly
|
||||
defined as an "int" data type.
|
||||
===============================================================================
|
||||
2460
doc/doxyfile
Normal file
2460
doc/doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
2
doc/extrastylesheet.css
Normal file
2
doc/extrastylesheet.css
Normal file
@@ -0,0 +1,2 @@
|
||||
h1 { font-size:1.5em; }
|
||||
|
||||
12
doc/footer.tex
Normal file
12
doc/footer.tex
Normal file
@@ -0,0 +1,12 @@
|
||||
% Latex footer for doxygen 1.8.10
|
||||
%--- End generated contents ---
|
||||
|
||||
% Index
|
||||
\backmatter
|
||||
\newpage
|
||||
\phantomsection
|
||||
\clearemptydoublepage
|
||||
\addcontentsline{toc}{chapter}{Index}
|
||||
\printindex
|
||||
|
||||
\end{document}
|
||||
141
doc/header.tex
Normal file
141
doc/header.tex
Normal file
@@ -0,0 +1,141 @@
|
||||
% Latex header for doxygen 1.8.10
|
||||
\documentclass[twoside]{book}
|
||||
|
||||
% Packages required by doxygen
|
||||
\usepackage{fixltx2e}
|
||||
\usepackage{calc}
|
||||
\usepackage{doxygen}
|
||||
\usepackage[export]{adjustbox} % also loads graphicx
|
||||
\usepackage{graphicx}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{makeidx}
|
||||
\usepackage{multicol}
|
||||
\usepackage{multirow}
|
||||
\PassOptionsToPackage{warn}{textcomp}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[nointegrals]{wasysym}
|
||||
\usepackage[table]{xcolor}
|
||||
|
||||
% Font selection
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[scaled=.90]{helvet}
|
||||
\usepackage{courier}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{sectsty}
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
\allsectionsfont{%
|
||||
\fontseries{bc}\selectfont%
|
||||
\color{darkgray}%
|
||||
}
|
||||
\renewcommand{\DoxyLabelFont}{%
|
||||
\fontseries{bc}\selectfont%
|
||||
\color{darkgray}%
|
||||
}
|
||||
\newcommand{\+}{\discretionary{\mbox{\scriptsize$\hookleftarrow$}}{}{}}
|
||||
|
||||
% Page & text layout
|
||||
\usepackage{geometry}
|
||||
\geometry{%
|
||||
a4paper,%
|
||||
top=2.5cm,%
|
||||
bottom=2.5cm,%
|
||||
left=2.5cm,%
|
||||
right=2.5cm%
|
||||
}
|
||||
\tolerance=750
|
||||
\hfuzz=15pt
|
||||
\hbadness=750
|
||||
\setlength{\emergencystretch}{15pt}
|
||||
\setlength{\parindent}{0cm}
|
||||
\setlength{\parskip}{0.2cm}
|
||||
\makeatletter
|
||||
\renewcommand{\paragraph}{%
|
||||
\@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{%
|
||||
\normalfont\normalsize\bfseries\SS@parafont%
|
||||
}%
|
||||
}
|
||||
\renewcommand{\subparagraph}{%
|
||||
\@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{%
|
||||
\normalfont\normalsize\bfseries\SS@subparafont%
|
||||
}%
|
||||
}
|
||||
\makeatother
|
||||
|
||||
% Headers & footers
|
||||
\usepackage{fancyhdr}
|
||||
\pagestyle{fancyplain}
|
||||
\fancyhead[LE]{\fancyplain{}{\bfseries\thepage}}
|
||||
\fancyhead[CE]{\fancyplain{}{}}
|
||||
\fancyhead[RE]{\fancyplain{}{\bfseries\leftmark}}
|
||||
\fancyhead[LO]{\fancyplain{}{\bfseries\rightmark}}
|
||||
\fancyhead[CO]{\fancyplain{}{}}
|
||||
\fancyhead[RO]{\fancyplain{}{\bfseries\thepage}}
|
||||
\fancyfoot[LE]{\fancyplain{}{}}
|
||||
\fancyfoot[CE]{\fancyplain{}{}}
|
||||
\fancyfoot[RE]{\fancyplain{}{\bfseries\scriptsize OWA-EPANET 2.2 \textcopyright 2019}}
|
||||
\fancyfoot[LO]{\fancyplain{}{\bfseries\scriptsize OWA-EPANET 2.2 \textcopyright 2019}}
|
||||
\fancyfoot[CO]{\fancyplain{}{}}
|
||||
\fancyfoot[RO]{\fancyplain{}{}}
|
||||
\renewcommand{\footrulewidth}{0.4pt}
|
||||
\renewcommand{\chaptermark}[1]{%
|
||||
\markboth{#1}{}%
|
||||
}
|
||||
\renewcommand{\sectionmark}[1]{%
|
||||
\markright{\thesection\ #1}%
|
||||
}
|
||||
|
||||
% Indices & bibliography
|
||||
\usepackage{natbib}
|
||||
\usepackage[titles]{tocloft}
|
||||
\setcounter{tocdepth}{1}
|
||||
\setcounter{secnumdepth}{5}
|
||||
\makeindex
|
||||
|
||||
% Hyperlinks (required, but should be loaded last)
|
||||
\usepackage{ifpdf}
|
||||
\ifpdf
|
||||
\usepackage[pdftex,pagebackref=true]{hyperref}
|
||||
\else
|
||||
\usepackage[ps2pdf,pagebackref=true]{hyperref}
|
||||
\fi
|
||||
\hypersetup{%
|
||||
colorlinks=true,%
|
||||
linkcolor=blue,%
|
||||
citecolor=blue,%
|
||||
unicode%
|
||||
}
|
||||
|
||||
% Custom commands
|
||||
\newcommand{\clearemptydoublepage}{%
|
||||
\newpage{\pagestyle{empty}\cleardoublepage}%
|
||||
}
|
||||
|
||||
|
||||
%===== C O N T E N T S =====
|
||||
|
||||
\begin{document}
|
||||
|
||||
% Titlepage & ToC
|
||||
\hypersetup{pageanchor=false,
|
||||
bookmarks=true,
|
||||
bookmarksnumbered=true,
|
||||
pdfencoding=unicode
|
||||
}
|
||||
\pagenumbering{roman}
|
||||
\begin{titlepage}
|
||||
\vspace*{7cm}
|
||||
\begin{center}%
|
||||
{\Large OWA-EPANET Toolkit\linebreak\linebreak 2.2}\\
|
||||
\vspace*{1cm}
|
||||
{\large January 2019}\\
|
||||
%\vspace*{0.5cm}
|
||||
%{\small Wed Jan 23 2019 17:57:36}\\
|
||||
\end{center}
|
||||
\end{titlepage}
|
||||
\clearemptydoublepage
|
||||
\tableofcontents
|
||||
\clearemptydoublepage
|
||||
\pagenumbering{arabic}
|
||||
\hypersetup{pageanchor=true}
|
||||
|
||||
%--- Begin generated contents ---
|
||||
98
doc/main.dox
Executable file
98
doc/main.dox
Executable file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
@mainpage Overview
|
||||
|
||||
EPANET is a program that performs extended period simulation of hydraulic and water quality behavior within pressurized pipe networks. A network can consist of pipes, nodes (pipe junctions), pumps, valves and storage tanks or reservoirs. EPANET tracks the flow of water in each pipe, the pressure at each node, the height of water in each tank, and the concentration of a chemical species throughout the network during a multi-time period simulation. In addition to chemical species, water age and source tracing can also be simulated. The EPANET Programmer's Toolkit is a library of functions (or API) that allow programmers to customize the use of EPANET's hydraulic and water quality solution engine to their own applications. Both EPANET and its toolkit were originally developed and are currently maintained by the U.S. Environmental Protection Agency (USEPA).
|
||||
|
||||
The OWA-EPANET Toolkit is an open-source version of the original EPANET Toolkit that extends its capabilities by:
|
||||
- providing a full set of functions to set and retrieve values for all parameters contained in a network model
|
||||
- allowing networks to be built completely from function calls instead of from an input file
|
||||
- allowing multiple projects to be analyzed in parallel in a thread-safe manner
|
||||
- adding the ability to use pressure dependent demands in hydraulic analyses
|
||||
- producing more robust results with regard to hydraulic convergence, low/zero flow conditions, and water quality mass balance
|
||||
- achieving faster run times for hydraulic analyses.
|
||||
|
||||
Before using the OWA-EPANET Toolkit one should be familiar with the way that EPANET represents a pipe network, the design and operating information it requires, and the steps it uses to simulate a network's behavior. The following topics provide some introductory material on these subjects:
|
||||
- @subpage DataModel "Network Data Model"
|
||||
- @subpage DataFlow "Data Flow Diagram"
|
||||
- @subpage ToolkitVersions "Toolkit Versions"
|
||||
|
||||
More detailed information can be obtained from reading the <a href="https://nepis.epa.gov/Adobe/PDF/P1007WWU.pdf">EPANET 2 Users Manual</a>.
|
||||
|
||||
__Note:__ OWA (Open Water Analytics) exists on GitHub as an open community for the exchange of information and ideas related to computing in the water & wastewater industries. It's activities and code projects are neither affiliated with nor endorsed by the USEPA.
|
||||
*/
|
||||
|
||||
/**
|
||||
@page DataModel Network Data Model
|
||||
|
||||
EPANET models a pipe network as a collection of links connected to nodes. The links represent pipes, pumps, and control valves. The nodes represent junctions, tanks, and reservoirs. The figure below illustrates how these objects can be connected to one another to form a network.
|
||||
@image html Network.png
|
||||
@image latex Network.eps
|
||||
|
||||
Junctions have a user-supplied water withdrawal rate (i.e., consumer demand) associated with them. Tanks are storage units whose water level changes over time. Reservoirs are boundary points where a fixed hydraulic head applies.
|
||||
|
||||
Pipes have a length, diameter and roughness coefficient that determines their head loss as a function of flow rate. Pumps have either a constant power rating or a head curve that determines the head they add as a function of flow rate. Valves are used to regulate either flow or pressure. Controls can be applied to completely open or close a link or to adjust its setting (pump speed or valve setting).
|
||||
|
||||
In addition to these physical objects an EPANET model can also contain the following data objects:
|
||||
- time patterns that allow demands, quality source inflows and pump speed settings to vary at fixed
|
||||
intervals of time
|
||||
- data curves that describe relationships between two quantities, such as head versus flow for pumps and
|
||||
volume versus water level for tanks
|
||||
- simple controls that adjust a link's setting (such as a pump's status) based on node pressure, tank
|
||||
level, elapsed time, ot time of day
|
||||
- rule-based controls that consist of one or more premises that if true result in one set of actions
|
||||
being taken and if false result in a different set of actions being taken.
|
||||
|
||||
An EPANET model also contains a number of analysis options that specify:
|
||||
- the project's flow units which in turn determines its unit system (US or SI)
|
||||
- the formula used to compute head loss
|
||||
- whether to use a demand driven or a pressure driven analysis
|
||||
- hydraulic convergence criteria
|
||||
- the type of water quality analysis to perform
|
||||
- time steps used for hydraulic, water quality and reporting
|
||||
- global values for reaction coefficients that can be overridden for individual pipes
|
||||
- global values for energy usage parameters that can be overridden for individual pumps.
|
||||
|
||||
Please refer to the <a href="https://nepis.epa.gov/Adobe/PDF/P1007WWU.pdf">EPANET 2 Users Manual</a>
|
||||
for more information on EPANET's data model.
|
||||
*/
|
||||
|
||||
/**
|
||||
@page DataFlow Data Flow Diagram
|
||||
|
||||
The EPANET Toolkit contains separate code modules for network building, hydraulic analysis, water quality analysis, and report generation. The data flow diagram for analyzing a pipe network is shown below. The processing steps depicted in this diagram can be summarized as follows:
|
||||
@image html DataFlow.png
|
||||
@image latex DataFlow.eps
|
||||
|
||||
- The network builder receives a description of the network being simulated either from an external input file (.inp) or from a series of function calls that create network objects and assign their properties via code. These data are stored in a Project data structure.
|
||||
|
||||
- The hydraulics solver carries out an extended period hydraulic simulation. The results obtained at every time step can be written to an external, unformatted (binary) hydraulics file (.hyd). Some of these time steps might represent intermediate points in time where system conditions change because of tanks becoming full or empty or pumps turning on or off due to level controls or timed operation.
|
||||
|
||||
- If a water quality simulation is requested, the water quality solver accesses the flow data from the hydraulics file as it computes substance transport and reaction throughout the network over each hydraulic time step. During this process it can write both the formerly computed hydraulic results as well as its water quality results for each preset reporting interval to an unformatted (binary) output file (.out). If no water quality analysis was called for, then the hydraulic results stored in the .hyd file can simply be written out to the binary output file at uniform reporting intervals.
|
||||
|
||||
- If requested, a report writer reads back the computed simulation results from the binary output file (.out) for each reporting period and writes out selected values to a formatted report file (.rpt). Any error or warning messages generated during the run are also written to this file.
|
||||
|
||||
Toolkit functions exist to carry out all of these steps under the programmer's control, including the ability to read and modify the contents of the Project data structure.
|
||||
*/
|
||||
|
||||
/**
|
||||
@page ToolkitVersions Toolkit Versions
|
||||
|
||||
The toolkit comes with two sets of identical functions that programmers can utilize:
|
||||
- the single-threaded version of the toolkit is compatible with previous releases and only works
|
||||
with single threaded applications.
|
||||
- the multi-threaded version allows users to create multiple EPANET data sets (called projects) that can be
|
||||
analyzed concurrently.
|
||||
|
||||
Both toolkit versions utilize identical function names and argument lists with the following exceptions:
|
||||
- Function names in the single-threaded library begin with `EN` while those in the multi-threaded
|
||||
library begin with `EN_`.
|
||||
- The multi-threaded functions contain an additional argument that references a particular network project
|
||||
that the function is applied to.
|
||||
- The multi-threaded library contains two additional functions that allow users to create and delete
|
||||
EPANET projects.
|
||||
- The single-threaded library uses single precision for its floating point arguments while the
|
||||
multi-threaded library uses double precision.
|
||||
|
||||
To avoid unnecessary duplication this document only discusses the multi-threaded version of the
|
||||
toolkit.
|
||||
*/
|
||||
448
doc/modules.dox
Normal file
448
doc/modules.dox
Normal file
@@ -0,0 +1,448 @@
|
||||
/**
|
||||
@defgroup Project Project Functions
|
||||
These functions are used to manage a project.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Hydraulics Hydraulic Analysis Functions
|
||||
These functions are used to perform a hydraulic analysis.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Quality Water Quality Analysis Functions
|
||||
These functions are used to perform a water quality analysis.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Reporting Reporting Functions
|
||||
These functions are used to report simulation results.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Options Analysis Options Functions
|
||||
These functions are used to get and set analysis options.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Nodes Network Node Functions
|
||||
These functions are used for working with network nodes.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Demands Nodal Demand Functions
|
||||
These functions are used for managing nodal demands.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Links Network Link Functions
|
||||
These functions are used for working with network links.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Patterns Time Pattern Functions
|
||||
These functions are used for working with time patterns.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Curves Data Curve Functions
|
||||
These functions are used for working with data curves.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Controls Simple Control Functions
|
||||
These functions are used for working with simple conditional controls.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Rules Rule-Based Control Functions
|
||||
These functions are used for working with rule-based controls.
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Constants Symbolic Constants
|
||||
These are symbolic constants used as function arguments.
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Project
|
||||
@{
|
||||
@fn int EN_createproject(EN_Project *ph)
|
||||
@fn int EN_deleteproject(EN_Project *ph)
|
||||
@fn int EN_runproject(EN_Project ph, const char *f1, const char *f2, const char *f3, void (*pviewprog)(char *))
|
||||
@fn int EN_init(EN_Project ph, const char *rptFile, const char *outFile, int unitsType, int headLossType)
|
||||
@fn int EN_open(EN_Project ph, const char *inpFile, const char *rptFile, const char *binOutFile)
|
||||
@fn int EN_getcount(EN_Project ph, int code, int *count)
|
||||
@fn int EN_gettitle(EN_Project ph, char *line1, char *line2, char *line3)
|
||||
@fn int EN_settitle(EN_Project ph, char *line1, char *line2, char *line3)
|
||||
@fn int EN_saveinpfile(EN_Project ph, const char *filename)
|
||||
@fn int EN_close(EN_Project ph)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Hydraulics
|
||||
@{
|
||||
@fn int EN_solveH(EN_Project ph)
|
||||
@fn int EN_usehydfile(EN_Project ph, char *filename)
|
||||
@fn int EN_openH(EN_Project ph)
|
||||
@fn int EN_initH(EN_Project ph, int initFlag)
|
||||
@fn int EN_runH(EN_Project ph, long *currentTime)
|
||||
@fn int EN_nextH(EN_Project ph, long *tStep)
|
||||
@fn int EN_saveH(EN_Project ph)
|
||||
@fn int EN_savehydfile(EN_Project ph, char *filename)
|
||||
@fn int EN_closeH(EN_Project ph)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Quality
|
||||
@{
|
||||
@fn int EN_solveQ(EN_Project ph)
|
||||
@fn int EN_openQ(EN_Project ph)
|
||||
@fn int EN_initQ(EN_Project ph, int saveFlag)
|
||||
@fn int EN_runQ(EN_Project ph, long *currentTime)
|
||||
@fn int EN_nextQ(EN_Project ph, long *tStep)
|
||||
@fn int EN_stepQ(EN_Project ph, long *timeLeft)
|
||||
@fn int EN_closeQ(EN_Project ph)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Reporting
|
||||
@{
|
||||
@fn int EN_writeline(EN_Project ph, char *line)
|
||||
@fn int EN_report(EN_Project ph)
|
||||
@fn int EN_copyreport(EN_Project ph, char *filename)
|
||||
@fn int EN_clearreport(EN_Project ph)
|
||||
@fn int EN_resetreport(EN_Project ph)
|
||||
@fn int EN_setreport(EN_Project ph, char *reportFormat)
|
||||
@fn int EN_setstatusreport(EN_Project ph, int code)
|
||||
@fn int EN_getversion(int *version)
|
||||
@fn int EN_geterror(int errcode, char *errmsg, int maxLen)
|
||||
@fn int EN_getstatistic(EN_Project ph, int type, double* value)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Options
|
||||
@{
|
||||
@fn int EN_getoption(EN_Project ph, int option, double *value)
|
||||
@fn int EN_setoption(EN_Project ph, int option, double value)
|
||||
@fn int EN_getflowunits(EN_Project ph, int *units)
|
||||
@fn int EN_setflowunits(EN_Project ph, int units)
|
||||
@fn int EN_gettimeparam(EN_Project ph, int param, long *value)
|
||||
@fn int EN_settimeparam(EN_Project ph, int param, long value)
|
||||
@fn int EN_getqualinfo(EN_Project ph, int *qualType, char *chemName, char *chemUnits, int *traceNode)
|
||||
@fn int EN_getqualtype(EN_Project ph, int *qualType, int *traceNode)
|
||||
@fn int EN_setqualtype(EN_Project ph, int qualType, char *chemName, char *chemUnits, char *traceNode)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Nodes
|
||||
@{
|
||||
@fn int EN_addnode(EN_Project ph, char *id, int nodeType, int *index)
|
||||
@fn int EN_deletenode(EN_Project ph, int index, int actionCode)
|
||||
@fn int EN_getnodeindex(EN_Project ph, char *id, int *index)
|
||||
@fn int EN_getnodeid(EN_Project ph, int index, char *id)
|
||||
@fn int EN_setnodeid(EN_Project ph, int index, char *newid)
|
||||
@fn int EN_getnodetype(EN_Project ph, int index, int *code)
|
||||
@fn int EN_getnodevalue(EN_Project ph, int index, int code, double *value)
|
||||
@fn int EN_setnodevalue(EN_Project ph, int index, int code, double v)
|
||||
@fn int EN_setjuncdata(EN_Project ph, int index, double elev, double dmnd, char *dmndpat)
|
||||
@fn int EN_settankdata(EN_Project ph, int index, double elev, double initlvl,
|
||||
double minlvl, double maxlvl, double diam, double minvol, char *volcurve)
|
||||
@fn int EN_getcoord(EN_Project ph, int index, double *x, double *y)
|
||||
@fn int EN_setcoord(EN_Project ph, int index, double x, double y)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Demands
|
||||
@{
|
||||
@fn int EN_getdemandmodel(EN_Project ph, int *type, double *pmin, double *preq, double *pexp)
|
||||
@fn int EN_setdemandmodel(EN_Project ph, int type, double pmin, double preq, double pexp)
|
||||
@fn int EN_getnumdemands(EN_Project ph, int nodeIndex, int *numDemands)
|
||||
@fn int EN_getbasedemand(EN_Project ph, int nodeIndex, int demandIndex, double *baseDemand)
|
||||
@fn int EN_setbasedemand(EN_Project ph, int nodeIndex, int demandIndex, double baseDemand)
|
||||
@fn int EN_getdemandpattern(EN_Project ph, int nodeIndex, int demandIndex, int *pattIndex)
|
||||
@fn int EN_setdemandpattern(EN_Project ph, int nodeIndex, int demandIndex, int patIndex)
|
||||
@fn int EN_getdemandname(EN_Project ph, int nodeIndex, int demandIdx, char *demandName)
|
||||
@fn int EN_setdemandname(EN_Project ph, int nodeIndex, int demandIdx, char *demandName)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Links
|
||||
@{
|
||||
@fn int EN_addlink(EN_Project ph, char *id, int linkType, char *fromNode, char *toNode, int *index)
|
||||
@fn int EN_deletelink(EN_Project ph, int index, int actionCode)
|
||||
@fn int EN_getlinkindex(EN_Project ph, char *id, int *index)
|
||||
@fn int EN_getlinkid(EN_Project ph, int index, char *id)
|
||||
@fn int EN_setlinkid(EN_Project ph, int index, char *newid)
|
||||
@fn int EN_getlinktype(EN_Project ph, int index, int *linkType)
|
||||
@fn int EN_setlinktype(EN_Project ph, int *index, int linkType, int actionCode)
|
||||
@fn int EN_getlinknodes(EN_Project ph, int index, int *node1, int *node2)
|
||||
@fn int EN_setlinknodes(EN_Project ph, int index, int node1, int node2)
|
||||
@fn int EN_getlinkvalue(EN_Project ph, int index, int property, double *value)
|
||||
@fn int EN_setlinkvalue(EN_Project ph, int index, int property, double value)
|
||||
@fn int EN_setpipedata(EN_Project ph, int index, double length, double diam, double rough, double mloss)
|
||||
@fn int EN_getpumptype(EN_Project ph, int linkIndex, int *pumpType)
|
||||
@fn int EN_getheadcurveindex(EN_Project ph, int pumpIndex, int *curveIndex)
|
||||
@fn int EN_setheadcurveindex(EN_Project ph, int pumpIndex, int curveIndex)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Patterns
|
||||
@{
|
||||
@fn int EN_addpattern(EN_Project ph, char *id)
|
||||
@fn int EN_deletepattern(EN_Project ph, int index)
|
||||
@fn int EN_getpatternindex(EN_Project ph, char *id, int *index)
|
||||
@fn int EN_getpatternid(EN_Project ph, int index, char *id)
|
||||
@fn int EN_setpatternid(EN_Project ph, int index, char *id)
|
||||
@fn int EN_getpatternlen(EN_Project ph, int index, int *len)
|
||||
@fn int EN_getpatternvalue(EN_Project ph, int index, int period, double *value)
|
||||
@fn int EN_setpatternvalue(EN_Project ph, int index, int period, double value)
|
||||
@fn int EN_getaveragepatternvalue(EN_Project ph, int index, double *value)
|
||||
@fn int EN_setpattern(EN_Project ph, int index, double *f, int len)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Curves
|
||||
@{
|
||||
@fn int EN_addcurve(EN_Project ph, char *id)
|
||||
@fn int EN_deletecurve(EN_Project ph, int index)
|
||||
@fn int EN_getcurveindex(EN_Project ph, char *id, int *index)
|
||||
@fn int EN_getcurveid(EN_Project ph, int index, char *id)
|
||||
@fn int EN_setcurveid(EN_Project ph, int index, char *id)
|
||||
@fn int EN_getcurvelen(EN_Project ph, int index, int *len)
|
||||
@fn int EN_getcurvetype(EN_Project ph, int index, int *type)
|
||||
@fn int EN_getcurvevalue(EN_Project ph, int curveIndex, int pointIndex, double *x, double *y)
|
||||
@fn int EN_setcurvevalue(EN_Project ph, int curveIndex, int pointIndex, double x, double y)
|
||||
@fn int EN_getcurve(EN_Project ph, int curveIndex, char* id, int *nPoints, double **xValues, double **yValues)
|
||||
@fn int EN_setcurve(EN_Project ph, int index, double *xValues, double *yValues, int nPoints)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Controls
|
||||
@{
|
||||
@fn int EN_addcontrol(EN_Project ph, int type, int linkIndex, double setting, int nodeIndex, double level, int *index)
|
||||
@fn int EN_deletecontrol(EN_Project ph, int index)
|
||||
@fn int EN_getcontrol(EN_Project ph, int index, int *type, int *linkIndex, double *setting, int *nodeIndex, double *level)
|
||||
@fn int EN_setcontrol(EN_Project ph, int index, int type, int linkIndex, double setting, int nodeIndex, double level)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Rules
|
||||
@{
|
||||
@fn int EN_addrule(EN_Project ph, char *rule)
|
||||
@fn int EN_deleterule(EN_Project ph, int index)
|
||||
@fn int EN_getrule(EN_Project ph, int index, int *nPremises, int *nThenActions, int *nElseActions, double *priority)
|
||||
@fn int EN_getruleID(EN_Project ph, int index, char* id);
|
||||
@fn int EN_getpremise(EN_Project ph, int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex,
|
||||
int *variable, int *relop, int *status, double *value)
|
||||
@fn int EN_setpremise(EN_Project ph, int ruleIndex, int premiseIndex,
|
||||
int logop, int object, int objIndex, int variable, int relop, int status, double value)
|
||||
@fn int EN_setpremiseindex(EN_Project ph, int ruleIndex, int premiseIndex, int objIndex)
|
||||
@fn int EN_setpremisestatus(EN_Project ph, int ruleIndex, int premiseIndex, int status)
|
||||
@fn int EN_setpremisevalue(EN_Project ph, int ruleIndex, int premiseIndex, double value)
|
||||
@fn int EN_getthenaction(EN_Project ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
|
||||
@fn int EN_setthenaction(EN_Project ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
|
||||
@fn int EN_getelseaction(EN_Project ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
|
||||
@fn int EN_setelseaction(EN_Project ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
|
||||
@fn int EN_setrulepriority(EN_Project ph, int index, double priority)
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup Constants
|
||||
@{
|
||||
@file epanet2_enums.h
|
||||
\enum EN_CountType
|
||||
\enum EN_NodeType
|
||||
\enum EN_LinkType
|
||||
\enum EN_PumpType
|
||||
\enum EN_CurveType
|
||||
\enum EN_QualityType
|
||||
\enum EN_SourceType
|
||||
\enum EN_ControlType
|
||||
\enum EN_HeadLossType
|
||||
\enum EN_NodeProperty
|
||||
\enum EN_LinkProperty
|
||||
\enum EN_TimeParameter
|
||||
\enum EN_Option
|
||||
\enum EN_FlowUnits
|
||||
\enum EN_DemandModel
|
||||
\enum EN_MixingModel
|
||||
\enum EN_StatusReport
|
||||
\enum EN_StatisticType
|
||||
\enum EN_InitHydOption
|
||||
\enum EN_ActionCodeType
|
||||
\enum EN_AnalysisStatistic
|
||||
\enum EN_RuleObject
|
||||
\enum EN_RuleVariable
|
||||
\enum EN_RuleOperator
|
||||
\enum EN_RuleStatus
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Files File Descriptions
|
||||
|
||||
These are the various files used by the Toolkit.
|
||||
|
||||
@section InputFile Input File
|
||||
|
||||
The Input file is a standard EPANET input data file that describes the system being analyzed. It can either be created external to the application being developed with the Toolkit or by the application itself. It is the first file name supplied to the @ref EN_open function. The format of the file is described in Appendix C of the <a href="https://nepis.epa.gov/Adobe/PDF/P1007WWU.pdf">EPANET 2 Users Manual</a>. A project's data associated with its Input file remains accessible until the project is closed down with the @ref EN_close or deleted with @ref EN_deleteproject.
|
||||
|
||||
@section ReportFile Report File
|
||||
|
||||
The Report file is the second file name supplied to the @ref EN_open function (or the first file name to @ref EN_init). It is used to log any error messages that occur when the Input file is being processed and to record all status messages that are generated during a hydraulic simulation. In addition, if the @ref EN_report function is called the resulting report can also be written to this file as can user-generated lines of text using the @ref EN_writeline function. The format of the report is controlled by statements placed in the [REPORT] section of the Input file and by similar statements included in calls to the @ref EN_setreport function. Only results at a specified uniform reporting time interval are written to this file.
|
||||
|
||||
To suppress the writing of all error and warning messages to the Report file either include the command `MESSAGES NO` in the [REPORT] section of the Input file or call the Toolkit function `EN_setreport("MESSAGES NO")`.
|
||||
|
||||
To route a formatted report to a different file than the Report file either include the command `FILE filename` in the [REPORT] section of the Input file or call the Toolkit function `EN_setreport("FILE filename")`, where `filename` is the name of the file to use.
|
||||
|
||||
Toolkit clients will not be able to access the contents of a Report file until a project is closed. If access is needed before then, the @ref EN_copyreport function can be used to copy its current contents to another file. A @ref EN_clearreport function is also available to clear the current contents of the Report file.
|
||||
|
||||
@section OutputFile Output File
|
||||
|
||||
The Output file is an unformatted binary file used to store both hydraulic and water quality results at uniform reporting intervals (see @ref OutFileFormat). It is the third file name supplied to the @ref EN_open function (or second name to @ref EN_init). If an empty string ("") is used as its name then a scratch temporary file will be used. Otherwise the Output file will be saved after the @ref EN_close function is called. Saving this file is useful if further post-processing of the output results are needed. The function @ref EN_saveH will transfer hydraulic results to the Output file if no water quality analysis will be made. Using @ref EN_solveQ to run a water quality analysis automatically saves both hydraulic and water quality results to this file. If the @ref EN_initQ - @ref EN_runQ - @ref EN_nextQ set of functions is used to perform a water quality analysis, then results will be saved only if the `saveflag` argument of @ref EN_initQ is set to @ref EN_SAVE. Again, the need to save results to the Output file is application-dependent. If a formatted output report is to be generated using @ref EN_report, then results must first be saved to the Output file.
|
||||
|
||||
@section HydraulicsFile Hydraulics File
|
||||
The Hydraulics file is an unformatted binary file used to store the results of a hydraulic analysis. Results for all time periods are stored, including those at intermediate times when special hydraulic events occur (e.g., pumps and tanks opening or closing because control conditions have been satisfied).
|
||||
|
||||
Normally it is a temporary file that is deleted after the @ref EN_deleteproject function is called. However, it will be saved if the @ref EN_savehydfile function is called before that.
|
||||
|
||||
Likewise, a previously saved Hydraulics file can be used if the command `HYDRAULICS USE` filename appears in the [OPTIONS] section of the input file, or if the @ref EN_usehydfile function is called.
|
||||
|
||||
When the Toolkit function @ref EN_solveH is used to make a hydraulic analysis, results are automatically saved to the Hydraulics file. When the @ref EN_initH - @ref EN_runH - @ref EN_nextH set of functions is used, the `initFlag` argument to @ref EN_initH determines whether results are saved or not. The need to save hydraulic results is application-dependent. They must always be saved to the Hydraulics file if a water quality analysis will follow.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup ErrorCodes Error Codes
|
||||
|
||||
| Code | Meaning |
|
||||
|------|--------- |
|
||||
| 0 | No error |
|
||||
| 101 | Insufficient memory available |
|
||||
| 102 | No network data available |
|
||||
| 103 | Hydraulic solver not opened |
|
||||
| 104 | No hydraulics for water quality analysis |
|
||||
| 105 | Water quality solver not opened |
|
||||
| 106 | No results saved to report on |
|
||||
| 107 | Hydraulics supplied from external file |
|
||||
| 108 | Cannot use external file while hydraulics solver is open |
|
||||
| 110 | Cannot solve network hydraulic equations |
|
||||
| 120 | Cannot solve water quality transport equations |
|
||||
| ||
|
||||
| 200 | One or more errors in an input file |
|
||||
| 201 | Syntax error |
|
||||
| 202 | Function call contains an illegal numeric value |
|
||||
| 203 | Function call refers to an undefined node |
|
||||
| 204 | Function call refers to an undefined link |
|
||||
| 205 | Function call refers to an undefined time pattern |
|
||||
| 206 | Function call refers to an undefined curve |
|
||||
| 207 | Function call attempts to control a check valve pipe or a GPV valve |
|
||||
| 209 | Function call contains an illegal node property value |
|
||||
| 211 | Function call contains an illegal link property value |
|
||||
| 212 | Function call refers to an undefined Trace Node |
|
||||
| 213 | Function call contains an invalid option value |
|
||||
| 214 | Too many characters in a line of an input file |
|
||||
| 215 | Function call contains a duplicate ID label |
|
||||
| 216 | Function call refers to an undefined pump |
|
||||
| 217 | Invalid pump energy data |
|
||||
| 219 | Illegal valve connection to tank node |
|
||||
| 220 | Illegal valve connection to another valve |
|
||||
| 221 | Mis-placed clause in rule-based control |
|
||||
| 222 | Link assigned same start and end nodes |
|
||||
| 223 | Not enough nodes in network |
|
||||
| 224 | No tanks or reservoirs in network |
|
||||
| 225 | Invalid lower/upper levels for tank |
|
||||
| 226 | No head curve or power rating for pump |
|
||||
| 227 | Invalid head curve for pump |
|
||||
| 230 | Nonincreasing x-values for curve |
|
||||
| 233 | Network has unconnected node |
|
||||
| 240 | Function call refers to nonexistent water quality source |
|
||||
| 241 | Function call refers to nonexistent control |
|
||||
| 250 | Function call contains invalid format (e.g. too long an ID name) |
|
||||
| 251 | Function call contains invalid parameter code |
|
||||
| 253 | Function call refers to nonexistent demand category |
|
||||
| 254 | Function call refers to node with no coordinates |
|
||||
| 257 | Function call refers to nonexistent rule |
|
||||
| 258 | Function call refers to nonexistent rule clause |
|
||||
| 260 | Function call attempts to delete node assigned as a Trace Node |
|
||||
| 261 | Function call attempts to delete a node or link contained in a control |
|
||||
| 262 | Function call attempts to modify network structure while a solver is open |
|
||||
| ||
|
||||
| 301 | Identical file names used for different types of files |
|
||||
| 302 | Cannot open input file |
|
||||
| 303 | Cannot open report file |
|
||||
| 304 | Cannot open output file |
|
||||
| 305 | Cannot open hydraulics file |
|
||||
| 306 | Hydraulics file does not match network data |
|
||||
| 307 | Cannot read hydraulics file |
|
||||
| 308 | Cannot save results to binary file |
|
||||
| 309 | Cannot save results to report file |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup WarningCodes Warning Codes
|
||||
|
||||
| Code | Description |
|
||||
|------|--------- |
|
||||
|1 | System hydraulically unbalanced - convergence to a hydraulic solution was not achieved in the allowed number of trials |
|
||||
|2 | System may be hydraulically unstable - hydraulic convergence was only achieved after the status of all links was held fixed |
|
||||
|3 | System disconnected - one or more nodes with positive demands were disconnected from all supply sources |
|
||||
|4 | Pumps cannot deliver enough flow or head - one or more pumps were forced to either shut down (due to insufficient head) or operate beyond the maximum rated flow |
|
||||
|5 | Valves cannot deliver enough flow - one or more flow control valves could not deliver the required flow even when fully open |
|
||||
|6 | System has negative pressures - negative pressures occurred at one or more junctions with positive demand |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup Units Parameter Units
|
||||
|
||||
| Parameter | US Customary | SI Metric |
|
||||
|----------------|-------------------------|---------------------------|
|
||||
|Concentration | mg/L or ug/L | mg/L or ug/L |
|
||||
|Demand | (see Flow units) | (see Flow units) |
|
||||
|Diameter (Pipes)| inches | millimeters |
|
||||
|Diameter (Tanks)| feet | meters |
|
||||
|Efficiency | percent | percent |
|
||||
|Elevation | feet | meters |
|
||||
|Emitter Coeff. | flow units @ 1 psi drop | flow units @ 1 meter drop |
|
||||
|Energy | kwatt - hours | kwatt - hours |
|
||||
|Flow | CFS (cubic feet / sec) | LPS (liters / sec) |
|
||||
| | GPM (gallons / min) | LPM (liters / min) |
|
||||
| | MGD (million gal / day) | MLD (megaliters / day) |
|
||||
| | IMGD (Imperial MGD) | CMH (cubic meters / hr) |
|
||||
| | AFD (acre-feet / day) | CMD (cubic meters / day) |
|
||||
|Friction Factor | unitless | unitless |
|
||||
|Head | feet | meters |
|
||||
|Length | feet | meters |
|
||||
|Minor Loss Coeff. | unitless | unitless |
|
||||
|Power | horsepower | kwatts |
|
||||
|Pressure | psi | meters |
|
||||
|Reaction Coeff. (Bulk) | 1/day (1st-order)| 1/day (1st-order) |
|
||||
|Reaction Coeff. (Wall) | mass/sq-ft/day (0-order) | mass/sq-m/day (0-order) |
|
||||
| | ft/day (1st-order) | meters/day (1st-order) |
|
||||
|Roughness Coeff. | millifeet (Darcy-Weisbach) unitless otherwise| mm (Darcy-Weisbach) unitless otherwise |
|
||||
|Source Mass Injection | mass/minute | mass/minute |
|
||||
|Velocity | ft/sec | meters/sec |
|
||||
|Volume | cubic feet | cubic meters |
|
||||
|Water Age | hours | hours |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup OutFileFormat Output File Format
|
||||
|
||||
*/
|
||||
|
||||
15
doc/newfooter.html
Normal file
15
doc/newfooter.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!-- HTML footer for doxygen 1.8.10-->
|
||||
<!-- start footer part -->
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
$navpath
|
||||
<li class="footer">OWA-EPANET Toolkit 2.2 © 2019</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<li class="footer">OWA-EPANET Toolkit 2.2 © 2019</li>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
</body>
|
||||
</html>
|
||||
140
doc/output-format.dox
Normal file
140
doc/output-format.dox
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
@addtogroup OutFileFormat
|
||||
@{
|
||||
The Toolkit uses an unformatted binary output file to store both hydraulic and water quality results at uniform reporting intervals. Data written to the file is either 4-byte integers, 4-byte floats, or fixed-size strings whose size is a multiple of 4 bytes. This allows the file to be divided conveniently into 4-byte records. The file consists of four sections of the following sizes in bytes:
|
||||
|
||||
| Section | Size in Bytes |
|
||||
|----------------|----------------------------------------|
|
||||
|Prolog | 884 + 36*Nnodes + 52*Nlinks + 8*Ntanks |
|
||||
|Energy Usage | 28*Npumps + 4 |
|
||||
|Dynamic Results | (16*Nnodes + 32*Nlinks)*Nperiods |
|
||||
|Epilog | 28 |
|
||||
|
||||
where:
|
||||
- Nnodes = number of nodes (junctions + reservoirs + tanks),
|
||||
- Nlinks = number of links (pipes + pumps + valves),
|
||||
- Ntanks = number of tanks and reservoirs,
|
||||
- Npumps = number of pumps,
|
||||
- Nperiods = number of reporting periods.
|
||||
|
||||
All of these counts are themselves written to the file's Prolog or Epilog sections.
|
||||
@}
|
||||
*/
|
||||
|
||||
/**
|
||||
@page Output_Prolog Prolog Section
|
||||
@ingroup OutFileFormat
|
||||
|
||||
The Prolog section of an EPANET binary output file contains the following data:
|
||||
|
||||
|Item | Type | # Bytes |
|
||||
|----------------|-----------|-----------|
|
||||
| Magic Number = 516114521 | Integer | 4 |
|
||||
| Version (= 200) | Integer | 4 |
|
||||
| Number of Nodes | Integer | 4 |
|
||||
| Number of Reservoirs & Tanks | Integer | 4|
|
||||
| Number of Links | Integer | 4 |
|
||||
| Number of Pumps | Integer | 4 |
|
||||
| Number of Valves | Integer | 4 |
|
||||
| Water Quality Option - see @ref EN_QualityType | Integer | 4 |
|
||||
| Traced Node Index | Integer | 4 |
|
||||
| Flow Units Option | Integer | 4 |
|
||||
| Pressure Units Option | Integer | 4 |
|
||||
| 0 = psi || |
|
||||
| 1 = meters || |
|
||||
| 2 = kPa || |
|
||||
| Report Statistic Type - see @ref EN_StatisticType | Integer | 4 |
|
||||
| Reporting Start Time (sec) | Integer | 4 |
|
||||
| Reporting Time Step (sec) | Integer | 4 |
|
||||
| Simulation Duration (sec) | Integer | 4 |
|
||||
| Project Title (1st line) | Char | 80 |
|
||||
| Project Title (2nd line) | Char | 80 |
|
||||
| Project Title (3rd line) | Char | 80 |
|
||||
| Name of Input File | Char | 260 |
|
||||
| Name of Report File | Char | 260 |
|
||||
| Name of Quality Chemical | Char | 32 |
|
||||
| Chemical Concentration Units | Char | 32 |
|
||||
| ID String of Each Node | Char | 32*Nnodes |
|
||||
| ID String of Each Link | Char | 32*Nlinks |
|
||||
| Index of Head Node of Each Link | Integer | 4*Nlinks |
|
||||
| Index of Tail Node of Each Link | Integer | 4*Nlinks |
|
||||
| Type Code of Each Link (see @ref EN_LinkType) | Integer | 4*Nlinks |
|
||||
| Node Index of Each Tank | Integer | 4*Ntanks |
|
||||
| Surface Area of Each Tank | Float | 4*Ntanks |
|
||||
| Elevation of Each Node | Float | 4*Nnodes |
|
||||
| Length of Each Link | Float | 4*Nlinks |
|
||||
| Diameter of Each Link | Float | 4*Nlinks |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@page Output_Energy Energy Usage Section
|
||||
@ingroup OutFileFormat
|
||||
|
||||
The Energy Usage section of an EPANET binary output file contains the following data:
|
||||
|
||||
|Item (Repeated for Each Pump) | Type | # Bytes |
|
||||
|------------------------------|---------|---------|
|
||||
| Pump Index in list of links | Integer | 4 |
|
||||
| Pump Utilization (%) | Float | 4 |
|
||||
| Average Efficiency (%) | Float | 4 |
|
||||
| Average kwatts/MGal (or kwatts/cu m) | Float | 4 |
|
||||
| Average kwatts | Float | 4 |
|
||||
| Peak kwatts | Float | 4 |
|
||||
| Average Cost per Day | Float | 4 |
|
||||
| Peak Energy Usage (kw-hrs) | Float | 4 |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@page Output_Results Dynamic Results Section
|
||||
@ingroup OutFileFormat
|
||||
|
||||
The Dynamic Results section of an EPANET binary output file contains the following set of data for each reporting period (the reporting time step is written to the Output File's @ref Output_Prolog and the number of such steps is written to the @ref Output_Epilog):
|
||||
|
||||
| Item | Type | # Bytes |
|
||||
|------|------|---------|
|
||||
|Demand at Each Node | Float | 4*Nnodes |
|
||||
|Head (Grade) at Each Node | Float | 4*Nnodes |
|
||||
|Pressure at Each Node | Float | 4*Nnodes |
|
||||
|Water Quality at Each Node | Float | 4*Nnodes |
|
||||
|Flow in Each Link | Float | 4*Nlinks |
|
||||
|(negative for reverse flow) || |
|
||||
|Velocity in Each Link | Float | 4*Nlinks |
|
||||
|Headloss per 1000 Units of Length for Each Link | Float | 4*Nlinks |
|
||||
|(total head for pumps and head loss for valves) || |
|
||||
|Average Water Quality in Each Link | Float | 4*Nlinks |
|
||||
| Status Code for Each Link | Float | 4*Nlinks |
|
||||
| 0 = closed (pump shutoff head exceeded) || |
|
||||
| 1 = temporarily closed || |
|
||||
| 2 = closed || |
|
||||
| 3 = open || |
|
||||
| 4 = active (partially open || |
|
||||
| 5 = open (pump max. flow exceeded) || |
|
||||
| 6 = open (FCV can't supply flow || |
|
||||
| 7 = open (PRV/PSV can't supply pressure) || |
|
||||
| Setting for Each Link | Float | 4*Nlinks |
|
||||
|Reaction Rate for Each Link (mass/L/day) | Float | 4*Nlinks |
|
||||
|Friction Factor for Each Link | Float | 4*Nlinks |
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@page Output_Epilog Epilog Section
|
||||
@ingroup OutFileFormat
|
||||
|
||||
The Epilog section of an EPANET binary output file contains the following data:
|
||||
|
||||
|Item | Type | # Bytes |
|
||||
|-----|------|---------|
|
||||
|Average bulk reaction rate (mass/hr) | Float | 4 |
|
||||
|Average wall reaction rate (mass/hr) | Float | 4 |
|
||||
|Average tank reaction rate (mass/hr) | Float | 4 |
|
||||
|Average source inflow rate (mass/hr) | Float | 4 |
|
||||
|Number of Reporting Periods | Integer | 4 |
|
||||
|Warning Flag: | Integer | 4 |
|
||||
|0 = no warnings || |
|
||||
|1 = warnings were generated || |
|
||||
|Magic Number = 516114521 | Integer | 4 |
|
||||
|
||||
*/
|
||||
61
doc/readme.txt
Normal file
61
doc/readme.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
Generating Documentation for OWA-EPANET 2.2
|
||||
===========================================
|
||||
|
||||
You must have Doxygen (http://www.doxygen.nl/)installed on your machine to generate
|
||||
documentation for OWA-EPANET's API (aka Toolkit). Assuming this is the case, open a
|
||||
terminal window, navigate to the project's 'doc' directory and issue the command
|
||||
'doxygen' to generate documentation in the following formats:
|
||||
|
||||
- HTML documentation will be placed in the 'html' sub-directory. Launch 'index.html'
|
||||
to view it in a web browser.
|
||||
|
||||
- Latex documentation will be placed in the 'latex' sub-directory. Assuming you
|
||||
have a TeX system, such as MikTex (https://miktex.org), installed on your machine
|
||||
you can generate a PDF of the documentation by issuing the 'make pdf' command from
|
||||
within the 'latex' directory. The resulting pdf file will be named 'refman.pdf'.
|
||||
|
||||
To generate a Windows compiled HTML Help file you must have Microsoft's HTML Help Workshop
|
||||
(https://www.microsoft.com/en-us/download/details.aspx?id=21138) installed. In this case
|
||||
you need to first edit the Doxygen configuration file 'Doxyfile' as follows:
|
||||
|
||||
1. Change the 'GENERATE_HTMLHELP' setting to 'YES'.
|
||||
|
||||
2. Enter the location where the Help Workshop system was installed next to the
|
||||
'HHC_LOCATION' setting.
|
||||
|
||||
After running 'doxygen' again the resulting Help file named 'owa-epanet.chm' will
|
||||
appear in the 'html' sub-directory.
|
||||
|
||||
Doxygen uses the special comments placed in the project's 'epanet2_2.h' and
|
||||
'epanet2_enums.h' header files to document EPANET's API. It also uses supplementary
|
||||
material contained in the following files of the project's 'doc' folder to generate
|
||||
additional pages of documentation:
|
||||
|
||||
main.dox - generates the Overview pages.
|
||||
|
||||
toolkit-usage.dox: generates the Toolkit Usage page.
|
||||
|
||||
toolkit-examples.dox : generates the Toolkit Examples pages.
|
||||
|
||||
modules.dox: generates the Reference section of the document consisting of several
|
||||
module pages that describe Toolkit functions by group, enumerated
|
||||
constants, file descriptions, error codes, property units, and output
|
||||
file format.
|
||||
|
||||
output-format.dox: generates the pages that describe the format used in different
|
||||
sections of the output file.
|
||||
|
||||
Finally, a group of special Doxygen files are used to customize the format of the
|
||||
generated documentation. These include the following:
|
||||
|
||||
Doxyfile - the main Doxygen configuration file
|
||||
|
||||
DoxygenLayout.xml - replaces the title "Modules" with "Reference" and hides the
|
||||
"Files" section in the tree view pane of the document.
|
||||
|
||||
extrastylesheet.css - reduces the size of the the h1 heading style.
|
||||
|
||||
newfooter.html - replaces the default Doxygen footer in HTML output with a custom one.
|
||||
|
||||
header.tex - replaces the standard title page and footer text used in Latex output.
|
||||
|
||||
224
doc/toolkit-examples.dox
Normal file
224
doc/toolkit-examples.dox
Normal file
@@ -0,0 +1,224 @@
|
||||
/** @page ToolkitExamples Examples
|
||||
Here are several examples of how the Toolkit can be used for different types of network analyses.
|
||||
|
||||
- @subpage Example1 "Embedded Engine Example"
|
||||
- @subpage Example2 "Network Building Example"
|
||||
- @subpage Example3 "Hydrant Rating Curve Example"
|
||||
- @subpage Example4 "Chlorine Dosage Example"
|
||||
|
||||
*/
|
||||
|
||||
/** @page Example1 Embedded Engine Example
|
||||
This example shows how simple it is for the Toolkit to provide a network analysis engine for other applications. There are three steps that the application would need to take:
|
||||
-# Have the application write network data to an EPANET-formatted input file.
|
||||
|
||||
-# Create a project and call EN_runproject, supplying the name of the EPANET input file, the name of a Report file where status and error messages are written, and the name of a binary Output file which will contain analysis results.
|
||||
|
||||
-# Have the application access the output file to display desired analysis results (see @ref OutFileFormat).
|
||||
|
||||
Here is an example where a callback function `writeConsole` is provided to write EPANET's progress messages to the console:
|
||||
|
||||
\code {.c}
|
||||
#include "epanet2_2.h"
|
||||
|
||||
void writeConsole(char *s)
|
||||
{
|
||||
fprintf(stdout, "\n%s", s);
|
||||
}
|
||||
|
||||
int runEpanet(char* inpFile, char* rptFile, char* outFile)
|
||||
{
|
||||
int errcode;
|
||||
EN_project ph;
|
||||
EN_createproject(&pH);
|
||||
errcode = EN_runproject(ph, inpFile, rptFile, outFile, &writeConsole);
|
||||
EN_deleteproject(&ph);
|
||||
return errcode;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/** @page Example2 Network Building Example
|
||||
This example shows how a network can be built just through toolkit function calls, eliminating the
|
||||
need to always use an EPANET formatted input file. This creates opportunities to use other sources
|
||||
of network data in one's code, such as relational database files or GIS/CAD files.
|
||||
|
||||
Below is a schematic of the network to be built.
|
||||
@image html Example2.png
|
||||
|
||||
\code {.c}
|
||||
#include "epanet2_2.h"
|
||||
|
||||
void netbuilder()
|
||||
{
|
||||
// Create a project that uses gpm for flow units and
|
||||
// the Hazen-Williams formula for head loss
|
||||
int index;
|
||||
EN_Project ph;
|
||||
EN_createproject(&ph);
|
||||
EN_init(ph, "", "", EN_GPM, EN_HW);
|
||||
|
||||
// Add the first junction node to the project with
|
||||
// an elevation of 700 ft and a demand of 0
|
||||
EN_addnode(ph, "J1", EN_JUNCTION, &index);
|
||||
EN_setjuncdata(ph, index, 700, 0, "");
|
||||
|
||||
// Add the remaining two junctions with elevations of
|
||||
// 710 ft and demands of 250 and 500 gpm, respectively
|
||||
EN_addnode(ph, "J2", EN_JUNCTION, &index);
|
||||
EN_setjuncdata(ph, index, 710, 250, "");
|
||||
EN_addnode(ph, "J3", EN_JUNCTION, &index);
|
||||
EN_setjuncdata(ph, index, 710, 500, "");
|
||||
|
||||
// Add the reservoir at an elevation of 650 ft
|
||||
EN_addnode(ph, "R1", EN_RESERVOIR, &index);
|
||||
EN_setnodevalue(ph, index, EN_ELEVATION, 650);
|
||||
|
||||
// Add the tank node at elevation of 850 ft, initial water level
|
||||
// at 120 ft, minimum level at 100 ft, maximum level at 150 ft
|
||||
// and a diameter of 50.5 ft
|
||||
EN_addnode(ph, "T1", EN_TANK, &index);
|
||||
EN_settankdata(ph, index, 850, 120, 100, 150, 50.5, 0, "");
|
||||
|
||||
// Add the pipes to the project, setting their length,
|
||||
// diameter, and roughness values
|
||||
EN_addlink(ph, "P1", EN_PIPE, "J1", "J2", &index);
|
||||
EN_setpipedata(ph, index, 10560, 12, 100, 0);
|
||||
EN_addlink(ph, "P2", EN_PIPE, "J1", "T1", &index);
|
||||
EN_setpipedata(ph, index, 5280, 14, 100, 0);
|
||||
EN_addlink(ph, "P3", EN_PIPE, "J1", "J3", &index);
|
||||
EN_setpipedata(ph, index, 5280, 14, 100, 0);
|
||||
EN_addlink(ph, "P4", EN_PIPE, "J2", "J3", &index);
|
||||
EN_setpipedata(ph, index, 5280, 14, 100, 0);
|
||||
|
||||
// Add a pump to the project
|
||||
EN_addlink(ph, "PUMP", EN_PUMP, "R1", "J1", &index);
|
||||
|
||||
// Create a single point head curve (index = 1) and
|
||||
// assign it to the pump
|
||||
EN_addcurve(ph, "C1");
|
||||
EN_setcurvevalue(ph, 1, 1, 1500, 250);
|
||||
EN_setlinkvalue(ph, index, EN_PUMP_HCURVE, 1);
|
||||
|
||||
// Save the project for future use
|
||||
EN_saveinpfile(ph, "example2.inp");
|
||||
|
||||
// Delete the project
|
||||
EN_deleteproject(&ph);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/** @page Example3 Hydrant Rating Curve Example
|
||||
|
||||
This example illustrates how the Toolkit could be used to develop a hydrant rating curve used in fire flow studies. This curve shows the amount of flow available at a node in the system as a function of pressure. The curve is generated by running a number of steady state hydraulic analyses with the node of interest subjected to a different demand in each analysis. For this example we assume that the ID label of the node of interest is `MyNode` and that `N` different demand levels stored in the array `D` need to be examined. The corresponding pressures will be stored in `P`. To keep the code more readable, no error checking is made on the results returned from the Toolkit function calls.
|
||||
|
||||
\code {.c}
|
||||
#include "epanet2_2.h"
|
||||
|
||||
void HydrantRating(char *MyNode, int N, double D[], double P[])
|
||||
{
|
||||
EN_Project ph;
|
||||
int i, nodeindex;
|
||||
long t;
|
||||
double pressure;
|
||||
|
||||
// Create a project
|
||||
EN_createproject(&ph);
|
||||
|
||||
// Retrieve network data from an input file
|
||||
EN_open(ph, "example2.inp", "example2.rpt", "");
|
||||
|
||||
// Open the hydraulic solver
|
||||
EN_openH(ph);
|
||||
|
||||
// Get the index of the node of interest
|
||||
EN_getnodeindex(ph, MyNode, &nodeindex);
|
||||
|
||||
// Iterate over all demands
|
||||
for (i=1; i<N; i++)
|
||||
{
|
||||
// Set nodal demand, initialize hydraulics, make a
|
||||
// single period run, and retrieve pressure
|
||||
EN_setnodevalue(ph, nodeindex, EN_BASEDEMAND, D[i]);
|
||||
EN_initH(ph, 0);
|
||||
EN_runH(ph, &t);
|
||||
EN_getnodevalue(ph, nodeindex, EN_PRESSURE, &pressure);
|
||||
P[i] = pressure;
|
||||
}
|
||||
|
||||
// Close hydraulics solver & delete the project
|
||||
EN_closeH(ph);
|
||||
EN_deleteproject(&ph);
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/** @page Example4 Chlorine Dosage Example
|
||||
|
||||
This example illustrates how the Toolkit could be used to determine the lowest dose of chlorine applied at the entrance to a distribution system needed to ensure that a minimum residual is met throughout the system. We assume that the EPANET input file contains the proper set of kinetic coefficients that describe the rate at which chlorine will decay in the system being studied. In the example code, the ID label of the source node is contained in `SourceID`, the minimum residual target is given by `Ctarget`, and the target is only checked after a start-up duration of 5 days (432,000 seconds). To keep the code more readable, no error checking is made on the results returned from the Toolkit function calls.
|
||||
|
||||
\code {.c}
|
||||
#include "epanet2_2.h"
|
||||
|
||||
double cl2dose(char *SourceID, double Ctarget)
|
||||
{
|
||||
int i, nnodes, sourceindex, violation;
|
||||
double c, csource;
|
||||
long t, tstep;
|
||||
EN_Project ph;
|
||||
|
||||
// Open the toolkit & obtain a hydraulic solution
|
||||
EN_createproject(&ph);
|
||||
EN_open(ph, "example3.inp", "example3.rpt", "");
|
||||
EN_solveH(ph);
|
||||
|
||||
// Get the number of nodes and the source node's index
|
||||
EN_getcount(ph, EN_NODES, &nnodes);
|
||||
EN_getnodeindex(ph, SourceID, &sourceindex);
|
||||
|
||||
// Setup the system to analyze for chlorine
|
||||
// (in case it was not done in the input file)
|
||||
EN_setqualtype(ph, EN_CHEM, "Chlorine", "mg/L", "");
|
||||
|
||||
// Open the water quality solver
|
||||
EN_openQ(ph);
|
||||
|
||||
// Begin the search for the source concentration
|
||||
csource = 0.0;
|
||||
do {
|
||||
|
||||
// Update source concentration to next level
|
||||
csource = csource + 0.1;
|
||||
EN_setnodevalue(ph, sourceindex, EN_SOURCEQUAL, csource);
|
||||
|
||||
// Run WQ simulation checking for target violations
|
||||
violation = 0;
|
||||
EN_initQ(ph, 0);
|
||||
do {
|
||||
EN_runQ(ph, &t);
|
||||
if (t > 432000) {
|
||||
for (i=1; i<=nnodes; i++) {
|
||||
EN_getnodevalue(ph, i, EN_QUALITY, &c);
|
||||
if (c < Ctarget) {
|
||||
violation = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
EN_nextQ(ph, &tstep);
|
||||
|
||||
// End WQ run if violation found
|
||||
} while (!violation && tstep > 0);
|
||||
|
||||
// Continue search if violation found
|
||||
} while (violation && csource <= 4.0);
|
||||
|
||||
// Close up the WQ solver and delete the project
|
||||
EN_closeQ(ph);
|
||||
EN_deleteproject(&ph);
|
||||
return csource;
|
||||
}
|
||||
\endcode
|
||||
|
||||
*/
|
||||
242
doc/toolkit-usage.dox
Normal file
242
doc/toolkit-usage.dox
Normal file
@@ -0,0 +1,242 @@
|
||||
/**
|
||||
@page toolkit-usage Usage
|
||||
|
||||
The following topics briefly describe how to accomplish some basic tasks using the OWA-EPANET Toolkit. See the @ref ToolkitExamples topic for code listings of complete applications of the Toolkit.
|
||||
|
||||
@section CreateProject Creating a Project
|
||||
|
||||
Before any use is made of the Toolkit, a project and its handle must be created. After all processing is
|
||||
completed the project should be deleted. See the code snippet below:
|
||||
|
||||
\code {.c}
|
||||
EN_Project ph; // a project handle
|
||||
EN_createproject(&ph);
|
||||
|
||||
// Call functions that perform desired analysis
|
||||
|
||||
EN_deleteproject(&ph);
|
||||
\endcode
|
||||
|
||||
@section DetectingErrors Detecting Error Conditions
|
||||
|
||||
All of the Toolkit functions return an error/warning code. A 0 indicates that the function ran successfully. A number greater than 0 but less than 100 indicates that a warning condition was generated while a number higher than 100 indicates that the function failed.
|
||||
The meaning of specific error and warning codes are listed in the @ref ErrorCodes and @ref WarningCodes sections of this guide. The Toolkit function @ref EN_geterror can be used to obtain the text of a specific error/warning code. The following example uses a macro named `ERRCODE` along with a variable named `errcode` to execute Toolkit commands only if no fatal errors have already been detected:
|
||||
|
||||
\code {.c}
|
||||
#define ERRCODE(x) (errcode = ((errcode > 100) ? (errcode) : (x)))
|
||||
|
||||
void runHydraulics(EN_Project ph, char *inputFile, char *reportFile)
|
||||
{
|
||||
int errcode = 0;
|
||||
char errmsg[EN_MAXMSG + 1];
|
||||
|
||||
ERRCODE(EN_open(ph, inputFile, reportFile, ""));
|
||||
ERRCODE(EN_solveH(ph));
|
||||
ERRCODE(EN_saveH(ph));
|
||||
ERRCODE(EN_report(ph));
|
||||
EN_geterror(ph, errcode, errmsg);
|
||||
if (errcode) printf("\n%s\n", errmsg);
|
||||
}
|
||||
\endcode
|
||||
|
||||
@section NetworkData Providing Network Data
|
||||
|
||||
Once a project is created there are two ways in which it can be populated with data. The first is to use the @ref EN_open function to load an EPANET-formatted input file that provides a description of the network to be analyzed. The format of this file is described in Appendix C of the <a href="https://nepis.epa.gov/Adobe/PDF/P1007WWU.pdf">EPANET 2 Users Manual</a>. This function should be called immediately after a project is created. It takes as arguments the name of the input file to open and the names of a report file and a binary output file, both of which are optional. Here is a code sample showing this approach:
|
||||
|
||||
\code {.c}
|
||||
EN_Project ph;
|
||||
int errcode;
|
||||
EN_createproject(&ph);
|
||||
errcode = EN_open(ph, "net1.inp", "net1.rpt", "");
|
||||
if (errcode == 0)
|
||||
{
|
||||
// Call functions that perform desired analysis
|
||||
}
|
||||
EN_deleteproject(&ph);
|
||||
\endcode
|
||||
|
||||
After an input file has been loaded in this fashion the resulting network can have objects added or deleted, and their properties set using the various Toolkit functions .
|
||||
|
||||
The second method for supplying network data to a project is to use the Toolkit's functions to add objects and to set their properties via code. In this case the @ref EN_init function should be called immediately after creating a project, passing in the names of a report and binary output files (both optional) as well as the choices of flow units and head loss formulas to use. After that the various `EN_add` functions, such as @ref EN_addnode, @ref EN_addlink, @ref EN_addpattern, @ref EN_addcontrol, etc., can be called to add new objects to the network. Here is a partial example of constructing a network from code:
|
||||
|
||||
\code {.c}
|
||||
int index;
|
||||
EN_Project ph;
|
||||
EN_createproject(&ph);
|
||||
EN_init(ph, "net1.rpt", "", EN_GPM, EN_HW);
|
||||
EN_addnode(ph, "J1", EN_JUNCTION, &index);
|
||||
EN_addnode(ph, "J2", EN_JUNCTION, &index);
|
||||
EN_addlink(ph, "P1", EN_PIPE, "J1", "J2", &index);
|
||||
// additional function calls to complete building the network
|
||||
\endcode
|
||||
|
||||
See the @ref Example2 for a more complete example. The labels used to name objects cannot contain spaces, semi-colons, or double quotes nor exceed @ref EN_MAXID characters in length. While adding objects their properties can be set as described in the next section. Attemtping to change a network's structure by adding or deleting nodes and links while the Toolkit's hydraulic or water quality solvers are open will result in an error condition.
|
||||
|
||||
@section Properties Setting Object Properties
|
||||
|
||||
The Toolkit contains several functions for retrieving and setting the properties of a network's objects and its analysis options. The names of retrieval functions all begin with `EN_get` (e.g., @ref EN_getnodevalue, @ref EN_getoption, etc.) while the functions used for setting parameter values begin with `EN_set` (e.g., @ref EN_setnodevalue, @ref EN_setoption, etc.).
|
||||
|
||||
Most of these functions use an index number to refer to a specific network component (such as a node, link, time pattern or data curve). This number is simply the position of the component in the list of all components of similar type (e.g., node 10 is the tenth node, starting from 1, in the network) and is not the same as the ID label assigned to the component. A series of functions exist to determine a component's index number given its ID label (see @ref EN_getnodeindex, @ref EN_getlinkindex, @ref EN_getpatternindex, and @ref EN_getcurveindex). Likewise, functions exist to retrieve a component's ID label given its index number (see @ref EN_getlinkid, @ref EN_getnodeid, @ref EN_getpatternid, and @ref EN_getcurveid). The @ref EN_getcount function can be used to determine the number of different components in the network. Be aware that a component's index can change as elements are added or deleted from the network. The @ref EN_addnode and @ref EN_addlink functions return the index of the newly added node or link as a convenience for immediately setting their properties.
|
||||
|
||||
The code below is an example of using the property retrieval and setting functions. It changes all links with diameter of 10 inches to 12 inches.
|
||||
|
||||
\code {.c}
|
||||
void changeDiameters(EN_Project ph)
|
||||
{
|
||||
int i, nLinks;
|
||||
double diam;
|
||||
EN_getcount(ph, EN_LINKCOUNT, &nLinks);
|
||||
for (i = 1; i <= nLinks; i++)
|
||||
{
|
||||
EN_getlinkvalue(ph, i, EN_DIAMETER, &diam);
|
||||
if (diam == 10) EN_setlinkvalue(ph, i, EN_DIAMETER, 12);
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
@section hydraulics Computing Hydraulics
|
||||
|
||||
There are two ways to use the Toolkit to run a hydraulic analysis:
|
||||
-# Use the @ref EN_solveH function to run a complete extended period analysis, without having access to intermediate results.
|
||||
-# Use the @ref EN_openH - @ref EN_initH - @ref EN_runH - @ref EN_nextH - @ref EN_closeH series of functions to step through the simulation one hydraulic time step at a time.
|
||||
|
||||
Method 1 is useful if you only want to run a single hydraulic analysis, perhaps to provide input to a water quality analysis. With this method hydraulic results are always saved to an intermediate hydraulics file at every time step.
|
||||
|
||||
Method 2 must be used if you need to access results between time steps or if you wish to run many analyses efficiently. To accomplish the latter, you would make only one call to `EN_openH` to begin the process, then make successive calls to `EN_initH` - `EN_runH` - `EN_nextH` to perform each analysis, and finally call EN_closeH to close down the hydraulics system. An example of this is shown below (calls to `EN_nextH` are not needed because we are only making a single period analysis in this example).
|
||||
|
||||
\code {.c}
|
||||
void runHydraulics(EN_Project ph, int nRuns)
|
||||
{
|
||||
int i;
|
||||
long t;
|
||||
EN_openH(ph);
|
||||
for (i = 1; i <= nRuns; i++)
|
||||
{
|
||||
// user-supplied function to set parameters
|
||||
setparams(ph, i);
|
||||
// initialize hydraulics; don't save them to file
|
||||
EN_initH(ph, EN_NOSAVE);
|
||||
// solve hydraulics
|
||||
EN_runH(ph, &t);
|
||||
// user-supplied function to process results
|
||||
getresults(ph, i);
|
||||
}
|
||||
EN_closeH(ph);
|
||||
}
|
||||
\endcode
|
||||
|
||||
@section quality Computing Water Quality
|
||||
|
||||
As with a hydraulic analysis, there are two ways to carry out a water quality analysis:
|
||||
|
||||
-# Use the @ref EN_solveQ function to run a complete extended period analysis, without having access to intermediate results. A complete set of hydraulic results must have been generated either from running a hydraulic analysis or from importing a saved hydraulics file from a previous run.
|
||||
-# Use the @ref EN_openQ - @ref EN_initQ - @ref EN_runQ - @ref EN_nextQ - @ref EN_closeQ series of functions to step through the simulation one hydraulic time step at a time. (Replacing `EN_nextQ` with @ref EN_stepQ will step through one water quality time step at a time.)
|
||||
|
||||
The second option can either be carried out after a hydraulic analysis has been run or simultaneously as hydraulics are being computed. Example code for these two alternatives is shown below:
|
||||
|
||||
\code {.c}
|
||||
int runSequentialQuality(EN_Project ph)
|
||||
{
|
||||
int err;
|
||||
long t, tStep;
|
||||
err = EN_solveH(ph);
|
||||
if (err > 100) return err;
|
||||
EN_openQ(ph);
|
||||
EN_initQ(ph, EN_NOSAVE);
|
||||
do {
|
||||
EN_runQ(ph, &t);
|
||||
// Access quality results for time t here
|
||||
EN_nextQ(ph, &tStep);
|
||||
} while (tStep > 0);
|
||||
EN_closeQ(ph);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runConcurrentQuality(EN_Project ph)
|
||||
{
|
||||
int err = 0;
|
||||
long t, tStep;
|
||||
EN_openH(ph);
|
||||
EN_initH(ph, EN_NOSAVE);
|
||||
EN_openQ(ph);
|
||||
EN_initQ(ph, EN_NOSAVE);
|
||||
do {
|
||||
err = EN_runH(ph, &t);
|
||||
if (err > 100) break;
|
||||
EN_runQ(ph, &t);
|
||||
// Access hydraulic & quality results for time t here
|
||||
EN_nextH(ph, &tStep);
|
||||
EN_nextQ(ph, &tStep);
|
||||
} while (tStep > 0);
|
||||
EN_closeH(ph);
|
||||
EN_closeQ(ph);
|
||||
return err;
|
||||
}
|
||||
\endcode
|
||||
|
||||
@section results Retrieving Computed Results
|
||||
|
||||
The @ref EN_getnodevalue and @ref EN_getlinkvalue functions can also be used to retrieve the results of hydraulic and water quality simulations. The computed parameters (and their Toolkit codes) that can be retrieved are as follows:
|
||||
|For Nodes: | For Links: |
|
||||
|----------------------------------- | ----------------------------------------- |
|
||||
|`EN_DEMAND` (demand) |`EN_FLOW` (flow rate) |
|
||||
|`EN_HEAD` (hydraulic head) |`EN_VELOCITY` (flow velocity) |
|
||||
|`EN_PRESSURE` (pressure) |`EN_HEADLOSS` (head loss) |
|
||||
|`EN_TANKLEVEL` (tank water level) |`EN_STATUS` (link status) |
|
||||
|`EN_TANKVOLUME` (tank water volume) |`EN_SETTING` (pump speed or valve setting) |
|
||||
|`EN_QUALITY` (water quality) |`EN_ENERGY` (pump energy usage) |
|
||||
|`EN_SOURCEMASS` (source mass inflow)|`EN_PUMP_EFFIC` (pump efficiency) |
|
||||
|
||||
The following code shows how to retrieve the pressure at each node of a network after each time step of a hydraulic analysis (`writetofile` is a user-defined function that will write a record to a file):
|
||||
\code {.c}
|
||||
void getPressures(EN_Project ph)
|
||||
{
|
||||
int i, numNodes;
|
||||
long t, tStep;
|
||||
double p;
|
||||
char id[EN_MAXID + 1];
|
||||
EN_getcount(ph, EN_NODECOUNT, &numNodes);
|
||||
EN_openH(ph);
|
||||
ENinitH(ph, EN_NOSAVE);
|
||||
do {
|
||||
ENrunH(ph, &t);
|
||||
for (i = 1; i <= NumNodes; i++) {
|
||||
EN_getnodevalue(ph, i, EN_PRESSURE, &p);
|
||||
EN_getnodeid(ph, i, id);
|
||||
writetofile(t, id, p);
|
||||
}
|
||||
EN_nextH(&tStep);
|
||||
} while (tStep > 0);
|
||||
ENcloseH(ph);
|
||||
}
|
||||
\endcode
|
||||
|
||||
@section report Writing a Report
|
||||
|
||||
The Toolkit has some built-in capabilities to produce formatted output results saved to a file. More specialized reporting needs can always be handled by writing custom code.
|
||||
|
||||
The @ref EN_setreport function is used to define the format of a report while the @ref EN_report function actually writes the report. The latter should be called only after a hydraulic or water quality analysis has been made. An example of creating a report that lists all nodes where the pressure variation over the duration of the simulation exceeds 20 psi is shown below:
|
||||
|
||||
\code {.c}
|
||||
void reportPressureVariation(EN_Project ph)
|
||||
{
|
||||
// Compute ranges (max - min)
|
||||
EN_settimeparam(ph, EN_STATISTIC, EN_RANGE);
|
||||
|
||||
// Solve and save hydraulics
|
||||
EN_solveH(ph);
|
||||
EN_saveH(ph);
|
||||
|
||||
// Define contents of the report
|
||||
EN_resetreport(ph);
|
||||
ENsetreport(ph, "FILE myfile.rpt");
|
||||
EN_setreport(ph, "NODES ALL");
|
||||
EN_setreport(ph, "PRESSURE PRECISION 1");
|
||||
EN_setreport(ph, "PRESSURE ABOVE 20");
|
||||
|
||||
// Write the report to file
|
||||
EN_report(ph);
|
||||
}
|
||||
\endcode
|
||||
|
||||
*/
|
||||
178
example-networks/Net1.inp
Normal file
178
example-networks/Net1.inp
Normal file
@@ -0,0 +1,178 @@
|
||||
[TITLE]
|
||||
EPANET Example Network 1
|
||||
A simple example of modeling chlorine decay. Both bulk and
|
||||
wall reactions are included.
|
||||
|
||||
[JUNCTIONS]
|
||||
;ID Elev Demand Pattern
|
||||
10 710 0 ;
|
||||
11 710 150 ;
|
||||
12 700 150 ;
|
||||
13 695 100 ;
|
||||
21 700 150 ;
|
||||
22 695 200 ;
|
||||
23 690 150 ;
|
||||
31 700 100 ;
|
||||
32 710 100 ;
|
||||
|
||||
[RESERVOIRS]
|
||||
;ID Head Pattern
|
||||
9 800 ;
|
||||
|
||||
[TANKS]
|
||||
;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
|
||||
2 850 120 100 150 50.5 0 ;
|
||||
|
||||
[PIPES]
|
||||
;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
|
||||
10 10 11 10530 18 100 0 Open ;
|
||||
11 11 12 5280 14 100 0 Open ;
|
||||
12 12 13 5280 10 100 0 Open ;
|
||||
21 21 22 5280 10 100 0 Open ;
|
||||
22 22 23 5280 12 100 0 Open ;
|
||||
31 31 32 5280 6 100 0 Open ;
|
||||
110 2 12 200 18 100 0 Open ;
|
||||
111 11 21 5280 10 100 0 Open ;
|
||||
112 12 22 5280 12 100 0 Open ;
|
||||
113 13 23 5280 8 100 0 Open ;
|
||||
121 21 31 5280 8 100 0 Open ;
|
||||
122 22 32 5280 6 100 0 Open ;
|
||||
|
||||
[PUMPS]
|
||||
;ID Node1 Node2 Parameters
|
||||
9 9 10 HEAD 1 ;
|
||||
|
||||
[VALVES]
|
||||
;ID Node1 Node2 Diameter Type Setting MinorLoss
|
||||
|
||||
[TAGS]
|
||||
|
||||
[DEMANDS]
|
||||
;Junction Demand Pattern Category
|
||||
|
||||
[STATUS]
|
||||
;ID Status/Setting
|
||||
|
||||
[PATTERNS]
|
||||
;ID Multipliers
|
||||
;Demand Pattern
|
||||
1 1.0 1.2 1.4 1.6 1.4 1.2
|
||||
1 1.0 0.8 0.6 0.4 0.6 0.8
|
||||
|
||||
[CURVES]
|
||||
;ID X-Value Y-Value
|
||||
;PUMP: Pump Curve for Pump 9
|
||||
1 1500 250
|
||||
|
||||
[CONTROLS]
|
||||
LINK 9 OPEN IF NODE 2 BELOW 110
|
||||
LINK 9 CLOSED IF NODE 2 ABOVE 140
|
||||
|
||||
|
||||
[RULES]
|
||||
|
||||
[ENERGY]
|
||||
Global Efficiency 75
|
||||
Global Price 0.0
|
||||
Demand Charge 0.0
|
||||
|
||||
[EMITTERS]
|
||||
;Junction Coefficient
|
||||
|
||||
[QUALITY]
|
||||
;Node InitQual
|
||||
10 0.5
|
||||
11 0.5
|
||||
12 0.5
|
||||
13 0.5
|
||||
21 0.5
|
||||
22 0.5
|
||||
23 0.5
|
||||
31 0.5
|
||||
32 0.5
|
||||
9 1.0
|
||||
2 1.0
|
||||
|
||||
[SOURCES]
|
||||
;Node Type Quality Pattern
|
||||
|
||||
[REACTIONS]
|
||||
;Type Pipe/Tank Coefficient
|
||||
|
||||
|
||||
[REACTIONS]
|
||||
Order Bulk 1
|
||||
Order Tank 1
|
||||
Order Wall 1
|
||||
Global Bulk -.5
|
||||
Global Wall -1
|
||||
Limiting Potential 0.0
|
||||
Roughness Correlation 0.0
|
||||
|
||||
[MIXING]
|
||||
;Tank Model
|
||||
|
||||
[TIMES]
|
||||
Duration 24:00
|
||||
Hydraulic Timestep 1:00
|
||||
Quality Timestep 0:05
|
||||
Pattern Timestep 2:00
|
||||
Pattern Start 0:00
|
||||
Report Timestep 1:00
|
||||
Report Start 0:00
|
||||
Start ClockTime 12 am
|
||||
Statistic None
|
||||
|
||||
[REPORT]
|
||||
Status Yes
|
||||
Summary No
|
||||
Page 0
|
||||
|
||||
[OPTIONS]
|
||||
Units GPM
|
||||
Headloss H-W
|
||||
Specific Gravity 1.0
|
||||
Viscosity 1.0
|
||||
Trials 40
|
||||
Accuracy 0.001
|
||||
CHECKFREQ 2
|
||||
MAXCHECK 10
|
||||
DAMPLIMIT 0
|
||||
Unbalanced Continue 10
|
||||
Pattern 1
|
||||
Demand Multiplier 1.0
|
||||
Emitter Exponent 0.5
|
||||
Quality Chlorine mg/L
|
||||
Diffusivity 1.0
|
||||
Tolerance 0.01
|
||||
|
||||
[COORDINATES]
|
||||
;Node X-Coord Y-Coord
|
||||
10 20.00 70.00
|
||||
11 30.00 70.00
|
||||
12 50.00 70.00
|
||||
13 70.00 70.00
|
||||
21 30.00 40.00
|
||||
22 50.00 40.00
|
||||
23 70.00 40.00
|
||||
31 30.00 10.00
|
||||
32 50.00 10.00
|
||||
9 10.00 70.00
|
||||
2 50.00 90.00
|
||||
|
||||
[VERTICES]
|
||||
;Link X-Coord Y-Coord
|
||||
|
||||
[LABELS]
|
||||
;X-Coord Y-Coord Label & Anchor Node
|
||||
6.99 73.63 "Source"
|
||||
13.48 68.13 "Pump"
|
||||
43.85 91.21 "Tank"
|
||||
|
||||
[BACKDROP]
|
||||
DIMENSIONS 7.00 6.00 73.00 94.00
|
||||
UNITS None
|
||||
FILE
|
||||
OFFSET 0.00 0.00
|
||||
|
||||
[END]
|
||||
309
example-networks/Net2.inp
Normal file
309
example-networks/Net2.inp
Normal file
@@ -0,0 +1,309 @@
|
||||
[TITLE]
|
||||
EPANET Example Network 2
|
||||
Example of modeling a 55-hour fluoride tracer study.
|
||||
Measured fluoride data is contained in the file Net2-FL.dat
|
||||
and should be registered with the project to produce a
|
||||
Calibration Report (select Calibration Data from the Project
|
||||
menu).
|
||||
|
||||
[JUNCTIONS]
|
||||
;ID Elev Demand Pattern
|
||||
1 50 -694.4 2 ;
|
||||
2 100 8 ;
|
||||
3 60 14 ;
|
||||
4 60 8 ;
|
||||
5 100 8 ;
|
||||
6 125 5 ;
|
||||
7 160 4 ;
|
||||
8 110 9 ;
|
||||
9 180 14 ;
|
||||
10 130 5 ;
|
||||
11 185 34.78 ;
|
||||
12 210 16 ;
|
||||
13 210 2 ;
|
||||
14 200 2 ;
|
||||
15 190 2 ;
|
||||
16 150 20 ;
|
||||
17 180 20 ;
|
||||
18 100 20 ;
|
||||
19 150 5 ;
|
||||
20 170 19 ;
|
||||
21 150 16 ;
|
||||
22 200 10 ;
|
||||
23 230 8 ;
|
||||
24 190 11 ;
|
||||
25 230 6 ;
|
||||
27 130 8 ;
|
||||
28 110 0 ;
|
||||
29 110 7 ;
|
||||
30 130 3 ;
|
||||
31 190 17 ;
|
||||
32 110 17 ;
|
||||
33 180 1.5 ;
|
||||
34 190 1.5 ;
|
||||
35 110 0 ;
|
||||
36 110 1 ;
|
||||
|
||||
[RESERVOIRS]
|
||||
;ID Head Pattern
|
||||
|
||||
[TANKS]
|
||||
;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
|
||||
26 235 56.7 50 70 50 0 ;
|
||||
|
||||
[PIPES]
|
||||
;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
|
||||
1 1 2 2400 12 100 0 Open ;
|
||||
2 2 5 800 12 100 0 Open ;
|
||||
3 2 3 1300 8 100 0 Open ;
|
||||
4 3 4 1200 8 100 0 Open ;
|
||||
5 4 5 1000 12 100 0 Open ;
|
||||
6 5 6 1200 12 100 0 Open ;
|
||||
7 6 7 2700 12 100 0 Open ;
|
||||
8 7 8 1200 12 140 0 Open ;
|
||||
9 7 9 400 12 100 0 Open ;
|
||||
10 8 10 1000 8 140 0 Open ;
|
||||
11 9 11 700 12 100 0 Open ;
|
||||
12 11 12 1900 12 100 0 Open ;
|
||||
13 12 13 600 12 100 0 Open ;
|
||||
14 13 14 400 12 100 0 Open ;
|
||||
15 14 15 300 12 100 0 Open ;
|
||||
16 13 16 1500 8 100 0 Open ;
|
||||
17 15 17 1500 8 100 0 Open ;
|
||||
18 16 17 600 8 100 0 Open ;
|
||||
19 17 18 700 12 100 0 Open ;
|
||||
20 18 32 350 12 100 0 Open ;
|
||||
21 16 19 1400 8 100 0 Open ;
|
||||
22 14 20 1100 12 100 0 Open ;
|
||||
23 20 21 1300 8 100 0 Open ;
|
||||
24 21 22 1300 8 100 0 Open ;
|
||||
25 20 22 1300 8 100 0 Open ;
|
||||
26 24 23 600 12 100 0 Open ;
|
||||
27 15 24 250 12 100 0 Open ;
|
||||
28 23 25 300 12 100 0 Open ;
|
||||
29 25 26 200 12 100 0 Open ;
|
||||
30 25 31 600 12 100 0 Open ;
|
||||
31 31 27 400 8 100 0 Open ;
|
||||
32 27 29 400 8 100 0 Open ;
|
||||
34 29 28 700 8 100 0 Open ;
|
||||
35 22 33 1000 8 100 0 Open ;
|
||||
36 33 34 400 8 100 0 Open ;
|
||||
37 32 19 500 8 100 0 Open ;
|
||||
38 29 35 500 8 100 0 Open ;
|
||||
39 35 30 1000 8 100 0 Open ;
|
||||
40 28 35 700 8 100 0 Open ;
|
||||
41 28 36 300 8 100 0 Open ;
|
||||
|
||||
[PUMPS]
|
||||
;ID Node1 Node2 Parameters
|
||||
|
||||
[VALVES]
|
||||
;ID Node1 Node2 Diameter Type Setting MinorLoss
|
||||
|
||||
[TAGS]
|
||||
|
||||
[DEMANDS]
|
||||
;Junction Demand Pattern Category
|
||||
|
||||
[STATUS]
|
||||
;ID Status/Setting
|
||||
|
||||
[PATTERNS]
|
||||
;ID Multipliers
|
||||
;Demand Pattern
|
||||
1 1.26 1.04 .97 .97 .89 1.19
|
||||
1 1.28 .67 .67 1.34 2.46 .97
|
||||
1 .92 .68 1.43 .61 .31 .78
|
||||
1 .37 .67 1.26 1.56 1.19 1.26
|
||||
1 .6 1.1 1.03 .73 .88 1.06
|
||||
1 .99 1.72 1.12 1.34 1.12 .97
|
||||
1 1.04 1.15 .91 .61 .68 .46
|
||||
1 .51 .74 1.12 1.34 1.26 .97
|
||||
1 .82 1.37 1.03 .81 .88 .81
|
||||
1 .81
|
||||
;Pump Station Outflow Pattern
|
||||
2 .96 .96 .96 .96 .96 .96
|
||||
2 .62 0 0 0 0 0
|
||||
2 .8 1 1 1 1 .15
|
||||
2 0 0 0 0 0 0
|
||||
2 .55 .92 .92 .92 .92 .9
|
||||
2 .9 .45 0 0 0 0
|
||||
2 0 .7 1 1 1 1
|
||||
2 .2 0 0 0 0 0
|
||||
2 0 .74 .92 .92 .92 .92
|
||||
2 .92
|
||||
;Pump Station Fluoride Pattern
|
||||
3 .98 1.02 1.05 .99 .64 .46
|
||||
3 .35 .35 .35 .35 .35 .35
|
||||
3 .17 .17 .13 .13 .13 .15
|
||||
3 .15 .15 .15 .15 .15 .15
|
||||
3 .15 .12 .1 .08 .11 .09
|
||||
3 .09 .08 .08 .08 .08 .08
|
||||
3 .08 .09 .07 .07 .09 .09
|
||||
3 .09 .09 .09 .09 .09 .09
|
||||
3 .09 .08 .35 .72 .82 .92
|
||||
3 1
|
||||
|
||||
[CURVES]
|
||||
;ID X-Value Y-Value
|
||||
|
||||
[CONTROLS]
|
||||
|
||||
[RULES]
|
||||
|
||||
[ENERGY]
|
||||
Global Efficiency 75
|
||||
Global Price 0.0
|
||||
Demand Charge 0.0
|
||||
|
||||
[EMITTERS]
|
||||
;Junction Coefficient
|
||||
|
||||
[QUALITY]
|
||||
;Node InitQual
|
||||
1 1.0
|
||||
2 1.0
|
||||
3 1.0
|
||||
4 1.0
|
||||
5 1.0
|
||||
6 1.0
|
||||
7 1.0
|
||||
8 1.0
|
||||
9 1.0
|
||||
10 1.0
|
||||
11 1.0
|
||||
12 1.0
|
||||
13 1.0
|
||||
14 1.0
|
||||
15 1.0
|
||||
16 1.0
|
||||
17 1.0
|
||||
18 1.0
|
||||
19 1.0
|
||||
20 1.0
|
||||
21 1.0
|
||||
22 1.0
|
||||
23 1.0
|
||||
24 1.0
|
||||
25 1.0
|
||||
27 1.0
|
||||
28 1.0
|
||||
29 1.0
|
||||
30 1.0
|
||||
31 1.0
|
||||
32 1.0
|
||||
33 1.0
|
||||
34 1.0
|
||||
35 1.0
|
||||
36 1.0
|
||||
26 1.0
|
||||
|
||||
[SOURCES]
|
||||
;Node Type Quality Pattern
|
||||
1 CONCEN 1.0 3
|
||||
|
||||
[REACTIONS]
|
||||
;Type Pipe/Tank Coefficient
|
||||
|
||||
|
||||
[REACTIONS]
|
||||
Order Bulk 1
|
||||
Order Tank 1
|
||||
Order Wall 1
|
||||
Global Bulk 0.0
|
||||
Global Wall 0.0
|
||||
Limiting Potential 0.0
|
||||
Roughness Correlation 0.0
|
||||
|
||||
[MIXING]
|
||||
;Tank Model
|
||||
|
||||
[TIMES]
|
||||
Duration 55:00
|
||||
Hydraulic Timestep 1:00
|
||||
Quality Timestep 0:05
|
||||
Pattern Timestep 1:00
|
||||
Pattern Start 0:00
|
||||
Report Timestep 1:00
|
||||
Report Start 0:00
|
||||
Start ClockTime 8 am
|
||||
Statistic None
|
||||
|
||||
[REPORT]
|
||||
Status No
|
||||
Summary No
|
||||
Page 0
|
||||
|
||||
[OPTIONS]
|
||||
Units GPM
|
||||
Headloss H-W
|
||||
Specific Gravity 1.0
|
||||
Viscosity 1.0
|
||||
Trials 40
|
||||
Accuracy 0.001
|
||||
CHECKFREQ 2
|
||||
MAXCHECK 10
|
||||
DAMPLIMIT 0
|
||||
Unbalanced Continue 10
|
||||
Pattern 1
|
||||
Demand Multiplier 1.0
|
||||
Emitter Exponent 0.5
|
||||
Quality Fluoride mg/L
|
||||
Diffusivity 1.0
|
||||
Tolerance 0.01
|
||||
|
||||
[COORDINATES]
|
||||
;Node X-Coord Y-Coord
|
||||
1 21.00 4.00
|
||||
2 19.00 20.00
|
||||
3 11.00 21.00
|
||||
4 14.00 28.00
|
||||
5 19.00 25.00
|
||||
6 28.00 23.00
|
||||
7 36.00 39.00
|
||||
8 38.00 30.00
|
||||
9 36.00 42.00
|
||||
10 37.00 23.00
|
||||
11 37.00 49.00
|
||||
12 39.00 60.00
|
||||
13 38.00 64.00
|
||||
14 38.00 66.00
|
||||
15 37.00 69.00
|
||||
16 27.00 65.00
|
||||
17 27.00 69.00
|
||||
18 23.00 68.00
|
||||
19 21.00 59.00
|
||||
20 45.00 68.00
|
||||
21 51.00 62.00
|
||||
22 54.00 69.00
|
||||
23 35.00 74.00
|
||||
24 37.00 71.00
|
||||
25 35.00 76.00
|
||||
27 39.00 87.00
|
||||
28 49.00 85.00
|
||||
29 42.00 86.00
|
||||
30 47.00 80.00
|
||||
31 37.00 80.00
|
||||
32 23.00 64.00
|
||||
33 56.00 73.00
|
||||
34 56.00 77.00
|
||||
35 43.00 81.00
|
||||
36 53.00 87.00
|
||||
26 33.00 76.00
|
||||
|
||||
[VERTICES]
|
||||
;Link X-Coord Y-Coord
|
||||
|
||||
[LABELS]
|
||||
;X-Coord Y-Coord Label & Anchor Node
|
||||
24.00 7.00 "Pump"
|
||||
24.00 4.00 "Station"
|
||||
26.76 77.42 "Tank"
|
||||
|
||||
[BACKDROP]
|
||||
DIMENSIONS 8.75 -0.15 58.25 91.15
|
||||
UNITS None
|
||||
FILE
|
||||
OFFSET 0.00 0.00
|
||||
|
||||
[END]
|
||||
481
example-networks/Net3.inp
Executable file
481
example-networks/Net3.inp
Executable file
@@ -0,0 +1,481 @@
|
||||
[TITLE]
|
||||
EPANET Example Network 3
|
||||
Example showing how the percent of Lake water in a dual-source
|
||||
system changes over time.
|
||||
|
||||
[JUNCTIONS]
|
||||
;ID Elev Demand Pattern
|
||||
10 147 0 ;
|
||||
15 32 1 3 ;
|
||||
20 129 0 ;
|
||||
35 12.5 1 4 ;
|
||||
40 131.9 0 ;
|
||||
50 116.5 0 ;
|
||||
60 0 0 ;
|
||||
601 0 0 ;
|
||||
61 0 0 ;
|
||||
101 42 189.95 ;
|
||||
103 43 133.2 ;
|
||||
105 28.5 135.37 ;
|
||||
107 22 54.64 ;
|
||||
109 20.3 231.4 ;
|
||||
111 10 141.94 ;
|
||||
113 2 20.01 ;
|
||||
115 14 52.1 ;
|
||||
117 13.6 117.71 ;
|
||||
119 2 176.13 ;
|
||||
120 0 0 ;
|
||||
121 -2 41.63 ;
|
||||
123 11 1 2 ;
|
||||
125 11 45.6 ;
|
||||
127 56 17.66 ;
|
||||
129 51 0 ;
|
||||
131 6 42.75 ;
|
||||
139 31 5.89 ;
|
||||
141 4 9.85 ;
|
||||
143 -4.5 6.2 ;
|
||||
145 1 27.63 ;
|
||||
147 18.5 8.55 ;
|
||||
149 16 27.07 ;
|
||||
151 33.5 144.48 ;
|
||||
153 66.2 44.17 ;
|
||||
157 13.1 51.79 ;
|
||||
159 6 41.32 ;
|
||||
161 4 15.8 ;
|
||||
163 5 9.42 ;
|
||||
164 5 0 ;
|
||||
166 -2 2.6 ;
|
||||
167 -5 14.56 ;
|
||||
169 -5 0 ;
|
||||
171 -4 39.34 ;
|
||||
173 -4 0 ;
|
||||
177 8 58.17 ;
|
||||
179 8 0 ;
|
||||
181 8 0 ;
|
||||
183 11 0 ;
|
||||
184 16 0 ;
|
||||
185 16 25.65 ;
|
||||
187 12.5 0 ;
|
||||
189 4 107.92 ;
|
||||
191 25 81.9 ;
|
||||
193 18 71.31 ;
|
||||
195 15.5 0 ;
|
||||
197 23 17.04 ;
|
||||
199 -2 119.32 ;
|
||||
201 0.1 44.61 ;
|
||||
203 2 1 5 ;
|
||||
204 21 0 ;
|
||||
205 21 65.36 ;
|
||||
206 1 0 ;
|
||||
207 9 69.39 ;
|
||||
208 16 0 ;
|
||||
209 -2 0.87 ;
|
||||
211 7 8.67 ;
|
||||
213 7 13.94 ;
|
||||
215 7 92.19 ;
|
||||
217 6 24.22 ;
|
||||
219 4 41.32 ;
|
||||
225 8 22.8 ;
|
||||
229 10.5 64.18 ;
|
||||
231 5 16.48 ;
|
||||
237 14 15.61 ;
|
||||
239 13 44.61 ;
|
||||
241 13 0 ;
|
||||
243 14 4.34 ;
|
||||
247 18 70.38 ;
|
||||
249 18 0 ;
|
||||
251 30 24.16 ;
|
||||
253 36 54.52 ;
|
||||
255 27 40.39 ;
|
||||
257 17 0 ;
|
||||
259 25 0 ;
|
||||
261 0 0 ;
|
||||
263 0 0 ;
|
||||
265 0 0 ;
|
||||
267 21 0 ;
|
||||
269 0 0 ;
|
||||
271 6 0 ;
|
||||
273 8 0 ;
|
||||
275 10 0 ;
|
||||
|
||||
[RESERVOIRS]
|
||||
;ID Head Pattern
|
||||
River 220.0 ;
|
||||
Lake 167.0 ;
|
||||
|
||||
[TANKS]
|
||||
;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
|
||||
1 131.9 13.1 .1 32.1 85 0 ;
|
||||
2 116.5 23.5 6.5 40.3 50 0 ;
|
||||
3 129.0 29.0 4.0 35.5 164 0 ;
|
||||
|
||||
[PIPES]
|
||||
;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
|
||||
20 3 20 99 99 199 0 Open ;
|
||||
40 1 40 99 99 199 0 Open ;
|
||||
50 2 50 99 99 199 0 Open ;
|
||||
60 River 60 1231 24 140 0 Open ;
|
||||
101 10 101 14200 18 110 0 Open ;
|
||||
103 101 103 1350 16 130 0 Open ;
|
||||
105 101 105 2540 12 130 0 Open ;
|
||||
107 105 107 1470 12 130 0 Open ;
|
||||
109 103 109 3940 16 130 0 Open ;
|
||||
111 109 111 2000 12 130 0 Open ;
|
||||
112 115 111 1160 12 130 0 Open ;
|
||||
113 111 113 1680 12 130 0 Open ;
|
||||
114 115 113 2000 8 130 0 Open ;
|
||||
115 107 115 1950 8 130 0 Open ;
|
||||
116 113 193 1660 12 130 0 Open ;
|
||||
117 263 105 2725 12 130 0 Open ;
|
||||
119 115 117 2180 12 130 0 Open ;
|
||||
120 119 120 730 12 130 0 Open ;
|
||||
121 120 117 1870 12 130 0 Open ;
|
||||
122 121 120 2050 8 130 0 Open ;
|
||||
123 121 119 2000 30 141 0 Open ;
|
||||
125 123 121 1500 30 141 0 Open ;
|
||||
129 121 125 930 24 130 0 Open ;
|
||||
131 125 127 3240 24 130 0 Open ;
|
||||
133 20 127 785 20 130 0 Open ;
|
||||
135 127 129 900 24 130 0 Open ;
|
||||
137 129 131 6480 16 130 0 Open ;
|
||||
145 129 139 2750 8 130 0 Open ;
|
||||
147 139 141 2050 8 130 0 Open ;
|
||||
149 143 141 1400 8 130 0 Open ;
|
||||
151 15 143 1650 8 130 0 Open ;
|
||||
153 145 141 3510 12 130 0 Open ;
|
||||
155 147 145 2200 12 130 0 Open ;
|
||||
159 147 149 880 12 130 0 Open ;
|
||||
161 149 151 1020 8 130 0 Open ;
|
||||
163 151 153 1170 12 130 0 Open ;
|
||||
169 125 153 4560 8 130 0 Open ;
|
||||
171 119 151 3460 12 130 0 Open ;
|
||||
173 119 157 2080 30 141 0 Open ;
|
||||
175 157 159 2910 30 141 0 Open ;
|
||||
177 159 161 2000 30 141 0 Open ;
|
||||
179 161 163 430 30 141 0 Open ;
|
||||
180 163 164 150 14 130 0 Open ;
|
||||
181 164 166 490 14 130 0 Open ;
|
||||
183 265 169 590 30 141 0 Open ;
|
||||
185 167 169 60 8 130 0 Open ;
|
||||
186 187 204 99.9 8 130 0 Open ;
|
||||
187 169 171 1270 30 141 0 Open ;
|
||||
189 171 173 50 30 141 0 Open ;
|
||||
191 271 171 760 24 130 0 Open ;
|
||||
193 35 181 30 24 130 0 Open ;
|
||||
195 181 177 30 12 130 0 Open ;
|
||||
197 177 179 30 12 130 0 Open ;
|
||||
199 179 183 210 12 130 0 Open ;
|
||||
201 40 179 1190 12 130 0 Open ;
|
||||
202 185 184 99.9 8 130 0 Open ;
|
||||
203 183 185 510 8 130 0 Open ;
|
||||
204 184 205 4530. 12 130 0 Open ;
|
||||
205 204 185 1325. 12 130 0 Open ;
|
||||
207 189 183 1350 12 130 0 Open ;
|
||||
209 189 187 500 8 130 0 Open ;
|
||||
211 169 269 646 12 130 0 Open ;
|
||||
213 191 187 2560 12 130 0 Open ;
|
||||
215 267 189 1230 12 130 0 Open ;
|
||||
217 191 193 520 12 130 0 Open ;
|
||||
219 193 195 360 12 130 0 Open ;
|
||||
221 161 195 2300 8 130 0 Open ;
|
||||
223 197 191 1150 12 130 0 Open ;
|
||||
225 111 197 2790 12 130 0 Open ;
|
||||
229 173 199 4000 24 141 0 Open ;
|
||||
231 199 201 630 24 141 0 Open ;
|
||||
233 201 203 120 24 130 0 Open ;
|
||||
235 199 273 725 12 130 0 Open ;
|
||||
237 205 207 1200 12 130 0 Open ;
|
||||
238 207 206 450 12 130 0 Open ;
|
||||
239 275 207 1430 12 130 0 Open ;
|
||||
240 206 208 510 12 130 0 Open ;
|
||||
241 208 209 885 12 130 0 Open ;
|
||||
243 209 211 1210 16 130 0 Open ;
|
||||
245 211 213 990 16 130 0 Open ;
|
||||
247 213 215 4285 16 130 0 Open ;
|
||||
249 215 217 1660 16 130 0 Open ;
|
||||
251 217 219 2050 14 130 0 Open ;
|
||||
257 217 225 1560 12 130 0 Open ;
|
||||
261 213 229 2200 8 130 0 Open ;
|
||||
263 229 231 1960 12 130 0 Open ;
|
||||
269 211 237 2080 12 130 0 Open ;
|
||||
271 237 229 790 8 130 0 Open ;
|
||||
273 237 239 510 12 130 0 Open ;
|
||||
275 239 241 35 12 130 0 Open ;
|
||||
277 241 243 2200 12 130 0 Open ;
|
||||
281 241 247 445 10 130 0 Open ;
|
||||
283 239 249 430 12 130 0 Open ;
|
||||
285 247 249 10 12 130 0 Open ;
|
||||
287 247 255 1390 10 130 0 Open ;
|
||||
289 50 255 925 10 130 0 Open ;
|
||||
291 255 253 1100 10 130 0 Open ;
|
||||
293 255 251 1100 8 130 0 Open ;
|
||||
295 249 251 1450 12 130 0 Open ;
|
||||
297 120 257 645 8 130 0 Open ;
|
||||
299 257 259 350 8 130 0 Open ;
|
||||
301 259 263 1400 8 130 0 Open ;
|
||||
303 257 261 1400 8 130 0 Open ;
|
||||
305 117 261 645 12 130 0 Open ;
|
||||
307 261 263 350 12 130 0 Open ;
|
||||
309 265 267 1580 8 130 0 Open ;
|
||||
311 193 267 1170 12 130 0 Open ;
|
||||
313 269 189 646 12 130 0 Open ;
|
||||
315 181 271 260 24 130 0 Open ;
|
||||
317 273 275 2230 8 130 0 Open ;
|
||||
319 273 205 645 12 130 0 Open ;
|
||||
321 163 265 1200 30 141 0 Open ;
|
||||
323 201 275 300 12 130 0 Open ;
|
||||
325 269 271 1290 8 130 0 Open ;
|
||||
329 61 123 45500 30 140 0 Open ;
|
||||
330 60 601 1 30 140 0 Closed ;
|
||||
333 601 61 1 30 140 0 Open ;
|
||||
|
||||
[PUMPS]
|
||||
;ID Node1 Node2 Parameters
|
||||
10 Lake 10 HEAD 1 ;
|
||||
335 60 61 HEAD 2 ;
|
||||
|
||||
[VALVES]
|
||||
;ID Node1 Node2 Diameter Type Setting MinorLoss
|
||||
|
||||
[TAGS]
|
||||
|
||||
[DEMANDS]
|
||||
;Junction Demand Pattern Category
|
||||
|
||||
[STATUS]
|
||||
;ID Status/Setting
|
||||
10 Closed
|
||||
|
||||
[PATTERNS]
|
||||
;ID Multipliers
|
||||
;General Default Demand Pattern
|
||||
1 1.34 1.94 1.46 1.44 .76 .92
|
||||
1 .85 1.07 .96 1.1 1.08 1.19
|
||||
1 1.16 1.08 .96 .83 .79 .74
|
||||
1 .64 .64 .85 .96 1.24 1.67
|
||||
;Demand Pattern for Node 123
|
||||
2 0 0 0 0 0 1219
|
||||
2 0 0 0 1866 1836 1818
|
||||
2 1818 1822 1822 1817 1824 1816
|
||||
2 1833 1817 1830 1814 1840 1859
|
||||
;Demand Pattern for Node 15
|
||||
3 620 620 620 620 620 360
|
||||
3 360 0 0 0 0 360
|
||||
3 360 360 360 360 0 0
|
||||
3 0 0 0 0 360 360
|
||||
;Demand Pattern for Node 35
|
||||
4 1637 1706 1719 1719 1791 1819
|
||||
4 1777 1842 1815 1825 1856 1801
|
||||
4 1819 1733 1664 1620 1613 1620
|
||||
4 1616 1647 1627 1627 1671 1668
|
||||
;Demand Pattern for Node 203
|
||||
5 4439 4531 4511 4582 4531 4582
|
||||
5 4572 4613 4643 4643 4592 4613
|
||||
5 4531 4521 4449 4439 4449 4460
|
||||
5 4439 4419 4368 4399 4470 4480
|
||||
|
||||
[CURVES]
|
||||
;ID X-Value Y-Value
|
||||
;PUMP: Pump Curve for Pump 10 (Lake Source)
|
||||
1 0 104.
|
||||
1 2000. 92.
|
||||
1 4000. 63.
|
||||
;PUMP: Pump Curve for Pump 335 (River Source)
|
||||
2 0 200.
|
||||
2 8000. 138.
|
||||
2 14000. 86.
|
||||
|
||||
[CONTROLS]
|
||||
;Lake source operates only part of the day
|
||||
Link 10 OPEN AT TIME 1
|
||||
Link 10 CLOSED AT TIME 15
|
||||
|
||||
;Pump 335 controlled by level in Tank 1
|
||||
;When pump is closed, bypass pipe is opened
|
||||
Link 335 OPEN IF Node 1 BELOW 17.1
|
||||
Link 335 CLOSED IF Node 1 ABOVE 19.1
|
||||
Link 330 CLOSED IF Node 1 BELOW 17.1
|
||||
Link 330 OPEN IF Node 1 ABOVE 19.1
|
||||
|
||||
|
||||
[RULES]
|
||||
|
||||
[ENERGY]
|
||||
Global Efficiency 75
|
||||
Global Price 0.0
|
||||
Demand Charge 0.0
|
||||
|
||||
[EMITTERS]
|
||||
;Junction Coefficient
|
||||
|
||||
[QUALITY]
|
||||
;Node InitQual
|
||||
|
||||
[SOURCES]
|
||||
;Node Type Quality Pattern
|
||||
|
||||
[REACTIONS]
|
||||
;Type Pipe/Tank Coefficient
|
||||
|
||||
|
||||
[REACTIONS]
|
||||
Order Bulk 1
|
||||
Order Tank 1
|
||||
Order Wall 1
|
||||
Global Bulk 0.0
|
||||
Global Wall 0.0
|
||||
Limiting Potential 0.0
|
||||
Roughness Correlation 0.0
|
||||
|
||||
[MIXING]
|
||||
;Tank Model
|
||||
|
||||
[TIMES]
|
||||
Duration 24:00
|
||||
Hydraulic Timestep 1:00
|
||||
Quality Timestep 0:05
|
||||
Pattern Timestep 1:00
|
||||
Pattern Start 0:00
|
||||
Report Timestep 1:00
|
||||
Report Start 0:00
|
||||
Start ClockTime 12 am
|
||||
Statistic None
|
||||
|
||||
[REPORT]
|
||||
Status Yes
|
||||
Summary No
|
||||
Page 0
|
||||
|
||||
[OPTIONS]
|
||||
Units GPM
|
||||
Headloss H-W
|
||||
Specific Gravity 1.0
|
||||
Viscosity 1.0
|
||||
Trials 40
|
||||
Accuracy 0.001
|
||||
CHECKFREQ 2
|
||||
MAXCHECK 10
|
||||
DAMPLIMIT 0
|
||||
Unbalanced Continue 10
|
||||
Pattern 1
|
||||
Demand Multiplier 1.0
|
||||
Emitter Exponent 0.5
|
||||
Quality Trace Lake
|
||||
Diffusivity 1.0
|
||||
Tolerance 0.01
|
||||
|
||||
[COORDINATES]
|
||||
;Node X-Coord Y-Coord
|
||||
10 9.00 27.85
|
||||
15 38.68 23.76
|
||||
20 29.44 26.91
|
||||
35 25.46 10.52
|
||||
40 27.02 9.81
|
||||
50 33.01 3.01
|
||||
60 23.90 29.94
|
||||
601 23.00 29.49
|
||||
61 23.71 29.03
|
||||
101 13.81 22.94
|
||||
103 12.96 21.31
|
||||
105 16.97 21.28
|
||||
107 18.45 20.46
|
||||
109 17.64 18.92
|
||||
111 20.21 17.53
|
||||
113 22.04 16.61
|
||||
115 20.98 19.18
|
||||
117 21.69 21.28
|
||||
119 23.70 22.76
|
||||
120 22.08 23.10
|
||||
121 23.54 25.50
|
||||
123 23.37 27.31
|
||||
125 24.59 25.64
|
||||
127 29.29 26.40
|
||||
129 30.32 26.39
|
||||
131 37.89 29.55
|
||||
139 33.28 24.54
|
||||
141 35.68 23.08
|
||||
143 37.47 21.97
|
||||
145 33.02 19.29
|
||||
147 30.24 20.38
|
||||
149 29.62 20.74
|
||||
151 28.29 21.39
|
||||
153 28.13 22.63
|
||||
157 24.85 20.16
|
||||
159 23.12 17.50
|
||||
161 25.10 15.28
|
||||
163 25.39 14.98
|
||||
164 25.98 15.14
|
||||
166 26.48 15.13
|
||||
167 25.88 12.98
|
||||
169 25.68 12.74
|
||||
171 26.65 11.80
|
||||
173 26.87 11.59
|
||||
177 25.92 10.59
|
||||
179 25.71 10.40
|
||||
181 25.72 10.74
|
||||
183 25.45 10.18
|
||||
184 25.15 9.52
|
||||
185 25.01 9.67
|
||||
187 23.64 11.04
|
||||
189 24.15 11.37
|
||||
191 22.10 14.07
|
||||
193 22.88 14.35
|
||||
195 23.18 14.72
|
||||
197 20.97 15.18
|
||||
199 29.42 8.44
|
||||
201 30.89 8.57
|
||||
203 31.14 8.89
|
||||
204 23.80 10.90
|
||||
205 29.20 6.46
|
||||
206 31.66 6.64
|
||||
207 31.00 6.61
|
||||
208 32.54 6.81
|
||||
209 33.76 6.59
|
||||
211 34.20 5.54
|
||||
213 35.26 6.16
|
||||
215 39.95 8.73
|
||||
217 42.11 8.67
|
||||
219 44.86 9.32
|
||||
225 43.53 7.38
|
||||
229 36.16 3.49
|
||||
231 38.38 2.54
|
||||
237 35.37 3.08
|
||||
239 35.76 2.31
|
||||
241 35.87 2.11
|
||||
243 37.04 0.00
|
||||
247 35.02 2.05
|
||||
249 35.02 1.81
|
||||
251 34.15 1.10
|
||||
253 32.17 1.88
|
||||
255 33.51 2.45
|
||||
257 21.17 23.32
|
||||
259 20.80 23.40
|
||||
261 20.79 21.45
|
||||
263 20.32 21.57
|
||||
265 25.39 13.60
|
||||
267 23.38 12.95
|
||||
269 25.03 12.14
|
||||
271 25.97 11.00
|
||||
273 29.16 7.38
|
||||
275 31.07 8.29
|
||||
River 24.15 31.06
|
||||
Lake 8.00 27.53
|
||||
1 27.46 9.84
|
||||
2 32.99 3.45
|
||||
3 29.41 27.27
|
||||
|
||||
[VERTICES]
|
||||
;Link X-Coord Y-Coord
|
||||
|
||||
[LABELS]
|
||||
;X-Coord Y-Coord Label & Anchor Node
|
||||
8.00 29.42 "LAKE"
|
||||
25.00 31.10 "RIVER"
|
||||
|
||||
[BACKDROP]
|
||||
DIMENSIONS 6.16 -1.55 46.70 32.61
|
||||
UNITS None
|
||||
FILE
|
||||
OFFSET 0.00 0.00
|
||||
|
||||
[END]
|
||||
@@ -5,208 +5,378 @@ Attribute VB_Name = "Module1"
|
||||
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
||||
'(EPANET2.DLL)
|
||||
|
||||
'Last updated on 4/3/07
|
||||
'Last updated on 03/17/2019
|
||||
|
||||
' These are codes used by the DLL functions
|
||||
Global Const EN_ELEVATION = 0 ' Node parameters
|
||||
Global Const EN_BASEDEMAND = 1
|
||||
Global Const EN_PATTERN = 2
|
||||
Global Const EN_EMITTER = 3
|
||||
Global Const EN_INITQUAL = 4
|
||||
Global Const EN_SOURCEQUAL = 5
|
||||
Global Const EN_SOURCEPAT = 6
|
||||
Global Const EN_SOURCETYPE = 7
|
||||
Global Const EN_TANKLEVEL = 8
|
||||
Global Const EN_DEMAND = 9
|
||||
Global Const EN_HEAD = 10
|
||||
Global Const EN_PRESSURE = 11
|
||||
Global Const EN_QUALITY = 12
|
||||
Global Const EN_SOURCEMASS = 13
|
||||
Global Const EN_INITVOLUME = 14
|
||||
Global Const EN_MIXMODEL = 15
|
||||
Global Const EN_MIXZONEVOL = 16
|
||||
Public Const EN_ELEVATION = 0 ' Node parameters
|
||||
Public Const EN_BASEDEMAND = 1
|
||||
Public Const EN_PATTERN = 2
|
||||
Public Const EN_EMITTER = 3
|
||||
Public Const EN_INITQUAL = 4
|
||||
Public Const EN_SOURCEQUAL = 5
|
||||
Public Const EN_SOURCEPAT = 6
|
||||
Public Const EN_SOURCETYPE = 7
|
||||
Public Const EN_TANKLEVEL = 8
|
||||
Public Const EN_DEMAND = 9
|
||||
Public Const EN_HEAD = 10
|
||||
Public Const EN_PRESSURE = 11
|
||||
Public Const EN_QUALITY = 12
|
||||
Public Const EN_SOURCEMASS = 13
|
||||
Public Const EN_INITVOLUME = 14
|
||||
Public Const EN_MIXMODEL = 15
|
||||
Public Const EN_MIXZONEVOL = 16
|
||||
|
||||
Global Const EN_TANKDIAM = 17
|
||||
Global Const EN_MINVOLUME = 18
|
||||
Global Const EN_VOLCURVE = 19
|
||||
Global Const EN_MINLEVEL = 20
|
||||
Global Const EN_MAXLEVEL = 21
|
||||
Global Const EN_MIXFRACTION = 22
|
||||
Global Const EN_TANK_KBULK = 23
|
||||
Public Const EN_TANKDIAM = 17
|
||||
Public Const EN_MINVOLUME = 18
|
||||
Public Const EN_VOLCURVE = 19
|
||||
Public Const EN_MINLEVEL = 20
|
||||
Public Const EN_MAXLEVEL = 21
|
||||
Public Const EN_MIXFRACTION = 22
|
||||
Public Const EN_TANK_KBULK = 23
|
||||
Public Const EN_TANKVOLUME = 24
|
||||
Public Const EN_MAXVOLUME = 25
|
||||
|
||||
Global Const EN_TANKVOLUME = 24 'ES
|
||||
Public Const EN_DIAMETER = 0 ' Link parameters
|
||||
Public Const EN_LENGTH = 1
|
||||
Public Const EN_ROUGHNESS = 2
|
||||
Public Const EN_MINORLOSS = 3
|
||||
Public Const EN_INITSTATUS = 4
|
||||
Public Const EN_INITSETTING = 5
|
||||
Public Const EN_KBULK = 6
|
||||
Public Const EN_KWALL = 7
|
||||
Public Const EN_FLOW = 8
|
||||
Public Const EN_VELOCITY = 9
|
||||
Public Const EN_HEADLOSS = 10
|
||||
Public Const EN_STATUS = 11
|
||||
Public Const EN_SETTING = 12
|
||||
Public Const EN_ENERGY = 13
|
||||
Public Const EN_LINKQUAL = 14
|
||||
Public Const EN_LINKPATTERN = 15
|
||||
|
||||
Global Const EN_DIAMETER = 0 ' Link parameters
|
||||
Global Const EN_LENGTH = 1
|
||||
Global Const EN_ROUGHNESS = 2
|
||||
Global Const EN_MINORLOSS = 3
|
||||
Global Const EN_INITSTATUS = 4
|
||||
Global Const EN_INITSETTING = 5
|
||||
Global Const EN_KBULK = 6
|
||||
Global Const EN_KWALL = 7
|
||||
Global Const EN_FLOW = 8
|
||||
Global Const EN_VELOCITY = 9
|
||||
Global Const EN_HEADLOSS = 10
|
||||
Global Const EN_STATUS = 11
|
||||
Global Const EN_SETTING = 12
|
||||
Global Const EN_ENERGY = 13
|
||||
Global Const EN_LINKQUAL = 14 'ES
|
||||
Public Const EN_PUMP_STATE = 16
|
||||
Public Const EN_PUMP_EFFIC = 17
|
||||
Public Const EN_PUMP_POWER = 18
|
||||
Public Const EN_PUMP_HCURVE = 19
|
||||
Public Const EN_PUMP_ECURVE = 20
|
||||
Public Const EN_PUMP_ECOST = 21
|
||||
Public Const EN_PUMP_EPAT = 22
|
||||
|
||||
Global Const EN_DURATION = 0 ' Time parameters
|
||||
Global Const EN_HYDSTEP = 1
|
||||
Global Const EN_QUALSTEP = 2
|
||||
Global Const EN_PATTERNSTEP = 3
|
||||
Global Const EN_PATTERNSTART = 4
|
||||
Global Const EN_REPORTSTEP = 5
|
||||
Global Const EN_REPORTSTART = 6
|
||||
Global Const EN_RULESTEP = 7
|
||||
Global Const EN_STATISTIC = 8
|
||||
Global Const EN_PERIODS = 9
|
||||
Global Const EN_STARTTIME = 10 'ES
|
||||
Public Const EN_DURATION = 0 ' Time parameters
|
||||
Public Const EN_HYDSTEP = 1
|
||||
Public Const EN_QUALSTEP = 2
|
||||
Public Const EN_PATTERNSTEP = 3
|
||||
Public Const EN_PATTERNSTART = 4
|
||||
Public Const EN_REPORTSTEP = 5
|
||||
Public Const EN_REPORTSTART = 6
|
||||
Public Const EN_RULESTEP = 7
|
||||
Public Const EN_STATISTIC = 8
|
||||
Public Const EN_PERIODS = 9
|
||||
Public Const EN_STARTTIME = 10
|
||||
Public Const EN_HTIME = 11
|
||||
Public Const EN_QTIME = 12
|
||||
Public Const EN_HALTFLAG = 13
|
||||
Public Const EN_NEXTEVENT = 14
|
||||
|
||||
Global Const EN_NODECOUNT = 0 'Component counts
|
||||
Global Const EN_TANKCOUNT = 1
|
||||
Global Const EN_LINKCOUNT = 2
|
||||
Global Const EN_PATCOUNT = 3
|
||||
Global Const EN_CURVECOUNT = 4
|
||||
Global Const EN_CONTROLCOUNT = 5
|
||||
Public Const EN_ITERATIONS = 0 ' Run statistics
|
||||
Public Const EN_RELATIVEERROR = 1
|
||||
Public Const EN_MAXHEADERROR = 2
|
||||
Public Const EN_MAXFLOWCHANGE = 3
|
||||
Public Const EN_MASSBALANCE = 4
|
||||
|
||||
Global Const EN_JUNCTION = 0 ' Node types
|
||||
Global Const EN_RESERVOIR = 1
|
||||
Global Const EN_TANK = 2
|
||||
Public Const EN_NODE = 0 ' Component types
|
||||
Public Const EN_LINK = 1
|
||||
Public Const EN_TIMEPAT = 2
|
||||
Public Const EN_CURVE = 3
|
||||
Public Const EN_CONTROL = 4
|
||||
Public Const EN_RULE = 5
|
||||
|
||||
Global Const EN_CVPIPE = 0 ' Link types
|
||||
Global Const EN_PIPE = 1
|
||||
Global Const EN_PUMP = 2
|
||||
Global Const EN_PRV = 3
|
||||
Global Const EN_PSV = 4
|
||||
Global Const EN_PBV = 5
|
||||
Global Const EN_FCV = 6
|
||||
Global Const EN_TCV = 7
|
||||
Global Const EN_GPV = 8
|
||||
Public Const EN_NODECOUNT = 0 ' Component counts
|
||||
Public Const EN_TANKCOUNT = 1
|
||||
Public Const EN_LINKCOUNT = 2
|
||||
Public Const EN_PATCOUNT = 3
|
||||
Public Const EN_CURVECOUNT = 4
|
||||
Public Const EN_CONTROLCOUNT = 5
|
||||
Public Const EN_RULECOUNT = 6
|
||||
|
||||
Global Const EN_NONE = 0 ' Quality analysis types
|
||||
Global Const EN_CHEM = 1
|
||||
Global Const EN_AGE = 2
|
||||
Global Const EN_TRACE = 3
|
||||
Public Const EN_JUNCTION = 0 ' Node types
|
||||
Public Const EN_RESERVOIR = 1
|
||||
Public Const EN_TANK = 2
|
||||
|
||||
Global Const EN_CONCEN = 0 ' Source quality types
|
||||
Global Const EN_MASS = 1
|
||||
Global Const EN_SETPOINT = 2
|
||||
Global Const EN_FLOWPACED = 3
|
||||
Public Const EN_CVPIPE = 0 ' Link types
|
||||
Public Const EN_PIPE = 1
|
||||
Public Const EN_PUMP = 2
|
||||
Public Const EN_PRV = 3
|
||||
Public Const EN_PSV = 4
|
||||
Public Const EN_PBV = 5
|
||||
Public Const EN_FCV = 6
|
||||
Public Const EN_TCV = 7
|
||||
Public Const EN_GPV = 8
|
||||
|
||||
Global Const EN_CFS = 0 ' Flow units types
|
||||
Global Const EN_GPM = 1
|
||||
Global Const EN_MGD = 2
|
||||
Global Const EN_IMGD = 3
|
||||
Global Const EN_AFD = 4
|
||||
Global Const EN_LPS = 5
|
||||
Global Const EN_LPM = 6
|
||||
Global Const EN_MLD = 7
|
||||
Global Const EN_CMH = 8
|
||||
Global Const EN_CMD = 9
|
||||
Public Const EN_NONE = 0 ' Quality analysis types
|
||||
Public Const EN_CHEM = 1
|
||||
Public Const EN_AGE = 2
|
||||
Public Const EN_TRACE = 3
|
||||
|
||||
Global Const EN_TRIALS = 0 ' Misc. options
|
||||
Global Const EN_ACCURACY = 1
|
||||
Global Const EN_TOLERANCE = 2
|
||||
Global Const EN_EMITEXPON = 3
|
||||
Global Const EN_DEMANDMULT = 4
|
||||
Public Const EN_CONCEN = 0 ' Source quality types
|
||||
Public Const EN_MASS = 1
|
||||
Public Const EN_SETPOINT = 2
|
||||
Public Const EN_FLOWPACED = 3
|
||||
|
||||
Global Const EN_LOWLEVEL = 0 ' Control types
|
||||
Global Const EN_HILEVEL = 1
|
||||
Global Const EN_TIMER = 2
|
||||
Global Const EN_TIMEOFDAY = 3
|
||||
Public Const EN_HW = 0 ' Head loss formulas
|
||||
Public Const EN_DW = 1
|
||||
Public Const EN_CM = 2
|
||||
|
||||
Global Const EN_AVERAGE = 1 'Time statistic types
|
||||
Global Const EN_MINIMUM = 2
|
||||
Global Const EN_MAXIMUM = 3
|
||||
Global Const EN_RANGE = 4
|
||||
Public Const EN_CFS = 0 ' Flow units types
|
||||
Public Const EN_GPM = 1
|
||||
Public Const EN_MGD = 2
|
||||
Public Const EN_IMGD = 3
|
||||
Public Const EN_AFD = 4
|
||||
Public Const EN_LPS = 5
|
||||
Public Const EN_LPM = 6
|
||||
Public Const EN_MLD = 7
|
||||
Public Const EN_CMH = 8
|
||||
Public Const EN_CMD = 9
|
||||
|
||||
Global Const EN_MIX1 = 0 'Tank mixing models
|
||||
Global Const EN_MIX2 = 1
|
||||
Global Const EN_FIFO = 2
|
||||
Global Const EN_LIFO = 3
|
||||
Public Const EN_DDA = 0 ' Demand driven analysis
|
||||
Public Const EN_PDA = 1 ' Pressure driven analysis
|
||||
|
||||
Global Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
||||
Global Const EN_SAVE = 1
|
||||
Public Const EN_TRIALS = 0 ' Simulation options
|
||||
Public Const EN_ACCURACY = 1
|
||||
Public Const EN_TOLERANCE = 2
|
||||
Public Const EN_EMITEXPON = 3
|
||||
Public Const EN_DEMANDMULT = 4
|
||||
Public Const EN_HEADERROR = 5
|
||||
Public Const EN_FLOWCHANGE = 6
|
||||
Public Const EN_HEADLOSSFORM = 7
|
||||
Public Const EN_GLOBALEFFIC = 8
|
||||
Public Const EN_GLOBALPRICE = 9
|
||||
Public Const EN_GLOBALPATTERN = 10
|
||||
Public Const EN_DEMANDCHARGE = 11
|
||||
Public Const EN_SP_GRAVITY = 12
|
||||
Public Const EN_SP_VISCOS = 13
|
||||
Public Const EN_UNBALANCED = 14
|
||||
Public Const EN_CHECKFREQ = 15
|
||||
Public Const EN_MAXCHECK = 16
|
||||
Public Const EN_DAMPLIMIT = 17
|
||||
Public Const EN_SP_DIFFUS = 18
|
||||
Public Const EN_BULKORDER = 19
|
||||
Public Const EN_WALLORDER = 20
|
||||
Public Const EN_TANKORDER = 21
|
||||
Public Const EN_CONCENLIMIT = 22
|
||||
|
||||
Global Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
||||
Public Const EN_LOWLEVEL = 0 ' Control types
|
||||
Public Const EN_HILEVEL = 1
|
||||
Public Const EN_TIMER = 2
|
||||
Public Const EN_TIMEOFDAY = 3
|
||||
|
||||
Global Const EN_CONST_HP = 0 ' constant horsepower
|
||||
Global Const EN_POWER_FUNC = 1 ' power function
|
||||
Global Const EN_CUSTOM = 2 ' user-defined custom curve
|
||||
Public Const EN_AVERAGE = 1 ' Time statistic types
|
||||
Public Const EN_MINIMUM = 2
|
||||
Public Const EN_MAXIMUM = 3
|
||||
Public Const EN_RANGE = 4
|
||||
|
||||
Public Const EN_MIX1 = 0 ' Tank mixing models
|
||||
Public Const EN_MIX2 = 1
|
||||
Public Const EN_FIFO = 2
|
||||
Public Const EN_LIFO = 3
|
||||
|
||||
Public Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
||||
Public Const EN_SAVE = 1
|
||||
Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
||||
Public Const EN_SAVE_AND_INIT = 11
|
||||
|
||||
Public Const EN_CONST_HP = 0 ' Constant horsepower pump curve
|
||||
Public Const EN_POWER_FUNC = 1 ' Power function pump cuve
|
||||
Public Const EN_CUSTOM = 2 ' User-defined custom pump curve
|
||||
Public Const EN_NOCURVE = 3 ' No pump curve
|
||||
|
||||
Public Const EN_VOLUME_CURVE = 0 ' Volume curve
|
||||
Public Const EN_PUMP_CURVE = 1 ' Pump curve
|
||||
Public Const EN_EFFIC_CURVE = 2 ' Efficiency curve
|
||||
Public Const EN_HLOSS_CURVE = 3 ' Head loss curve
|
||||
Public Const EN_GENERIC_CURVE = 4 ' Generic curve
|
||||
|
||||
Public Const EN_UNCONDITIONAL = 0 ' Unconditional object deletion
|
||||
Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
||||
|
||||
Public Const EN_NO_REPORT = 0 ' No status report
|
||||
Public Const EN_NORMAL_REPORT = 1 ' Normal status report
|
||||
Public Const EN_FULL_REPORT = 2 ' Full status report
|
||||
|
||||
Public Const EN_R_NODE = 6 ' Rule objects
|
||||
Public Const EN_R_LINK = 7
|
||||
Public Const EN_R_SYSTEM = 8
|
||||
|
||||
Public Const EN_R_DEMAND = 0 ' Rule variables
|
||||
Public Const EN_R_HEAD = 1
|
||||
Public Const EN_R_GRADE = 2
|
||||
Public Const EN_R_LEVEL = 3
|
||||
Public Const EN_R_PRESSURE = 4
|
||||
Public Const EN_R_FLOW = 5
|
||||
Public Const EN_R_STATUS = 6
|
||||
Public Const EN_R_SETTING = 7
|
||||
Public Const EN_R_POWER = 8
|
||||
Public Const EN_R_TIME = 9
|
||||
Public Const EN_R_CLOCKTIME = 10
|
||||
Public Const EN_R_FILLTIME = 11
|
||||
Public Const EN_R_DRAINTIME = 12
|
||||
|
||||
Public Const EN_R_EQ = 0 ' Rule operators
|
||||
Public Const EN_R_NE = 1
|
||||
Public Const EN_R_LE = 2
|
||||
Public Const EN_R_GE = 3
|
||||
Public Const EN_R_LT = 4
|
||||
Public Const EN_R_GT = 5
|
||||
Public Const EN_R_IS = 6
|
||||
Public Const EN_R_NOT = 7
|
||||
Public Const EN_R_BELOW = 8
|
||||
Public Const EN_R_ABOVE = 9
|
||||
|
||||
Public Const EN_R_IS_OPEN = 1 ' Rule status types
|
||||
Public Const EN_R_IS_CLOSED = 2
|
||||
Public Const EN_R_IS_ACTIVE = 3
|
||||
|
||||
'These are the external functions that comprise the DLL
|
||||
|
||||
Declare Function ENepanet Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String, ByVal F4 As Any) As Long
|
||||
Declare Function ENopen Lib "epanet2.dll" (ByVal F1 As String, ByVal F2 As String, ByVal F3 As String) As Long
|
||||
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal F As String) As Long
|
||||
'Project Functions
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (value As Long) As Long
|
||||
Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Long
|
||||
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Long, ByVal headlossType As Long) As Long
|
||||
Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Long
|
||||
Declare Function ENgettitle Lib "epanet2.dll" (ByVal line1 As String, ByVal line2 As String, ByVal line3 As String) As Long
|
||||
Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Long
|
||||
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Long
|
||||
Declare Function ENclose Lib "epanet2.dll" () As Long
|
||||
|
||||
'Hydraulic Analysis Functions
|
||||
Declare Function ENsolveH Lib "epanet2.dll" () As Long
|
||||
Declare Function ENsaveH Lib "epanet2.dll" () As Long
|
||||
Declare Function ENopenH Lib "epanet2.dll" () As Long
|
||||
Declare Function ENinitH Lib "epanet2.dll" (ByVal SaveFlag As Long) As Long
|
||||
Declare Function ENrunH Lib "epanet2.dll" (T As Long) As Long
|
||||
Declare Function ENnextH Lib "epanet2.dll" (Tstep As Long) As Long
|
||||
Declare Function ENinitH Lib "epanet2.dll" (ByVal initFlag As Long) As Long
|
||||
Declare Function ENrunH Lib "epanet2.dll" (currentTime As Long) As Long
|
||||
Declare Function ENnextH Lib "epanet2.dll" (tStep As Long) As Long
|
||||
Declare Function ENcloseH Lib "epanet2.dll" () As Long
|
||||
Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal F As String) As Long
|
||||
Declare Function ENusehydfile Lib "epanet2.dll" (ByVal F As String) As Long
|
||||
Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal filename As String) As Long
|
||||
Declare Function ENusehydfile Lib "epanet2.dll" (ByVal filename As String) As Long
|
||||
|
||||
'Water Quality Analysis Functions
|
||||
Declare Function ENsolveQ Lib "epanet2.dll" () As Long
|
||||
Declare Function ENopenQ Lib "epanet2.dll" () As Long
|
||||
Declare Function ENinitQ Lib "epanet2.dll" (ByVal SaveFlag As Long) As Long
|
||||
Declare Function ENrunQ Lib "epanet2.dll" (T As Long) As Long
|
||||
Declare Function ENnextQ Lib "epanet2.dll" (Tstep As Long) As Long
|
||||
Declare Function ENstepQ Lib "epanet2.dll" (Tleft As Long) As Long
|
||||
Declare Function ENinitQ Lib "epanet2.dll" (ByVal saveFlag As Long) As Long
|
||||
Declare Function ENrunQ Lib "epanet2.dll" (currentTime As Long) As Long
|
||||
Declare Function ENnextQ Lib "epanet2.dll" (tStep As Long) As Long
|
||||
Declare Function ENstepQ Lib "epanet2.dll" (timeLeft As Long) As Long
|
||||
Declare Function ENcloseQ Lib "epanet2.dll" () As Long
|
||||
|
||||
Declare Function ENwriteline Lib "epanet2.dll" (ByVal S As String) As Long
|
||||
'Reporting Functions
|
||||
Declare Function ENwriteline Lib "epanet2.dll" (ByVal line As String) As Long
|
||||
Declare Function ENreport Lib "epanet2.dll" () As Long
|
||||
Declare Function ENcopyreport Lib "epanet2.dll" (ByVal filename As String) As Long
|
||||
Declare Function ENclearreport Lib "epanet2.dll" () As Long
|
||||
Declare Function ENresetreport Lib "epanet2.dll" () As Long
|
||||
Declare Function ENsetreport Lib "epanet2.dll" (ByVal S As String) As Long
|
||||
Declare Function ENsetreport Lib "epanet2.dll" (ByVal format As String) As Long
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level As Long) As Long
|
||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Long, count As Long) As Long
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal errcode As Long, ByVal errmsg As String, ByVal maxLen As Long) As Long
|
||||
Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Long, ByRef value As Single) As Long
|
||||
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, Ctype As Long, Lindex As Long, Setting As Single, Nindex As Long, Level As Single) As Long
|
||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal Code As Long, Value As Long) As Long
|
||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal Code As Long, Value As Single) As Long
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal Code As Long, Value As Long) As Long
|
||||
Declare Function ENgetflowunits Lib "epanet2.dll" (Code As Long) As Long
|
||||
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal ID As String, Index As Long) As Long
|
||||
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal Index As Long, ByVal ID As String) As Long
|
||||
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal Index As Long, L As Long) As Long
|
||||
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Period As Long, Value As Single) As Long
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (QualCode As Long, TraceNode As Long) As Long
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal ErrCode As Long, ByVal ErrMsg As String, ByVal N As Long)
|
||||
'Analysis Options Functions
|
||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option_ As Long, value As Single) As Long
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal option_ As Long, ByVal value As Single) As Long
|
||||
Declare Function ENgetflowunits Lib "epanet2.dll" (units As Long) As Long
|
||||
Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal units As Long) As Long
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal param As Long, value As Long) As Long
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal param As Long, ByVal value As Long) As Long
|
||||
Declare Function ENgetqualinfo Lib "epanet2.dll" (qualType As Long, ByVal chemName As String, ByVal chemUnits As String, traceNode As Long) As Long
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (qualType As Long, traceNode As Long) As Long
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal qualType As Long, ByVal chemName As String, ByVal chemUnits As String, ByVal traceNode As String) As Long
|
||||
|
||||
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal ID As String, Index As Long) As Long
|
||||
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal Index As Long, ByVal ID As String) As Long
|
||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Long, Code As Long) As Long
|
||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Code As Long, Value As Single) As Long
|
||||
'Node Functions
|
||||
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Long, index As Long) As Long
|
||||
Declare Function ENdeletenode Lib "epanet2.dll" (ByVal index As Long, ByVal actionCode As Long) As Long
|
||||
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
|
||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, nodeType As Long) As Long
|
||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, value As Single) As Long
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, ByVal value As Single) As Long
|
||||
Declare Function ENsetjuncdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal dmnd As Single, ByVal dmndpat As String) As Long
|
||||
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Long
|
||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, x As Double, y As Double) As Long
|
||||
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal x As Double, ByVal y As Double) As Long
|
||||
|
||||
'Nodal Demand Functions
|
||||
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Long, pmin As Single, preq As Single, pexp As Single) As Long
|
||||
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type_ As Long, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Long
|
||||
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Long, numDemands As Long) As Long
|
||||
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, value As Single) As Long
|
||||
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal BaseDemand As Single) As Long
|
||||
Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, patIndex As Long) As Long
|
||||
Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal patIndex As Long) As Long
|
||||
Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal demandName As String) As Long
|
||||
Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Long, ByVal demandIndex As Long, ByVal demandName As String) As Long
|
||||
|
||||
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal Index As Long, numDemands As Long) As Long 'ES
|
||||
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal Index As Long, ByVal DemandIndex As Long, Value As Single) As Long 'ES
|
||||
Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal Index As Long, ByVal DemandIndex As Long, PatIndex As Long) As Long 'ES
|
||||
'Link Functions
|
||||
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Long, ByVal fromNode As String, ByVal toNode As String, index As Long) As Long
|
||||
Declare Function ENdeletelink Lib "epanet2.dll" (ByVal index As Long, ByVal actionCode As Long) As Long
|
||||
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
|
||||
Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Long, linkType As Long) As Long
|
||||
Declare Function ENsetlinktype Lib "epanet2.dll" (index As Long, ByVal linkType As Long, ByVal actionCode As Long) As Long
|
||||
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal index As Long, node1 As Long, node2 As Long) As Long
|
||||
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Long, ByVal node1 As Long, ByVal node2 As Long) As Long
|
||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, value As Single) As Long
|
||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal property As Long, ByVal value As Single) As Long
|
||||
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Long, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Long
|
||||
|
||||
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal ID As String, Index As Long) As Long
|
||||
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal Index As Long, ByVal ID As String) As Long
|
||||
Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal Index As Long, Code As Long) As Long
|
||||
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal Index As Long, Node1 As Long, Node2 As Long) As Long
|
||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Code As Long, Value As Single) As Long
|
||||
'Pump Functions
|
||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Long, curveIndex As Long) As Long
|
||||
Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Long, ByVal curveIndex As Long) As Long
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal linkIndex As Long, pumpType As Long) As Long
|
||||
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal CurveIndex As Long, nValues As Long, xValues As Any, yValues As Any) As Long 'ES
|
||||
Declare Function ENgetheadcurve Lib "epanet2.dll" (ByVal Index As Long, ID As String) As Long 'ES
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal Index As Long, PumpType As Long) As Long 'ES
|
||||
'Time Pattern Functions
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Long
|
||||
Declare Function ENdeletepattern Lib "epanet2.dll" (ByVal index As Long) As Long
|
||||
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetpatternid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
|
||||
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Long, len_ As Long) As Long
|
||||
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal period As Long, value As Single) As Long
|
||||
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Long, ByVal period As Long, ByVal value As Single) As Long
|
||||
Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Long, value As Single) As Long
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Long, values As Any, ByVal len_ As Long) As Long
|
||||
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (Value As Long) As Long
|
||||
'Data Curve Functions
|
||||
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Long
|
||||
Declare Function ENdeletecurve Lib "epanet2.dll" (ByVal index As Long) As Long
|
||||
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal id As String, index As Long) As Long
|
||||
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetcurveid Lib "epanet2.dll" (ByVal index As Long, ByVal newid As String) As Long
|
||||
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Long, len_ As Long) As Long
|
||||
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal index As Long, type_ As Long) As Long
|
||||
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal pointIndex As Long, x As Single, y As Single) As Long
|
||||
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Long, ByVal pointIndex As Long, ByVal x As Single, ByVal y As Single) As Long
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal index As Long, ByVal id As String, nPoints As Long, xValues As Any, yValues As Any) As Long
|
||||
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Long, xValues As Any, yValues As Any, ByVal nPoints As Long) As Long
|
||||
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal Cindex As Long, ByVal Ctype As Long, ByVal Lindex As Long, ByVal Setting As Single, ByVal Nindex As Long, ByVal Level As Single) As Long
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Code As Long, ByVal Value As Single) As Long
|
||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Code As Long, ByVal Value As Single) As Long
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal ID As String) As Long
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal Index As Long, F As Any, ByVal N As Long) As Long
|
||||
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal Index As Long, ByVal Period As Long, ByVal Value As Single) As Long
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal Code As Long, ByVal Value As Long) As Long
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal Code As Long, ByVal Value As Single) As Long
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal Code As Long) As Long
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal QualCode As Long, ByVal ChemName As String, ByVal ChemUnits As String, ByVal TraceNode As String) As Long
|
||||
'Simple Control Functions
|
||||
Declare Function ENaddcontrol Lib "epanet2.dll" (ByVal type_ As Long, ByVal linkIndex As Long, ByVal setting As Single, ByVal nodeIndex As Long, ByVal level As Single, index As Long) As Long
|
||||
Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal index As Long) As Long
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal index As Long, type_ As Long, linkIndex As Long, setting As Single, nodeIndex As Long, level As Single) As Long
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal index As Long, ByVal type_ As Long, ByVal linkIndex As Long, ByVal setting As Single, ByVal nodeIndex As Long, ByVal level As Single) As Long
|
||||
|
||||
'Rule-Based Control Functions
|
||||
Declare Function ENaddrule Lib "epanet2.dll" (ByVal rule As String) As Long
|
||||
Declare Function ENdeleterule Lib "epanet2.dll" (ByVal index As Long) As Long
|
||||
Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Long, nPremises As Long, nThenActions As Long, nElseActions As Long, priority As Single) As Long
|
||||
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal index As Long, ByVal id As String) As Long
|
||||
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Long, ByVal priority As Single) As Long
|
||||
Declare Function ENgetpremise Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, logop As Long, object As Long, objIndex As Long, variable As Long, relop As Long, status As Long, value As Single) As Long
|
||||
Declare Function ENsetpremise Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal logop As Long, ByVal object As Long, ByVal objIndex As Long, ByVal variable As Long, ByVal relop As Long, ByVal status As Long, ByVal value As Single) As Long
|
||||
Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal objIndex As Long) As Long
|
||||
Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal status As Long) As Long
|
||||
Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal premiseIndex As Long, ByVal value As Single) As Long
|
||||
Declare Function ENgetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, linkIndex As Long, status As Long, setting As Single) As Long
|
||||
Declare Function ENsetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, ByVal linkIndex As Long, ByVal status As Long, ByVal setting As Single) As Long
|
||||
Declare Function ENgetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, linkIndex As Long, status As Long, setting As Single) As Long
|
||||
Declare Function ENsetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Long, ByVal actionIndex As Long, ByVal linkIndex As Long, ByVal status As Long, ByVal setting As Single) As Long
|
||||
|
||||
124
include/epanet2.def
Normal file
124
include/epanet2.def
Normal file
@@ -0,0 +1,124 @@
|
||||
LIBRARY EPANET2.DLL
|
||||
|
||||
EXPORTS
|
||||
ENaddcontrol = _ENaddcontrol@24
|
||||
ENaddcurve = _ENaddcurve@4
|
||||
ENaddlink = _ENaddlink@20
|
||||
ENaddnode = _ENaddnode@12
|
||||
ENaddpattern = _ENaddpattern@4
|
||||
ENaddrule = _ENaddrule@4
|
||||
ENclearreport = _ENclearreport@0
|
||||
ENclose = _ENclose@0
|
||||
ENcloseH = _ENcloseH@0
|
||||
ENcloseQ = _ENcloseQ@0
|
||||
ENcopyreport = _ENcopyreport@4
|
||||
ENdeletecontrol = _ENdeletecontrol@4
|
||||
ENdeletecurve = _ENdeletecurve@4
|
||||
ENdeletelink = _ENdeletelink@8
|
||||
ENdeletenode = _ENdeletenode@8
|
||||
ENdeletepattern = _ENdeletepattern@4
|
||||
ENdeleterule = _ENdeleterule@4
|
||||
ENepanet = _ENepanet@16
|
||||
ENgetaveragepatternvalue = _ENgetaveragepatternvalue@8
|
||||
ENgetbasedemand = _ENgetbasedemand@12
|
||||
ENgetcomment = _ENgetcomment@12
|
||||
ENgetcontrol = _ENgetcontrol@24
|
||||
ENgetcoord = _ENgetcoord@12
|
||||
ENgetcount = _ENgetcount@8
|
||||
ENgetcurve = _ENgetcurve@20
|
||||
ENgetcurveid = _ENgetcurveid@8
|
||||
ENgetcurveindex = _ENgetcurveindex@8
|
||||
ENgetcurvelen = _ENgetcurvelen@8
|
||||
ENgetcurvetype = _ENgetcurvetype@8
|
||||
ENgetcurvevalue = _ENgetcurvevalue@16
|
||||
ENgetdemandmodel = _ENgetdemandmodel@16
|
||||
ENgetdemandname = _ENgetdemandname@12
|
||||
ENgetdemandpattern = _ENgetdemandpattern@12
|
||||
ENgetelseaction = _ENgetelseaction@20
|
||||
ENgeterror = _ENgeterror@12
|
||||
ENgetflowunits = _ENgetflowunits@4
|
||||
ENgetheadcurveindex = _ENgetheadcurveindex@8
|
||||
ENgetlinkid = _ENgetlinkid@8
|
||||
ENgetlinkindex = _ENgetlinkindex@8
|
||||
ENgetlinknodes = _ENgetlinknodes@12
|
||||
ENsetlinknodes = _ENsetlinknodes@12
|
||||
ENgetlinktype = _ENgetlinktype@8
|
||||
ENgetlinkvalue = _ENgetlinkvalue@12
|
||||
ENgetnodeid = _ENgetnodeid@8
|
||||
ENgetnodeindex = _ENgetnodeindex@8
|
||||
ENgetnodetype = _ENgetnodetype@8
|
||||
ENgetnodevalue = _ENgetnodevalue@12
|
||||
ENgetnumdemands = _ENgetnumdemands@8
|
||||
ENgetoption = _ENgetoption@8
|
||||
ENgetpatternid = _ENgetpatternid@8
|
||||
ENgetpatternindex = _ENgetpatternindex@8
|
||||
ENgetpatternlen = _ENgetpatternlen@8
|
||||
ENgetpatternvalue = _ENgetpatternvalue@12
|
||||
ENgetpremise = _ENgetpremise@36
|
||||
ENgetpumptype = _ENgetpumptype@8
|
||||
ENgetqualinfo = _ENgetqualinfo@16
|
||||
ENgetqualtype = _ENgetqualtype@8
|
||||
ENgetrule = _ENgetrule@20
|
||||
ENgetruleID = _ENgetruleID@8
|
||||
ENgetstatistic = _ENgetstatistic@8
|
||||
ENgetthenaction = _ENgetthenaction@20
|
||||
ENgettimeparam = _ENgettimeparam@8
|
||||
ENgettitle = _ENgettitle@12
|
||||
ENgetversion = _ENgetversion@4
|
||||
ENinit = _ENinit@16
|
||||
ENinitH = _ENinitH@4
|
||||
ENinitQ = _ENinitQ@4
|
||||
ENnextH = _ENnextH@4
|
||||
ENnextQ = _ENnextQ@4
|
||||
ENopen = _ENopen@12
|
||||
ENopenH = _ENopenH@0
|
||||
ENopenQ = _ENopenQ@0
|
||||
ENreport = _ENreport@0
|
||||
ENresetreport = _ENresetreport@0
|
||||
ENrunH = _ENrunH@4
|
||||
ENrunQ = _ENrunQ@4
|
||||
ENsaveH = _ENsaveH@0
|
||||
ENsavehydfile = _ENsavehydfile@4
|
||||
ENsaveinpfile = _ENsaveinpfile@4
|
||||
ENsetbasedemand = _ENsetbasedemand@12
|
||||
ENsetcomment = _ENsetcomment@12
|
||||
ENsetcontrol = _ENsetcontrol@24
|
||||
ENsetcoord = _ENsetcoord@20
|
||||
ENsetcurve = _ENsetcurve@16
|
||||
ENsetcurveid = _ENsetcurveid@8
|
||||
ENsetcurvevalue = _ENsetcurvevalue@16
|
||||
ENsetdemandmodel = _ENsetdemandmodel@16
|
||||
ENsetdemandname = _ENsetdemandname@12
|
||||
ENsetdemandpattern = _ENsetdemandpattern@12
|
||||
ENsetelseaction = _ENsetelseaction@20
|
||||
ENsetflowunits = _ENsetflowunits@4
|
||||
ENsetheadcurveindex = _ENsetheadcurveindex@8
|
||||
ENsetjuncdata = _ENsetjuncdata@16
|
||||
ENsetlinkid = _ENsetlinkid@8
|
||||
ENsetlinknodes = _ENsetlinknodes@12
|
||||
ENsetlinktype = _ENsetlinktype@12
|
||||
ENsetlinkvalue = _ENsetlinkvalue@12
|
||||
ENsetnodeid = _ENsetnodeid@8
|
||||
ENsetnodevalue = _ENsetnodevalue@12
|
||||
ENsetoption = _ENsetoption@8
|
||||
ENsetpattern = _ENsetpattern@12
|
||||
ENsetpatternid = _ENsetpatternid@8
|
||||
ENsetpatternvalue = _ENsetpatternvalue@12
|
||||
ENsetpipedata = _ENsetpipedata@20
|
||||
ENsetpremise = _ENsetpremise@36
|
||||
ENsetpremiseindex = _ENsetpremiseindex@12
|
||||
ENsetpremisestatus = _ENsetpremisestatus@12
|
||||
ENsetpremisevalue = _ENsetpremisevalue@12
|
||||
ENsetqualtype = _ENsetqualtype@16
|
||||
ENsetreport = _ENsetreport@4
|
||||
ENsetrulepriority = _ENsetrulepriority@8
|
||||
ENsetstatusreport = _ENsetstatusreport@4
|
||||
ENsettankdata = _ENsettankdata@32
|
||||
ENsetthenaction = _ENsetthenaction@20
|
||||
ENsettimeparam = _ENsettimeparam@8
|
||||
ENsettitle = _ENsettitle@12
|
||||
ENsolveH = _ENsolveH@0
|
||||
ENsolveQ = _ENsolveQ@0
|
||||
ENstepQ = _ENstepQ@4
|
||||
ENusehydfile = _ENusehydfile@4
|
||||
ENwriteline = _ENwriteline@4
|
||||
668
include/epanet2.h
Executable file → Normal file
668
include/epanet2.h
Executable file → Normal file
@@ -1,251 +1,417 @@
|
||||
/*
|
||||
** EPANET2.H
|
||||
**
|
||||
** C/C++ header file for EPANET Programmers Toolkit
|
||||
**
|
||||
** Last updated on 2/14/08 (2.00.12)
|
||||
*/
|
||||
|
||||
#ifndef EPANET2_H
|
||||
#define EPANET2_H
|
||||
|
||||
// --- Define the EPANET toolkit constants
|
||||
|
||||
#define EN_ELEVATION 0 /* Node parameters */
|
||||
#define EN_BASEDEMAND 1
|
||||
#define EN_PATTERN 2
|
||||
#define EN_EMITTER 3
|
||||
#define EN_INITQUAL 4
|
||||
#define EN_SOURCEQUAL 5
|
||||
#define EN_SOURCEPAT 6
|
||||
#define EN_SOURCETYPE 7
|
||||
#define EN_TANKLEVEL 8
|
||||
#define EN_DEMAND 9
|
||||
#define EN_HEAD 10
|
||||
#define EN_PRESSURE 11
|
||||
#define EN_QUALITY 12
|
||||
#define EN_SOURCEMASS 13
|
||||
#define EN_INITVOLUME 14
|
||||
#define EN_MIXMODEL 15
|
||||
#define EN_MIXZONEVOL 16
|
||||
|
||||
#define EN_TANKDIAM 17
|
||||
#define EN_MINVOLUME 18
|
||||
#define EN_VOLCURVE 19
|
||||
#define EN_MINLEVEL 20
|
||||
#define EN_MAXLEVEL 21
|
||||
#define EN_MIXFRACTION 22
|
||||
#define EN_TANK_KBULK 23
|
||||
|
||||
#define EN_TANKVOLUME 24 /* TNT */
|
||||
|
||||
#define EN_DIAMETER 0 /* Link parameters */
|
||||
#define EN_LENGTH 1
|
||||
#define EN_ROUGHNESS 2
|
||||
#define EN_MINORLOSS 3
|
||||
#define EN_INITSTATUS 4
|
||||
#define EN_INITSETTING 5
|
||||
#define EN_KBULK 6
|
||||
#define EN_KWALL 7
|
||||
#define EN_FLOW 8
|
||||
#define EN_VELOCITY 9
|
||||
#define EN_HEADLOSS 10
|
||||
#define EN_STATUS 11
|
||||
#define EN_SETTING 12
|
||||
#define EN_ENERGY 13
|
||||
#define EN_LINKQUAL 14 /* TNT */
|
||||
|
||||
#define EN_DURATION 0 /* Time parameters */
|
||||
#define EN_HYDSTEP 1
|
||||
#define EN_QUALSTEP 2
|
||||
#define EN_PATTERNSTEP 3
|
||||
#define EN_PATTERNSTART 4
|
||||
#define EN_REPORTSTEP 5
|
||||
#define EN_REPORTSTART 6
|
||||
#define EN_RULESTEP 7
|
||||
#define EN_STATISTIC 8
|
||||
#define EN_PERIODS 9
|
||||
#define EN_STARTTIME 10 /* Added TNT 10/2/2009 */
|
||||
|
||||
#define EN_NODECOUNT 0 /* Component counts */
|
||||
#define EN_TANKCOUNT 1
|
||||
#define EN_LINKCOUNT 2
|
||||
#define EN_PATCOUNT 3
|
||||
#define EN_CURVECOUNT 4
|
||||
#define EN_CONTROLCOUNT 5
|
||||
|
||||
#define EN_JUNCTION 0 /* Node types */
|
||||
#define EN_RESERVOIR 1
|
||||
#define EN_TANK 2
|
||||
|
||||
#define EN_CVPIPE 0 /* Link types */
|
||||
#define EN_PIPE 1
|
||||
#define EN_PUMP 2
|
||||
#define EN_PRV 3
|
||||
#define EN_PSV 4
|
||||
#define EN_PBV 5
|
||||
#define EN_FCV 6
|
||||
#define EN_TCV 7
|
||||
#define EN_GPV 8
|
||||
|
||||
#define EN_NONE 0 /* Quality analysis types */
|
||||
#define EN_CHEM 1
|
||||
#define EN_AGE 2
|
||||
#define EN_TRACE 3
|
||||
|
||||
#define EN_CONCEN 0 /* Source quality types */
|
||||
#define EN_MASS 1
|
||||
#define EN_SETPOINT 2
|
||||
#define EN_FLOWPACED 3
|
||||
|
||||
#define EN_CFS 0 /* Flow units types */
|
||||
#define EN_GPM 1
|
||||
#define EN_MGD 2
|
||||
#define EN_IMGD 3
|
||||
#define EN_AFD 4
|
||||
#define EN_LPS 5
|
||||
#define EN_LPM 6
|
||||
#define EN_MLD 7
|
||||
#define EN_CMH 8
|
||||
#define EN_CMD 9
|
||||
|
||||
#define EN_TRIALS 0 /* Misc. options */
|
||||
#define EN_ACCURACY 1
|
||||
#define EN_TOLERANCE 2
|
||||
#define EN_EMITEXPON 3
|
||||
#define EN_DEMANDMULT 4
|
||||
|
||||
#define EN_LOWLEVEL 0 /* Control types */
|
||||
#define EN_HILEVEL 1
|
||||
#define EN_TIMER 2
|
||||
#define EN_TIMEOFDAY 3
|
||||
|
||||
#define EN_AVERAGE 1 /* Time statistic types. */
|
||||
#define EN_MINIMUM 2
|
||||
#define EN_MAXIMUM 3
|
||||
#define EN_RANGE 4
|
||||
|
||||
#define EN_MIX1 0 /* Tank mixing models */
|
||||
#define EN_MIX2 1
|
||||
#define EN_FIFO 2
|
||||
#define EN_LIFO 3
|
||||
|
||||
#define EN_NOSAVE 0 /* Save-results-to-file flag */
|
||||
#define EN_SAVE 1
|
||||
#define EN_INITFLOW 10 /* Re-initialize flow flag */
|
||||
|
||||
|
||||
|
||||
// --- define WINDOWS
|
||||
|
||||
#undef WINDOWS
|
||||
#ifdef _WIN32
|
||||
#define WINDOWS
|
||||
#endif
|
||||
#ifdef __WIN32__
|
||||
#define WINDOWS
|
||||
#endif
|
||||
|
||||
// --- define DLLEXPORT
|
||||
|
||||
#ifndef DLLEXPORT
|
||||
#ifdef DLL
|
||||
#if defined(CYGWIN)
|
||||
#define DLLEXPORT __stdcall
|
||||
#elif defined(WINDOWS)
|
||||
#ifdef __cplusplus
|
||||
#define DLLEXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
#define DLLEXPORT extern "C"
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// --- declare the EPANET toolkit functions
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *));
|
||||
int DLLEXPORT ENopen(char *, char *, char *);
|
||||
int DLLEXPORT ENsaveinpfile(char *);
|
||||
int DLLEXPORT ENclose(void);
|
||||
|
||||
int DLLEXPORT ENsolveH(void);
|
||||
int DLLEXPORT ENsaveH(void);
|
||||
int DLLEXPORT ENopenH(void);
|
||||
int DLLEXPORT ENinitH(int);
|
||||
int DLLEXPORT ENrunH(long *);
|
||||
int DLLEXPORT ENnextH(long *);
|
||||
int DLLEXPORT ENcloseH(void);
|
||||
int DLLEXPORT ENsavehydfile(char *);
|
||||
int DLLEXPORT ENusehydfile(char *);
|
||||
|
||||
int DLLEXPORT ENsolveQ(void);
|
||||
int DLLEXPORT ENopenQ(void);
|
||||
int DLLEXPORT ENinitQ(int);
|
||||
int DLLEXPORT ENrunQ(long *);
|
||||
int DLLEXPORT ENnextQ(long *);
|
||||
int DLLEXPORT ENstepQ(long *);
|
||||
int DLLEXPORT ENcloseQ(void);
|
||||
|
||||
int DLLEXPORT ENwriteline(char *);
|
||||
int DLLEXPORT ENreport(void);
|
||||
int DLLEXPORT ENresetreport(void);
|
||||
int DLLEXPORT ENsetreport(char *);
|
||||
|
||||
int DLLEXPORT ENgetcontrol(int, int *, int *, float *,
|
||||
int *, float *);
|
||||
int DLLEXPORT ENgetcount(int, int *);
|
||||
int DLLEXPORT ENgetoption(int, float *);
|
||||
int DLLEXPORT ENgettimeparam(int, long *);
|
||||
int DLLEXPORT ENgetflowunits(int *);
|
||||
int DLLEXPORT ENgetpatternindex(char *, int *);
|
||||
int DLLEXPORT ENgetpatternid(int, char *);
|
||||
int DLLEXPORT ENgetpatternlen(int, int *);
|
||||
int DLLEXPORT ENgetpatternvalue(int, int, float *);
|
||||
int DLLEXPORT ENgetqualtype(int *, int *);
|
||||
int DLLEXPORT ENgeterror(int, char *, int);
|
||||
|
||||
int DLLEXPORT ENgetnodeindex(char *, int *);
|
||||
int DLLEXPORT ENgetnodeid(int, char *);
|
||||
int DLLEXPORT ENgetnodetype(int, int *);
|
||||
int DLLEXPORT ENgetnodevalue(int, int, float *);
|
||||
|
||||
int DLLEXPORT ENgetnumdemands(int, int *);
|
||||
int DLLEXPORT ENgetbasedemand(int, int, float *);
|
||||
int DLLEXPORT ENgetdemandpattern(int, int, int *);
|
||||
|
||||
int DLLEXPORT ENgetlinkindex(char *, int *);
|
||||
int DLLEXPORT ENgetlinkid(int, char *);
|
||||
int DLLEXPORT ENgetlinktype(int, int *);
|
||||
int DLLEXPORT ENgetlinknodes(int, int *, int *);
|
||||
int DLLEXPORT ENgetlinkvalue(int, int, float *);
|
||||
|
||||
int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float **yValues);
|
||||
|
||||
int DLLEXPORT ENgetversion(int *);
|
||||
|
||||
int DLLEXPORT ENsetcontrol(int, int, int, float, int, float);
|
||||
int DLLEXPORT ENsetnodevalue(int, int, float);
|
||||
int DLLEXPORT ENsetlinkvalue(int, int, float);
|
||||
int DLLEXPORT ENaddpattern(char *);
|
||||
int DLLEXPORT ENsetpattern(int, float *, int);
|
||||
int DLLEXPORT ENsetpatternvalue(int, int, float);
|
||||
int DLLEXPORT ENsettimeparam(int, long);
|
||||
int DLLEXPORT ENsetoption(int, float);
|
||||
int DLLEXPORT ENsetstatusreport(int);
|
||||
int DLLEXPORT ENsetqualtype(int, char *, char *, char *);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: epanet2.h
|
||||
Description: declarations of the legacy style EPANET 2 API functions
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 03/17/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
This module contains declarations of the legacy style EPANET API functions, with
|
||||
version 2.2 updates, that apply only to single threaded applications. A second
|
||||
set of thread safe API functions that allows one to run concurrent analyses on
|
||||
multiple EPANET projects can be found in the epanet2_2.h header file. The two
|
||||
APIs share the same function names and arguments with the difference being that
|
||||
the thread safe functions use the prefix "EN_" and include an extra argument that
|
||||
represents the EPANET project being analyzed. To avoid unneccesary repetition,
|
||||
only the thread safe API functions have been documented. To see a description of
|
||||
a legacy style API function declared here please refer to its complementary named
|
||||
function in epanet2_2.h.
|
||||
*/
|
||||
|
||||
#ifndef EPANET2_H
|
||||
#define EPANET2_H
|
||||
|
||||
// The legacy style EPANET API can be compiled with support for either single
|
||||
// precision or double precision floating point arguments, with the default
|
||||
// being single precision. To compile for double precision one must #define
|
||||
// EN_API_FLOAT_TYPE as double both here and in any client code that uses the
|
||||
// API.
|
||||
#ifndef EN_API_FLOAT_TYPE
|
||||
#define EN_API_FLOAT_TYPE float
|
||||
#endif
|
||||
|
||||
#ifndef DLLEXPORT
|
||||
#ifdef _WIN32
|
||||
#ifdef epanet2_EXPORTS
|
||||
#define DLLEXPORT __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define DLLEXPORT __declspec(dllimport) __stdcall
|
||||
#endif
|
||||
#elif defined(__CYGWIN__)
|
||||
#define DLLEXPORT __stdcall
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "epanet2_enums.h"
|
||||
|
||||
// --- Declare the EPANET toolkit functions
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Project Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile,
|
||||
const char *outFile, void (*pviewprog) (char *));
|
||||
|
||||
int DLLEXPORT ENinit(const char *rptFile, const char *outFile,
|
||||
int unitsType, int headlossType);
|
||||
|
||||
int DLLEXPORT ENopen(const char *inpFile, const char *rptFile,
|
||||
const char *outFile);
|
||||
|
||||
int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3);
|
||||
|
||||
int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3);
|
||||
|
||||
int DLLEXPORT ENgetcomment(int object, int index, char *comment);
|
||||
|
||||
int DLLEXPORT ENsetcomment(int object, int index, char *comment);
|
||||
|
||||
int DLLEXPORT ENgetcount(int object, int *count);
|
||||
|
||||
int DLLEXPORT ENsaveinpfile(const char *filename);
|
||||
|
||||
int DLLEXPORT ENclose();
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Hydraulic Analysis Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENsolveH();
|
||||
|
||||
int DLLEXPORT ENsaveH();
|
||||
|
||||
int DLLEXPORT ENopenH();
|
||||
|
||||
int DLLEXPORT ENinitH(int initFlag);
|
||||
|
||||
int DLLEXPORT ENrunH(long *currentTime);
|
||||
|
||||
int DLLEXPORT ENnextH(long *tStep);
|
||||
|
||||
int DLLEXPORT ENcloseH();
|
||||
|
||||
int DLLEXPORT ENsavehydfile(char *filename);
|
||||
|
||||
int DLLEXPORT ENusehydfile(char *filename);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Water Quality Analysis Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENsolveQ();
|
||||
|
||||
int DLLEXPORT ENopenQ();
|
||||
|
||||
int DLLEXPORT ENinitQ(int saveFlag);
|
||||
|
||||
int DLLEXPORT ENrunQ(long *currentTime);
|
||||
|
||||
int DLLEXPORT ENnextQ(long *tStep);
|
||||
|
||||
int DLLEXPORT ENstepQ(long *timeLeft);
|
||||
|
||||
int DLLEXPORT ENcloseQ();
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Reporting Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENwriteline(char *line);
|
||||
|
||||
int DLLEXPORT ENreport();
|
||||
|
||||
int DLLEXPORT ENcopyreport(char *filename);
|
||||
|
||||
int DLLEXPORT ENclearreport();
|
||||
|
||||
int DLLEXPORT ENresetreport();
|
||||
|
||||
int DLLEXPORT ENsetreport(char *format);
|
||||
|
||||
int DLLEXPORT ENsetstatusreport(int level);
|
||||
|
||||
int DLLEXPORT ENgetversion(int *version);
|
||||
|
||||
int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen);
|
||||
|
||||
int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value);
|
||||
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Analysis Options Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value);
|
||||
|
||||
int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value);
|
||||
|
||||
int DLLEXPORT ENgetflowunits(int *units);
|
||||
|
||||
int DLLEXPORT ENsetflowunits(int units);
|
||||
|
||||
int DLLEXPORT ENgettimeparam(int param, long *value);
|
||||
|
||||
int DLLEXPORT ENsettimeparam(int param, long value);
|
||||
|
||||
int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits,
|
||||
int *traceNode);
|
||||
|
||||
int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode);
|
||||
|
||||
int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits,
|
||||
char *traceNode);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Node Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddnode(char *id, int nodeType, int *index);
|
||||
|
||||
int DLLEXPORT ENdeletenode(int index, int actionCode);
|
||||
|
||||
int DLLEXPORT ENgetnodeindex(char *id, int *index);
|
||||
|
||||
int DLLEXPORT ENgetnodeid(int index, char *id);
|
||||
|
||||
int DLLEXPORT ENsetnodeid(int index, char *newid);
|
||||
|
||||
int DLLEXPORT ENgetnodetype(int index, int *nodeType);
|
||||
|
||||
int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value);
|
||||
|
||||
int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value);
|
||||
|
||||
int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev,
|
||||
EN_API_FLOAT_TYPE dmnd, char *dmndpat);
|
||||
|
||||
int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev,
|
||||
EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
|
||||
EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
|
||||
EN_API_FLOAT_TYPE minvol, char *volcurve);
|
||||
|
||||
int DLLEXPORT ENgetcoord(int index, double *x, double *y);
|
||||
|
||||
int DLLEXPORT ENsetcoord(int index, double x, double y);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Nodal Demand Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin,
|
||||
EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp);
|
||||
|
||||
int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin,
|
||||
EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp);
|
||||
|
||||
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands);
|
||||
|
||||
int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex,
|
||||
EN_API_FLOAT_TYPE *baseDemand);
|
||||
|
||||
int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex,
|
||||
EN_API_FLOAT_TYPE baseDemand);
|
||||
|
||||
int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *patIndex);
|
||||
|
||||
int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex);
|
||||
|
||||
int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName);
|
||||
|
||||
int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Link Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode, int *index);
|
||||
|
||||
int DLLEXPORT ENdeletelink(int index, int actionCode);
|
||||
|
||||
int DLLEXPORT ENgetlinkindex(char *id, int *index);
|
||||
|
||||
int DLLEXPORT ENgetlinkid(int index, char *id);
|
||||
|
||||
int DLLEXPORT ENsetlinkid(int index, char *newid);
|
||||
|
||||
int DLLEXPORT ENgetlinktype(int index, int *linkType);
|
||||
|
||||
int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode);
|
||||
|
||||
int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2);
|
||||
|
||||
int DLLEXPORT ENsetlinknodes(int index, int node1, int node2);
|
||||
|
||||
int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value);
|
||||
|
||||
int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value);
|
||||
|
||||
int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length,
|
||||
EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough,
|
||||
EN_API_FLOAT_TYPE mloss);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Pump Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType);
|
||||
|
||||
int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex);
|
||||
|
||||
int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Time Pattern Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddpattern(char *id);
|
||||
|
||||
int DLLEXPORT ENdeletepattern(int index);
|
||||
|
||||
int DLLEXPORT ENgetpatternindex(char *id, int *index);
|
||||
|
||||
int DLLEXPORT ENgetpatternid(int index, char *id);
|
||||
|
||||
int DLLEXPORT ENsetpatternid(int index, char *id);
|
||||
|
||||
int DLLEXPORT ENgetpatternlen(int index, int *len);
|
||||
|
||||
int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value);
|
||||
|
||||
int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value);
|
||||
|
||||
int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value);
|
||||
|
||||
int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Data Curve Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddcurve(char *id);
|
||||
|
||||
int DLLEXPORT ENdeletecurve(int index);
|
||||
|
||||
int DLLEXPORT ENgetcurveindex(char *id, int *index);
|
||||
|
||||
int DLLEXPORT ENgetcurveid(int index, char *id);
|
||||
|
||||
int DLLEXPORT ENsetcurveid(int index, char *id);
|
||||
|
||||
int DLLEXPORT ENgetcurvelen(int index, int *len);
|
||||
|
||||
int DLLEXPORT ENgetcurvetype(int index, int *type);
|
||||
|
||||
int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex,
|
||||
EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y);
|
||||
|
||||
int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex,
|
||||
EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y);
|
||||
|
||||
int DLLEXPORT ENgetcurve(int index, char* id, int *nPoints,
|
||||
EN_API_FLOAT_TYPE *xValues, EN_API_FLOAT_TYPE *yValues);
|
||||
|
||||
int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues,
|
||||
EN_API_FLOAT_TYPE *yValues, int nPoints);
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Simple Controls Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting,
|
||||
int nodeIndex, EN_API_FLOAT_TYPE level, int *index);
|
||||
|
||||
int DLLEXPORT ENdeletecontrol(int index);
|
||||
|
||||
int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex,
|
||||
EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level);
|
||||
|
||||
int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex,
|
||||
EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level);
|
||||
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Rule-Based Controls Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddrule(char *rule);
|
||||
|
||||
int DLLEXPORT ENdeleterule(int index);
|
||||
|
||||
int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions,
|
||||
int *nElseActions, EN_API_FLOAT_TYPE *priority);
|
||||
|
||||
int DLLEXPORT ENgetruleID(int index, char* id);
|
||||
|
||||
int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop,
|
||||
int *object, int *objIndex, int *variable,
|
||||
int *relop, int *status, EN_API_FLOAT_TYPE *value);
|
||||
|
||||
int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop,
|
||||
int object, int objIndex, int variable, int relop,
|
||||
int status, EN_API_FLOAT_TYPE value);
|
||||
|
||||
int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex);
|
||||
|
||||
int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status);
|
||||
|
||||
int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex,
|
||||
EN_API_FLOAT_TYPE value);
|
||||
|
||||
int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex,
|
||||
int *status, EN_API_FLOAT_TYPE *setting);
|
||||
|
||||
int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex,
|
||||
int status, EN_API_FLOAT_TYPE setting);
|
||||
|
||||
int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex,
|
||||
int *status, EN_API_FLOAT_TYPE *setting);
|
||||
|
||||
int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex,
|
||||
int status, EN_API_FLOAT_TYPE setting);
|
||||
|
||||
int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //EPANET2_H
|
||||
|
||||
389
include/epanet2.vb
Normal file
389
include/epanet2.vb
Normal file
@@ -0,0 +1,389 @@
|
||||
|
||||
'EPANET2.VB
|
||||
'
|
||||
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
||||
'(EPANET2.DLL) for use with VB.Net.
|
||||
|
||||
'Last updated on 03/17/2019
|
||||
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Text
|
||||
|
||||
Module Epanet2
|
||||
|
||||
' These are codes used by the DLL functions
|
||||
Public Const EN_ELEVATION = 0 ' Node parameters
|
||||
Public Const EN_BASEDEMAND = 1
|
||||
Public Const EN_PATTERN = 2
|
||||
Public Const EN_EMITTER = 3
|
||||
Public Const EN_INITQUAL = 4
|
||||
Public Const EN_SOURCEQUAL = 5
|
||||
Public Const EN_SOURCEPAT = 6
|
||||
Public Const EN_SOURCETYPE = 7
|
||||
Public Const EN_TANKLEVEL = 8
|
||||
Public Const EN_DEMAND = 9
|
||||
Public Const EN_HEAD = 10
|
||||
Public Const EN_PRESSURE = 11
|
||||
Public Const EN_QUALITY = 12
|
||||
Public Const EN_SOURCEMASS = 13
|
||||
Public Const EN_INITVOLUME = 14
|
||||
Public Const EN_MIXMODEL = 15
|
||||
Public Const EN_MIXZONEVOL = 16
|
||||
|
||||
Public Const EN_TANKDIAM = 17
|
||||
Public Const EN_MINVOLUME = 18
|
||||
Public Const EN_VOLCURVE = 19
|
||||
Public Const EN_MINLEVEL = 20
|
||||
Public Const EN_MAXLEVEL = 21
|
||||
Public Const EN_MIXFRACTION = 22
|
||||
Public Const EN_TANK_KBULK = 23
|
||||
|
||||
Public Const EN_TANKVOLUME = 24 'ES
|
||||
Public Const EN_MAXVOLUME = 25
|
||||
|
||||
Public Const EN_DIAMETER = 0 ' Link parameters
|
||||
Public Const EN_LENGTH = 1
|
||||
Public Const EN_ROUGHNESS = 2
|
||||
Public Const EN_MINORLOSS = 3
|
||||
Public Const EN_INITSTATUS = 4
|
||||
Public Const EN_INITSETTING = 5
|
||||
Public Const EN_KBULK = 6
|
||||
Public Const EN_KWALL = 7
|
||||
Public Const EN_FLOW = 8
|
||||
Public Const EN_VELOCITY = 9
|
||||
Public Const EN_HEADLOSS = 10
|
||||
Public Const EN_STATUS = 11
|
||||
Public Const EN_SETTING = 12
|
||||
Public Const EN_ENERGY = 13
|
||||
Public Const EN_LINKQUAL = 14
|
||||
Public Const EN_LINKPATTERN = 15
|
||||
|
||||
Public Const EN_PUMP_STATE = 16
|
||||
Public Const EN_PUMP_EFFIC = 17
|
||||
Public Const EN_PUMP_POWER = 18
|
||||
Public Const EN_PUMP_HCURVE = 19
|
||||
Public Const EN_PUMP_ECURVE = 20
|
||||
Public Const EN_PUMP_ECOST = 21
|
||||
Public Const EN_PUMP_EPAT = 22
|
||||
|
||||
Public Const EN_DURATION = 0 ' Time parameters
|
||||
Public Const EN_HYDSTEP = 1
|
||||
Public Const EN_QUALSTEP = 2
|
||||
Public Const EN_PATTERNSTEP = 3
|
||||
Public Const EN_PATTERNSTART = 4
|
||||
Public Const EN_REPORTSTEP = 5
|
||||
Public Const EN_REPORTSTART = 6
|
||||
Public Const EN_RULESTEP = 7
|
||||
Public Const EN_STATISTIC = 8
|
||||
Public Const EN_PERIODS = 9
|
||||
Public Const EN_STARTTIME = 10
|
||||
Public Const EN_HTIME = 11
|
||||
Public Const EN_QTIME = 12
|
||||
Public Const EN_HALTFLAG = 13
|
||||
Public Const EN_NEXTEVENT = 14
|
||||
|
||||
Public Const EN_ITERATIONS = 0
|
||||
Public Const EN_RELATIVEERROR = 1
|
||||
Public Const EN_MAXHEADERROR = 2
|
||||
Public Const EN_MAXFLOWCHANGE = 3
|
||||
Public Const EN_MASSBALANCE = 4
|
||||
|
||||
Public Const EN_NODE = 0 ' Component types
|
||||
Public Const EN_LINK = 1
|
||||
Public Const EN_TIMEPAT = 2
|
||||
Public Const EN_CURVE = 3
|
||||
Public Const EN_CONTROL = 4
|
||||
Public Const EN_RULE = 5
|
||||
|
||||
Public Const EN_NODECOUNT = 0 'Component counts
|
||||
Public Const EN_TANKCOUNT = 1
|
||||
Public Const EN_LINKCOUNT = 2
|
||||
Public Const EN_PATCOUNT = 3
|
||||
Public Const EN_CURVECOUNT = 4
|
||||
Public Const EN_CONTROLCOUNT = 5
|
||||
Public Const EN_RULECOUNT = 6
|
||||
|
||||
Public Const EN_JUNCTION = 0 ' Node types
|
||||
Public Const EN_RESERVOIR = 1
|
||||
Public Const EN_TANK = 2
|
||||
|
||||
Public Const EN_CVPIPE = 0 ' Link types
|
||||
Public Const EN_PIPE = 1
|
||||
Public Const EN_PUMP = 2
|
||||
Public Const EN_PRV = 3
|
||||
Public Const EN_PSV = 4
|
||||
Public Const EN_PBV = 5
|
||||
Public Const EN_FCV = 6
|
||||
Public Const EN_TCV = 7
|
||||
Public Const EN_GPV = 8
|
||||
|
||||
Public Const EN_NONE = 0 ' Quality analysis types
|
||||
Public Const EN_CHEM = 1
|
||||
Public Const EN_AGE = 2
|
||||
Public Const EN_TRACE = 3
|
||||
|
||||
Public Const EN_CONCEN = 0 ' Source quality types
|
||||
Public Const EN_MASS = 1
|
||||
Public Const EN_SETPOINT = 2
|
||||
Public Const EN_FLOWPACED = 3
|
||||
|
||||
Public Const EN_HW = 0 ' Head loss formulas
|
||||
Public Const EN_DW = 1
|
||||
Public Const EN_CM = 2
|
||||
|
||||
Public Const EN_CFS = 0 ' Flow units types
|
||||
Public Const EN_GPM = 1
|
||||
Public Const EN_MGD = 2
|
||||
Public Const EN_IMGD = 3
|
||||
Public Const EN_AFD = 4
|
||||
Public Const EN_LPS = 5
|
||||
Public Const EN_LPM = 6
|
||||
Public Const EN_MLD = 7
|
||||
Public Const EN_CMH = 8
|
||||
Public Const EN_CMD = 9
|
||||
|
||||
Public Const EN_DDA = 0 ' Demand driven analysis
|
||||
Public Const EN_PDA = 1 ' Pressure driven analysis
|
||||
|
||||
Public Const EN_TRIALS = 0 ' Simulation options
|
||||
Public Const EN_ACCURACY = 1
|
||||
Public Const EN_TOLERANCE = 2
|
||||
Public Const EN_EMITEXPON = 3
|
||||
Public Const EN_DEMANDMULT = 4
|
||||
Public Const EN_HEADERROR = 5
|
||||
Public Const EN_FLOWCHANGE = 6
|
||||
Public Const EN_HEADLOSSFORM = 7
|
||||
Public Const EN_GLOBALEFFIC = 8
|
||||
Public Const EN_GLOBALPRICE = 9
|
||||
Public Const EN_GLOBALPATTERN = 10
|
||||
Public Const EN_DEMANDCHARGE = 11
|
||||
Public Const EN_SP_GRAVITY = 12
|
||||
Public Const EN_SP_VISCOS = 13
|
||||
Public Const EN_UNBALANCED = 14
|
||||
Public Const EN_CHECKFREQ = 15
|
||||
Public Const EN_MAXCHECK = 16
|
||||
Public Const EN_DAMPLIMIT = 17
|
||||
Public Const EN_SP_DIFFUS = 18
|
||||
Public Const EN_BULKORDER = 19
|
||||
Public Const EN_WALLORDER = 20
|
||||
Public Const EN_TANKORDER = 21
|
||||
Public Const EN_CONCENLIMIT = 22
|
||||
|
||||
Public Const EN_LOWLEVEL = 0 ' Control types
|
||||
Public Const EN_HILEVEL = 1
|
||||
Public Const EN_TIMER = 2
|
||||
Public Const EN_TIMEOFDAY = 3
|
||||
|
||||
Public Const EN_AVERAGE = 1 ' Time statistic types
|
||||
Public Const EN_MINIMUM = 2
|
||||
Public Const EN_MAXIMUM = 3
|
||||
Public Const EN_RANGE = 4
|
||||
|
||||
Public Const EN_MIX1 = 0 ' Tank mixing models
|
||||
Public Const EN_MIX2 = 1
|
||||
Public Const EN_FIFO = 2
|
||||
Public Const EN_LIFO = 3
|
||||
|
||||
Public Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
||||
Public Const EN_SAVE = 1
|
||||
Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
||||
Public Const EN_SAVE_AND_INIT = 11
|
||||
|
||||
Public Const EN_CONST_HP = 0 ' Constant horsepower pump curve
|
||||
Public Const EN_POWER_FUNC = 1 ' Power function pump curve
|
||||
Public Const EN_CUSTOM = 2 ' User-defined custom pump curve
|
||||
Public Const EN_NOCURVE = 3 ' No pump curve
|
||||
|
||||
Public Const EN_VOLUME_CURVE = 0 ' Volume curve
|
||||
Public Const EN_PUMP_CURVE = 1 ' Pump curve
|
||||
Public Const EN_EFFIC_CURVE = 2 ' Efficiency curve
|
||||
Public Const EN_HLOSS_CURVE = 3 ' Head loss curve
|
||||
Public Const EN_GENERIC_CURVE = 4 ' Generic curve
|
||||
|
||||
Public Const EN_UNCONDITIONAL = 0 ' Unconditional object deletion
|
||||
Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
||||
|
||||
Public Const EN_NO_REPORT = 0 ' No status report
|
||||
Public Const EN_NORMAL_REPORT = 1 ' Normal status report
|
||||
Public Const EN_FULL_REPORT = 2 ' Full status report
|
||||
|
||||
Public Const EN_R_NODE = 6 ' Rule objects
|
||||
Public Const EN_R_LINK = 7
|
||||
Public Const EN_R_SYSTEM = 8
|
||||
|
||||
Public Const EN_R_DEMAND = 0 ' Rule variables
|
||||
Public Const EN_R_HEAD = 1
|
||||
Public Const EN_R_GRADE = 2
|
||||
Public Const EN_R_LEVEL = 3
|
||||
Public Const EN_R_PRESSURE = 4
|
||||
Public Const EN_R_FLOW = 5
|
||||
Public Const EN_R_STATUS = 6
|
||||
Public Const EN_R_SETTING = 7
|
||||
Public Const EN_R_POWER = 8
|
||||
Public Const EN_R_TIME = 9
|
||||
Public Const EN_R_CLOCKTIME = 10
|
||||
Public Const EN_R_FILLTIME = 11
|
||||
Public Const EN_R_DRAINTIME = 12
|
||||
|
||||
Public Const EN_R_EQ = 0 ' Rule operators
|
||||
Public Const EN_R_NE = 1
|
||||
Public Const EN_R_LE = 2
|
||||
Public Const EN_R_GE = 3
|
||||
Public Const EN_R_LT = 4
|
||||
Public Const EN_R_GT = 5
|
||||
Public Const EN_R_IS = 6
|
||||
Public Const EN_R_NOT = 7
|
||||
Public Const EN_R_BELOW = 8
|
||||
Public Const EN_R_ABOVE = 9
|
||||
|
||||
Public Const EN_R_IS_OPEN = 1 ' Rule status types
|
||||
Public Const EN_R_IS_CLOSED = 2
|
||||
Public Const EN_R_IS_ACTIVE = 3
|
||||
|
||||
'These are the external functions that comprise the DLL
|
||||
|
||||
'Project Functions
|
||||
Declare Function ENgetversion Lib "epanet2.dll" (value As Int32) As Int32
|
||||
Declare Function ENepanet Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String, ByVal pviewprog As Any) As Int32
|
||||
Declare Function ENinit Lib "epanet2.dll" (ByVal rptFile As String, ByVal outFile As String, ByVal unitsType As Int32, ByVal headlossType As Int32) As Int32
|
||||
Declare Function ENopen Lib "epanet2.dll" (ByVal inpFile As String, ByVal rptFile As String, ByVal outFile As String) As Int32
|
||||
Declare Function ENgettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32
|
||||
Declare Function ENsettitle Lib "epanet2.dll" (ByVal titleline1 As String, ByVal titleline2 As String, ByVal titleline3 As String) As Int32
|
||||
Declare Function ENsaveinpfile Lib "epanet2.dll" (ByVal filename As String) As Int32
|
||||
Declare Function ENclose Lib "epanet2.dll" () As Int32
|
||||
|
||||
'Hydraulic Analysis Functions
|
||||
Declare Function ENsolveH Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENsaveH Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENopenH Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENinitH Lib "epanet2.dll" (ByVal initFlag As Int32) As Int32
|
||||
Declare Function ENrunH Lib "epanet2.dll" (currentTime As Int32) As Int32
|
||||
Declare Function ENnextH Lib "epanet2.dll" (tStep As Int32) As Int32
|
||||
Declare Function ENcloseH Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENsavehydfile Lib "epanet2.dll" (ByVal filename As String) As Int32
|
||||
Declare Function ENusehydfile Lib "epanet2.dll" (ByVal filename As String) As Int32
|
||||
|
||||
'Water Quality Analysis Functions
|
||||
Declare Function ENsolveQ Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENopenQ Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENinitQ Lib "epanet2.dll" (ByVal saveFlag As Int32) As Int32
|
||||
Declare Function ENrunQ Lib "epanet2.dll" (currentTime As Int32) As Int32
|
||||
Declare Function ENnextQ Lib "epanet2.dll" (tStep As Int32) As Int32
|
||||
Declare Function ENstepQ Lib "epanet2.dll" (timeLeft As Int32) As Int32
|
||||
Declare Function ENcloseQ Lib "epanet2.dll" () As Int32
|
||||
|
||||
'Reporting Functions
|
||||
Declare Function ENwriteline Lib "epanet2.dll" (ByVal line As String) As Int32
|
||||
Declare Function ENreport Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENcopyreport Lib "epanet2.dll" (ByVal filename As String) As Int32
|
||||
Declare Function ENclearreport Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENresetreport Lib "epanet2.dll" () As Int32
|
||||
Declare Function ENsetreport Lib "epanet2.dll" (ByVal format As String) As Int32
|
||||
Declare Function ENsetstatusreport Lib "epanet2.dll" (ByVal level As Int32) As Int32
|
||||
Declare Function ENgetcount Lib "epanet2.dll" (ByVal object As Int32, count As Int32) As Int32
|
||||
Declare Function ENgeterror Lib "epanet2.dll" (ByVal errcode As Int32, ByVal errmsg As String, ByVal maxLen As Int32) As Int32
|
||||
Declare Function ENgetstatistic Lib "epanet2.dll" (ByVal type_ As Int32, ByRef value As Single) As Int32
|
||||
|
||||
'Analysis Options Functions
|
||||
Declare Function ENgetoption Lib "epanet2.dll" (ByVal option As Int32, value As Single) As Int32
|
||||
Declare Function ENsetoption Lib "epanet2.dll" (ByVal option As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENgetflowunits Lib "epanet2.dll" (units As Int32) As Int32
|
||||
Declare Function ENsetflowunits Lib "epanet2.dll" (ByVal units As Int32) As Int32
|
||||
Declare Function ENgettimeparam Lib "epanet2.dll" (ByVal param As Int32, value As Int32) As Int32
|
||||
Declare Function ENsettimeparam Lib "epanet2.dll" (ByVal param As Int32, ByVal value As Int32) As Int32
|
||||
Declare Function ENgetqualinfo Lib "epanet2.dll" (qualType As Int32, ByVal chemName As String, ByVal chemUnits As String, traceNode As Int32) As Int32
|
||||
Declare Function ENgetqualtype Lib "epanet2.dll" (qualType As Int32, traceNode As Int32) As Int32
|
||||
Declare Function ENsetqualtype Lib "epanet2.dll" (ByVal qualType As Int32, ByVal chemName As String, ByVal chemUnits As String, ByVal traceNode As String) As Int32
|
||||
|
||||
'Node Functions
|
||||
Declare Function ENaddnode Lib "epanet2.dll" (ByVal id As String, ByVal nodeType As Int32, Index As Int32) As Int32
|
||||
Declare Function ENdeletenode Lib "epanet2.dll" (ByVal index As Int32, ByVal actionCode As Int32) As Int32
|
||||
Declare Function ENgetnodeindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
|
||||
Declare Function ENgetnodeid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
|
||||
Declare Function ENsetnodeid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
|
||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Int32, nodeType As Int32) As Int32
|
||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, value As Single) As Int32
|
||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENsetjuncdata Lib "epanet2.dll" (ByVal index As Int32, ByVal elev As Single, ByVal dmnd As Single, ByVal dmndpat As String) As Int32
|
||||
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Int32, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Int32
|
||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Int32, x As Double, y As Double) As Int32
|
||||
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Int32, ByVal x As Double, ByVal y As Double) As Int32
|
||||
|
||||
'Nodal Demand Functions
|
||||
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Int32, pmin As Single, preq As Single, pexp As Single) As Int32
|
||||
Declare Function ENsetdemandmodel Lib "epanet2.dll" (ByVal type_ As Int32, ByVal pmin As Single, ByVal preq As Single, ByVal pexp As Single) As Int32
|
||||
Declare Function ENgetnumdemands Lib "epanet2.dll" (ByVal nodeIndex As Int32, numDemands As Int32) As Int32
|
||||
Declare Function ENgetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, value As Single) As Int32
|
||||
Declare Function ENsetbasedemand Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal BaseDemand As Single) As Int32
|
||||
Declare Function ENgetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, patIndex As Int32) As Int32
|
||||
Declare Function ENsetdemandpattern Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal patIndex As Int32) As Int32
|
||||
Declare Function ENgetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal demandName As String) As Int32
|
||||
Declare Function ENsetdemandname Lib "epanet2.dll" (ByVal nodeIndex As Int32, ByVal demandIndex As Int32, ByVal demandName As String) As Int32
|
||||
|
||||
'Link Functions
|
||||
Declare Function ENaddlink Lib "epanet2.dll" (ByVal id As String, ByVal linkType As Int32, ByVal fromNode As String, ByVal toNode As String, Index As Int32) As Int32
|
||||
Declare Function ENdeletelink Lib "epanet2.dll" (ByVal index As Int32, ByVal actionCode As Int32) As Int32
|
||||
Declare Function ENgetlinkindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
|
||||
Declare Function ENgetlinkid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
|
||||
Declare Function ENsetlinkid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
|
||||
Declare Function ENgetlinktype Lib "epanet2.dll" (ByVal index As Int32, linkType As Int32) As Int32
|
||||
Declare Function ENsetlinktype Lib "epanet2.dll" (index As Int32, ByVal linkType As Int32, ByVal actionCode As Int32) As Int32
|
||||
Declare Function ENgetlinknodes Lib "epanet2.dll" (ByVal index As Int32, node1 As Int32, node2 As Int32) As Int32
|
||||
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Int32, ByVal node1 As Int32, ByVal node2 As Int32) As Int32
|
||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, value As Single) As Int32
|
||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal property As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Int32, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Int32
|
||||
|
||||
'Pump Functions
|
||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Int32, curveIndex As Int32) As Int32
|
||||
Declare Function ENsetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Int32, ByVal curveIndex As Int32) As Int32
|
||||
Declare Function ENgetpumptype Lib "epanet2.dll" (ByVal linkIndex As Int32, pumpType As Int32) As Int32
|
||||
|
||||
'Time Pattern Functions
|
||||
Declare Function ENaddpattern Lib "epanet2.dll" (ByVal id As String) As Int32
|
||||
Declare Function ENdeletepattern Lib "epanet2.dll" (ByVal index As Int32) As Int32
|
||||
Declare Function ENgetpatternindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
|
||||
Declare Function ENgetpatternid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
|
||||
Declare Function ENsetpatternid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
|
||||
Declare Function ENgetpatternlen Lib "epanet2.dll" (ByVal index As Int32, len_ As Int32) As Int32
|
||||
Declare Function ENgetpatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal period As Int32, value As Single) As Int32
|
||||
Declare Function ENsetpatternvalue Lib "epanet2.dll" (ByVal index As Int32, ByVal period As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENgetaveragepatternvalue Lib "epanet2.dll" (ByVal index As Int32, value As Single) As Int32
|
||||
Declare Function ENsetpattern Lib "epanet2.dll" (ByVal index As Int32, values As Any, ByVal len_ As Int32) As Int32
|
||||
|
||||
'Data Curve Functions
|
||||
Declare Function ENaddcurve Lib "epanet2.dll" (ByVal id As String) As Int32
|
||||
Declare Function ENdeletecurve Lib "epanet2.dll" (ByVal index As Int32) As Int32
|
||||
Declare Function ENgetcurveindex Lib "epanet2.dll" (ByVal id As String, index As Int32) As Int32
|
||||
Declare Function ENgetcurveid Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
|
||||
Declare Function ENsetcurveid Lib "epanet2.dll" (ByVal index As Int32, ByVal newid As String) As Int32
|
||||
Declare Function ENgetcurvelen Lib "epanet2.dll" (ByVal index As Int32, len_ As Int32) As Int32
|
||||
Declare Function ENgetcurvetype Lib "epanet2.dll" (ByVal index As Int32, type_ As Int32) As Int32
|
||||
Declare Function ENgetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Int32, ByVal pointIndex As Int32, x As Single, y As Single) As Int32
|
||||
Declare Function ENsetcurvevalue Lib "epanet2.dll" (ByVal curveIndex As Int32, ByVal pointIndex As Int32, ByVal x As Single, ByVal y As Single) As Int32
|
||||
Declare Function ENgetcurve Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String, nPoints As Int32, xValues As Any, yValues As Any) As Int32
|
||||
Declare Function ENsetcurve Lib "epanet2.dll" (ByVal index As Int32, xValues As Any, yValues As Any, ByVal nPoints As Int32) As Int32
|
||||
|
||||
'Simple Control Functions
|
||||
Declare Function ENaddcontrol Lib "epanet2.dll" (ByVal type_ As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single, index As Int32) As Int32
|
||||
Declare Function ENdeletecontrol Lib "epanet2.dll" (ByVal index As Int32) As Int32
|
||||
Declare Function ENgetcontrol Lib "epanet2.dll" (ByVal index As Int32, type_ As Int32, linkIndex As Int32, setting As Single, nodeIndex As Int32, level As Single) As Int32
|
||||
Declare Function ENsetcontrol Lib "epanet2.dll" (ByVal index As Int32, ByVal type_ As Int32, ByVal linkIndex As Int32, ByVal setting As Single, ByVal nodeIndex As Int32, ByVal level As Single) As Int32
|
||||
|
||||
'Rule-Based Control Functions
|
||||
Declare Function ENaddrule Lib "epanet2.dll" (ByVal rule As String) As Int32
|
||||
Declare Function ENdeleterule Lib "epanet2.dll" (ByVal index As Int32) As Int32
|
||||
Declare Function ENgetrule Lib "epanet2.dll" (ByVal index As Int32, nPremises As Int32, nThenActions As Int32, nElseActions As Int32, priority As Single) As Int32
|
||||
Declare Function ENgetruleID Lib "epanet2.dll" (ByVal index As Int32, ByVal id As String) As Int32
|
||||
Declare Function ENsetrulepriority Lib "epanet2.dll" (ByVal index As Int32, ByVal priority As Single) As Int32
|
||||
Declare Function ENgetpremise Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, logop As Int32, object As Int32, objIndex As Int32, variable As Int32, relop As Int32, status As Int32, value As Single) As Int32
|
||||
Declare Function ENsetpremise Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal logop As Int32, ByVal object As Int32, ByVal objIndex As Int32, ByVal variable As Int32, ByVal relop As Int32, ByVal status As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENsetpremiseindex Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal objIndex As Int32) As Int32
|
||||
Declare Function ENsetpremisestatus Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal status As Int32) As Int32
|
||||
Declare Function ENsetpremisevalue Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal premiseIndex As Int32, ByVal value As Single) As Int32
|
||||
Declare Function ENgetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, linkIndex As Int32, status As Int32, setting As Single) As Int32
|
||||
Declare Function ENsetthenaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, ByVal linkIndex As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
|
||||
Declare Function ENgetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, linkIndex As Int32, status As Int32, setting As Single) As Int32
|
||||
Declare Function ENsetelseaction Lib "epanet2.dll" (ByVal ruleIndex As Int32, ByVal actionIndex As Int32, ByVal linkIndex As Int32, ByVal status As Int32, ByVal setting As Single) As Int32
|
||||
|
||||
End Module
|
||||
1704
include/epanet2_2.h
Normal file
1704
include/epanet2_2.h
Normal file
File diff suppressed because it is too large
Load Diff
459
include/epanet2_enums.h
Normal file
459
include/epanet2_enums.h
Normal file
@@ -0,0 +1,459 @@
|
||||
/** @file epanet2_enums.h
|
||||
*/
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: epanet2_enums.h
|
||||
Description: enumerations of symbolic constants used by the API functions
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 04/03/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EPANET2_ENUMS_H
|
||||
#define EPANET2_ENUMS_H
|
||||
|
||||
|
||||
// --- Define the EPANET toolkit constants
|
||||
|
||||
#define EN_MAXID 31 //!< Max. # characters in ID name
|
||||
#define EN_MAXMSG 255 //!< Max. # characters in message text
|
||||
|
||||
/// Node properties
|
||||
/**
|
||||
These node properties can be accessed with @ref EN_getnodevalue and
|
||||
@ref EN_setnodevalue. Those marked as read only are computed values that can
|
||||
only be retrieved.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_ELEVATION = 0, //!< Elevation
|
||||
EN_BASEDEMAND = 1, //!< Primary demand baseline value
|
||||
EN_PATTERN = 2, //!< Primary demand time pattern index
|
||||
EN_EMITTER = 3, //!< Emitter flow coefficient
|
||||
EN_INITQUAL = 4, //!< Initial quality
|
||||
EN_SOURCEQUAL = 5, //!< Quality source strength
|
||||
EN_SOURCEPAT = 6, //!< Quality source pattern index
|
||||
EN_SOURCETYPE = 7, //!< Quality source type (see @ref EN_SourceType)
|
||||
EN_TANKLEVEL = 8, //!< Current computed tank water level (read only)
|
||||
EN_DEMAND = 9, //!< Current computed demand (read only)
|
||||
EN_HEAD = 10, //!< Current computed hydraulic head (read only)
|
||||
EN_PRESSURE = 11, //!< Current computed pressure (read only)
|
||||
EN_QUALITY = 12, //!< Current computed quality (read only)
|
||||
EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow (read only)
|
||||
EN_INITVOLUME = 14, //!< Tank initial volume (read only)
|
||||
EN_MIXMODEL = 15, //!< Tank mixing model (see @ref EN_MixingModel)
|
||||
EN_MIXZONEVOL = 16, //!< Tank mixing zone volume (read only)
|
||||
EN_TANKDIAM = 17, //!< Tank diameter
|
||||
EN_MINVOLUME = 18, //!< Tank minimum volume
|
||||
EN_VOLCURVE = 19, //!< Tank volume curve index
|
||||
EN_MINLEVEL = 20, //!< Tank minimum level
|
||||
EN_MAXLEVEL = 21, //!< Tank maximum level
|
||||
EN_MIXFRACTION = 22, //!< Tank mixing fraction
|
||||
EN_TANK_KBULK = 23, //!< Tank bulk decay coefficient
|
||||
EN_TANKVOLUME = 24, //!< Current computed tank volume (read only)
|
||||
EN_MAXVOLUME = 25 //!< Tank maximum volume (read only)
|
||||
} EN_NodeProperty;
|
||||
|
||||
/// Link properties
|
||||
/**
|
||||
These link properties can be accessed with @ref EN_getlinkvalue and @ref EN_setlinkvalue.
|
||||
Those marked as read only are computed values that can only be retrieved.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_DIAMETER = 0, //!< Pipe/valve diameter
|
||||
EN_LENGTH = 1, //!< Pipe length
|
||||
EN_ROUGHNESS = 2, //!< Pipe roughness coefficient
|
||||
EN_MINORLOSS = 3, //!< Pipe/valve minor loss coefficient
|
||||
EN_INITSTATUS = 4, //!< Initial status (see @ref EN_LinkStatusType)
|
||||
EN_INITSETTING = 5, //!< Initial pump speed or valve setting
|
||||
EN_KBULK = 6, //!< Bulk chemical reaction coefficient
|
||||
EN_KWALL = 7, //!< Pipe wall chemical reaction coefficient
|
||||
EN_FLOW = 8, //!< Current computed flow rate (read only)
|
||||
EN_VELOCITY = 9, //!< Current computed flow velocity (read only)
|
||||
EN_HEADLOSS = 10, //!< Current computed head loss (read only)
|
||||
EN_STATUS = 11, //!< Current link status (see @ref EN_LinkStatusType)
|
||||
EN_SETTING = 12, //!< Current link setting
|
||||
EN_ENERGY = 13, //!< Current computed pump energy usage (read only)
|
||||
EN_LINKQUAL = 14, //!< Current computed link quality (read only)
|
||||
EN_LINKPATTERN = 15, //!< Pump speed time pattern index
|
||||
EN_PUMP_STATE = 16, //!< Current computed pump state (read only) (see @ref EN_PumpStateType)
|
||||
EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency (read only)
|
||||
EN_PUMP_POWER = 18, //!< Pump constant power rating
|
||||
EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve index
|
||||
EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve index
|
||||
EN_PUMP_ECOST = 21, //!< Pump average energy price
|
||||
EN_PUMP_EPAT = 22 //!< Pump energy price time pattern index
|
||||
} EN_LinkProperty;
|
||||
|
||||
/// Time parameters
|
||||
/**
|
||||
These time parameters are accessed using @ref EN_gettimeparam and@ref EN_settimeparam.
|
||||
All times are expressed in seconds The parameters marked as read only are
|
||||
computed values that can only be retrieved.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_DURATION = 0, //!< Total simulation duration
|
||||
EN_HYDSTEP = 1, //!< Hydraulic time step
|
||||
EN_QUALSTEP = 2, //!< Water quality time step
|
||||
EN_PATTERNSTEP = 3, //!< Time pattern period
|
||||
EN_PATTERNSTART = 4, //!< Time when time patterns begin
|
||||
EN_REPORTSTEP = 5, //!< Reporting time step
|
||||
EN_REPORTSTART = 6, //!< Time when reporting starts
|
||||
EN_RULESTEP = 7, //!< Rule-based control evaluation time step
|
||||
EN_STATISTIC = 8, //!< Reporting statistic code (see @ref EN_StatisticType)
|
||||
EN_PERIODS = 9, //!< Number of reporting time periods (read only)
|
||||
EN_STARTTIME = 10, //!< Simulation starting time of day
|
||||
EN_HTIME = 11, //!< Elapsed time of current hydraulic solution (read only)
|
||||
EN_QTIME = 12, //!< Elapsed time of current quality solution (read only)
|
||||
EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted (read only)
|
||||
EN_NEXTEVENT = 14, //!< Shortest time until a tank becomes empty or full (read only)
|
||||
EN_NEXTEVENTTANK = 15 //!< Index of tank with shortest time to become empty or full (read only)
|
||||
} EN_TimeParameter;
|
||||
|
||||
/// Analysis convergence statistics
|
||||
/**
|
||||
These statistics report the convergence criteria for the most current hydraulic analysis
|
||||
and the cumulative water quality mass balance error at the current simulation time. They
|
||||
can be retrieved with @ref EN_getstatistic.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_ITERATIONS = 0, //!< Number of hydraulic iterations taken
|
||||
EN_RELATIVEERROR = 1, //!< Sum of link flow changes / sum of link flows
|
||||
EN_MAXHEADERROR = 2, //!< Largest head loss error for links
|
||||
EN_MAXFLOWCHANGE = 3, //!< Largest flow change in links
|
||||
EN_MASSBALANCE = 4 //!< Cumulative water quality mass balance ratio
|
||||
} EN_AnalysisStatistic;
|
||||
|
||||
/// Types of network objects
|
||||
/**
|
||||
A network model is composed of these types of objects.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_NODE = 0, //!< Nodes
|
||||
EN_LINK = 1, //!< Links
|
||||
EN_TIMEPAT = 2, //!< Time patterns
|
||||
EN_CURVE = 3, //!< Data curves
|
||||
EN_CONTROL = 4, //!< Simple controls
|
||||
EN_RULE = 5 //!< Control rules
|
||||
} EN_ObjectType;
|
||||
|
||||
/// Types of objects to count
|
||||
/**
|
||||
These options tell @ref EN_getcount which type of object to count.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_NODECOUNT = 0, //!< Number of nodes (junctions + tanks + reservoirs)
|
||||
EN_TANKCOUNT = 1, //!< Number of tanks and reservoirs
|
||||
EN_LINKCOUNT = 2, //!< Number of links (pipes + pumps + valves)
|
||||
EN_PATCOUNT = 3, //!< Number of time patterns
|
||||
EN_CURVECOUNT = 4, //!< Number of data curves
|
||||
EN_CONTROLCOUNT = 5, //!< Number of simple controls
|
||||
EN_RULECOUNT = 6 //!< Number of rule-based controls
|
||||
} EN_CountType;
|
||||
|
||||
/// Types of nodes
|
||||
/**
|
||||
These are the different types of nodes that can be returned by calling @ref EN_getnodetype.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_JUNCTION = 0, //!< Junction node
|
||||
EN_RESERVOIR = 1, //!< Reservoir node
|
||||
EN_TANK = 2 //!< Storage tank node
|
||||
} EN_NodeType;
|
||||
|
||||
/// Types of links
|
||||
/**
|
||||
These are the different types of links that can be returned by calling @ref EN_getlinktype.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_CVPIPE = 0, //!< Pipe with check valve
|
||||
EN_PIPE = 1, //!< Pipe
|
||||
EN_PUMP = 2, //!< Pump
|
||||
EN_PRV = 3, //!< Pressure reducing valve
|
||||
EN_PSV = 4, //!< Pressure sustaining valve
|
||||
EN_PBV = 5, //!< Pressure breaker valve
|
||||
EN_FCV = 6, //!< Flow control valve
|
||||
EN_TCV = 7, //!< Throttle control valve
|
||||
EN_GPV = 8 //!< General purpose valve
|
||||
} EN_LinkType;
|
||||
|
||||
/// Link status
|
||||
/**
|
||||
One of these values is returned when @ref EN_getlinkvalue is used to retrieve a link's
|
||||
initial status (EN_INITSTATUS) or its current status (EN_STATUS). These options are
|
||||
also used with @ref EN_setlinkvalue to set values for these same properties.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_CLOSED = 0,
|
||||
EN_OPEN = 1
|
||||
} EN_LinkStatusType;
|
||||
|
||||
/// Pump states
|
||||
/**
|
||||
One of these codes is returned when @ref EN_getlinkvalue is used to retrieve a pump's
|
||||
current operating state (EN_PUMP_STATE). EN_PUMP_XHEAD indicates that the pump has been
|
||||
shut down because it is being asked to deliver more than its shutoff head. EN_PUMP_XFLOW
|
||||
indicates that the pump is being asked to deliver more than its maximum flow.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_PUMP_XHEAD = 0, //!< Pump closed - cannot supply head
|
||||
EN_PUMP_CLOSED = 2, //!< Pump closed
|
||||
EN_PUMP_OPEN = 3, //!< Pump open
|
||||
EN_PUMP_XFLOW = 5 //!< Pump open - cannot supply flow
|
||||
} EN_PumpStateType;
|
||||
|
||||
/// Types of water quality analyses
|
||||
/**
|
||||
These are the different types of water quality analyses that EPANET can run. They
|
||||
are used with @ref EN_getqualinfo, @ref EN_getqualtype, and @ref EN_setqualtype.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_NONE = 0, //!< No quality analysis
|
||||
EN_CHEM = 1, //!< Chemical fate and transport
|
||||
EN_AGE = 2, //!< Water age analysis
|
||||
EN_TRACE = 3 //!< Source tracing analysis
|
||||
} EN_QualityType;
|
||||
|
||||
/// Types of water quality sources
|
||||
/**
|
||||
These are the options for EN_SOURCETYPE, the type of external water quality
|
||||
source assigned to a node. They are used in @ref EN_getnodevalue and @ref EN_setnodevalue.
|
||||
The EN_SOURCEQUAL property is used in these functions to access a source's strength
|
||||
and EN_SOURCEPATTERN to access a time pattern applied to the source.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_CONCEN = 0, //!< Concentration of any external inflow entering a node
|
||||
EN_MASS = 1, //!< Injects a given mass/minute into a node
|
||||
EN_SETPOINT = 2, //!< Sets the concentration leaving a node to a given value
|
||||
EN_FLOWPACED = 3 //!< Adds a given value to the concentration leaving a node
|
||||
} EN_SourceType;
|
||||
|
||||
/// Head loss formula choices
|
||||
/**
|
||||
These are the choices for the EN_HEADLOSSFORM option in @ref EN_getoption and
|
||||
@ref EN_setoption. They are also used for the head loss type argument in @ref EN_init.
|
||||
Each head loss formula uses a different type of roughness coefficient (EN_ROUGHNESS)
|
||||
that can be set with @ref EN_setlinkvalue.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_HW = 0, //!< Hazen-Williams
|
||||
EN_DW = 1, //!< Darcy-Weisbach
|
||||
EN_CM = 2 //!< Chezy-Manning
|
||||
} EN_HeadLossType;
|
||||
|
||||
/// Flow units choices
|
||||
/**
|
||||
These choices for flow units are used with @ref EN_getflowunits and @ref EN_setflowunits.
|
||||
They are also used for the flow units type argument in @ref EN_init. If flow units are
|
||||
expressed in US Customary units (EN_CFS through EN_AFD) then all other quantities are
|
||||
in US Customary units. Otherwise they are in metric units.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_CFS = 0, //!< Cubic feet per second
|
||||
EN_GPM = 1, //!< Gallons per minute
|
||||
EN_MGD = 2, //!< Million gallons per day
|
||||
EN_IMGD = 3, //!< Imperial million gallons per day
|
||||
EN_AFD = 4, //!< Acre-feet per day
|
||||
EN_LPS = 5, //!< Liters per second
|
||||
EN_LPM = 6, //!< Liters per minute
|
||||
EN_MLD = 7, //!< Million liters per day
|
||||
EN_CMH = 8, //!< Cubic meters per hour
|
||||
EN_CMD = 9 //!< Cubic meters per day
|
||||
} EN_FlowUnits;
|
||||
|
||||
/// Types of demand models
|
||||
/**
|
||||
These choices for representing consumer demands are used with @ref EN_getdemandmodel
|
||||
and @ref EN_setdemandmodel.
|
||||
|
||||
A demand driven analysis requires that a junction's full demand be supplied
|
||||
in each time period independent of how much pressure is available. A pressure
|
||||
driven analysis makes demand be a power function of pressure, up to the point
|
||||
where the full demand is met.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_DDA = 0, //!< Demand driven analysis
|
||||
EN_PDA = 1 //!< Pressure driven analysis
|
||||
} EN_DemandModel;
|
||||
|
||||
/// Simulation options
|
||||
/**
|
||||
These constants identify the hydraulic and water quality simulation options
|
||||
that are applied on a network-wide basis. They are accessed using the
|
||||
@ref EN_getoption and @ref EN_setoption functions.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_TRIALS = 0, //!< Maximum hydraulic trials allowed for hydraulic convergence
|
||||
EN_ACCURACY = 1, //!< Total normalized flow change for hydraulic convergence
|
||||
EN_TOLERANCE = 2, //!< Water quality tolerance
|
||||
EN_EMITEXPON = 3, //!< Exponent in emitter discharge formula
|
||||
EN_DEMANDMULT = 4, //!< Global demand multiplier
|
||||
EN_HEADERROR = 5, //!< Maximum head loss error for hydraulic convergence
|
||||
EN_FLOWCHANGE = 6, //!< Maximum flow change for hydraulic convergence
|
||||
EN_HEADLOSSFORM = 7, //!< Head loss formula (see @ref EN_HeadLossType)
|
||||
EN_GLOBALEFFIC = 8, //!< Global pump efficiency (percent)
|
||||
EN_GLOBALPRICE = 9, //!< Global energy price per KWH
|
||||
EN_GLOBALPATTERN = 10, //!< Index of a global energy price pattern
|
||||
EN_DEMANDCHARGE = 11, //!< Energy charge per max. KW usage
|
||||
EN_SP_GRAVITY = 12, //!< Specific gravity
|
||||
EN_SP_VISCOS = 13, //!< Specific viscosity (relative to water at 20 deg C)
|
||||
EN_UNBALANCED = 14, //!< Extra trials allowed if hydraulics don't converge
|
||||
EN_CHECKFREQ = 15, //!< Frequency of hydraulic status checks
|
||||
EN_MAXCHECK = 16, //!< Maximum trials for status checking
|
||||
EN_DAMPLIMIT = 17, //!< Accuracy level where solution damping begins
|
||||
EN_SP_DIFFUS = 18, //!< Specific diffusivity (relative to chlorine at 20 deg C)
|
||||
EN_BULKORDER = 19, //!< Bulk water reaction order for pipes
|
||||
EN_WALLORDER = 20, //!< Wall reaction order for pipes (either 0 or 1)
|
||||
EN_TANKORDER = 21, //!< Bulk water reaction order for tanks
|
||||
EN_CONCENLIMIT = 22 //!< Limiting concentration for growth reactions
|
||||
} EN_Option;
|
||||
|
||||
/// Types of simple controls
|
||||
/**
|
||||
These are the different types of simple (single statement) controls that can be applied
|
||||
to network links. They are used as an argument to @ref EN_addcontrol,@ref EN_getcontrol,
|
||||
and @ref EN_setcontrol.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_LOWLEVEL = 0, //!< Act when pressure or tank level drops below a setpoint
|
||||
EN_HILEVEL = 1, //!< Act when pressure or tank level rises above a setpoint
|
||||
EN_TIMER = 2, //!< Act at a prescribed elapsed amount of time
|
||||
EN_TIMEOFDAY = 3 //!< Act at a particular time of day
|
||||
} EN_ControlType;
|
||||
|
||||
/// Reporting statistic choices
|
||||
/**
|
||||
These options determine what kind of statistical post-processing should be done on
|
||||
the time series of simulation results generated before they are reported using
|
||||
@ref EN_report. An option can be chosen by using `STATISTIC option` as the argument
|
||||
to @ref EN_setreport.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_SERIES = 0, //!< Report all time series points
|
||||
EN_AVERAGE = 1, //!< Report average value over simulation period
|
||||
EN_MINIMUM = 2, //!< Report minimum value over simulation period
|
||||
EN_MAXIMUM = 3, //!< Report maximum value over simulation period
|
||||
EN_RANGE = 4 //!< Report maximum - minimum over simulation period
|
||||
} EN_StatisticType;
|
||||
|
||||
/// Tank mixing models
|
||||
/**
|
||||
These are the different types of models that describe water quality mixing in storage tanks.
|
||||
The choice of model is accessed with the EN_MIXMODEL property of a Tank node using
|
||||
@ref EN_getnodevalue and @ref EN_setnodevalue.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_MIX1 = 0, //!< Complete mix model
|
||||
EN_MIX2 = 1, //!< 2-compartment model
|
||||
EN_FIFO = 2, //!< First in, first out model
|
||||
EN_LIFO = 3 //!< Last in, first out model
|
||||
} EN_MixingModel;
|
||||
|
||||
/// Hydraulic initialization options
|
||||
/**
|
||||
These options are used to initialize a new hydraulic analysis when @ref EN_initH is called.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_NOSAVE = 0, //!< Don't save hydraulics; don't re-initialize flows
|
||||
EN_SAVE = 1, //!< Save hydraulics to file, don't re-initialize flows
|
||||
EN_INITFLOW = 10, //!< Don't save hydraulics; re-initialize flows
|
||||
EN_SAVE_AND_INIT = 11 //!< Save hydraulics; re-initialize flows
|
||||
} EN_InitHydOption;
|
||||
|
||||
/// Types of pump curves
|
||||
/**
|
||||
@ref EN_getpumptype returns one of these values when it is called.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_CONST_HP = 0, //!< Constant horsepower
|
||||
EN_POWER_FUNC = 1, //!< Power function
|
||||
EN_CUSTOM = 2, //!< User-defined custom curve
|
||||
EN_NOCURVE = 3 //!< No curve
|
||||
} EN_PumpType;
|
||||
|
||||
/// Types of data curves
|
||||
/**
|
||||
These are the different types of physical relationships that a data curve could
|
||||
represent as returned by calling @ref EN_getcurvetype.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_VOLUME_CURVE = 0, //!< Tank volume v. depth curve
|
||||
EN_PUMP_CURVE = 1, //!< Pump head v. flow curve
|
||||
EN_EFFIC_CURVE = 2, //!< Pump efficiency v. flow curve
|
||||
EN_HLOSS_CURVE = 3, //!< Valve head loss v. flow curve
|
||||
EN_GENERIC_CURVE = 4 //!< Generic curve
|
||||
} EN_CurveType;
|
||||
|
||||
/// Deletion action codes
|
||||
/**
|
||||
These codes are used in @ref EN_deletenode and @ref EN_deletelink to indicate what action
|
||||
should be taken if the node or link being deleted appears in any simple or rule-based
|
||||
controls.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_UNCONDITIONAL = 0, //!< Delete all controls that contain object
|
||||
EN_CONDITIONAL = 1 //!< Cancel object deletion if contained in controls
|
||||
} EN_ActionCodeType;
|
||||
|
||||
/// Status reporting levels
|
||||
/**
|
||||
These choices specify the level of status reporting written to a project's report
|
||||
file during a hydraulic analysis. The level is set using the @ref EN_setstatusreport function.
|
||||
*/
|
||||
typedef enum {
|
||||
EN_NO_REPORT = 0, //!< No status reporting
|
||||
EN_NORMAL_REPORT = 1, //!< Normal level of status reporting
|
||||
EN_FULL_REPORT = 2 //!< Full level of status reporting
|
||||
} EN_StatusReport;
|
||||
|
||||
/// Network objects used in rule-based controls
|
||||
typedef enum {
|
||||
EN_R_NODE = 6, //!< Clause refers to a node
|
||||
EN_R_LINK = 7, //!< Clause refers to a link
|
||||
EN_R_SYSTEM = 8 //!< Clause refers to a system parameter (e.g., time)
|
||||
} EN_RuleObject;
|
||||
|
||||
/// Object variables used in rule-based controls
|
||||
typedef enum {
|
||||
EN_R_DEMAND = 0, //!< Nodal demand
|
||||
EN_R_HEAD = 1, //!< Nodal hydraulic head
|
||||
EN_R_GRADE = 2, //!< Nodal hydraulic grade
|
||||
EN_R_LEVEL = 3, //!< Tank water level
|
||||
EN_R_PRESSURE = 4, //!< Nodal pressure
|
||||
EN_R_FLOW = 5, //!< Link flow rate
|
||||
EN_R_STATUS = 6, //!< Link status
|
||||
EN_R_SETTING = 7, //!< Link setting
|
||||
EN_R_POWER = 8, //!< Pump power output
|
||||
EN_R_TIME = 9, //!< Elapsed simulation time
|
||||
EN_R_CLOCKTIME = 10, //!< Time of day
|
||||
EN_R_FILLTIME = 11, //!< Time to fill a tank
|
||||
EN_R_DRAINTIME = 12 //!< Time to drain a tank
|
||||
} EN_RuleVariable;
|
||||
|
||||
/// Comparison operators used in rule-based controls
|
||||
typedef enum {
|
||||
EN_R_EQ = 0, //!< Equal to
|
||||
EN_R_NE = 1, //!< Not equal
|
||||
EN_R_LE = 2, //!< Less than or equal to
|
||||
EN_R_GE = 3, //!< Greater than or equal to
|
||||
EN_R_LT = 4, //!< Less than
|
||||
EN_R_GT = 5, //!< Greater than
|
||||
EN_R_IS = 6, //!< Is equal to
|
||||
EN_R_NOT = 7, //!< Is not equal to
|
||||
EN_R_BELOW = 8, //!< Is below
|
||||
EN_R_ABOVE = 9 //!< Is above
|
||||
} EN_RuleOperator;
|
||||
|
||||
/// Link status codes used in rule-based controls
|
||||
typedef enum {
|
||||
EN_R_IS_OPEN = 1, //!< Link is open
|
||||
EN_R_IS_CLOSED = 2, //!< Link is closed
|
||||
EN_R_IS_ACTIVE = 3 //!< Control valve is active
|
||||
} EN_RuleStatus;
|
||||
|
||||
|
||||
#endif //EPANET2_ENUMS_H
|
||||
178
include/epanet_py.h
Normal file
178
include/epanet_py.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: epanet_py.h
|
||||
Description: EPANET API functions for Python SWIG wrap
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 02/08/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EPANET_PY_H
|
||||
#define EPANET_PY_H
|
||||
|
||||
|
||||
// Opaque pointer to project
|
||||
typedef void *Handle;
|
||||
|
||||
|
||||
#include "epanet2_enums.h"
|
||||
#include "epanet_py_export.h"
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int EXPORT_PY_API proj_create(Handle *ph_out);
|
||||
int EXPORT_PY_API proj_delete(Handle *ph_inout);
|
||||
int EXPORT_PY_API proj_run(Handle ph, const char *input_path, const char *report_path, const char *output_path);
|
||||
int EXPORT_PY_API proj_init(Handle ph, const char *rptFile, const char *outFile, EN_FlowUnits unitsType, EN_HeadLossType headLossType);
|
||||
int EXPORT_PY_API proj_open(Handle ph, const char *inpFile, const char *rptFile, const char *binOutFile);
|
||||
int EXPORT_PY_API proj_gettitle(Handle ph, char *line1, char *line2, char *line3);
|
||||
int EXPORT_PY_API proj_settitle(Handle ph, const char *line1, const char *line2, const char *line3);
|
||||
int EXPORT_PY_API proj_getcount(Handle ph, EN_CountType code, int *count);
|
||||
int EXPORT_PY_API proj_savefile(Handle ph, const char *inpfilename);
|
||||
int EXPORT_PY_API proj_close(Handle ph);
|
||||
|
||||
|
||||
int EXPORT_PY_API hydr_solve(Handle ph);
|
||||
int EXPORT_PY_API hydr_save(Handle ph);
|
||||
int EXPORT_PY_API hydr_open(Handle ph);
|
||||
int EXPORT_PY_API hydr_init(Handle ph, EN_InitHydOption saveFlag);
|
||||
int EXPORT_PY_API hydr_run(Handle ph, long *currentTime);
|
||||
int EXPORT_PY_API hydr_next(Handle ph, long *tStep);
|
||||
int EXPORT_PY_API hydr_close(Handle ph);
|
||||
int EXPORT_PY_API hydr_savefile(Handle ph, char *filename);
|
||||
int EXPORT_PY_API hydr_usefile(Handle ph, char *filename);
|
||||
|
||||
|
||||
int EXPORT_PY_API qual_solve(Handle ph);
|
||||
int EXPORT_PY_API qual_open(Handle ph);
|
||||
int EXPORT_PY_API qual_init(Handle ph, EN_InitHydOption saveFlag);
|
||||
int EXPORT_PY_API qual_run(Handle ph, long *currentTime);
|
||||
int EXPORT_PY_API qual_next(Handle ph, long *tStep);
|
||||
int EXPORT_PY_API qual_step(Handle ph, long *timeLeft);
|
||||
int EXPORT_PY_API qual_close(Handle ph);
|
||||
|
||||
|
||||
int EXPORT_PY_API rprt_writeline(Handle ph, char *line);
|
||||
int EXPORT_PY_API rprt_writeresults(Handle ph);
|
||||
int EXPORT_PY_API rprt_clear(Handle ph);
|
||||
int EXPORT_PY_API rprt_reset(Handle ph);
|
||||
int EXPORT_PY_API rprt_set(Handle ph, char *reportCommand);
|
||||
int EXPORT_PY_API rprt_setlevel(Handle ph, EN_StatusReport code);
|
||||
int EXPORT_PY_API rprt_anlysstats(Handle ph, EN_AnalysisStatistic code, double* value);
|
||||
|
||||
|
||||
int EXPORT_PY_API anlys_getoption(Handle ph, EN_Option code, double *value);
|
||||
int EXPORT_PY_API anlys_setoption(Handle ph, EN_Option code, double value);
|
||||
int EXPORT_PY_API anlys_getflowunits(Handle ph, int *code);
|
||||
int EXPORT_PY_API anlys_setflowunits(Handle ph, EN_FlowUnits code);
|
||||
int EXPORT_PY_API anlys_gettimeparam(Handle ph, EN_TimeParameter code, long *value);
|
||||
int EXPORT_PY_API anlys_settimeparam(Handle ph, EN_TimeParameter code, long value);
|
||||
int EXPORT_PY_API anlys_getqualinfo(Handle ph, int *qualcode, char *chemname, char *chemunits, int *tracenode);
|
||||
int EXPORT_PY_API anlys_getqualtype(Handle ph, int *qualcode, int *tracenode);
|
||||
int EXPORT_PY_API anlys_setqualtype(Handle ph, EN_QualityType qualcode, char *chemname, char *chemunits, char *tracenode);
|
||||
|
||||
|
||||
int EXPORT_PY_API node_add(Handle ph, char *id, EN_NodeType nodeType, int *index);
|
||||
int EXPORT_PY_API node_delete(Handle ph, int index, int actionCode);
|
||||
int EXPORT_PY_API node_getindex(Handle ph, char *id, int *index);
|
||||
int EXPORT_PY_API node_getid(Handle ph, int index, char *id);
|
||||
int EXPORT_PY_API node_setid(Handle ph, int index, char *newid);
|
||||
int EXPORT_PY_API node_gettype(Handle ph, int index, int *code);
|
||||
int EXPORT_PY_API node_getvalue(Handle ph, int index, EN_NodeProperty code, double *value);
|
||||
int EXPORT_PY_API node_setvalue(Handle ph, int index, EN_NodeProperty code, double value);
|
||||
int EXPORT_PY_API node_getcoord(Handle ph, int index, double *x, double *y);
|
||||
int EXPORT_PY_API node_setcoord(Handle ph, int index, double x, double y);
|
||||
|
||||
|
||||
int EXPORT_PY_API dmnd_getmodel(Handle ph, int *type, double *pmin, double *preq, double *pexp);
|
||||
int EXPORT_PY_API dmnd_setmodel(Handle ph, int type, double pmin, double preq, double pexp);
|
||||
int EXPORT_PY_API dmnd_getcount(Handle ph, int nodeIndex, int *numDemands);
|
||||
int EXPORT_PY_API dmnd_getbase(Handle ph, int nodeIndex, int demandIndex, double *baseDemand);
|
||||
int EXPORT_PY_API dmnd_setbase(Handle ph, int nodeIndex, int demandIndex, double baseDemand);
|
||||
int EXPORT_PY_API dmnd_getpattern(Handle ph, int nodeIndex, int demandIndex, int *pattIndex);
|
||||
int EXPORT_PY_API dmnd_setpattern(Handle ph, int nodeIndex, int demandIndex, int patIndex);
|
||||
int EXPORT_PY_API dmnd_getname(Handle ph, int nodeIndex, int demandIdx, char *demandName);
|
||||
int EXPORT_PY_API dmnd_setname(Handle ph, int nodeIndex, int demandIdx, char *demandName);
|
||||
|
||||
|
||||
int EXPORT_PY_API link_add(Handle ph, char *id, EN_LinkType linkType, char *fromNode, char *toNode, int *index);
|
||||
int EXPORT_PY_API link_delete(Handle ph, int index, int actionCode);
|
||||
int EXPORT_PY_API link_getindex(Handle ph, char *id, int *index);
|
||||
int EXPORT_PY_API link_getid(Handle ph, int index, char *id);
|
||||
int EXPORT_PY_API link_setid(Handle ph, int index, char *newid);
|
||||
int EXPORT_PY_API link_gettype(Handle ph, int index, int *code);
|
||||
int EXPORT_PY_API link_settype(Handle ph, int *index, EN_LinkType type, int actionCode);
|
||||
int EXPORT_PY_API link_getnodes(Handle ph, int index, int *node1, int *node2);
|
||||
int EXPORT_PY_API link_setnodes(Handle ph, int index, int node1, int node2);
|
||||
int EXPORT_PY_API link_getvalue(Handle ph, int index, EN_LinkProperty code, double *value);
|
||||
int EXPORT_PY_API link_setvalue(Handle ph, int index, int code, double v);
|
||||
|
||||
|
||||
int EXPORT_PY_API pump_gettype(Handle ph, int linkIndex, int *outType);
|
||||
int EXPORT_PY_API pump_getheadcurveindex(Handle ph, int pumpIndex, int *curveIndex);
|
||||
int EXPORT_PY_API pump_setheadcurveindex(Handle ph, int pumpIndex, int curveIndex);
|
||||
|
||||
|
||||
int EXPORT_PY_API ptrn_add(Handle ph, char *id);
|
||||
int EXPORT_PY_API ptrn_getindex(Handle ph, char *id, int *index);
|
||||
int EXPORT_PY_API ptrn_getid(Handle ph, int index, char *id);
|
||||
int EXPORT_PY_API ptrn_getlength(Handle ph, int index, int *len);
|
||||
int EXPORT_PY_API ptrn_getvalue(Handle ph, int index, int period, double *value);
|
||||
int EXPORT_PY_API ptrn_setvalue(Handle ph, int index, int period, double value);
|
||||
int EXPORT_PY_API ptrn_getavgvalue(Handle ph, int index, double *value);
|
||||
int EXPORT_PY_API ptrn_set(Handle ph, int index, double *f, int len);
|
||||
|
||||
|
||||
int EXPORT_PY_API curv_add(Handle ph, char *id);
|
||||
int EXPORT_PY_API curv_getindex(Handle ph, char *id, int *index);
|
||||
int EXPORT_PY_API curv_getid(Handle ph, int index, char *id);
|
||||
int EXPORT_PY_API curv_getlength(Handle ph, int index, int *len);
|
||||
int EXPORT_PY_API curv_gettype(Handle ph, int curveIndex, int *outType);
|
||||
int EXPORT_PY_API curv_getvalue(Handle ph, int curveIndex, int pointIndex, double *x, double *y);
|
||||
int EXPORT_PY_API curv_setvalue(Handle ph, int curveIndex, int pointIndex, double x, double y);
|
||||
int EXPORT_PY_API curv_get(Handle ph, int curveIndex, char* id, int *nValues, double *xValues, double *yValues);
|
||||
int EXPORT_PY_API curv_set(Handle ph, int index, double *x, double *y, int len);
|
||||
|
||||
int EXPORT_PY_API scntl_add(Handle ph, int type, int linkIndex, double setting, int nodeIndex, double level, int *index);
|
||||
int EXPORT_PY_API scntl_delete(Handle ph, int index);
|
||||
int EXPORT_PY_API scntl_get(Handle ph, int controlIndex, int *controlType, int *linkIndex, double *setting, int *nodeIndex, double *level);
|
||||
int EXPORT_PY_API scntl_set(Handle ph, int cindex, int ctype, int lindex, double setting, int nindex, double level);
|
||||
|
||||
|
||||
int EXPORT_PY_API rcntl_add(Handle ph, char *rule);
|
||||
int EXPORT_PY_API rcntl_delete(Handle ph, int index);
|
||||
int EXPORT_PY_API rcntl_get(Handle ph, int index, int *nPremises, int *nThenActions, int *nElseActions, double *priority);
|
||||
int EXPORT_PY_API rcntl_getid(Handle ph, int index, char* id);
|
||||
int EXPORT_PY_API rcntl_getpremise(Handle ph, int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex, int *variable, int *relop, int *status, double *value);
|
||||
int EXPORT_PY_API rcntl_setpremise(Handle ph, int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, double value);
|
||||
int EXPORT_PY_API rcntl_setpremiseindex(Handle ph, int ruleIndex, int premiseIndex, int objIndex);
|
||||
int EXPORT_PY_API rcntl_setpremisestatus(Handle ph, int ruleIndex, int premiseIndex, int status);
|
||||
int EXPORT_PY_API rcntl_setpremisevalue(Handle ph, int ruleIndex, int premiseIndex, double value);
|
||||
int EXPORT_PY_API rcntl_getthenaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting);
|
||||
int EXPORT_PY_API rcntl_setthenaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting);
|
||||
int EXPORT_PY_API rcntl_getelseaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting);
|
||||
int EXPORT_PY_API rcntl_setelseaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting);
|
||||
int EXPORT_PY_API rcntl_setrulepriority(Handle ph, int index, double priority);
|
||||
|
||||
|
||||
void EXPORT_PY_API err_clear(Handle ph);
|
||||
int EXPORT_PY_API err_check(Handle ph, char** msg_buffer);
|
||||
void EXPORT_PY_API toolkit_free(void **memory);
|
||||
int EXPORT_PY_API toolkit_getversion(int *version);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif //EPANET_PY_H
|
||||
27
run/CMakeLists.txt
Normal file
27
run/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
# EPANET COMMAND LINE EXECUTABLE
|
||||
cmake_minimum_required (VERSION 3.0.2)
|
||||
|
||||
|
||||
# Sets for output directory for executables and libraries.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
# Sets the position independent code property for all targets.
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
|
||||
# Set up file groups for exe target
|
||||
set(EPANET_CLI_SOURCES main.c)
|
||||
include_directories(include)
|
||||
|
||||
source_group("CLI" FILES ${EPANET_CLI_SOURCES})
|
||||
|
||||
|
||||
# Creates the EPANET command line executable
|
||||
add_executable(runepanet ${EPANET_CLI_SOURCES})
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(runepanet LINK_PUBLIC epanet2 m)
|
||||
else(NOT WIN32)
|
||||
target_link_libraries(runepanet LINK_PUBLIC epanet2)
|
||||
endif(NOT WIN32)
|
||||
93
run/main.c
Normal file
93
run/main.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: main.c
|
||||
Description: main stub for a command line executable version of EPANET
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 12/07/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "epanet2.h"
|
||||
|
||||
void writeConsole(char *s)
|
||||
{
|
||||
fprintf(stdout, "\r%s", s);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
/*--------------------------------------------------------------
|
||||
** Input: argc = number of command line arguments
|
||||
** *argv[] = array of command line arguments
|
||||
** Output: none
|
||||
** Purpose: main program stub for command line EPANET
|
||||
**
|
||||
** Command line for stand-alone operation is:
|
||||
** progname f1 f2 f3
|
||||
** where progname = name of executable this code was compiled to,
|
||||
** f1 = name of input file,
|
||||
** f2 = name of report file
|
||||
** f3 = name of binary output file (optional).
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
char *f1,*f2,*f3;
|
||||
char blank[] = "";
|
||||
char errmsg[256] = "";
|
||||
int errcode;
|
||||
int version;
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
|
||||
// Check for proper number of command line arguments
|
||||
if (argc < 3)
|
||||
{
|
||||
printf(
|
||||
"\nUsage:\n %s <input_filename> <report_filename> [<binary_filename>]\n",
|
||||
argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get version number and display in Major.Minor.Patch format
|
||||
ENgetversion(&version);
|
||||
major = version/10000;
|
||||
minor = (version%10000)/100;
|
||||
patch = version%100;
|
||||
printf("\n... Running EPANET Version %d.%d.%d\n", major, minor, patch);
|
||||
|
||||
// Assign pointers to file names
|
||||
f1 = argv[1];
|
||||
f2 = argv[2];
|
||||
if (argc > 3) f3 = argv[3];
|
||||
else f3 = blank;
|
||||
|
||||
// Run EPANET
|
||||
errcode = ENepanet(f1, f2, f3, &writeConsole);
|
||||
|
||||
// Blank out the last progress message
|
||||
printf("\r ");
|
||||
|
||||
// Check for errors/warnings and report accordingly
|
||||
if (errcode == 0)
|
||||
{
|
||||
printf("\n... EPANET ran successfully.\n");
|
||||
return 0;
|
||||
}
|
||||
else if (errcode < 100)
|
||||
{
|
||||
printf("\n... EPANET ran with warnings - check the Status Report.\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ENgeterror(errcode, errmsg, 255);
|
||||
printf("\n... EPANET failed with %s.\n", errmsg);
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
133
src/demand.c
Normal file
133
src/demand.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: demand.c
|
||||
Description: data for demand pattern list
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 04/12/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "demand.h"
|
||||
|
||||
|
||||
typedef struct demand_data_s
|
||||
{
|
||||
double base_demand;
|
||||
int pattern_index;
|
||||
char *category_name;
|
||||
} demand_data_t;
|
||||
|
||||
|
||||
|
||||
list_t *create_demand_list(double base_demand, int pattern_index, const char *category_name)
|
||||
{
|
||||
list_t *demand_list;
|
||||
demand_data_t *demand_data;
|
||||
|
||||
demand_list = create_list(get_demand_data_size(), delete_demand_data);
|
||||
if (!demand_list) return NULL;
|
||||
|
||||
demand_data = create_demand_data(base_demand, pattern_index, category_name);
|
||||
if (!demand_data) return NULL;
|
||||
|
||||
append_list(demand_list, &demand_data);
|
||||
|
||||
return demand_list;
|
||||
}
|
||||
|
||||
|
||||
demand_data_t *create_demand_data(double base_demand, int pattern_index, const char *category_name)
|
||||
{
|
||||
demand_data_t *demand_data = (demand_data_t *)malloc(sizeof(demand_data_t));
|
||||
|
||||
demand_data->base_demand = base_demand;
|
||||
demand_data->pattern_index = pattern_index;
|
||||
|
||||
if (category_name)
|
||||
demand_data->category_name = strdup(category_name);
|
||||
else
|
||||
demand_data->category_name = NULL;
|
||||
|
||||
return demand_data;
|
||||
}
|
||||
|
||||
void delete_demand_data(void *data)
|
||||
{
|
||||
demand_data_t *demand_data = *(demand_data_t **)data;
|
||||
|
||||
if (demand_data->category_name)
|
||||
free(demand_data->category_name);
|
||||
|
||||
free(demand_data);
|
||||
}
|
||||
|
||||
size_t get_demand_data_size(void)
|
||||
{
|
||||
return sizeof(demand_data_t *);
|
||||
}
|
||||
|
||||
demand_data_t *get_demand_data(list_node_t *lnode)
|
||||
{
|
||||
return *(demand_data_t **)get_data(lnode);
|
||||
}
|
||||
|
||||
|
||||
bool convert_units(list_node_t *lnode, double unit_conversion)
|
||||
{
|
||||
double base_demand = get_base_demand(lnode);
|
||||
|
||||
set_base_demand(lnode, base_demand/unit_conversion);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
double get_base_demand(list_node_t *lnode)
|
||||
{
|
||||
return get_demand_data(lnode)->base_demand;
|
||||
}
|
||||
|
||||
void set_base_demand(list_node_t *lnode, double base_demand)
|
||||
{
|
||||
get_demand_data(lnode)->base_demand = base_demand;
|
||||
}
|
||||
|
||||
int get_pattern_index(list_node_t *lnode)
|
||||
{
|
||||
return get_demand_data(lnode)->pattern_index;
|
||||
}
|
||||
|
||||
void set_pattern_index(list_node_t *lnode, int pattern_index)
|
||||
{
|
||||
get_demand_data(lnode)->pattern_index = pattern_index;
|
||||
}
|
||||
|
||||
char *get_category_name(list_node_t *lnode)
|
||||
// Be advised: caller must free memory returned
|
||||
{
|
||||
char *temp = get_demand_data(lnode)->category_name;
|
||||
|
||||
if (temp)
|
||||
return strdup(temp);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void set_category_name(list_node_t *lnode, const char *category_name)
|
||||
{
|
||||
free(get_demand_data(lnode)->category_name);
|
||||
get_demand_data(lnode)->category_name = strdup(category_name);
|
||||
}
|
||||
63
src/demand.h
Normal file
63
src/demand.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: demand.h
|
||||
Description: data for demand pattern list
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 04/12/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef DEMAND_H
|
||||
#define DEMAND_H
|
||||
|
||||
|
||||
#include "util/list.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// Forward declarations
|
||||
typedef struct demand_data_s demand_data_t;
|
||||
|
||||
// demand list gets declared in types.h struct Snode
|
||||
|
||||
|
||||
list_t *create_demand_list(double base_demand, int pattern_index, const char *category_name);
|
||||
|
||||
|
||||
demand_data_t *create_demand_data(double base_demand, int pat_index, const char *cat_name);
|
||||
|
||||
void delete_demand_data(void *data);
|
||||
|
||||
size_t get_demand_data_size(void);
|
||||
|
||||
|
||||
bool convert_units(list_node_t *lnode, double unit_conversion);
|
||||
|
||||
|
||||
double get_base_demand(list_node_t *lnode);
|
||||
void set_base_demand(list_node_t *lnode, double base_demand);
|
||||
|
||||
int get_pattern_index(list_node_t *lnode);
|
||||
void set_pattern_index(list_node_t *lnode, int pattern_index);
|
||||
|
||||
char *get_category_name(list_node_t *lnode);
|
||||
void set_category_name(list_node_t *lnode, const char *category_name);
|
||||
|
||||
// Make this private?
|
||||
demand_data_t *get_demand_data(list_node_t *lnode);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* DEMAND_H */
|
||||
268
src/enumstxt.h
268
src/enumstxt.h
@@ -1,135 +1,133 @@
|
||||
/*
|
||||
***********************************************************************
|
||||
|
||||
ENUMSTXT.H -- Text strings for enumerated data types in EPANET
|
||||
|
||||
VERSION: 2.00
|
||||
DATE: 5/8/00
|
||||
AUTHOR: L. Rossman
|
||||
US EPA - NRMRL
|
||||
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
char *NodeTxt[] = {t_JUNCTION,
|
||||
t_RESERVOIR,
|
||||
t_TANK};
|
||||
|
||||
char *LinkTxt[] = {w_CV,
|
||||
w_PIPE,
|
||||
w_PUMP,
|
||||
w_PRV,
|
||||
w_PSV,
|
||||
w_PBV,
|
||||
w_FCV,
|
||||
w_TCV,
|
||||
w_GPV};
|
||||
|
||||
char *StatTxt[] = {t_XHEAD,
|
||||
t_TEMPCLOSED,
|
||||
t_CLOSED,
|
||||
t_OPEN,
|
||||
t_ACTIVE,
|
||||
t_XFLOW,
|
||||
t_XFCV,
|
||||
t_XPRESSURE,
|
||||
t_FILLING,
|
||||
t_EMPTYING};
|
||||
|
||||
char *FormTxt[] = {w_HW,
|
||||
w_DW,
|
||||
w_CM};
|
||||
|
||||
char *RptFormTxt[] = {t_HW,
|
||||
t_DW,
|
||||
t_CM};
|
||||
|
||||
char *RptFlowUnitsTxt[] = {u_CFS,
|
||||
u_GPM,
|
||||
u_MGD,
|
||||
u_IMGD,
|
||||
u_AFD,
|
||||
u_LPS,
|
||||
u_LPM,
|
||||
u_MLD,
|
||||
u_CMH,
|
||||
u_CMD};
|
||||
|
||||
char *FlowUnitsTxt[] = {w_CFS,
|
||||
w_GPM,
|
||||
w_MGD,
|
||||
w_IMGD,
|
||||
w_AFD,
|
||||
w_LPS,
|
||||
w_LPM,
|
||||
w_MLD,
|
||||
w_CMH,
|
||||
w_CMD};
|
||||
|
||||
char *PressUnitsTxt[] = {w_PSI,
|
||||
w_KPA,
|
||||
w_METERS};
|
||||
|
||||
char *QualTxt[] = {w_NONE,
|
||||
w_CHEM,
|
||||
w_AGE,
|
||||
w_TRACE};
|
||||
|
||||
|
||||
char *SourceTxt[] = {w_CONCEN,
|
||||
w_MASS,
|
||||
w_SETPOINT,
|
||||
w_FLOWPACED};
|
||||
|
||||
char *ControlTxt[] = {w_BELOW,
|
||||
w_ABOVE,
|
||||
w_TIME,
|
||||
w_CLOCKTIME};
|
||||
|
||||
char *TstatTxt[] = {w_NONE,
|
||||
w_AVG,
|
||||
w_MIN,
|
||||
w_MAX,
|
||||
w_RANGE};
|
||||
|
||||
char *MixTxt[] = {w_MIXED,
|
||||
w_2COMP,
|
||||
w_FIFO,
|
||||
w_LIFO,
|
||||
NULL};
|
||||
|
||||
char *RptFlagTxt[] = {w_NO,
|
||||
w_YES,
|
||||
w_FULL};
|
||||
|
||||
char *SectTxt[] = {s_TITLE, s_JUNCTIONS, s_RESERVOIRS,
|
||||
s_TANKS, s_PIPES, s_PUMPS,
|
||||
s_VALVES, s_CONTROLS, s_RULES,
|
||||
s_DEMANDS, s_SOURCES, s_EMITTERS,
|
||||
s_PATTERNS, s_CURVES, s_QUALITY,
|
||||
s_STATUS, s_ROUGHNESS, s_ENERGY,
|
||||
s_REACTIONS, s_MIXING, s_REPORT,
|
||||
s_TIMES, s_OPTIONS, s_COORDS,
|
||||
s_VERTICES, s_LABELS, s_BACKDROP,
|
||||
s_TAGS, s_END,
|
||||
NULL};
|
||||
|
||||
char *RptSectTxt[] = {NULL, t_JUNCTION, t_RESERVOIR,
|
||||
t_TANK, t_PIPE, t_PUMP,
|
||||
t_VALVE, t_CONTROL, t_RULE,
|
||||
t_DEMANDFOR,t_SOURCE, t_EMITTER,
|
||||
t_PATTERN, t_CURVE, t_QUALITY,
|
||||
t_STATUS, t_ROUGHNESS,t_ENERGY,
|
||||
t_REACTION, t_MIXING, t_REPORT,
|
||||
t_TIME, t_OPTION};
|
||||
|
||||
char *Fldname[] = {t_ELEV, t_DEMAND, t_HEAD,
|
||||
t_PRESSURE, t_QUALITY, t_LENGTH,
|
||||
t_DIAM, t_FLOW, t_VELOCITY,
|
||||
t_HEADLOSS, t_LINKQUAL, t_LINKSTATUS,
|
||||
t_SETTING, t_REACTRATE, t_FRICTION,
|
||||
"", "", "", "", "", "", NULL};
|
||||
|
||||
char *LogoTxt[] = {LOGO1,LOGO2,LOGO3,LOGO4,LOGO5,LOGO6,NULL};
|
||||
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: enumstxt.h
|
||||
Description: text strings for enumerated data types
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ENUMSTXT_H
|
||||
#define ENUMSTXT_H
|
||||
#include "text.h"
|
||||
|
||||
char *NodeTxt[] = {t_JUNCTION,
|
||||
t_RESERVOIR,
|
||||
t_TANK};
|
||||
|
||||
char *LinkTxt[] = {w_CV,
|
||||
w_PIPE,
|
||||
w_PUMP,
|
||||
w_PRV,
|
||||
w_PSV,
|
||||
w_PBV,
|
||||
w_FCV,
|
||||
w_TCV,
|
||||
w_GPV};
|
||||
|
||||
char *StatTxt[] = {t_XHEAD,
|
||||
t_TEMPCLOSED,
|
||||
t_CLOSED,
|
||||
t_OPEN,
|
||||
t_ACTIVE,
|
||||
t_XFLOW,
|
||||
t_XFCV,
|
||||
t_XPRESSURE,
|
||||
t_FILLING,
|
||||
t_EMPTYING};
|
||||
|
||||
char *FormTxt[] = {w_HW,
|
||||
w_DW,
|
||||
w_CM};
|
||||
|
||||
char *RptFormTxt[] = {t_HW,
|
||||
t_DW,
|
||||
t_CM};
|
||||
|
||||
char *RptFlowUnitsTxt[] = {u_CFS,
|
||||
u_GPM,
|
||||
u_MGD,
|
||||
u_IMGD,
|
||||
u_AFD,
|
||||
u_LPS,
|
||||
u_LPM,
|
||||
u_MLD,
|
||||
u_CMH,
|
||||
u_CMD};
|
||||
|
||||
char *FlowUnitsTxt[] = {w_CFS,
|
||||
w_GPM,
|
||||
w_MGD,
|
||||
w_IMGD,
|
||||
w_AFD,
|
||||
w_LPS,
|
||||
w_LPM,
|
||||
w_MLD,
|
||||
w_CMH,
|
||||
w_CMD};
|
||||
|
||||
char *PressUnitsTxt[] = {w_PSI,
|
||||
w_KPA,
|
||||
w_METERS};
|
||||
|
||||
char *DemandModelTxt[] = { w_DDA,
|
||||
w_PDA,
|
||||
NULL };
|
||||
|
||||
char *QualTxt[] = {w_NONE,
|
||||
w_CHEM,
|
||||
w_AGE,
|
||||
w_TRACE};
|
||||
|
||||
|
||||
char *SourceTxt[] = {w_CONCEN,
|
||||
w_MASS,
|
||||
w_SETPOINT,
|
||||
w_FLOWPACED};
|
||||
|
||||
char *ControlTxt[] = {w_BELOW,
|
||||
w_ABOVE,
|
||||
w_TIME,
|
||||
w_CLOCKTIME};
|
||||
|
||||
char *TstatTxt[] = {w_NONE,
|
||||
w_AVG,
|
||||
w_MIN,
|
||||
w_MAX,
|
||||
w_RANGE};
|
||||
|
||||
char *MixTxt[] = {w_MIXED,
|
||||
w_2COMP,
|
||||
w_FIFO,
|
||||
w_LIFO,
|
||||
NULL};
|
||||
|
||||
char *RptFlagTxt[] = {w_NO,
|
||||
w_YES,
|
||||
w_FULL};
|
||||
|
||||
char *SectTxt[] = {s_TITLE, s_JUNCTIONS, s_RESERVOIRS,
|
||||
s_TANKS, s_PIPES, s_PUMPS,
|
||||
s_VALVES, s_CONTROLS, s_RULES,
|
||||
s_DEMANDS, s_SOURCES, s_EMITTERS,
|
||||
s_PATTERNS, s_CURVES, s_QUALITY,
|
||||
s_STATUS, s_ROUGHNESS, s_ENERGY,
|
||||
s_REACTIONS, s_MIXING, s_REPORT,
|
||||
s_TIMES, s_OPTIONS, s_COORDS,
|
||||
s_VERTICES, s_LABELS, s_BACKDROP,
|
||||
s_TAGS, s_END,
|
||||
NULL};
|
||||
|
||||
char *Fldname[] = {t_ELEV, t_DEMAND, t_HEAD,
|
||||
t_PRESSURE, t_QUALITY, t_LENGTH,
|
||||
t_DIAM, t_FLOW, t_VELOCITY,
|
||||
t_HEADLOSS, t_LINKQUAL, t_LINKSTATUS,
|
||||
t_SETTING, t_REACTRATE, t_FRICTION,
|
||||
"", "", "", "", "", "", NULL};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
8662
src/epanet.c
Executable file → Normal file
8662
src/epanet.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
828
src/epanet2.c
Normal file
828
src/epanet2.c
Normal file
@@ -0,0 +1,828 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: epanet2.c
|
||||
Description: implementation of the legacy EPANET API functions
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 03/17/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "funcs.h"
|
||||
|
||||
#include "epanet2.h"
|
||||
#include "epanet2_2.h"
|
||||
|
||||
|
||||
// This single global variable is used only when the library is called
|
||||
// in "legacy mode" with the 2.1-style API.
|
||||
Project __defaultProject;
|
||||
Project *_defaultProject = &__defaultProject;
|
||||
|
||||
// Functions for creating and removing default temporary files
|
||||
void createtmpfiles()
|
||||
{
|
||||
getTmpName(_defaultProject->TmpHydFname);
|
||||
getTmpName(_defaultProject->TmpOutFname);
|
||||
getTmpName(_defaultProject->TmpStatFname);
|
||||
}
|
||||
|
||||
void removetmpfiles()
|
||||
{
|
||||
remove(_defaultProject->TmpHydFname);
|
||||
remove(_defaultProject->TmpOutFname);
|
||||
remove(_defaultProject->TmpStatFname);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Project Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile,
|
||||
const char *outFile, void (*pviewprog)(char *))
|
||||
{
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: inpFile = name of EPANET formatted input file
|
||||
** rptFile = name of report file
|
||||
** outFile = name of binary output file
|
||||
** pviewprog = see note below
|
||||
** Output: none
|
||||
** Returns: error code
|
||||
** Purpose: runs a complete EPANET simulation
|
||||
**
|
||||
** The pviewprog() argument is a pointer to a callback function
|
||||
** that takes a character string (char *) as its only parameter.
|
||||
** The function would reside in and be used by the calling
|
||||
** program to display the progress messages that EPANET generates
|
||||
** as it carries out its computations. If this feature is not
|
||||
** needed then the argument should be NULL.
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
int errcode = 0;
|
||||
int warncode = 0;
|
||||
|
||||
// Run the project and record any warning
|
||||
createtmpfiles();
|
||||
errcode = EN_runproject(_defaultProject, inpFile, rptFile, outFile, pviewprog);
|
||||
if (errcode < 100) warncode = errcode;
|
||||
removetmpfiles();
|
||||
|
||||
// Return the warning code if the run had no errors
|
||||
if (warncode) errcode = MAX(errcode, warncode);
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENinit(const char *rptFile, const char *outFile, int unitsType,
|
||||
int headlossType)
|
||||
{
|
||||
int errcode = 0;
|
||||
createtmpfiles();
|
||||
errcode = EN_init(_defaultProject, rptFile, outFile, unitsType, headlossType);
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *outFile)
|
||||
{
|
||||
int errcode = 0;
|
||||
createtmpfiles();
|
||||
errcode = EN_open(_defaultProject, inpFile, rptFile, outFile);
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3)
|
||||
{
|
||||
return EN_gettitle(_defaultProject, line1, line2, line3) ;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3)
|
||||
{
|
||||
return EN_settitle(_defaultProject, line1, line2, line3) ;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcomment(int object, int index, char *comment)
|
||||
{
|
||||
return EN_getcomment(_defaultProject, object, index, comment);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetcomment(int object, int index, char *comment)
|
||||
{
|
||||
return EN_setcomment(_defaultProject, object, index, comment);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcount(int object, int *count)
|
||||
{
|
||||
return EN_getcount(_defaultProject, object, count);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsaveinpfile(const char *filename)
|
||||
{
|
||||
return EN_saveinpfile(_defaultProject, filename);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENclose()
|
||||
{
|
||||
EN_close(_defaultProject);
|
||||
removetmpfiles();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Hydraulic Analysis Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENsolveH() { return EN_solveH(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENsaveH() { return EN_saveH(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENopenH() { return EN_openH(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENinitH(int initFlag) { return EN_initH(_defaultProject, initFlag); }
|
||||
|
||||
int DLLEXPORT ENrunH(long *currentTime) { return EN_runH(_defaultProject, currentTime); }
|
||||
|
||||
int DLLEXPORT ENnextH(long *tStep) { return EN_nextH(_defaultProject, tStep); }
|
||||
|
||||
int DLLEXPORT ENcloseH() { return EN_closeH(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENsavehydfile(char *filename)
|
||||
{
|
||||
return EN_savehydfile(_defaultProject, filename);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENusehydfile(char *filename)
|
||||
{
|
||||
return EN_usehydfile(_defaultProject, filename);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Water Quality Analysis Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENsolveQ() { return EN_solveQ(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENopenQ() { return EN_openQ(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENinitQ(int saveFlag) { return EN_initQ(_defaultProject, saveFlag); }
|
||||
|
||||
int DLLEXPORT ENrunQ(long *currentTime) { return EN_runQ(_defaultProject, currentTime); }
|
||||
|
||||
int DLLEXPORT ENnextQ(long *tStep) { return EN_nextQ(_defaultProject, tStep); }
|
||||
|
||||
int DLLEXPORT ENstepQ(long *timeLeft) { return EN_stepQ(_defaultProject, timeLeft); }
|
||||
|
||||
int DLLEXPORT ENcloseQ() { return EN_closeQ(_defaultProject); }
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Reporting Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENwriteline(char *line) { return EN_writeline(_defaultProject, line); }
|
||||
|
||||
int DLLEXPORT ENreport() { return EN_report(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENcopyreport(char *filename)
|
||||
{
|
||||
return EN_copyreport(_defaultProject, filename);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENclearreport() { return EN_clearreport(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENresetreport() { return EN_resetreport(_defaultProject); }
|
||||
|
||||
int DLLEXPORT ENsetreport(char *format) { return EN_setreport(_defaultProject, format); }
|
||||
|
||||
int DLLEXPORT ENsetstatusreport(int level)
|
||||
{
|
||||
return EN_setstatusreport(_defaultProject, level);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetversion(int *version) { return EN_getversion(version); }
|
||||
|
||||
int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen)
|
||||
{
|
||||
return EN_geterror(errcode, errmsg, maxLen);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v = 0.0;
|
||||
int errcode = EN_getstatistic(_defaultProject, type, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Analysis Options Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v = 0.0;
|
||||
int errcode = EN_getoption(_defaultProject, option, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value)
|
||||
{
|
||||
return EN_setoption(_defaultProject, option, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetflowunits(int *units)
|
||||
{
|
||||
return EN_getflowunits(_defaultProject, units);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetflowunits(int units)
|
||||
{
|
||||
return EN_setflowunits(_defaultProject, units);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgettimeparam(int param, long *value)
|
||||
{
|
||||
return EN_gettimeparam(_defaultProject, param, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsettimeparam(int param, long value)
|
||||
{
|
||||
return EN_settimeparam(_defaultProject, param, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits,
|
||||
int *traceNode)
|
||||
{
|
||||
return EN_getqualinfo(_defaultProject, qualType, chemName, chemUnits, traceNode);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode)
|
||||
{
|
||||
return EN_getqualtype(_defaultProject, qualType, traceNode);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits,
|
||||
char *traceNode)
|
||||
{
|
||||
return EN_setqualtype(_defaultProject, qualType, chemName, chemUnits, traceNode);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Node Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddnode(char *id, int nodeType, int *index)
|
||||
{
|
||||
return EN_addnode(_defaultProject, id, nodeType, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENdeletenode(int index, int actionCode)
|
||||
{
|
||||
return EN_deletenode(_defaultProject, index, actionCode);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetnodeindex(char *id, int *index)
|
||||
{
|
||||
return EN_getnodeindex(_defaultProject, id, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetnodeid(int index, char *id)
|
||||
{
|
||||
return EN_getnodeid(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetnodeid(int index, char *newid)
|
||||
{
|
||||
return EN_setnodeid(_defaultProject, index, newid);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetnodetype(int index, int *nodeType)
|
||||
{
|
||||
return EN_getnodetype(_defaultProject, index, nodeType);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v = 0.0;
|
||||
int errcode = EN_getnodevalue(_defaultProject, index, property, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value)
|
||||
{
|
||||
return EN_setnodevalue(_defaultProject, index, property, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE dmnd,
|
||||
char *dmndpat)
|
||||
{
|
||||
return EN_setjuncdata(_defaultProject, index, elev, dmnd, dmndpat);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev,
|
||||
EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
|
||||
EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
|
||||
EN_API_FLOAT_TYPE minvol, char *volcurve)
|
||||
{
|
||||
return EN_settankdata(_defaultProject, index, elev, initlvl, minlvl, maxlvl,
|
||||
diam, minvol, volcurve);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcoord(int index, double *x, double *y)
|
||||
{
|
||||
return EN_getcoord(_defaultProject, index, x, y);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetcoord(int index, double x, double y)
|
||||
{
|
||||
return EN_setcoord(_defaultProject, index, x, y);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Nodal Demand Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin,
|
||||
EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp)
|
||||
{
|
||||
double pmin2 = 0.0, preq2 = 0.0, pexp2 = 0.0;
|
||||
int errcode = EN_getdemandmodel(_defaultProject, model, &pmin2, &preq2, &pexp2);
|
||||
*pmin = (EN_API_FLOAT_TYPE)pmin2;
|
||||
*preq = (EN_API_FLOAT_TYPE)preq2;
|
||||
*pexp = (EN_API_FLOAT_TYPE)pexp2;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin,
|
||||
EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp)
|
||||
{
|
||||
return EN_setdemandmodel(_defaultProject, model, pmin, preq, pexp);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands)
|
||||
{
|
||||
return EN_getnumdemands(_defaultProject, nodeIndex, numDemands);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex,
|
||||
EN_API_FLOAT_TYPE *baseDemand)
|
||||
{
|
||||
double bd2 = 0.0;
|
||||
int errcode = EN_getbasedemand(_defaultProject, nodeIndex, demandIndex, &bd2);
|
||||
*baseDemand = (EN_API_FLOAT_TYPE)bd2;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex,
|
||||
EN_API_FLOAT_TYPE baseDemand)
|
||||
{
|
||||
return EN_setbasedemand(_defaultProject, nodeIndex, demandIndex, baseDemand);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex)
|
||||
{
|
||||
return EN_setdemandpattern(_defaultProject, nodeIndex, demandIndex, patIndex);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *pattIdx)
|
||||
{
|
||||
return EN_getdemandpattern(_defaultProject, nodeIndex, demandIndex, pattIdx);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName)
|
||||
{
|
||||
return EN_getdemandname(_defaultProject, nodeIndex, demandIndex, demandName);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName)
|
||||
{
|
||||
return EN_setdemandname(_defaultProject, nodeIndex, demandIndex, demandName);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Link Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode, int *index)
|
||||
{
|
||||
return EN_addlink(_defaultProject, id, linkType, fromNode, toNode, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENdeletelink(int index, int actionCode)
|
||||
{
|
||||
return EN_deletelink(_defaultProject, index, actionCode);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetlinkindex(char *id, int *index)
|
||||
{
|
||||
return EN_getlinkindex(_defaultProject, id, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetlinkid(int index, char *id)
|
||||
{
|
||||
return EN_getlinkid(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetlinkid(int index, char *newid)
|
||||
{
|
||||
return EN_setlinkid(_defaultProject, index, newid);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetlinktype(int index, int *linkType)
|
||||
{
|
||||
return EN_getlinktype(_defaultProject, index, linkType);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode)
|
||||
{
|
||||
return EN_setlinktype(_defaultProject, index, linkType, actionCode);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2)
|
||||
{
|
||||
return EN_getlinknodes(_defaultProject, index, node1, node2);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetlinknodes(int index, int node1, int node2)
|
||||
{
|
||||
return EN_setlinknodes(_defaultProject, index, node1, node2);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v = 0.0;
|
||||
int errcode = EN_getlinkvalue(_defaultProject, index, property, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value)
|
||||
{
|
||||
return EN_setlinkvalue(_defaultProject, index, property, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length,
|
||||
EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss)
|
||||
{
|
||||
return EN_setpipedata(_defaultProject, index, length, diam, rough, mloss);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Pump Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType)
|
||||
{
|
||||
return EN_getpumptype(_defaultProject, linkIndex, pumpType);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex)
|
||||
{
|
||||
return EN_getheadcurveindex(_defaultProject, linkIndex, curveIndex);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex)
|
||||
{
|
||||
return EN_setheadcurveindex(_defaultProject, linkIndex, curveIndex);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Time Pattern Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddpattern(char *id)
|
||||
{
|
||||
return EN_addpattern(_defaultProject, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENdeletepattern(int index)
|
||||
{
|
||||
return EN_deletepattern(_defaultProject, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetpatternindex(char *id, int *index)
|
||||
{
|
||||
return EN_getpatternindex(_defaultProject, id, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetpatternid(int index, char *id)
|
||||
{
|
||||
return EN_getpatternid(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpatternid(int index, char *id)
|
||||
{
|
||||
return EN_setpatternid(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetpatternlen(int index, int *len)
|
||||
{
|
||||
return EN_getpatternlen(_defaultProject, index, len);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v = 0.0;
|
||||
int errcode = EN_getpatternvalue(_defaultProject, index, period, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value)
|
||||
{
|
||||
return EN_setpatternvalue(_defaultProject, index, period, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v;
|
||||
int errcode = EN_getaveragepatternvalue(_defaultProject, index, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len)
|
||||
{
|
||||
double *v = NULL;
|
||||
int i, errcode;
|
||||
v = (double *)calloc(len, sizeof(double));
|
||||
if (v)
|
||||
{
|
||||
for (i = 0; i < len; i++) v[i] = values[i];
|
||||
errcode = EN_setpattern(_defaultProject, index, v, len);
|
||||
}
|
||||
else errcode = 101;
|
||||
free(v);
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Data Curve Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddcurve(char *id)
|
||||
{
|
||||
return EN_addcurve(_defaultProject, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENdeletecurve(int index)
|
||||
{
|
||||
return EN_deletecurve(_defaultProject, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurveindex(char *id, int *index)
|
||||
{
|
||||
return EN_getcurveindex(_defaultProject, id, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurveid(int index, char *id)
|
||||
{
|
||||
return EN_getcurveid(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetcurveid(int index, char *id)
|
||||
{
|
||||
return EN_setcurveid(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurvelen(int index, int *len)
|
||||
{
|
||||
return EN_getcurvelen(_defaultProject, index, len);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurvetype(int index, int *type)
|
||||
{
|
||||
return EN_getcurvetype(_defaultProject, index, type);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex, EN_API_FLOAT_TYPE *x,
|
||||
EN_API_FLOAT_TYPE *y)
|
||||
{
|
||||
double xx = 0.0, yy = 0.0;
|
||||
int errcode = EN_getcurvevalue(_defaultProject, curveIndex, pointIndex, &xx, &yy);
|
||||
*x = (EN_API_FLOAT_TYPE)xx;
|
||||
*y = (EN_API_FLOAT_TYPE)yy;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex, EN_API_FLOAT_TYPE x,
|
||||
EN_API_FLOAT_TYPE y)
|
||||
{
|
||||
return EN_setcurvevalue(_defaultProject, curveIndex, pointIndex, x, y);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurve(int index, char *id, int *nPoints,
|
||||
EN_API_FLOAT_TYPE *xValues, EN_API_FLOAT_TYPE *yValues)
|
||||
{
|
||||
int i;
|
||||
Network *net = &_defaultProject->network;
|
||||
Scurve *curve;
|
||||
|
||||
if (index <= 0 || index > net->Ncurves) return 206;
|
||||
curve = &net->Curve[index];
|
||||
strncpy(id, curve->ID, MAXID);
|
||||
*nPoints = curve->Npts;
|
||||
for (i = 0; i < curve->Npts; i++)
|
||||
{
|
||||
xValues[i] = (EN_API_FLOAT_TYPE)curve->X[i];
|
||||
yValues[i] = (EN_API_FLOAT_TYPE)curve->Y[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues,
|
||||
EN_API_FLOAT_TYPE *yValues, int nPoints)
|
||||
{
|
||||
double *xx = NULL;
|
||||
double *yy = NULL;
|
||||
int i, errcode;
|
||||
xx = (double *)calloc(nPoints, sizeof(double));
|
||||
yy = (double *)calloc(nPoints, sizeof(double));
|
||||
if (xx && yy)
|
||||
{
|
||||
for (i = 0; i < nPoints; i++)
|
||||
{
|
||||
xx[i] = xValues[i];
|
||||
yy[i] = yValues[i];
|
||||
}
|
||||
errcode = EN_setcurve(_defaultProject, index, xx, yy, nPoints);
|
||||
}
|
||||
else errcode = 101;
|
||||
free(xx);
|
||||
free(yy);
|
||||
return errcode;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Simple Controls Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting,
|
||||
int nodeIndex, EN_API_FLOAT_TYPE level, int *index)
|
||||
{
|
||||
return EN_addcontrol(_defaultProject, type, linkIndex, setting, nodeIndex,
|
||||
level, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENdeletecontrol(int index)
|
||||
{
|
||||
return EN_deletecontrol(_defaultProject, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex,
|
||||
EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level)
|
||||
{
|
||||
double setting2 = 0.0, level2 = 0.0;
|
||||
int errcode = EN_getcontrol(_defaultProject, index, type, linkIndex, &setting2,
|
||||
nodeIndex, &level2);
|
||||
*setting = (EN_API_FLOAT_TYPE)setting2;
|
||||
*level = (EN_API_FLOAT_TYPE)level2;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex,
|
||||
EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level)
|
||||
{
|
||||
return EN_setcontrol(_defaultProject, index, type, linkIndex, setting,
|
||||
nodeIndex, level);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
||||
Rule-Based Controls Functions
|
||||
|
||||
********************************************************************/
|
||||
|
||||
int DLLEXPORT ENaddrule(char *rule)
|
||||
{
|
||||
return EN_addrule(_defaultProject, rule);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENdeleterule(int index)
|
||||
{
|
||||
return EN_deleterule(_defaultProject, index);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions,
|
||||
int *nElseActions, EN_API_FLOAT_TYPE *priority)
|
||||
{
|
||||
double priority2 = 0.0;
|
||||
int errcode = EN_getrule(_defaultProject, index, nPremises, nThenActions,
|
||||
nElseActions, &priority2);
|
||||
*priority = (EN_API_FLOAT_TYPE)priority2;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetruleID(int index, char* id)
|
||||
{
|
||||
return EN_getruleID(_defaultProject, index, id);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop, int *object,
|
||||
int *objIndex, int *variable, int *relop, int *status,
|
||||
EN_API_FLOAT_TYPE *value)
|
||||
{
|
||||
double v = 0.0;
|
||||
int errcode = EN_getpremise(_defaultProject, ruleIndex, premiseIndex, logop,
|
||||
object, objIndex, variable, relop, status, &v);
|
||||
*value = (EN_API_FLOAT_TYPE)v;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop, int object,
|
||||
int objIndex, int variable, int relop, int status, EN_API_FLOAT_TYPE value)
|
||||
{
|
||||
return EN_setpremise(_defaultProject, ruleIndex, premiseIndex, logop, object,
|
||||
objIndex, variable, relop, status, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex)
|
||||
{
|
||||
return EN_setpremiseindex(_defaultProject, ruleIndex, premiseIndex, objIndex);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status)
|
||||
{
|
||||
return EN_setpremisestatus(_defaultProject, ruleIndex, premiseIndex, status);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex, EN_API_FLOAT_TYPE value)
|
||||
{
|
||||
return EN_setpremisevalue(_defaultProject, ruleIndex, premiseIndex, value);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex,
|
||||
int *status, EN_API_FLOAT_TYPE *setting)
|
||||
{
|
||||
double setting2 = 0.0;
|
||||
int errcode = EN_getthenaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
|
||||
status, &setting2);
|
||||
*setting = (EN_API_FLOAT_TYPE)setting2;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex,
|
||||
int status, EN_API_FLOAT_TYPE setting)
|
||||
{
|
||||
return EN_setthenaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
|
||||
status, setting);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex,
|
||||
int *status, EN_API_FLOAT_TYPE *setting)
|
||||
{
|
||||
double setting2 = 0.0;
|
||||
int errcode = EN_getelseaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
|
||||
status, &setting2);
|
||||
*setting = (EN_API_FLOAT_TYPE)setting2;
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex,
|
||||
int status, EN_API_FLOAT_TYPE setting)
|
||||
{
|
||||
return EN_setelseaction(_defaultProject, ruleIndex, actionIndex, linkIndex,
|
||||
status, setting);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority)
|
||||
{
|
||||
return EN_setrulepriority(_defaultProject, index, priority);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
LIBRARY EPANET2.DLL
|
||||
|
||||
EXPORTS
|
||||
ENaddpattern = _ENaddpattern@4
|
||||
ENclose = _ENclose@0
|
||||
ENcloseH = _ENcloseH@0
|
||||
ENcloseQ = _ENcloseQ@0
|
||||
ENepanet = _ENepanet@16
|
||||
ENgetcontrol = _ENgetcontrol@24
|
||||
ENgetcount = _ENgetcount@8
|
||||
ENgeterror = _ENgeterror@12
|
||||
ENgetflowunits = _ENgetflowunits@4
|
||||
ENgetlinkid = _ENgetlinkid@8
|
||||
ENgetlinkindex = _ENgetlinkindex@8
|
||||
ENgetlinknodes = _ENgetlinknodes@12
|
||||
ENgetlinktype = _ENgetlinktype@8
|
||||
ENgetlinkvalue = _ENgetlinkvalue@12
|
||||
ENgetnodeid = _ENgetnodeid@8
|
||||
ENgetnodeindex = _ENgetnodeindex@8
|
||||
ENgetnodetype = _ENgetnodetype@8
|
||||
ENgetnodevalue = _ENgetnodevalue@12
|
||||
ENgetoption = _ENgetoption@8
|
||||
ENgetpatternid = _ENgetpatternid@8
|
||||
ENgetpatternindex = _ENgetpatternindex@8
|
||||
ENgetpatternlen = _ENgetpatternlen@8
|
||||
ENgetpatternvalue = _ENgetpatternvalue@12
|
||||
ENgetqualtype = _ENgetqualtype@8
|
||||
ENgettimeparam = _ENgettimeparam@8
|
||||
ENgetversion = _ENgetversion@4
|
||||
ENinitH = _ENinitH@4
|
||||
ENinitQ = _ENinitQ@4
|
||||
ENnextH = _ENnextH@4
|
||||
ENnextQ = _ENnextQ@4
|
||||
ENopen = _ENopen@12
|
||||
ENopenH = _ENopenH@0
|
||||
ENopenQ = _ENopenQ@0
|
||||
ENreport = _ENreport@0
|
||||
ENresetreport = _ENresetreport@0
|
||||
ENrunH = _ENrunH@4
|
||||
ENrunQ = _ENrunQ@4
|
||||
ENsaveH = _ENsaveH@0
|
||||
ENsavehydfile = _ENsavehydfile@4
|
||||
ENsaveinpfile = _ENsaveinpfile@4
|
||||
ENsetcontrol = _ENsetcontrol@24
|
||||
ENsetlinkvalue = _ENsetlinkvalue@12
|
||||
ENsetnodevalue = _ENsetnodevalue@12
|
||||
ENsetoption = _ENsetoption@8
|
||||
ENsetpattern = _ENsetpattern@12
|
||||
ENsetpatternvalue = _ENsetpatternvalue@12
|
||||
ENsetqualtype = _ENsetqualtype@16
|
||||
ENsetreport = _ENsetreport@4
|
||||
ENsetstatusreport = _ENsetstatusreport@4
|
||||
ENsettimeparam = _ENsettimeparam@8
|
||||
ENsolveH = _ENsolveH@0
|
||||
ENsolveQ = _ENsolveQ@0
|
||||
ENstepQ = _ENstepQ@4
|
||||
ENusehydfile = _ENusehydfile@4
|
||||
ENwriteline = _ENwriteline@4
|
||||
ENgetnumdemands = _ENgetnumdemands@8
|
||||
ENgetbasedemand = _ENgetbasedemand@12
|
||||
ENgetdemandpattern = _ENgetdemandpattern@12
|
||||
ENgetcurve = _ENgetcurve@16
|
||||
ENgetheadcurve = _ENgetheadcurve@8
|
||||
ENgetpumptype = _ENgetpumptype@8
|
||||
815
src/epanet_py.c
Normal file
815
src/epanet_py.c
Normal file
@@ -0,0 +1,815 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: epanet_py.c
|
||||
Description: EPANET API functions for Python SWIG wrap
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 02/08/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "epanet_py.h"
|
||||
#include "util/errormanager.h"
|
||||
#include "epanet2_2.h"
|
||||
#include "text.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
Project *project;
|
||||
error_handle_t *error;
|
||||
}handle_t;
|
||||
// Extern functions
|
||||
extern char *geterrmsg(int, char *);
|
||||
// Local functions
|
||||
void error_lookup(int errcode, char *errmsg, int len);
|
||||
|
||||
|
||||
int EXPORT_PY_API proj_create(Handle *ph)
|
||||
{
|
||||
handle_t *handle = (handle_t *)calloc(1, sizeof(handle_t));
|
||||
|
||||
if (handle != NULL)
|
||||
{
|
||||
EN_createproject(&handle->project);
|
||||
handle->error = create_error_manager(&error_lookup);
|
||||
*ph = handle;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_delete(Handle *ph)
|
||||
{
|
||||
handle_t *handle = (handle_t *)*ph;
|
||||
|
||||
if (handle == NULL)
|
||||
return -1;
|
||||
else
|
||||
{
|
||||
EN_deleteproject(&handle->project);
|
||||
delete_error_manager(handle->error);
|
||||
}
|
||||
free(handle);
|
||||
*ph = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_run(Handle ph, const char *input_path,
|
||||
const char *report_path, const char *output_path)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_runproject(pr->project, input_path, report_path, output_path, NULL));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_init(Handle ph, const char *rptFile, const char *outFile,
|
||||
EN_FlowUnits unitsType, EN_HeadLossType headLossType)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_init(pr->project, rptFile, outFile, unitsType, headLossType));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_open(Handle ph, const char *inpFile, const char *rptFile,
|
||||
const char *binOutFile)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_open(pr->project, inpFile, rptFile, binOutFile));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_gettitle(Handle ph, char *line1, char *line2, char *line3)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_gettitle(pr->project, line1, line2, line3));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_settitle(Handle ph, const char *line1, const char *line2, const char *line3)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_settitle(pr->project, (char *)line1, (char *)line2, (char *)line3));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_getcount(Handle ph, EN_CountType code, int *count)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcount(pr->project, code, count));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_savefile(Handle ph, const char *filename)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_saveinpfile(pr->project, filename));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API proj_close(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_close(pr->project));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API hydr_solve(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_solveH(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_save(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_saveH(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_open(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_openH(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_init(Handle ph, EN_InitHydOption saveFlag)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_initH(pr->project, saveFlag));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_run(Handle ph, long *currentTime)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_runH(pr->project, currentTime));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_next(Handle ph, long *tStep)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_nextH(pr->project, tStep));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_close(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_closeH(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_savefile(Handle ph, char *filename)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_savehydfile(pr->project, filename));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API hydr_usefile(Handle ph, char *filename)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_usehydfile(pr->project, filename));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API qual_solve(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_solveQ(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API qual_open(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_openQ(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API qual_init(Handle ph, EN_InitHydOption saveFlag)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_initQ(pr->project, saveFlag));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API qual_run(Handle ph, long *currentTime)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_runQ(pr->project, currentTime));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API qual_next(Handle ph, long *tStep)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_nextQ(pr->project, tStep));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API qual_step(Handle ph, long *timeLeft)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_stepQ(pr->project, timeLeft));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API qual_close(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_closeQ(pr->project));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API rprt_writeline(Handle ph, char *line)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_writeline(pr->project, line));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rprt_writeresults(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_report(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rprt_clear(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_clearreport(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rprt_reset(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_resetreport(pr->project));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rprt_set(Handle ph, char *reportCommand)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setreport(pr->project, reportCommand));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rprt_setlevel(Handle ph, EN_StatusReport code)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setstatusreport(pr->project, code));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rprt_anlysstats(Handle ph, EN_AnalysisStatistic code, double* value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getstatistic(pr->project, code, value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API anlys_getoption(Handle ph, EN_Option code, double *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getoption(pr->project, (int)code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_setoption(Handle ph, EN_Option code, double value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setoption(pr->project, (int)code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_getflowunits(Handle ph, int *code)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getflowunits(pr->project, code));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_setflowunits(Handle ph, EN_FlowUnits code)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setflowunits(pr->project, code));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_gettimeparam(Handle ph, EN_TimeParameter code, long *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_gettimeparam(pr->project, code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_settimeparam(Handle ph, EN_TimeParameter code, long value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_settimeparam(pr->project, code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_getqualinfo(Handle ph, int *qualcode, char *chemname, char *chemunits, int *tracenode)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getqualinfo(pr->project, qualcode, chemname, chemunits, tracenode));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_getqualtype(Handle ph, int *qualcode, int *tracenode)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getqualtype(pr->project, qualcode, tracenode));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API anlys_setqualtype(Handle ph, EN_QualityType qualcode, char *chemname, char *chemunits, char *tracenode)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setqualtype(pr->project, qualcode, chemname, chemunits, tracenode));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API node_add(Handle ph, char *id, EN_NodeType nodeType, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_addnode(pr->project, id, nodeType, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_delete(Handle ph, int index, int actionCode)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_deletenode(pr->project, index, actionCode));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_getindex(Handle ph, char *id, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getnodeindex(pr->project, id, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_getid(Handle ph, int index, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getnodeid(pr->project, index, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_setid(Handle ph, int index, char *newid)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getnodeid(pr->project, index, newid));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_gettype(Handle ph, int index, int *code)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getnodetype(pr->project, index, code));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_getvalue(Handle ph, int index, EN_NodeProperty code, double *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getnodevalue(pr->project, index, (int)code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_setvalue(Handle ph, int index, EN_NodeProperty code, double value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setnodevalue(pr->project, index, (int)code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_getcoord(Handle ph, int index, double *x, double *y)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcoord(pr->project, index, x, y));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API node_setcoord(Handle ph, int index, double x, double y)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setcoord(pr->project, index, x, y));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API dmnd_getmodel(Handle ph, int *type, double *pmin, double *preq, double *pexp)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getdemandmodel(pr->project, type, pmin, preq, pexp));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_setmodel(Handle ph, int type, double pmin, double preq, double pexp)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setdemandmodel(pr->project, type, pmin, preq, pexp));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_getcount(Handle ph, int nodeIndex, int *numDemands)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getnumdemands(pr->project, nodeIndex, numDemands));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_getbase(Handle ph, int nodeIndex, int demandIndex, double *baseDemand)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getbasedemand(pr->project, nodeIndex, demandIndex, baseDemand));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_setbase(Handle ph, int nodeIndex, int demandIndex, double baseDemand)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setbasedemand(pr->project, nodeIndex, demandIndex, baseDemand));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_getpattern(Handle ph, int nodeIndex, int demandIndex, int *patIndex)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getdemandpattern(pr->project, nodeIndex, demandIndex, patIndex));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_setpattern(Handle ph, int nodeIndex, int demandIndex, int patIndex)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setdemandpattern(pr->project, nodeIndex, demandIndex, patIndex));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_getname(Handle ph, int nodeIndex, int demandIdx, char *demandName)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getdemandname(pr->project, nodeIndex, demandIdx, demandName));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API dmnd_setname(Handle ph, int nodeIndex, int demandIdx, char *demandName)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setdemandname(pr->project, nodeIndex, demandIdx, demandName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API link_add(Handle ph, char *id, EN_LinkType linkType, char *fromNode, char *toNode, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_addlink(pr->project, id, linkType, fromNode, toNode, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_delete(Handle ph, int index, int actionCode)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_deletelink(pr->project, index, actionCode));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_getindex(Handle ph, char *id, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getlinkindex(pr->project, id, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_getid(Handle ph, int index, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getlinkid(pr->project, index, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_setid(Handle ph, int index, char *newid)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setlinkid(pr->project, index, newid));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_gettype(Handle ph, int index, int *code)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getlinktype(pr->project, index, code));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_settype(Handle ph, int *index, EN_LinkType type, int actionCode)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setlinktype(pr->project, index, type, actionCode));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_getnodes(Handle ph, int index, int *node1, int *node2)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getlinknodes(pr->project, index, node1, node2));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_setnodes(Handle ph, int index, int node1, int node2)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setlinknodes(pr->project, index, node1, node2));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_getvalue(Handle ph, int index, EN_LinkProperty code, double *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getlinkvalue(pr->project, index, code, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API link_setvalue(Handle ph, int index, int code, double value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setlinkvalue(pr->project, index, code, value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API pump_gettype(Handle ph, int linkIndex, int *outType)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getpumptype(pr->project, linkIndex, outType));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API pump_getheadcurveindex(Handle ph, int pumpIndex, int *curveIndex)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getheadcurveindex(pr->project, pumpIndex, curveIndex));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API pump_setheadcurveindex(Handle ph, int pumpIndex, int curveIndex)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setheadcurveindex(pr->project, pumpIndex, curveIndex));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API ptrn_add(Handle ph, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_addpattern(pr->project, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_getindex(Handle ph, char *id, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getpatternindex(pr->project, id, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_getid(Handle ph, int index, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getpatternid(pr->project, index, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_getlength(Handle ph, int index, int *len)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getpatternlen(pr->project, index, len));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_getvalue(Handle ph, int index, int period, double *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getpatternvalue(pr->project, index, period, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_setvalue(Handle ph, int index, int period, double value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setpatternvalue(pr->project, index, period, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_getavgvalue(Handle ph, int index, double *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getaveragepatternvalue(pr->project, index, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API ptrn_set(Handle ph, int index, double *values, int len)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setpattern(pr->project, index, values, len));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API curv_add(Handle ph, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_addcurve(pr->project, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_getindex(Handle ph, char *id, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcurveindex(pr->project, id, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_getid(Handle ph, int index, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcurveid(pr->project, index, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_getlength(Handle ph, int index, int *len)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcurvelen(pr->project, index, len));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_gettype(Handle ph, int index, int *type)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcurvetype(pr->project, index, type));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_getvalue(Handle ph, int curveIndex, int pointIndex, double *x, double *y)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcurvevalue(pr->project, curveIndex, pointIndex, x, y));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_setvalue(Handle ph, int curveIndex, int pointIndex, double x, double y)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setcurvevalue(pr->project, curveIndex, pointIndex, x, y));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_get(Handle ph, int curveIndex, char* id, int *nValues, double *xValues, double *yValues)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcurve(pr->project, curveIndex, id, nValues, xValues, yValues));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API curv_set(Handle ph, int index, double *x, double *y, int len)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setcurve(pr->project, index, x, y, len));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API scntl_add(Handle ph, int type, int linkIndex, double setting, int nodeIndex, double level, int *index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_addcontrol(pr->project, type, linkIndex, setting, nodeIndex, level, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API scntl_delete(Handle ph, int index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_deletecontrol(pr->project, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API scntl_get(Handle ph, int controlIndex, int *controlType, int *linkIndex, double *setting, int *nodeIndex, double *level)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getcontrol(pr->project, controlIndex, controlType, linkIndex, setting, nodeIndex, level));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API scntl_set(Handle ph, int cindex, int ctype, int lindex, double setting, int nindex, double level)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setcontrol(pr->project, cindex, ctype, lindex, setting, nindex, level));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int EXPORT_PY_API rcntl_add(Handle ph, char *rule)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_addrule(pr->project, rule));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_delete(Handle ph, int index)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_deleterule(pr->project, index));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_get(Handle ph, int index, int *nPremises, int *nThenActions, int *nElseActions, double *priority)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getrule(pr->project, index, nPremises, nThenActions, nElseActions, priority));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_getid(Handle ph, int index, char *id)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getruleID(pr->project, index, id));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_getpremise(Handle ph, int ruleIndex, int premiseIndex, int *logop, int *object, int *objIndex, int *variable, int *relop, int *status, double *value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getpremise(pr->project, ruleIndex, premiseIndex, logop, object, objIndex, variable, relop, status, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setpremise(Handle ph, int ruleIndex, int premiseIndex, int logop, int object, int objIndex, int variable, int relop, int status, double value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setpremise(pr->project, ruleIndex, premiseIndex, logop, object, objIndex, variable, relop, status, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setpremiseindex(Handle ph, int ruleIndex, int premiseIndex, int objIndex)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setpremiseindex(pr->project, ruleIndex, premiseIndex, objIndex));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setpremisestatus(Handle ph, int ruleIndex, int premiseIndex, int status)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setpremisestatus(pr->project, ruleIndex, premiseIndex, status));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setpremisevalue(Handle ph, int ruleIndex, int premiseIndex, double value)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setpremisevalue(pr->project, ruleIndex, premiseIndex, value));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_getthenaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getthenaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setthenaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setthenaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_getelseaction(Handle ph, int ruleIndex, int actionIndex, int *linkIndex, int *status, double *setting)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_getelseaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setelseaction(Handle ph, int ruleIndex, int actionIndex, int linkIndex, int status, double setting)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setelseaction(pr->project, ruleIndex, actionIndex, linkIndex, status, setting));
|
||||
}
|
||||
|
||||
int EXPORT_PY_API rcntl_setrulepriority(Handle ph, int index, double priority)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return set_error(pr->error, EN_setrulepriority(pr->project, index, priority));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EXPORT_PY_API err_clear(Handle ph)
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
clear_error(pr->error);
|
||||
}
|
||||
|
||||
int EXPORT_PY_API err_check(Handle ph, char** msg_buffer)
|
||||
//
|
||||
// Purpose: Returns the error code and message or 0 and NULL respectively.
|
||||
//
|
||||
// Note: Caller must free memory allocated by EN_check_error
|
||||
//
|
||||
{
|
||||
handle_t *pr = (handle_t *)ph;
|
||||
return check_error(pr->error, msg_buffer);
|
||||
}
|
||||
|
||||
int EXPORT_PY_API toolkit_getversion(int *version)
|
||||
{
|
||||
return EN_getversion(version);
|
||||
}
|
||||
|
||||
void EXPORT_PY_API toolkit_free(void **memory)
|
||||
{
|
||||
free(*memory);
|
||||
*memory = NULL;
|
||||
}
|
||||
|
||||
void error_lookup(int errcode, char *dest_msg, int dest_len)
|
||||
// Purpose: takes error code returns error message
|
||||
{
|
||||
char *msg = NULL;
|
||||
|
||||
switch (errcode)
|
||||
{
|
||||
case 1: msg = WARN1;
|
||||
break;
|
||||
case 2: msg = WARN2;
|
||||
break;
|
||||
case 3: msg = WARN3;
|
||||
break;
|
||||
case 4: msg = WARN4;
|
||||
break;
|
||||
case 5: msg = WARN5;
|
||||
break;
|
||||
case 6: msg = WARN6;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
char new_msg[MAXMSG + 1];
|
||||
msg = geterrmsg(errcode, new_msg);
|
||||
}
|
||||
}
|
||||
strncpy(dest_msg, msg, dest_len);
|
||||
}
|
||||
70
src/errors.dat
Normal file
70
src/errors.dat
Normal file
@@ -0,0 +1,70 @@
|
||||
//EPANET 2 Error Messages
|
||||
DAT(0,"ok")
|
||||
DAT(101,"insufficient memory available")
|
||||
DAT(102,"no network data available")
|
||||
DAT(103,"hydraulic solver not opened")
|
||||
DAT(104,"no hydraulics for water quality analysis")
|
||||
DAT(105,"water quality solver not opened")
|
||||
DAT(106,"no results saved to report on")
|
||||
DAT(107,"hydraulics supplied from external file")
|
||||
DAT(108,"cannot use external file while hydraulics solver is active")
|
||||
DAT(110,"cannot solve network hydraulic equations")
|
||||
DAT(120,"cannot solve water quality transport equations")
|
||||
|
||||
// These errors apply only to an input file
|
||||
DAT(200,"one or more errors in input file")
|
||||
DAT(201,"syntax error")
|
||||
|
||||
// These errors apply to both an input file and to API functions
|
||||
DAT(202,"illegal numeric value")
|
||||
DAT(203,"undefined node")
|
||||
DAT(204,"undefined link")
|
||||
DAT(205,"undefined time pattern")
|
||||
DAT(206,"undefined curve")
|
||||
DAT(207,"attempt to control CV/GPV link")
|
||||
DAT(209,"illegal node property value")
|
||||
DAT(211,"illegal link property value")
|
||||
DAT(212,"undefined trace node")
|
||||
DAT(213,"invalid option value")
|
||||
DAT(214,"too many characters in input line")
|
||||
DAT(215,"duplicate ID label")
|
||||
DAT(216,"reference to undefined pump")
|
||||
DAT(217,"invalid pump energy data")
|
||||
DAT(219,"illegal valve connection to tank node")
|
||||
DAT(220,"illegal valve connection to another valve")
|
||||
DAT(221,"mis-placed rule clause in rule-based control")
|
||||
DAT(222,"same start and end nodes for link")
|
||||
|
||||
// These errors apply to network consistency check
|
||||
DAT(223,"not enough nodes in network")
|
||||
DAT(224,"no tanks or reservoirs in network")
|
||||
DAT(225,"invalid lower/upper levels for tank")
|
||||
DAT(226,"no head curve or power rating for pump")
|
||||
DAT(227,"invalid head curve for pump")
|
||||
DAT(230,"nonincreasing x-values for curve")
|
||||
DAT(233,"network has unconnected node")
|
||||
|
||||
// These errors apply only to API functions
|
||||
DAT(240,"nonexistent source")
|
||||
DAT(241,"nonexistent control")
|
||||
DAT(250,"invalid format")
|
||||
DAT(251,"invalid parameter code")
|
||||
DAT(252,"invalid ID name")
|
||||
DAT(253,"nonexistent demand category")
|
||||
DAT(254,"node with no coordinates")
|
||||
DAT(257,"nonexistent rule")
|
||||
DAT(258,"nonexistent rule clause")
|
||||
DAT(260,"attempt to delete node assigned as a Trace Node")
|
||||
DAT(261,"attempt to delete a node or link contained in a control")
|
||||
DAT(262,"attempt to modify network structure while solver is active")
|
||||
|
||||
// File errors
|
||||
DAT(301,"identical file names")
|
||||
DAT(302,"cannot open input file")
|
||||
DAT(303,"cannot open report file")
|
||||
DAT(304,"cannot open binary output file")
|
||||
DAT(305,"cannot open hydraulics file")
|
||||
DAT(306,"hydraulics file does not match network data")
|
||||
DAT(307,"cannot read hydraulics file")
|
||||
DAT(308,"cannot save results to file")
|
||||
DAT(309,"cannot save results to report file")
|
||||
466
src/funcs.h
466
src/funcs.h
@@ -1,281 +1,185 @@
|
||||
/*
|
||||
**************************************************************************
|
||||
|
||||
FUNCS.H -- Function Prototypes for EPANET Program
|
||||
|
||||
VERSION: 2.00
|
||||
DATE: 5/8/00
|
||||
9/25/00
|
||||
10/25/00
|
||||
12/29/00
|
||||
3/1/01
|
||||
2/14/08 (2.00.12)
|
||||
AUTHOR: L. Rossman
|
||||
US EPA - NRMRL
|
||||
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
/*****************************************************************/
|
||||
/* Most float arguments have been changed to double - 7/3/07 */
|
||||
/*****************************************************************/
|
||||
|
||||
/* ------- EPANET.C --------------------*/
|
||||
/*
|
||||
** NOTE: The exportable functions that can be called
|
||||
** via the DLL are prototyped in TOOLKIT.H.
|
||||
*/
|
||||
void initpointers(void); /* Initializes pointers */
|
||||
int allocdata(void); /* Allocates memory */
|
||||
void freeTmplist(STmplist *); /* Frees items in linked list */
|
||||
void freeFloatlist(SFloatlist *); /* Frees list of floats */
|
||||
void freedata(void); /* Frees allocated memory */
|
||||
int openfiles(char *,char *,char *); /* Opens input & report files */
|
||||
int openhydfile(void); /* Opens hydraulics file */
|
||||
int openoutfile(void); /* Opens binary output file */
|
||||
int strcomp(char *, char *); /* Compares two strings */
|
||||
char* getTmpName(char* fname); /* Gets temporary file name */ //(2.00.12 - LR)
|
||||
double interp(int, double *, /* Interpolates a data curve */
|
||||
double *, double);
|
||||
int findnode(char *); /* Finds node's index from ID */
|
||||
int findlink(char *); /* Finds link's index from ID */
|
||||
char* geterrmsg(int); /* Gets text of error message */
|
||||
void errmsg(int); /* Reports program error */
|
||||
void writecon(char *); /* Writes text to console */
|
||||
void writewin(char *); /* Passes text to calling app */
|
||||
|
||||
/* ------- INPUT1.C --------------------*/
|
||||
int getdata(void); /* Gets network data */
|
||||
void setdefaults(void); /* Sets default values */
|
||||
void initreport(void); /* Initializes report options */
|
||||
void adjustdata(void); /* Adjusts input data */
|
||||
int inittanks(void); /* Initializes tank levels */
|
||||
void initunits(void); /* Determines reporting units */
|
||||
void convertunits(void); /* Converts data to std. units*/
|
||||
|
||||
/* -------- INPUT2.C -------------------*/
|
||||
int netsize(void); /* Determines network size */
|
||||
int readdata(void); /* Reads in network data */
|
||||
int newline(int, char *); /* Processes new line of data */
|
||||
int addnodeID(int, char *); /* Adds node ID to data base */
|
||||
int addlinkID(int, char *); /* Adds link ID to data base */
|
||||
int addpattern(char *); /* Adds pattern to data base */
|
||||
int addcurve(char *); /* Adds curve to data base */
|
||||
STmplist *findID(char *, STmplist *); /* Locates ID on linked list */
|
||||
int unlinked(void); /* Checks for unlinked nodes */
|
||||
int getpumpparams(void); /* Computes pump curve coeffs.*/
|
||||
int getpatterns(void); /* Gets pattern data from list*/
|
||||
int getcurves(void); /* Gets curve data from list */
|
||||
int findmatch(char *,char *[]); /* Finds keyword in line */
|
||||
int match(char *, char *); /* Checks for word match */
|
||||
int gettokens(char *); /* Tokenizes input line */
|
||||
int getfloat(char *, double *); /* Converts string to double */
|
||||
double hour(char *, char *); /* Converts time to hours */
|
||||
int setreport(char *); /* Processes reporting command*/
|
||||
void inperrmsg(int,int,char *); /* Input error message */
|
||||
|
||||
/* ---------- INPUT3.C -----------------*/
|
||||
int juncdata(void); /* Processes junction data */
|
||||
int tankdata(void); /* Processes tank data */
|
||||
int pipedata(void); /* Processes pipe data */
|
||||
int pumpdata(void); /* Processes pump data */
|
||||
int valvedata(void); /* Processes valve data */
|
||||
int patterndata(void); /* Processes pattern data */
|
||||
int curvedata(void); /* Processes curve data */
|
||||
int demanddata(void); /* Processes demand data */
|
||||
int controldata(void); /* Processes simple controls */
|
||||
int energydata(void); /* Processes energy data */
|
||||
int sourcedata(void); /* Processes source data */
|
||||
int emitterdata(void); /* Processes emitter data */
|
||||
int qualdata(void); /* Processes quality data */
|
||||
int reactdata(void); /* Processes reaction data */
|
||||
int mixingdata(void); /* Processes tank mixing data */
|
||||
int statusdata(void); /* Processes link status data */
|
||||
int reportdata(void); /* Processes report options */
|
||||
int timedata(void); /* Processes time options */
|
||||
int optiondata(void); /* Processes analysis options */
|
||||
int optionchoice(int); /* Processes option choices */
|
||||
int optionvalue(int); /* Processes option values */
|
||||
int getpumpcurve(int); /* Constructs a pump curve */
|
||||
int powercurve(double, double, double,/* Coeffs. of power pump curve*/
|
||||
double, double, double *,
|
||||
double *, double *);
|
||||
int valvecheck(int, int, int); /* Checks valve placement */
|
||||
void changestatus(int, char, double); /* Changes status of a link */
|
||||
|
||||
/* -------------- RULES.C --------------*/
|
||||
void initrules(void); /* Initializes rule base */
|
||||
void addrule(char *); /* Adds rule to rule base */
|
||||
int allocrules(void); /* Allocates memory for rule */
|
||||
int ruledata(void); /* Processes rule input data */
|
||||
int checkrules(long); /* Checks all rules */
|
||||
void freerules(void); /* Frees rule base memory */
|
||||
|
||||
/* ------------- REPORT.C --------------*/
|
||||
int writereport(void); /* Writes formatted report */
|
||||
void writelogo(void); /* Writes program logo */
|
||||
void writesummary(void); /* Writes network summary */
|
||||
void writehydstat(int,double); /* Writes hydraulic status */
|
||||
void writeenergy(void); /* Writes energy usage */
|
||||
int writeresults(void); /* Writes node/link results */
|
||||
void writeheader(int,int); /* Writes heading on report */
|
||||
void writeline(char *); /* Writes line to report file */
|
||||
void writerelerr(int, double); /* Writes convergence error */
|
||||
void writestatchange(int,char,char); /* Writes link status change */
|
||||
void writecontrolaction(int, int); /* Writes control action taken*/
|
||||
void writeruleaction(int, char *); /* Writes rule action taken */
|
||||
int writehydwarn(int,double); /* Writes hydraulic warnings */
|
||||
void writehyderr(int); /* Writes hydraulic error msg.*/
|
||||
int disconnected(void); /* Checks for disconnections */
|
||||
void marknodes(int, int *, char *); /* Identifies connected nodes */
|
||||
void getclosedlink(int, char *); /* Finds a disconnecting link */
|
||||
void writelimits(int,int); /* Writes reporting limits */
|
||||
int checklimits(double *,int,int); /* Checks variable limits */
|
||||
void writetime(char *); /* Writes current clock time */
|
||||
char *clocktime(char *, long); /* Converts time to hrs:min */
|
||||
char *fillstr(char *, char, int); /* Fills string with character*/
|
||||
int getnodetype(int); /* Determines node type */
|
||||
|
||||
/* --------- HYDRAUL.C -----------------*/
|
||||
int openhyd(void); /* Opens hydraulics solver */
|
||||
|
||||
/*** Updated 3/1/01 ***/
|
||||
void inithyd(int); /* Re-sets initial conditions */
|
||||
|
||||
int runhyd(long *); /* Solves 1-period hydraulics */
|
||||
int nexthyd(long *); /* Moves to next time period */
|
||||
void closehyd(void); /* Closes hydraulics solver */
|
||||
int allocmatrix(void); /* Allocates matrix coeffs. */
|
||||
void freematrix(void); /* Frees matrix coeffs. */
|
||||
void initlinkflow(int, char, double); /* Initializes link flow */
|
||||
void setlinkflow(int, double); /* Sets link flow via headloss*/
|
||||
void setlinkstatus(int, char, char *, /* Sets link status */
|
||||
double *);
|
||||
void setlinksetting(int, double, /* Sets pump/valve setting */
|
||||
char *, double *);
|
||||
void resistance(int); /* Computes resistance coeff. */
|
||||
void demands(void); /* Computes current demands */
|
||||
int controls(void); /* Controls link settings */
|
||||
long timestep(void); /* Computes new time step */
|
||||
void tanktimestep(long *); /* Time till tanks fill/drain */
|
||||
void controltimestep(long *); /* Time till control action */
|
||||
void ruletimestep(long *); /* Time till rule action */
|
||||
void addenergy(long); /* Accumulates energy usage */
|
||||
void getenergy(int, double *, double *); /* Computes link energy use */
|
||||
void tanklevels(long); /* Computes new tank levels */
|
||||
double tankvolume(int,double); /* Finds tank vol. from grade */
|
||||
double tankgrade(int,double); /* Finds tank grade from vol. */
|
||||
int netsolve(int *,double *); /* Solves network equations */
|
||||
int badvalve(int); /* Checks for bad valve */
|
||||
int valvestatus(void); /* Updates valve status */
|
||||
int linkstatus(void); /* Updates link status */
|
||||
char cvstatus(char,double,double); /* Updates CV status */
|
||||
char pumpstatus(int,double); /* Updates pump status */
|
||||
char prvstatus(int,char,double, /* Updates PRV status */
|
||||
double,double);
|
||||
char psvstatus(int,char,double, /* Updates PSV status */
|
||||
double,double);
|
||||
char fcvstatus(int,char,double, /* Updates FCV status */
|
||||
double);
|
||||
void tankstatus(int,int,int); /* Checks if tank full/empty */
|
||||
int pswitch(void); /* Pressure switch controls */
|
||||
double newflows(void); /* Updates link flows */
|
||||
void newcoeffs(void); /* Computes matrix coeffs. */
|
||||
void linkcoeffs(void); /* Computes link coeffs. */
|
||||
void nodecoeffs(void); /* Computes node coeffs. */
|
||||
void valvecoeffs(void); /* Computes valve coeffs. */
|
||||
void pipecoeff(int); /* Computes pipe coeff. */
|
||||
double DWcoeff(int, double *); /* Computes D-W coeff. */
|
||||
void pumpcoeff(int); /* Computes pump coeff. */
|
||||
|
||||
/*** Updated 10/25/00 ***/
|
||||
/*** Updated 12/29/00 ***/
|
||||
void curvecoeff(int,double,double *, /* Computes curve coeffs. */
|
||||
double *);
|
||||
|
||||
void gpvcoeff(int); /* Computes GPV coeff. */
|
||||
void pbvcoeff(int); /* Computes PBV coeff. */
|
||||
void tcvcoeff(int); /* Computes TCV coeff. */
|
||||
void prvcoeff(int,int,int); /* Computes PRV coeff. */
|
||||
void psvcoeff(int,int,int); /* Computes PSV coeff. */
|
||||
void fcvcoeff(int,int,int); /* Computes FCV coeff. */
|
||||
void emittercoeffs(void); /* Computes emitter coeffs. */
|
||||
double emitflowchange(int); /* Computes new emitter flow */
|
||||
|
||||
/* ----------- SMATRIX.C ---------------*/
|
||||
int createsparse(void); /* Creates sparse matrix */
|
||||
int allocsparse(void); /* Allocates matrix memory */
|
||||
void freesparse(void); /* Frees matrix memory */
|
||||
int buildlists(int); /* Builds adjacency lists */
|
||||
int paralink(int, int, int); /* Checks for parallel links */
|
||||
void xparalinks(void); /* Removes parallel links */
|
||||
void freelists(void); /* Frees adjacency lists */
|
||||
void countdegree(void); /* Counts links at each node */
|
||||
int reordernodes(void); /* Finds a node re-ordering */
|
||||
int mindegree(int, int); /* Finds min. degree node */
|
||||
int growlist(int); /* Augments adjacency list */
|
||||
int newlink(Padjlist); /* Adds fill-ins for a node */
|
||||
int linked(int, int); /* Checks if 2 nodes linked */
|
||||
int addlink(int, int, int); /* Creates new fill-in */
|
||||
int storesparse(int); /* Stores sparse matrix */
|
||||
int ordersparse(int); /* Orders matrix storage */
|
||||
void transpose(int,int *,int *, /* Transposes sparse matrix */
|
||||
int *,int *,int *,int *,int *);
|
||||
int linsolve(int, double *, double *, /* Solution of linear eqns. */
|
||||
double *); /* via Cholesky factorization */
|
||||
|
||||
/* ----------- QUALITY.C ---------------*/
|
||||
int openqual(void); /* Opens WQ solver system */
|
||||
void initqual(void); /* Initializes WQ solver */
|
||||
int runqual(long *); /* Gets current WQ results */
|
||||
int nextqual(long *); /* Updates WQ by hyd.timestep */
|
||||
int stepqual(long *); /* Updates WQ by WQ time step */
|
||||
int closequal(void); /* Closes WQ solver system */
|
||||
int gethyd(long *, long *); /* Gets next hyd. results */
|
||||
char setReactflag(void); /* Checks for reactive chem. */
|
||||
void transport(long); /* Transports mass in network */
|
||||
void initsegs(void); /* Initializes WQ segments */
|
||||
void reorientsegs(void); /* Re-orients WQ segments */
|
||||
void updatesegs(long); /* Updates quality in segments*/
|
||||
void removesegs(int); /* Removes a WQ segment */
|
||||
void addseg(int,double,double); /* Adds a WQ segment to pipe */
|
||||
void accumulate(long); /* Sums mass flow into node */
|
||||
void updatenodes(long); /* Updates WQ at nodes */
|
||||
void sourceinput(long); /* Computes source inputs */
|
||||
void release(long); /* Releases mass from nodes */
|
||||
void updatetanks(long); /* Updates WQ in tanks */
|
||||
void updatesourcenodes(long); /* Updates WQ at source nodes */
|
||||
void tankmix1(int, long); /* Complete mix tank model */
|
||||
void tankmix2(int, long); /* 2-compartment tank model */
|
||||
void tankmix3(int, long); /* FIFO tank model */
|
||||
void tankmix4(int, long); /* LIFO tank model */
|
||||
double sourcequal(Psource); /* Finds WQ input from source */
|
||||
double avgqual(int); /* Finds avg. quality in pipe */
|
||||
void ratecoeffs(void); /* Finds wall react. coeffs. */
|
||||
double piperate(int); /* Finds wall react. coeff. */
|
||||
double pipereact(int,double,double,long);/* Reacts water in a pipe */
|
||||
double tankreact(double,double,double,
|
||||
long); /* Reacts water in a tank */
|
||||
double bulkrate(double,double,double); /* Finds bulk reaction rate */
|
||||
double wallrate(double,double,double,double);/* Finds wall reaction rate */
|
||||
|
||||
|
||||
/* ------------ OUTPUT.C ---------------*/
|
||||
int savenetdata(void); /* Saves basic data to file */
|
||||
int savehyd(long *); /* Saves hydraulic solution */
|
||||
int savehydstep(long *); /* Saves hydraulic timestep */
|
||||
int saveenergy(void); /* Saves energy usage */
|
||||
int readhyd(long *); /* Reads hydraulics from file */
|
||||
int readhydstep(long *); /* Reads time step from file */
|
||||
int saveoutput(void); /* Saves results to file */
|
||||
int nodeoutput(int, REAL4 *, double); /* Saves node results to file */
|
||||
int linkoutput(int, REAL4 *, double); /* Saves link results to file */
|
||||
int savefinaloutput(void); /* Finishes saving output */
|
||||
int savetimestat(REAL4 *, char); /* Saves time stats to file */
|
||||
int savenetreacts(double, double,
|
||||
double, double); /* Saves react. rates to file */
|
||||
int saveepilog(void); /* Saves output file epilog */
|
||||
|
||||
|
||||
/* ------------ INPFILE.C --------------*/
|
||||
int saveinpfile(char *); /* Saves network to text file */
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: funcs.h
|
||||
Description: prototypes of external functions called by various modules
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 04/18/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef FUNCS_H
|
||||
#define FUNCS_H
|
||||
|
||||
// ------- PROJECT.C ------------
|
||||
|
||||
void initpointers(Project *);
|
||||
int allocdata(Project *);
|
||||
void freedata(Project *);
|
||||
|
||||
int openfiles(Project *, const char *, const char *,const char *);
|
||||
int openhydfile(Project *);
|
||||
int openoutfile(Project *);
|
||||
void closeoutfile(Project *);
|
||||
|
||||
int buildadjlists(Network *);
|
||||
void freeadjlists(Network *);
|
||||
|
||||
int incontrols(Project *, int, int);
|
||||
int valvecheck(Project *, int, int, int);
|
||||
int findnode(Network *, char *);
|
||||
int findlink(Network *, char *);
|
||||
int findtank(Network *, int);
|
||||
int findvalve(Network *, int);
|
||||
int findpump(Network *, int);
|
||||
int findpattern(Network *, char *);
|
||||
int findcurve(Network *, char *);
|
||||
|
||||
void adjustpatterns(Network *, int);
|
||||
void adjustcurves(Network *, int);
|
||||
int resizecurve(Scurve *, int);
|
||||
|
||||
int getcomment(Network *, int, int, char *);
|
||||
int setcomment(Network *, int, int, const char *);
|
||||
|
||||
int namevalid(const char *);
|
||||
char *getTmpName(char *);
|
||||
char *xstrcpy(char **, const char *, const size_t n);
|
||||
int strcomp(const char *, const char *);
|
||||
double interp(int, double [], double [], double);
|
||||
char *geterrmsg(int, char *);
|
||||
void errmsg(Project *, int);
|
||||
void writewin(void (*vp)(char *), char *);
|
||||
|
||||
// ------- INPUT1.C ----------------
|
||||
|
||||
int getdata(Project *);
|
||||
void setdefaults(Project *);
|
||||
void initreport(Report *);
|
||||
void adjustdata(Project *);
|
||||
int inittanks(Project *);
|
||||
void initunits(Project *);
|
||||
void convertunits(Project *);
|
||||
|
||||
//-------- INPUT2.C -----------------
|
||||
|
||||
int netsize(Project *);
|
||||
int readdata(Project *);
|
||||
int updatepumpparams(Project *, int);
|
||||
int findmatch(char *, char *[]);
|
||||
int match(const char *, const char *);
|
||||
int gettokens(char *, char **, int, char *);
|
||||
int getfloat(char *, double *);
|
||||
double hour(char *, char *);
|
||||
int setreport(Project *, char *);
|
||||
|
||||
// ------- INPUT3.C -----------------
|
||||
|
||||
int juncdata(Project *);
|
||||
int tankdata(Project *);
|
||||
int pipedata(Project *);
|
||||
int pumpdata(Project *);
|
||||
int valvedata(Project *);
|
||||
int patterndata(Project *);
|
||||
int curvedata(Project *);
|
||||
int coordata(Project *);
|
||||
int demanddata(Project *);
|
||||
int controldata(Project *);
|
||||
int energydata(Project *);
|
||||
int sourcedata(Project *);
|
||||
int emitterdata(Project *);
|
||||
int qualdata(Project *);
|
||||
int reactdata(Project *);
|
||||
int mixingdata(Project *);
|
||||
int statusdata(Project *);
|
||||
int reportdata(Project *);
|
||||
int timedata(Project *);
|
||||
int optiondata(Project *);
|
||||
|
||||
// ------- RULES.C ------------------
|
||||
|
||||
void initrules(Project *);
|
||||
void addrule(Parser *, char *);
|
||||
void deleterule(Project *, int);
|
||||
int allocrules(Project *);
|
||||
void freerules(Project *);
|
||||
int ruledata(Project *);
|
||||
void ruleerrmsg(Project *);
|
||||
void adjustrules(Project *, int, int);
|
||||
void adjusttankrules(Project *);
|
||||
Spremise *getpremise(Spremise *, int);
|
||||
Saction *getaction(Saction *, int);
|
||||
int writerule(Project *, FILE *, int);
|
||||
int checkrules(Project *, long);
|
||||
|
||||
// ------- REPORT.C -----------------
|
||||
|
||||
int clearreport(Project *);
|
||||
int copyreport(Project *, char *);
|
||||
int writereport(Project *);
|
||||
void writelogo(Project *);
|
||||
void writesummary(Project *);
|
||||
void writehydstat(Project *, int, double);
|
||||
void writeheader(Project *, int,int);
|
||||
void writeline(Project *, char *);
|
||||
void writerelerr(Project *, int, double);
|
||||
void writestatchange(Project *, int,char,char);
|
||||
void writecontrolaction(Project *, int, int);
|
||||
void writeruleaction(Project *, int, char *);
|
||||
int writehydwarn(Project *, int,double);
|
||||
void writehyderr(Project *, int);
|
||||
void writemassbalance(Project *);
|
||||
void writetime(Project *, char *);
|
||||
char *clocktime(char *, long);
|
||||
|
||||
// ------- HYDRAUL.C -----------------
|
||||
|
||||
int openhyd(Project *);
|
||||
void inithyd(Project *, int initFlags);
|
||||
int runhyd(Project *, long *);
|
||||
int nexthyd(Project *, long *);
|
||||
void closehyd(Project *);
|
||||
void setlinkstatus(Project *, int, char, StatusType *, double *);
|
||||
void setlinksetting(Project *, int, double, StatusType *, double *);
|
||||
int tanktimestep(Project *, long *);
|
||||
void getenergy(Project *, int, double *, double *);
|
||||
double tankvolume(Project *, int, double);
|
||||
double tankgrade(Project *, int, double);
|
||||
|
||||
// ------- HYDCOEFFS.C -----------------
|
||||
|
||||
void resistcoeff(Project *, int);
|
||||
void headlosscoeffs(Project *);
|
||||
void matrixcoeffs(Project *);
|
||||
void emitheadloss(Project *, int, double *, double *);
|
||||
double demandflowchange(Project *, int, double, double);
|
||||
void demandparams(Project *, double *, double *);
|
||||
|
||||
// ------- QUALITY.C --------------------
|
||||
|
||||
int openqual(Project *);
|
||||
int initqual(Project *);
|
||||
int runqual(Project *, long *);
|
||||
int nextqual(Project *, long *);
|
||||
int stepqual(Project *, long *);
|
||||
int closequal(Project *);
|
||||
double avgqual(Project *, int);
|
||||
|
||||
// ------- OUTPUT.C ---------------------
|
||||
|
||||
int savenetdata(Project *);
|
||||
int savehyd(Project *, long *);
|
||||
int savehydstep(Project *, long *);
|
||||
int saveenergy(Project *);
|
||||
int readhyd(Project *, long *);
|
||||
int readhydstep(Project *, long *);
|
||||
int saveoutput(Project *);
|
||||
int savefinaloutput(Project *);
|
||||
|
||||
// ------- INPFILE.C --------------------
|
||||
|
||||
int saveinpfile(Project *, const char *);
|
||||
|
||||
#endif
|
||||
|
||||
1000
src/genmmd.c
Normal file
1000
src/genmmd.c
Normal file
File diff suppressed because it is too large
Load Diff
255
src/hash.c
255
src/hash.c
@@ -1,114 +1,183 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
** hash.c
|
||||
**
|
||||
** Implementation of a simple Hash Table for string storage & retrieval
|
||||
**
|
||||
** Written by L. Rossman
|
||||
** Last Updated on 6/19/03
|
||||
**
|
||||
** The hash table data structure (HTable) is defined in "hash.h".
|
||||
** Interface Functions:
|
||||
** HTcreate() - creates a hash table
|
||||
** HTinsert() - inserts a string & its index value into a hash table
|
||||
** HTfind() - retrieves the index value of a string from a table
|
||||
** HTfree() - frees a hash table
|
||||
**
|
||||
*********************************************************************
|
||||
** NOTE: This is a modified version of the original HASH.C module.
|
||||
*********************************************************************
|
||||
*/
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: hash.c
|
||||
Description: implementation of a simple hash table
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include "hash.h"
|
||||
|
||||
/* Use Fletcher's checksum to compute 2-byte hash of string */
|
||||
unsigned int hash(char *str)
|
||||
#define HASHTABLEMAXSIZE 128000
|
||||
|
||||
// An entry in the hash table
|
||||
typedef struct DataEntryStruct
|
||||
{
|
||||
unsigned int sum1= 0, check1;
|
||||
unsigned long sum2= 0L;
|
||||
while( '\0' != *str )
|
||||
char *key;
|
||||
int data;
|
||||
struct DataEntryStruct *next;
|
||||
} DataEntry;
|
||||
|
||||
// Hash a string to an integer
|
||||
unsigned int gethash(char *str)
|
||||
{
|
||||
unsigned int hash = 5381;
|
||||
unsigned int retHash;
|
||||
int c;
|
||||
while ((c = *str++))
|
||||
{
|
||||
sum1 += (*str);
|
||||
str++;
|
||||
if ( 255 <= sum1 ) sum1 -= 255;
|
||||
sum2 += sum1;
|
||||
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||
}
|
||||
check1= sum2;
|
||||
check1 %= 255;
|
||||
check1= 255 - (sum1+check1) % 255;
|
||||
sum1= 255 - (sum1+check1) % 255;
|
||||
return( ( ( check1 << 8 ) | sum1 ) % HTMAXSIZE);
|
||||
retHash = hash % HASHTABLEMAXSIZE;
|
||||
return retHash;
|
||||
}
|
||||
|
||||
HTtable *HTcreate()
|
||||
// Produce a duplicate string
|
||||
char *dupstr(const char *s)
|
||||
{
|
||||
int i;
|
||||
HTtable *ht = (HTtable *) calloc(HTMAXSIZE, sizeof(HTtable));
|
||||
if (ht != NULL) for (i=0; i<HTMAXSIZE; i++) ht[i] = NULL;
|
||||
return(ht);
|
||||
size_t size = strlen(s) + 1;
|
||||
char *p = malloc(size);
|
||||
if (p) memcpy(p, s, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
int HTinsert(HTtable *ht, char *key, int data)
|
||||
// Create a hash table
|
||||
HashTable *hashtable_create()
|
||||
{
|
||||
unsigned int i = hash(key);
|
||||
struct HTentry *entry;
|
||||
if ( i >= HTMAXSIZE ) return(0);
|
||||
entry = (struct HTentry *) malloc(sizeof(struct HTentry));
|
||||
if (entry == NULL) return(0);
|
||||
entry->key = key;
|
||||
entry->data = data;
|
||||
entry->next = ht[i];
|
||||
ht[i] = entry;
|
||||
return(1);
|
||||
int i;
|
||||
HashTable *ht = (HashTable *) calloc(HASHTABLEMAXSIZE, sizeof(HashTable));
|
||||
if (ht != NULL)
|
||||
{
|
||||
for (i = 0; i < HASHTABLEMAXSIZE; i++) ht[i] = NULL;
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
|
||||
int HTfind(HTtable *ht, char *key)
|
||||
// Insert an entry into the hash table
|
||||
int hashtable_insert(HashTable *ht, char *key, int data)
|
||||
{
|
||||
unsigned int i = hash(key);
|
||||
struct HTentry *entry;
|
||||
if ( i >= HTMAXSIZE ) return(NOTFOUND);
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
if ( i >= HASHTABLEMAXSIZE ) return 0;
|
||||
entry = (DataEntry *) malloc(sizeof(DataEntry));
|
||||
if (entry == NULL) return(0);
|
||||
entry->key = dupstr(key);
|
||||
entry->data = data;
|
||||
entry->next = ht[i];
|
||||
ht[i] = entry;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Change the hash table's data entry for a particular key
|
||||
int hashtable_update(HashTable *ht, char *key, int new_data)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NOTFOUND;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key, key) == 0 )
|
||||
{
|
||||
entry->data = new_data;
|
||||
return 1;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return NOTFOUND;
|
||||
}
|
||||
|
||||
// Delete an entry in the hash table
|
||||
int hashtable_delete(HashTable *ht, char *key)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry, *preventry;
|
||||
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NOTFOUND;
|
||||
|
||||
preventry = NULL;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if (strcmp(entry->key, key) == 0)
|
||||
{
|
||||
if (preventry == NULL) ht[i] = entry->next;
|
||||
else preventry->next = entry->next;
|
||||
free(entry->key);
|
||||
free(entry);
|
||||
return 1;
|
||||
}
|
||||
preventry = entry;
|
||||
entry = entry->next;
|
||||
}
|
||||
return NOTFOUND;
|
||||
}
|
||||
|
||||
// Find the data for a particular key
|
||||
int hashtable_find(HashTable *ht, char *key)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NOTFOUND;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key, key) == 0 )
|
||||
{
|
||||
return entry->data;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return NOTFOUND;
|
||||
}
|
||||
|
||||
// Find a particular key in the hash table
|
||||
char *hashtable_findkey(HashTable *ht, char *key)
|
||||
{
|
||||
unsigned int i = gethash(key);
|
||||
DataEntry *entry;
|
||||
if ( i >= HASHTABLEMAXSIZE ) return NULL;
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key, key) == 0 ) return entry->key;
|
||||
entry = entry->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Delete a hash table and free all of its memory
|
||||
void hashtable_free(HashTable *ht)
|
||||
{
|
||||
DataEntry *entry, *nextentry;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < HASHTABLEMAXSIZE; i++)
|
||||
{
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key,key) == 0 ) return(entry->data);
|
||||
entry = entry->next;
|
||||
nextentry = entry->next;
|
||||
free(entry->key);
|
||||
free(entry);
|
||||
entry = nextentry;
|
||||
}
|
||||
return(NOTFOUND);
|
||||
}
|
||||
|
||||
char *HTfindKey(HTtable *ht, char *key)
|
||||
{
|
||||
unsigned int i = hash(key);
|
||||
struct HTentry *entry;
|
||||
if ( i >= HTMAXSIZE ) return(NULL);
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
if ( strcmp(entry->key,key) == 0 ) return(entry->key);
|
||||
entry = entry->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void HTfree(HTtable *ht)
|
||||
{
|
||||
struct HTentry *entry,
|
||||
*nextentry;
|
||||
int i;
|
||||
for (i=0; i<HTMAXSIZE; i++)
|
||||
{
|
||||
entry = ht[i];
|
||||
while (entry != NULL)
|
||||
{
|
||||
nextentry = entry->next;
|
||||
free(entry);
|
||||
entry = nextentry;
|
||||
}
|
||||
}
|
||||
free(ht);
|
||||
ht[i] = NULL;
|
||||
}
|
||||
free(ht);
|
||||
}
|
||||
|
||||
40
src/hash.h
40
src/hash.h
@@ -1,24 +1,28 @@
|
||||
/* HASH.H
|
||||
**
|
||||
** Header file for Hash Table module HASH.C
|
||||
**
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: hash.h
|
||||
Description: header for a simple hash table
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef HASH_H
|
||||
#define HASH_H
|
||||
|
||||
#define HTMAXSIZE 1999
|
||||
#define NOTFOUND 0
|
||||
|
||||
struct HTentry
|
||||
{
|
||||
char *key;
|
||||
int data;
|
||||
struct HTentry *next;
|
||||
};
|
||||
typedef struct DataEntryStruct *HashTable;
|
||||
|
||||
typedef struct HTentry *HTtable;
|
||||
HashTable *hashtable_create(void);
|
||||
int hashtable_insert(HashTable *, char *, int);
|
||||
int hashtable_find(HashTable *, char *);
|
||||
char *hashtable_findkey(HashTable *, char *);
|
||||
void hashtable_free(HashTable *);
|
||||
int hashtable_update(HashTable *ht, char *key, int new_data);
|
||||
int hashtable_delete(HashTable *ht, char *key);
|
||||
|
||||
HTtable *HTcreate(void);
|
||||
int HTinsert(HTtable *, char *, int);
|
||||
int HTfind(HTtable *, char *);
|
||||
char *HTfindKey(HTtable *, char *);
|
||||
void HTfree(HTtable *);
|
||||
|
||||
#endif
|
||||
|
||||
1208
src/hydcoeffs.c
Normal file
1208
src/hydcoeffs.c
Normal file
File diff suppressed because it is too large
Load Diff
3672
src/hydraul.c
3672
src/hydraul.c
File diff suppressed because it is too large
Load Diff
660
src/hydsolver.c
Normal file
660
src/hydsolver.c
Normal file
@@ -0,0 +1,660 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: hydsolver.c
|
||||
Description: computes flows and pressures throughout a pipe network using
|
||||
Todini's Global Gradient Algorithm
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "funcs.h"
|
||||
#include "text.h"
|
||||
|
||||
// Hydraulic balance error for network being analyzed
|
||||
typedef struct {
|
||||
double maxheaderror;
|
||||
double maxflowerror;
|
||||
double maxflowchange;
|
||||
int maxheadlink;
|
||||
int maxflownode;
|
||||
int maxflowlink;
|
||||
} Hydbalance;
|
||||
|
||||
// Exported functions
|
||||
int hydsolve(Project *, int *, double *);
|
||||
|
||||
// Imported functions
|
||||
extern int linsolve(Smatrix *, int); //(see SMATRIX.C)
|
||||
extern int valvestatus(Project *); //(see HYDSTATUS.C)
|
||||
extern int linkstatus(Project *); //(see HYDSTATUS.C)
|
||||
|
||||
// Local functions
|
||||
static int badvalve(Project *, int);
|
||||
static int pswitch(Project *);
|
||||
|
||||
static double newflows(Project *, Hydbalance *);
|
||||
static void newlinkflows(Project *, Hydbalance *, double *, double *);
|
||||
static void newemitterflows(Project *, Hydbalance *, double *, double *);
|
||||
static void newdemandflows(Project *, Hydbalance *, double *, double *);
|
||||
|
||||
static void checkhydbalance(Project *, Hydbalance *);
|
||||
static int hasconverged(Project *, double *, Hydbalance *);
|
||||
static void reporthydbal(Project *, Hydbalance *);
|
||||
|
||||
|
||||
int hydsolve(Project *pr, int *iter, double *relerr)
|
||||
/*
|
||||
**-------------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: *iter = # of iterations to reach solution
|
||||
** *relerr = convergence error in solution
|
||||
** returns error code
|
||||
** Purpose: solves network nodal equations for heads and flows
|
||||
** using Todini's Gradient algorithm
|
||||
**
|
||||
** Notes: Status checks on CVs, pumps and pipes to tanks are made
|
||||
** every CheckFreq iteration, up until MaxCheck iterations
|
||||
** are reached. Status checks on control valves are made
|
||||
** every iteration if DampLimit = 0 or only when the
|
||||
** convergence error is at or below DampLimit. If DampLimit
|
||||
** is > 0 then future computed flow changes are only 60% of
|
||||
** their full value. A complete status check on all links
|
||||
** is made when convergence is achieved. If convergence is
|
||||
** not achieved in MaxIter trials and ExtraIter > 0 then
|
||||
** another ExtraIter trials are made with no status changes
|
||||
** made to any links and a warning message is generated.
|
||||
**
|
||||
** This procedure calls linsolve() which appears in SMATRIX.C.
|
||||
**-------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Smatrix *sm = &hyd->smatrix;
|
||||
Report *rpt = &pr->report;
|
||||
|
||||
int i; // Node index
|
||||
int errcode = 0; // Node causing solution error
|
||||
int nextcheck; // Next status check trial
|
||||
int maxtrials; // Max. trials for convergence
|
||||
double newerr; // New convergence error
|
||||
int valveChange; // Valve status change flag
|
||||
int statChange; // Non-valve status change flag
|
||||
Hydbalance hydbal; // Hydraulic balance errors
|
||||
|
||||
// Initialize status checking & relaxation factor
|
||||
nextcheck = hyd->CheckFreq;
|
||||
hyd->RelaxFactor = 1.0;
|
||||
hydbal.maxheaderror = 0.0;
|
||||
hydbal.maxflowchange = 0.0;
|
||||
|
||||
// Repeat iterations until convergence or trial limit is exceeded.
|
||||
// (ExtraIter used to increase trials in case of status cycling.)
|
||||
if (rpt->Statflag == FULL) writerelerr(pr, 0, 0);
|
||||
maxtrials = hyd->MaxIter;
|
||||
if (hyd->ExtraIter > 0) maxtrials += hyd->ExtraIter;
|
||||
*iter = 1;
|
||||
while (*iter <= maxtrials)
|
||||
{
|
||||
// Compute coefficient matrices A & F and solve A*H = F
|
||||
// where H = heads, A = Jacobian coeffs. derived from
|
||||
// head loss gradients, & F = flow correction terms.
|
||||
// Solution for H is returned in F from call to linsolve().
|
||||
|
||||
headlosscoeffs(pr);
|
||||
matrixcoeffs(pr);
|
||||
errcode = linsolve(sm, net->Njuncs);
|
||||
|
||||
// Matrix ill-conditioning problem - if control valve causing problem,
|
||||
// fix its status & continue, otherwise quit with no solution.
|
||||
if (errcode > 0)
|
||||
{
|
||||
if (badvalve(pr, sm->Order[errcode])) continue;
|
||||
else break;
|
||||
}
|
||||
|
||||
// Update current solution.
|
||||
// (Row[i] = row of solution matrix corresponding to node i)
|
||||
for (i = 1; i <= net->Njuncs; i++)
|
||||
{
|
||||
hyd->NodeHead[i] = sm->F[sm->Row[i]]; // Update heads
|
||||
}
|
||||
newerr = newflows(pr, &hydbal); // Update flows
|
||||
*relerr = newerr;
|
||||
|
||||
// Write convergence error to status report if called for
|
||||
if (rpt->Statflag == FULL)
|
||||
{
|
||||
writerelerr(pr, *iter, *relerr);
|
||||
}
|
||||
|
||||
// Apply solution damping & check for change in valve status
|
||||
hyd->RelaxFactor = 1.0;
|
||||
valveChange = FALSE;
|
||||
if (hyd->DampLimit > 0.0)
|
||||
{
|
||||
if (*relerr <= hyd->DampLimit)
|
||||
{
|
||||
hyd->RelaxFactor = 0.6;
|
||||
valveChange = valvestatus(pr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valveChange = valvestatus(pr);
|
||||
}
|
||||
|
||||
// Check for convergence
|
||||
if (hasconverged(pr, relerr, &hydbal))
|
||||
{
|
||||
// We have convergence - quit if we are into extra iterations
|
||||
if (*iter > hyd->MaxIter) break;
|
||||
|
||||
// Quit if no status changes occur
|
||||
statChange = FALSE;
|
||||
if (valveChange) statChange = TRUE;
|
||||
if (linkstatus(pr)) statChange = TRUE;
|
||||
if (pswitch(pr)) statChange = TRUE;
|
||||
if (!statChange) break;
|
||||
|
||||
// We have a status change so continue the iterations
|
||||
nextcheck = *iter + hyd->CheckFreq;
|
||||
}
|
||||
|
||||
// No convergence yet - see if its time for a periodic status
|
||||
// check on pumps, CV's, and pipes connected to tank
|
||||
else if (*iter <= hyd->MaxCheck && *iter == nextcheck)
|
||||
{
|
||||
linkstatus(pr);
|
||||
nextcheck += hyd->CheckFreq;
|
||||
}
|
||||
(*iter)++;
|
||||
}
|
||||
|
||||
// Iterations ended - report any errors.
|
||||
if (errcode > 0)
|
||||
{
|
||||
writehyderr(pr, sm->Order[errcode]); // Ill-conditioned matrix error
|
||||
errcode = 110;
|
||||
}
|
||||
|
||||
// Replace junction demands with total outflow values
|
||||
for (i = 1; i <= net->Njuncs; i++)
|
||||
{
|
||||
hyd->NodeDemand[i] = hyd->DemandFlow[i] + hyd->EmitterFlow[i];
|
||||
}
|
||||
|
||||
// Save convergence info
|
||||
hyd->RelativeError = *relerr;
|
||||
hyd->MaxHeadError = hydbal.maxheaderror;
|
||||
hyd->MaxFlowChange = hydbal.maxflowchange;
|
||||
hyd->Iterations = *iter;
|
||||
|
||||
return errcode;
|
||||
}
|
||||
|
||||
|
||||
int badvalve(Project *pr, int n)
|
||||
/*
|
||||
**-----------------------------------------------------------------
|
||||
** Input: n = node index
|
||||
** Output: returns 1 if node n belongs to an active control valve,
|
||||
** 0 otherwise
|
||||
** Purpose: determines if a node belongs to an active control valve
|
||||
** whose setting causes an inconsistent set of eqns. If so,
|
||||
** the valve status is fixed open and a warning condition
|
||||
** is generated.
|
||||
**-----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Report *rpt = &pr->report;
|
||||
Times *time = &pr->times;
|
||||
|
||||
int i, k, n1, n2;
|
||||
Slink *link;
|
||||
LinkType t;
|
||||
|
||||
for (i = 1; i <= net->Nvalves; i++)
|
||||
{
|
||||
k = net->Valve[i].Link;
|
||||
link = &net->Link[k];
|
||||
n1 = link->N1;
|
||||
n2 = link->N2;
|
||||
if (n == n1 || n == n2)
|
||||
{
|
||||
t = link->Type;
|
||||
if (t == PRV || t == PSV || t == FCV)
|
||||
{
|
||||
if (hyd->LinkStatus[k] == ACTIVE)
|
||||
{
|
||||
if (rpt->Statflag == FULL)
|
||||
{
|
||||
sprintf(pr->Msg, FMT61,
|
||||
clocktime(rpt->Atime, time->Htime), link->ID);
|
||||
writeline(pr, pr->Msg);
|
||||
}
|
||||
if (link->Type == FCV) hyd->LinkStatus[k] = XFCV;
|
||||
else hyd->LinkStatus[k] = XPRESSURE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pswitch(Project *pr)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns 1 if status of any link changes, 0 if not
|
||||
** Purpose: adjusts settings of links controlled by junction
|
||||
** pressures after a hydraulic solution is found
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Report *rpt = &pr->report;
|
||||
|
||||
int i, // Control statement index
|
||||
k, // Index of link being controlled
|
||||
n, // Node controlling link k
|
||||
reset, // Flag on control conditions
|
||||
change, // Flag for status or setting change
|
||||
anychange = 0; // Flag for 1 or more control actions
|
||||
char s; // Current link status
|
||||
Slink *link;
|
||||
|
||||
// Check each control statement
|
||||
for (i = 1; i <= net->Ncontrols; i++)
|
||||
{
|
||||
reset = 0;
|
||||
k = net->Control[i].Link;
|
||||
if (k <= 0) continue;
|
||||
|
||||
// Determine if control based on a junction, not a tank
|
||||
n = net->Control[i].Node;
|
||||
if (n > 0 && n <= net->Njuncs)
|
||||
{
|
||||
// Determine if control conditions are satisfied
|
||||
if (net->Control[i].Type == LOWLEVEL &&
|
||||
hyd->NodeHead[n] <= net->Control[i].Grade + hyd->Htol)
|
||||
{
|
||||
reset = 1;
|
||||
}
|
||||
if (net->Control[i].Type == HILEVEL &&
|
||||
hyd->NodeHead[n] >= net->Control[i].Grade - hyd->Htol)
|
||||
{
|
||||
reset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if control forces a status or setting change
|
||||
if (reset == 1)
|
||||
{
|
||||
link = &net->Link[k];
|
||||
change = 0;
|
||||
s = hyd->LinkStatus[k];
|
||||
if (link->Type == PIPE)
|
||||
{
|
||||
if (s != net->Control[i].Status) change = 1;
|
||||
}
|
||||
if (link->Type == PUMP)
|
||||
{
|
||||
if (hyd->LinkSetting[k] != net->Control[i].Setting) change = 1;
|
||||
}
|
||||
if (link->Type >= PRV)
|
||||
{
|
||||
if (hyd->LinkSetting[k] != net->Control[i].Setting) change = 1;
|
||||
else if (hyd->LinkSetting[k] == MISSING && s != net->Control[i].Status)
|
||||
{
|
||||
change = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// If a change occurs, update status & setting
|
||||
if (change)
|
||||
{
|
||||
hyd->LinkStatus[k] = net->Control[i].Status;
|
||||
if (link->Type > PIPE)
|
||||
{
|
||||
hyd->LinkSetting[k] = net->Control[i].Setting;
|
||||
}
|
||||
if (rpt->Statflag == FULL)
|
||||
{
|
||||
writestatchange(pr, k, s, hyd->LinkStatus[k]);
|
||||
}
|
||||
anychange = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return anychange;
|
||||
}
|
||||
|
||||
|
||||
double newflows(Project *pr, Hydbalance *hbal)
|
||||
/*
|
||||
**----------------------------------------------------------------
|
||||
** Input: hbal = ptr. to hydraulic balance information
|
||||
** Output: returns solution convergence error
|
||||
** Purpose: updates link, emitter & demand flows after new
|
||||
** nodal heads are computed.
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
double dqsum, // Network flow change
|
||||
qsum; // Network total flow
|
||||
|
||||
// Initialize sum of flows & corrections
|
||||
qsum = 0.0;
|
||||
dqsum = 0.0;
|
||||
hbal->maxflowchange = 0.0;
|
||||
hbal->maxflowlink = 1;
|
||||
hbal->maxflownode = -1;
|
||||
|
||||
// Update flows in all real and virtual links
|
||||
newlinkflows(pr, hbal, &qsum, &dqsum);
|
||||
newemitterflows(pr, hbal, &qsum, &dqsum);
|
||||
newdemandflows(pr, hbal, &qsum, &dqsum);
|
||||
|
||||
// Return ratio of total flow corrections to total flow
|
||||
if (qsum > hyd->Hacc) return (dqsum / qsum);
|
||||
else return dqsum;
|
||||
}
|
||||
|
||||
|
||||
void newlinkflows(Project *pr, Hydbalance *hbal, double *qsum, double *dqsum)
|
||||
/*
|
||||
**----------------------------------------------------------------
|
||||
** Input: hbal = ptr. to hydraulic balance information
|
||||
** qsum = sum of current system flows
|
||||
** dqsum = sum of system flow changes
|
||||
** Output: updates hbal, qsum and dqsum
|
||||
** Purpose: updates link flows after new nodal heads computed
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
double dh, /* Link head loss */
|
||||
dq; /* Link flow change */
|
||||
int k, n, n1, n2;
|
||||
Slink *link;
|
||||
|
||||
// Initialize net inflows (i.e., demands) at fixed grade nodes
|
||||
for (n = net->Njuncs + 1; n <= net->Nnodes; n++)
|
||||
{
|
||||
hyd->NodeDemand[n] = 0.0;
|
||||
}
|
||||
|
||||
// Examine each link
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
// Get link and its end nodes
|
||||
link = &net->Link[k];
|
||||
n1 = link->N1;
|
||||
n2 = link->N2;
|
||||
|
||||
// Apply flow update formula:
|
||||
// dq = Y - P * (new head loss)
|
||||
// P = 1 / (previous head loss gradient)
|
||||
// Y = P * (previous head loss)
|
||||
// where P & Y were computed in hlosscoeff() in hydcoeffs.c
|
||||
|
||||
dh = hyd->NodeHead[n1] - hyd->NodeHead[n2];
|
||||
dq = hyd->Y[k] - hyd->P[k] * dh;
|
||||
|
||||
// Adjust flow change by the relaxation factor
|
||||
dq *= hyd->RelaxFactor;
|
||||
|
||||
// Prevent flow in constant HP pumps from going negative
|
||||
if (link->Type == PUMP)
|
||||
{
|
||||
n = findpump(net, k);
|
||||
if (net->Pump[n].Ptype == CONST_HP && dq > hyd->LinkFlow[k])
|
||||
{
|
||||
dq = hyd->LinkFlow[k] / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Update link flow and system flow summation
|
||||
hyd->LinkFlow[k] -= dq;
|
||||
*qsum += ABS(hyd->LinkFlow[k]);
|
||||
*dqsum += ABS(dq);
|
||||
|
||||
// Update identity of element with max. flow change
|
||||
if (ABS(dq) > hbal->maxflowchange)
|
||||
{
|
||||
hbal->maxflowchange = ABS(dq);
|
||||
hbal->maxflowlink = k;
|
||||
hbal->maxflownode = -1;
|
||||
}
|
||||
|
||||
// Update net flows to fixed grade nodes
|
||||
if (hyd->LinkStatus[k] > CLOSED)
|
||||
{
|
||||
if (n1 > net->Njuncs) hyd->NodeDemand[n1] -= hyd->LinkFlow[k];
|
||||
if (n2 > net->Njuncs) hyd->NodeDemand[n2] += hyd->LinkFlow[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void newemitterflows(Project *pr, Hydbalance *hbal, double *qsum,
|
||||
double *dqsum)
|
||||
/*
|
||||
**----------------------------------------------------------------
|
||||
** Input: hbal = ptr. to hydraulic balance information
|
||||
** qsum = sum of current system flows
|
||||
** dqsum = sum of system flow changes
|
||||
** Output: updates hbal, qsum and dqsum
|
||||
** Purpose: updates nodal emitter flows after new nodal heads computed
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
int i;
|
||||
double hloss, hgrad, dh, dq;
|
||||
|
||||
// Examine each network junction
|
||||
for (i = 1; i <= net->Njuncs; i++)
|
||||
{
|
||||
// Skip junction if it does not have an emitter
|
||||
if (net->Node[i].Ke == 0.0) continue;
|
||||
|
||||
// Find emitter head loss and gradient
|
||||
emitheadloss(pr, i, &hloss, &hgrad);
|
||||
|
||||
// Find emitter flow change
|
||||
dh = hyd->NodeHead[i] - net->Node[i].El;
|
||||
dq = (hloss - dh) / hgrad;
|
||||
hyd->EmitterFlow[i] -= dq;
|
||||
|
||||
// Update system flow summation
|
||||
*qsum += ABS(hyd->EmitterFlow[i]);
|
||||
*dqsum += ABS(dq);
|
||||
|
||||
// Update identity of element with max. flow change
|
||||
if (ABS(dq) > hbal->maxflowchange)
|
||||
{
|
||||
hbal->maxflowchange = ABS(dq);
|
||||
hbal->maxflownode = i;
|
||||
hbal->maxflowlink = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void newdemandflows(Project *pr, Hydbalance *hbal, double *qsum, double *dqsum)
|
||||
/*
|
||||
**----------------------------------------------------------------
|
||||
** Input: hbal = ptr. to hydraulic balance information
|
||||
** qsum = sum of current system flows
|
||||
** dqsum = sum of system flow changes
|
||||
** Output: updates hbal, qsum and dqsum
|
||||
** Purpose: updates nodal pressure dependent demand flows after
|
||||
** new nodal heads computed
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
double dp, // pressure range over which demand can vary (ft)
|
||||
dq, // change in demand flow (cfs)
|
||||
n; // exponent in head loss v. demand function
|
||||
int k;
|
||||
|
||||
// Get demand function parameters
|
||||
if (hyd->DemandModel == DDA) return;
|
||||
demandparams(pr, &dp, &n);
|
||||
|
||||
// Examine each junction
|
||||
for (k = 1; k <= net->Njuncs; k++)
|
||||
{
|
||||
// Skip junctions with no positive demand
|
||||
if (hyd->NodeDemand[k] <= 0.0) continue;
|
||||
|
||||
// Find change in demand flow (see hydcoeffs.c)
|
||||
dq = demandflowchange(pr, k, dp, n);
|
||||
hyd->DemandFlow[k] -= dq;
|
||||
|
||||
// Update system flow summation
|
||||
*qsum += ABS(hyd->DemandFlow[k]);
|
||||
*dqsum += ABS(dq);
|
||||
|
||||
// Update identity of element with max. flow change
|
||||
if (ABS(dq) > hbal->maxflowchange)
|
||||
{
|
||||
hbal->maxflowchange = ABS(dq);
|
||||
hbal->maxflownode = k;
|
||||
hbal->maxflowlink = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void checkhydbalance(Project *pr, Hydbalance *hbal)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: hbal = hydraulic balance errors
|
||||
** Output: none
|
||||
** Purpose: finds the link with the largest head imbalance
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
int k, n1, n2;
|
||||
double dh, headerror, headloss;
|
||||
Slink *link;
|
||||
|
||||
hbal->maxheaderror = 0.0;
|
||||
hbal->maxheadlink = 1;
|
||||
headlosscoeffs(pr);
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
if (hyd->LinkStatus[k] <= CLOSED) continue;
|
||||
if (hyd->P[k] == 0.0) continue;
|
||||
link = &net->Link[k];
|
||||
n1 = link->N1;
|
||||
n2 = link->N2;
|
||||
dh = hyd->NodeHead[n1] - hyd->NodeHead[n2];
|
||||
headloss = hyd->Y[k] / hyd->P[k];
|
||||
headerror = ABS(dh - headloss);
|
||||
if (headerror > hbal->maxheaderror)
|
||||
{
|
||||
hbal->maxheaderror = headerror;
|
||||
hbal->maxheadlink = k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int hasconverged(Project *pr, double *relerr, Hydbalance *hbal)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: relerr = current total relative flow change
|
||||
** hbal = current hydraulic balance errors
|
||||
** Output: returns 1 if system has converged or 0 if not
|
||||
** Purpose: checks various criteria to see if system has
|
||||
** become hydraulically balanced
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
if (*relerr > hyd->Hacc) return 0;
|
||||
checkhydbalance(pr, hbal);
|
||||
if (pr->report.Statflag == FULL)
|
||||
{
|
||||
reporthydbal(pr, hbal);
|
||||
}
|
||||
if (hyd->HeadErrorLimit > 0.0 &&
|
||||
hbal->maxheaderror > hyd->HeadErrorLimit) return 0;
|
||||
if (hyd->FlowChangeLimit > 0.0 &&
|
||||
hbal->maxflowchange > hyd->FlowChangeLimit) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void reporthydbal(Project *pr, Hydbalance *hbal)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: hbal = current hydraulic balance errors
|
||||
** Output: none
|
||||
** Purpose: identifies links with largest flow change and
|
||||
** largest head loss error.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
double qchange = hbal->maxflowchange * pr->Ucf[FLOW];
|
||||
double herror = hbal->maxheaderror * pr->Ucf[HEAD];
|
||||
int qlink = hbal->maxflowlink;
|
||||
int qnode = hbal->maxflownode;
|
||||
int hlink = hbal->maxheadlink;
|
||||
if (qlink >= 1)
|
||||
{
|
||||
sprintf(pr->Msg, FMT66, qchange, pr->network.Link[qlink].ID);
|
||||
writeline(pr, pr->Msg);
|
||||
}
|
||||
else if (qnode >= 1)
|
||||
{
|
||||
sprintf(pr->Msg, FMT67, qchange, pr->network.Node[qnode].ID);
|
||||
writeline(pr, pr->Msg);
|
||||
}
|
||||
if (hlink >= 1)
|
||||
{
|
||||
sprintf(pr->Msg, FMT68, herror, pr->network.Link[hlink].ID);
|
||||
writeline(pr, pr->Msg);
|
||||
}
|
||||
}
|
||||
481
src/hydstatus.c
Normal file
481
src/hydstatus.c
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: hydstatus.c
|
||||
Description: updates hydraulic status of network elements
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "funcs.h"
|
||||
|
||||
// Exported functions
|
||||
int valvestatus(Project *);
|
||||
int linkstatus(Project *);
|
||||
|
||||
// Local functions
|
||||
static StatusType cvstatus(Project *, StatusType, double, double);
|
||||
static StatusType pumpstatus(Project *, int, double);
|
||||
static StatusType prvstatus(Project *, int, StatusType, double, double, double);
|
||||
static StatusType psvstatus(Project *, int, StatusType, double, double, double);
|
||||
static StatusType fcvstatus(Project *, int, StatusType, double, double);
|
||||
static void tankstatus(Project *, int, int, int);
|
||||
|
||||
|
||||
int valvestatus(Project *pr)
|
||||
/*
|
||||
**-----------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns 1 if any pressure or flow control valve
|
||||
** changes status, 0 otherwise
|
||||
** Purpose: updates status for PRVs & PSVs whose status
|
||||
** is not fixed to OPEN/CLOSED
|
||||
**-----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Report *rpt = &pr->report;
|
||||
|
||||
int change = FALSE, // Status change flag
|
||||
i, k, // Valve & link indexes
|
||||
n1, n2; // Start & end nodes
|
||||
double hset; // Valve head setting
|
||||
StatusType status; // Valve status settings
|
||||
Slink *link;
|
||||
|
||||
// Examine each valve
|
||||
for (i = 1; i <= net->Nvalves; i++)
|
||||
{
|
||||
// Get valve's link and its index
|
||||
k = net->Valve[i].Link;
|
||||
link = &net->Link[k];
|
||||
|
||||
// Ignore valve if its status is fixed to OPEN/CLOSED
|
||||
if (hyd->LinkSetting[k] == MISSING) continue;
|
||||
|
||||
// Get start/end node indexes & save current status
|
||||
n1 = link->N1;
|
||||
n2 = link->N2;
|
||||
status = hyd->LinkStatus[k];
|
||||
|
||||
// Evaluate valve's new status
|
||||
switch (link->Type)
|
||||
{
|
||||
case PRV:
|
||||
hset = net->Node[n2].El + hyd->LinkSetting[k];
|
||||
hyd->LinkStatus[k] = prvstatus(pr, k, status, hset,
|
||||
hyd->NodeHead[n1], hyd->NodeHead[n2]);
|
||||
break;
|
||||
case PSV:
|
||||
hset = net->Node[n1].El + hyd->LinkSetting[k];
|
||||
hyd->LinkStatus[k] = psvstatus(pr, k, status, hset,
|
||||
hyd->NodeHead[n1], hyd->NodeHead[n2]);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for a status change
|
||||
if (status != hyd->LinkStatus[k])
|
||||
{
|
||||
if (rpt->Statflag == FULL)
|
||||
{
|
||||
writestatchange(pr, k, status, hyd->LinkStatus[k]);
|
||||
}
|
||||
change = TRUE;
|
||||
}
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
|
||||
int linkstatus(Project *pr)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns 1 if any link changes status, 0 otherwise
|
||||
** Purpose: determines new status for pumps, CVs, FCVs & pipes
|
||||
** to tanks.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Report *rpt = &pr->report;
|
||||
|
||||
int change = FALSE, // Status change flag
|
||||
k, // Link index
|
||||
n1, // Start node index
|
||||
n2; // End node index
|
||||
double dh; // Head difference across link
|
||||
StatusType status; // Current status
|
||||
Slink *link;
|
||||
|
||||
// Examine each link
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
link = &net->Link[k];
|
||||
n1 = link->N1;
|
||||
n2 = link->N2;
|
||||
dh = hyd->NodeHead[n1] - hyd->NodeHead[n2];
|
||||
|
||||
// Re-open temporarily closed links (status = XHEAD or TEMPCLOSED)
|
||||
status = hyd->LinkStatus[k];
|
||||
if (status == XHEAD || status == TEMPCLOSED)
|
||||
{
|
||||
hyd->LinkStatus[k] = OPEN;
|
||||
}
|
||||
|
||||
// Check for status changes in CVs and pumps
|
||||
if (link->Type == CVPIPE)
|
||||
{
|
||||
hyd->LinkStatus[k] = cvstatus(pr, hyd->LinkStatus[k], dh,
|
||||
hyd->LinkFlow[k]);
|
||||
}
|
||||
if (link->Type == PUMP && hyd->LinkStatus[k] >= OPEN &&
|
||||
hyd->LinkSetting[k] > 0.0)
|
||||
{
|
||||
hyd->LinkStatus[k] = pumpstatus(pr, k, -dh);
|
||||
}
|
||||
|
||||
// Check for status changes in non-fixed FCVs
|
||||
if (link->Type == FCV && hyd->LinkSetting[k] != MISSING)
|
||||
{
|
||||
hyd->LinkStatus[k] = fcvstatus(pr, k, status, hyd->NodeHead[n1],
|
||||
hyd->NodeHead[n2]);
|
||||
}
|
||||
|
||||
// Check for flow into (out of) full (empty) tanks
|
||||
if (n1 > net->Njuncs || n2 > net->Njuncs)
|
||||
{
|
||||
tankstatus(pr, k, n1, n2);
|
||||
}
|
||||
|
||||
// Note any change in link status; do not revise link flow
|
||||
if (status != hyd->LinkStatus[k])
|
||||
{
|
||||
change = TRUE;
|
||||
if (rpt->Statflag == FULL)
|
||||
{
|
||||
writestatchange(pr, k, status, hyd->LinkStatus[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
|
||||
StatusType cvstatus(Project *pr, StatusType s, double dh, double q)
|
||||
/*
|
||||
**--------------------------------------------------
|
||||
** Input: s = current link status
|
||||
** dh = head loss across link
|
||||
** q = link flow
|
||||
** Output: returns new link status
|
||||
** Purpose: updates status of a check valve link.
|
||||
**--------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
// Prevent reverse flow through CVs
|
||||
if (ABS(dh) > hyd->Htol)
|
||||
{
|
||||
if (dh < -hyd->Htol) return CLOSED;
|
||||
else if (q < -hyd->Qtol) return CLOSED;
|
||||
else return OPEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (q < -hyd->Qtol) return CLOSED;
|
||||
else return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StatusType pumpstatus(Project *pr, int k, double dh)
|
||||
/*
|
||||
**--------------------------------------------------
|
||||
** Input: k = link index
|
||||
** dh = head gain across link
|
||||
** Output: returns new pump status
|
||||
** Purpose: updates status of an open pump.
|
||||
**--------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Network *net = &pr->network;
|
||||
|
||||
int p;
|
||||
double hmax;
|
||||
|
||||
// Find maximum head (hmax) pump can deliver
|
||||
p = findpump(net, k);
|
||||
if (net->Pump[p].Ptype == CONST_HP)
|
||||
{
|
||||
// Use huge value for constant HP pump
|
||||
hmax = BIG;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use speed-adjusted shut-off head for other pumps
|
||||
hmax = SQR(hyd->LinkSetting[k]) * net->Pump[p].Hmax;
|
||||
}
|
||||
|
||||
// Check if currrent head gain exceeds pump's max. head
|
||||
if (dh > hmax + hyd->Htol) return XHEAD;
|
||||
|
||||
// No check is made to see if flow exceeds pump's max. flow
|
||||
return OPEN;
|
||||
}
|
||||
|
||||
|
||||
StatusType prvstatus(Project *pr, int k, StatusType s, double hset,
|
||||
double h1, double h2)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** s = current status
|
||||
** hset = valve head setting
|
||||
** h1 = head at upstream node
|
||||
** h2 = head at downstream node
|
||||
** Output: returns new valve status
|
||||
** Purpose: updates status of a pressure reducing valve.
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
StatusType status; // Valve's new status
|
||||
double hml; // Head loss when fully opened
|
||||
double htol;
|
||||
Slink *link;
|
||||
|
||||
htol = hyd->Htol;
|
||||
link = &pr->network.Link[k];
|
||||
|
||||
// Head loss when fully open
|
||||
hml = link->Km * SQR(hyd->LinkFlow[k]);
|
||||
|
||||
// Rules for updating valve's status from current value s
|
||||
status = s;
|
||||
switch (s)
|
||||
{
|
||||
case ACTIVE:
|
||||
if (hyd->LinkFlow[k] < -hyd->Qtol) status = CLOSED;
|
||||
else if (h1 - hml < hset - htol) status = OPEN;
|
||||
else status = ACTIVE;
|
||||
break;
|
||||
|
||||
case OPEN:
|
||||
if (hyd->LinkFlow[k] < -hyd->Qtol) status = CLOSED;
|
||||
else if (h2 >= hset + htol) status = ACTIVE;
|
||||
else status = OPEN;
|
||||
break;
|
||||
|
||||
case CLOSED:
|
||||
if (h1 >= hset + htol && h2 < hset - htol) status = ACTIVE;
|
||||
else if (h1 < hset - htol && h1 > h2 + htol) status = OPEN;
|
||||
else status = CLOSED;
|
||||
break;
|
||||
|
||||
case XPRESSURE:
|
||||
if (hyd->LinkFlow[k] < -hyd->Qtol) status = CLOSED;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
StatusType psvstatus(Project *pr, int k, StatusType s, double hset,
|
||||
double h1, double h2)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** s = current status
|
||||
** hset = valve head setting
|
||||
** h1 = head at upstream node
|
||||
** h2 = head at downstream node
|
||||
** Output: returns new valve status
|
||||
** Purpose: updates status of a pressure sustaining valve.
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
StatusType status; // Valve's new status
|
||||
double hml; // Head loss when fully opened
|
||||
double htol;
|
||||
Slink *link;
|
||||
|
||||
htol = hyd->Htol;
|
||||
link = &pr->network.Link[k];
|
||||
|
||||
// Head loss when fully open
|
||||
hml = link->Km * SQR(hyd->LinkFlow[k]);
|
||||
|
||||
// Rules for updating valve's status from current value s
|
||||
status = s;
|
||||
switch (s)
|
||||
{
|
||||
case ACTIVE:
|
||||
if (hyd->LinkFlow[k] < -hyd->Qtol) status = CLOSED;
|
||||
else if (h2 + hml > hset + htol) status = OPEN;
|
||||
else status = ACTIVE;
|
||||
break;
|
||||
|
||||
case OPEN:
|
||||
if (hyd->LinkFlow[k] < -hyd->Qtol) status = CLOSED;
|
||||
else if (h1 < hset - htol) status = ACTIVE;
|
||||
else status = OPEN;
|
||||
break;
|
||||
|
||||
case CLOSED:
|
||||
if (h2 > hset + htol && h1 > h2 + htol) status = OPEN;
|
||||
else if (h1 >= hset + htol && h1 > h2 + htol) status = ACTIVE;
|
||||
else status = CLOSED;
|
||||
break;
|
||||
|
||||
case XPRESSURE:
|
||||
if (hyd->LinkFlow[k] < -hyd->Qtol) status = CLOSED;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
StatusType fcvstatus(Project *pr, int k, StatusType s, double h1, double h2)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** s = current status
|
||||
** h1 = head at upstream node
|
||||
** h2 = head at downstream node
|
||||
** Output: returns new valve status
|
||||
** Purpose: updates status of a flow control valve.
|
||||
**
|
||||
** Valve status changes to XFCV if flow reversal.
|
||||
** If current status is XFCV and current flow is
|
||||
** above setting, then valve becomes active.
|
||||
** If current status is XFCV, and current flow
|
||||
** positive but still below valve setting, then
|
||||
** status remains same.
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
StatusType status; // New valve status
|
||||
|
||||
status = s;
|
||||
if (h1 - h2 < -hyd->Htol)
|
||||
{
|
||||
status = XFCV;
|
||||
}
|
||||
else if (hyd->LinkFlow[k] < -hyd->Qtol)
|
||||
{
|
||||
status = XFCV;
|
||||
}
|
||||
else if (s == XFCV && hyd->LinkFlow[k] >= hyd->LinkSetting[k])
|
||||
{
|
||||
status = ACTIVE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void tankstatus(Project *pr, int k, int n1, int n2)
|
||||
/*
|
||||
**----------------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** n1 = start node of link
|
||||
** n2 = end node of link
|
||||
** Output: none
|
||||
** Purpose: closes link flowing into full or out of empty tank
|
||||
**----------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
|
||||
int i, n;
|
||||
double h, q;
|
||||
Stank *tank;
|
||||
Slink *link = &net->Link[k];
|
||||
|
||||
// Return if link is closed
|
||||
if (hyd->LinkStatus[k] <= CLOSED) return;
|
||||
|
||||
// Make node n1 be the tank, reversing flow (q) if need be
|
||||
q = hyd->LinkFlow[k];
|
||||
i = n1 - net->Njuncs;
|
||||
if (i <= 0)
|
||||
{
|
||||
i = n2 - net->Njuncs;
|
||||
if (i <= 0) return;
|
||||
n = n1;
|
||||
n1 = n2;
|
||||
n2 = n;
|
||||
q = -q;
|
||||
}
|
||||
|
||||
// Ignore reservoirs
|
||||
tank = &net->Tank[i];
|
||||
if (tank->A == 0.0) return;
|
||||
|
||||
// Find head difference across link
|
||||
h = hyd->NodeHead[n1] - hyd->NodeHead[n2];
|
||||
|
||||
// If tank is full, then prevent flow into it
|
||||
if (hyd->NodeHead[n1] >= tank->Hmax - hyd->Htol)
|
||||
{
|
||||
// Case 1: Link is a pump discharging into tank
|
||||
if (link->Type == PUMP)
|
||||
{
|
||||
if (link->N2 == n1) hyd->LinkStatus[k] = TEMPCLOSED;
|
||||
}
|
||||
|
||||
// Case 2: Downstream head > tank head
|
||||
// (e.g., an open outflow check valve would close)
|
||||
else if (cvstatus(pr, OPEN, h, q) == CLOSED)
|
||||
{
|
||||
hyd->LinkStatus[k] = TEMPCLOSED;
|
||||
}
|
||||
}
|
||||
|
||||
// If tank is empty, then prevent flow out of it
|
||||
if (hyd->NodeHead[n1] <= tank->Hmin + hyd->Htol)
|
||||
{
|
||||
// Case 1: Link is a pump discharging from tank
|
||||
if (link->Type == PUMP)
|
||||
{
|
||||
if (link->N1 == n1) hyd->LinkStatus[k] = TEMPCLOSED;
|
||||
}
|
||||
|
||||
// Case 2: Tank head > downstream head
|
||||
// (e.g., a closed outflow check valve would open)
|
||||
else if (cvstatus(pr, CLOSED, h, q) == OPEN)
|
||||
{
|
||||
hyd->LinkStatus[k] = TEMPCLOSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
1459
src/inpfile.c
Executable file → Normal file
1459
src/inpfile.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1362
src/input1.c
Executable file → Normal file
1362
src/input1.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1833
src/input2.c
Executable file → Normal file
1833
src/input2.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
3980
src/input3.c
Executable file → Normal file
3980
src/input3.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
353
src/mempool.c
353
src/mempool.c
@@ -1,205 +1,148 @@
|
||||
/* mempool.c
|
||||
**
|
||||
** A simple fast memory allocation package.
|
||||
**
|
||||
** By Steve Hill in Graphics Gems III, David Kirk (ed.),
|
||||
** Academic Press, Boston, MA, 1992
|
||||
**
|
||||
** Modified by Lew Rossman, 8/13/94.
|
||||
**
|
||||
** AllocInit() - create an alloc pool, returns the old pool handle
|
||||
** Alloc() - allocate memory
|
||||
** AllocReset() - reset the current pool
|
||||
** AllocSetPool() - set the current pool
|
||||
** AllocFree() - free the memory used by the current pool.
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "mempool.h"
|
||||
|
||||
/*
|
||||
** ALLOC_BLOCK_SIZE - adjust this size to suit your installation - it
|
||||
** should be reasonably large otherwise you will be mallocing a lot.
|
||||
*/
|
||||
|
||||
#define ALLOC_BLOCK_SIZE 64000 /*(62*1024)*/
|
||||
|
||||
/*
|
||||
** alloc_hdr_t - Header for each block of memory.
|
||||
*/
|
||||
|
||||
typedef struct alloc_hdr_s
|
||||
{
|
||||
struct alloc_hdr_s *next; /* Next Block */
|
||||
char *block, /* Start of block */
|
||||
*free, /* Next free in block */
|
||||
*end; /* block + block size */
|
||||
} alloc_hdr_t;
|
||||
|
||||
/*
|
||||
** alloc_root_t - Header for the whole pool.
|
||||
*/
|
||||
|
||||
typedef struct alloc_root_s
|
||||
{
|
||||
alloc_hdr_t *first, /* First header in pool */
|
||||
*current; /* Current header */
|
||||
} alloc_root_t;
|
||||
|
||||
/*
|
||||
** root - Pointer to the current pool.
|
||||
*/
|
||||
|
||||
static alloc_root_t *root;
|
||||
|
||||
|
||||
/*
|
||||
** AllocHdr()
|
||||
**
|
||||
** Private routine to allocate a header and memory block.
|
||||
*/
|
||||
|
||||
static alloc_hdr_t *AllocHdr(void);
|
||||
|
||||
static alloc_hdr_t * AllocHdr()
|
||||
{
|
||||
alloc_hdr_t *hdr;
|
||||
char *block;
|
||||
|
||||
block = (char *) malloc(ALLOC_BLOCK_SIZE);
|
||||
hdr = (alloc_hdr_t *) malloc(sizeof(alloc_hdr_t));
|
||||
|
||||
if (hdr == NULL || block == NULL) return(NULL);
|
||||
hdr->block = block;
|
||||
hdr->free = block;
|
||||
hdr->next = NULL;
|
||||
hdr->end = block + ALLOC_BLOCK_SIZE;
|
||||
|
||||
return(hdr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** AllocInit()
|
||||
**
|
||||
** Create a new memory pool with one block.
|
||||
** Returns pointer to the new pool.
|
||||
*/
|
||||
|
||||
DLLEXPORT alloc_handle_t * AllocInit()
|
||||
{
|
||||
alloc_handle_t *newpool;
|
||||
root = (alloc_root_t *) malloc(sizeof(alloc_root_t));
|
||||
if (root == NULL) return(NULL);
|
||||
if ( (root->first = AllocHdr()) == NULL) return(NULL);
|
||||
root->current = root->first;
|
||||
newpool = (alloc_handle_t *) root;
|
||||
return(newpool);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Alloc()
|
||||
**
|
||||
** Use as a direct replacement for malloc(). Allocates
|
||||
** memory from the current pool.
|
||||
*/
|
||||
|
||||
DLLEXPORT char *Alloc(long size)
|
||||
{
|
||||
alloc_hdr_t *hdr = root->current;
|
||||
char *ptr;
|
||||
|
||||
/*
|
||||
** Align to 4 byte boundary - should be ok for most machines.
|
||||
** Change this if your machine has weird alignment requirements.
|
||||
*/
|
||||
size = (size + 3) & 0xfffffffc;
|
||||
|
||||
ptr = hdr->free;
|
||||
hdr->free += size;
|
||||
|
||||
/* Check if the current block is exhausted. */
|
||||
|
||||
if (hdr->free >= hdr->end)
|
||||
{
|
||||
/* Is the next block already allocated? */
|
||||
|
||||
if (hdr->next != NULL)
|
||||
{
|
||||
/* re-use block */
|
||||
hdr->next->free = hdr->next->block;
|
||||
root->current = hdr->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* extend the pool with a new block */
|
||||
if ( (hdr->next = AllocHdr()) == NULL) return(NULL);
|
||||
root->current = hdr->next;
|
||||
}
|
||||
|
||||
/* set ptr to the first location in the next block */
|
||||
ptr = root->current->free;
|
||||
root->current->free += size;
|
||||
}
|
||||
|
||||
/* Return pointer to allocated memory. */
|
||||
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** AllocSetPool()
|
||||
**
|
||||
** Change the current pool. Return the old pool.
|
||||
*/
|
||||
|
||||
DLLEXPORT alloc_handle_t * AllocSetPool(alloc_handle_t *newpool)
|
||||
{
|
||||
alloc_handle_t *old = (alloc_handle_t *) root;
|
||||
root = (alloc_root_t *) newpool;
|
||||
return(old);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** AllocReset()
|
||||
**
|
||||
** Reset the current pool for re-use. No memory is freed,
|
||||
** so this is very fast.
|
||||
*/
|
||||
|
||||
DLLEXPORT void AllocReset()
|
||||
{
|
||||
root->current = root->first;
|
||||
root->current->free = root->current->block;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** AllocFreePool()
|
||||
**
|
||||
** Free the memory used by the current pool.
|
||||
** Don't use where AllocReset() could be used.
|
||||
*/
|
||||
|
||||
DLLEXPORT void AllocFreePool()
|
||||
{
|
||||
alloc_hdr_t *tmp,
|
||||
*hdr = root->first;
|
||||
|
||||
while (hdr != NULL)
|
||||
{
|
||||
tmp = hdr->next;
|
||||
free((char *) hdr->block);
|
||||
free((char *) hdr);
|
||||
hdr = tmp;
|
||||
}
|
||||
free((char *) root);
|
||||
root = NULL;
|
||||
}
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: mempool.c
|
||||
Description: a simple fast poooled memory allocation package
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
|
||||
This module is based code by Steve Hill in Graphics Gems III,
|
||||
David Kirk (ed.), Academic Press, Boston, MA, 1992
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "mempool.h"
|
||||
|
||||
/*
|
||||
** ALLOC_BLOCK_SIZE - adjust this size to suit your installation - it
|
||||
** should be reasonably large otherwise you will be mallocing a lot.
|
||||
*/
|
||||
|
||||
#define ALLOC_BLOCK_SIZE 64000 /*(62*1024)*/
|
||||
|
||||
struct MemBlock
|
||||
{
|
||||
struct MemBlock *next; // Next block
|
||||
char *block, // Start of block
|
||||
*free, // Next free position in block
|
||||
*end; // block + block size
|
||||
};
|
||||
|
||||
struct Mempool
|
||||
{
|
||||
struct MemBlock *first;
|
||||
struct MemBlock *current;
|
||||
};
|
||||
|
||||
static struct MemBlock* createMemBlock()
|
||||
{
|
||||
struct MemBlock* memBlock = malloc(sizeof(struct MemBlock));
|
||||
if (memBlock)
|
||||
{
|
||||
memBlock->block = malloc(ALLOC_BLOCK_SIZE * sizeof(char));
|
||||
if (memBlock->block == NULL)
|
||||
{
|
||||
free(memBlock);
|
||||
return NULL;
|
||||
}
|
||||
memBlock->free = memBlock->block;
|
||||
memBlock->next = NULL;
|
||||
memBlock->end = memBlock->block + ALLOC_BLOCK_SIZE;
|
||||
}
|
||||
return memBlock;
|
||||
}
|
||||
|
||||
|
||||
static void deleteMemBlock(struct MemBlock* memBlock)
|
||||
{
|
||||
free(memBlock->block);
|
||||
free(memBlock);
|
||||
}
|
||||
|
||||
|
||||
struct Mempool * mempool_create()
|
||||
{
|
||||
struct Mempool *mempool;
|
||||
mempool = (struct Mempool *)malloc(sizeof(struct Mempool));
|
||||
if (mempool == NULL) return NULL;
|
||||
mempool->first = createMemBlock();
|
||||
mempool->current = mempool->first;
|
||||
if (mempool->first == NULL) return NULL;
|
||||
return mempool;
|
||||
}
|
||||
|
||||
void mempool_delete(struct Mempool *mempool)
|
||||
{
|
||||
if (mempool == NULL) return;
|
||||
while (mempool->first)
|
||||
{
|
||||
mempool->current = mempool->first->next;
|
||||
deleteMemBlock(mempool->first);
|
||||
mempool->first = mempool->current;
|
||||
}
|
||||
free(mempool);
|
||||
mempool = NULL;
|
||||
}
|
||||
|
||||
void mempool_reset(struct Mempool *mempool)
|
||||
{
|
||||
mempool->current = mempool->first;
|
||||
mempool->current->free = mempool->current->block;
|
||||
}
|
||||
|
||||
|
||||
char * mempool_alloc(struct Mempool *mempool, size_t size)
|
||||
{
|
||||
char* ptr;
|
||||
|
||||
/*
|
||||
** Align to 4 byte boundary - should be ok for most machines.
|
||||
** Change this if your machine has weird alignment requirements.
|
||||
*/
|
||||
size = (size + 3) & 0xfffffffc;
|
||||
|
||||
if (!mempool->current) return NULL;
|
||||
ptr = mempool->current->free;
|
||||
mempool->current->free += size;
|
||||
|
||||
// Check if the current block is exhausted
|
||||
|
||||
if (mempool->current->free >= mempool->current->end)
|
||||
{
|
||||
// Is the next block already allocated?
|
||||
|
||||
if (mempool->current->next)
|
||||
{
|
||||
// re-use block
|
||||
mempool->current->next->free = mempool->current->next->block;
|
||||
mempool->current = mempool->current->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// extend the pool with a new block
|
||||
mempool->current->next = createMemBlock();
|
||||
if (!mempool->current->next) return NULL;
|
||||
mempool->current = mempool->current->next;
|
||||
}
|
||||
|
||||
// set ptr to the first location in the next block
|
||||
|
||||
ptr = mempool->current->free;
|
||||
mempool->current->free += size;
|
||||
}
|
||||
|
||||
// Return pointer to allocated memory
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,24 @@
|
||||
/*
|
||||
** mempool.h
|
||||
**
|
||||
** Header for mempool.c
|
||||
**
|
||||
** The type alloc_handle_t provides an opaque reference to the
|
||||
** alloc pool - only the alloc routines know its structure.
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: mempool.h
|
||||
Description: header for a simple pooled memory allocator
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef DLLEXPORT
|
||||
#ifdef DLL
|
||||
#ifdef __cplusplus
|
||||
#define DLLEXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define DLLEXPORT __declspec(dllexport) __stdcall
|
||||
#endif
|
||||
#elif defined(CYGWIN)
|
||||
#define DLLEXPORT __stdcall
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
#define DLLEXPORT
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long dummy;
|
||||
} alloc_handle_t;
|
||||
#ifndef MEMPOOL_H
|
||||
#define MEMPOOL_H
|
||||
|
||||
DLLEXPORT alloc_handle_t *AllocInit(void);
|
||||
DLLEXPORT char *Alloc(long);
|
||||
DLLEXPORT alloc_handle_t *AllocSetPool(alloc_handle_t *);
|
||||
DLLEXPORT void AllocReset(void);
|
||||
DLLEXPORT void AllocFreePool(void);
|
||||
struct Mempool;
|
||||
|
||||
struct Mempool * mempool_create();
|
||||
void mempool_delete(struct Mempool *mempool);
|
||||
void mempool_reset(struct Mempool *mempool);
|
||||
char * mempool_alloc(struct Mempool *mempool, size_t size);
|
||||
|
||||
#endif
|
||||
42
src/outfile/CMakeLists.txt
Normal file
42
src/outfile/CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# CMakeLists.txt - CMake configuration file for epanet-output library
|
||||
#
|
||||
# Created: March 9, 2018
|
||||
# Author: Michael E. Tryby
|
||||
# US EPA ORD/NRMRL
|
||||
#
|
||||
|
||||
|
||||
# Sets for output directory for executables and libraries.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
|
||||
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
|
||||
# configure file groups
|
||||
set(EPANET_OUT_SOURCES src/epanet_output.c
|
||||
../util/errormanager.c
|
||||
../util/filemanager.c
|
||||
../util/cstr_helper.c)
|
||||
|
||||
|
||||
# the binary output file API
|
||||
add_library(epanet-output SHARED ${EPANET_OUT_SOURCES})
|
||||
target_include_directories(epanet-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../)
|
||||
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(epanet-output
|
||||
BASE_NAME epanet_output
|
||||
EXPORT_MACRO_NAME EXPORT_OUT_API
|
||||
EXPORT_FILE_NAME epanet_output_export.h
|
||||
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_output_export.h DESTINATION
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
82
src/outfile/include/epanet_output.h
Normal file
82
src/outfile/include/epanet_output.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* epanet_output.h - EPANET Output API
|
||||
*
|
||||
* Created on: Jun 4, 2014
|
||||
*
|
||||
* Author: Michael E. Tryby
|
||||
* US EPA - ORD/NRMRL
|
||||
*/
|
||||
|
||||
#ifndef EPANET_OUTPUT_H_
|
||||
#define EPANET_OUTPUT_H_
|
||||
/* Epanet Results binary file API */
|
||||
|
||||
|
||||
#define MAXFNAME 259 // Max characters in file name
|
||||
#define MAXID 31 // Max characters in ID name
|
||||
|
||||
|
||||
// This is an opaque pointer to struct. Do not access variables.
|
||||
typedef void* ENR_Handle;
|
||||
|
||||
|
||||
#include "epanet_output_enums.h"
|
||||
#include "epanet_output_export.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int EXPORT_OUT_API ENR_init(ENR_Handle* p_handle_out);
|
||||
|
||||
int EXPORT_OUT_API ENR_open(ENR_Handle p_handle_in, const char* path);
|
||||
|
||||
int EXPORT_OUT_API ENR_getVersion(ENR_Handle p_handle_in, int* int_out);
|
||||
|
||||
int EXPORT_OUT_API ENR_getNetSize(ENR_Handle p_handle_in, int** int_out, int* int_dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getUnits(ENR_Handle p_handle_in, ENR_Units t_enum, int* int_out);
|
||||
|
||||
int EXPORT_OUT_API ENR_getTimes(ENR_Handle p_handle_in, ENR_Time t_enum, int* int_out);
|
||||
|
||||
int EXPORT_OUT_API ENR_getElementName(ENR_Handle p_handle_in, ENR_ElementType t_enum,
|
||||
int elementIndex, char** string_out, int* slen);
|
||||
|
||||
int EXPORT_OUT_API ENR_getEnergyUsage(ENR_Handle p_handle_in, int pumpIndex,
|
||||
int* int_out, float** float_out, int* int_dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getNetReacts(ENR_Handle p_handle_in, float** float_out, int* int_dim);
|
||||
|
||||
|
||||
int EXPORT_OUT_API ENR_getNodeSeries(ENR_Handle p_handle_in, int nodeIndex, ENR_NodeAttribute t_enum,
|
||||
int startPeriod, int endPeriod, float** outValueSeries, int* dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getLinkSeries(ENR_Handle p_handle_in, int linkIndex, ENR_LinkAttribute t_enum,
|
||||
int startPeriod, int endPeriod, float** outValueSeries, int* dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getNodeAttribute(ENR_Handle p_handle_in, int periodIndex,
|
||||
ENR_NodeAttribute t_enum, float** outValueArray, int* dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getLinkAttribute(ENR_Handle p_handle_in, int periodIndex,
|
||||
ENR_LinkAttribute t_enum, float** outValueArray, int* dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle_in, int periodIndex, int nodeIndex,
|
||||
float** float_out, int* int_dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle_in, int periodIndex, int linkIndex,
|
||||
float** float_out, int* int_dim);
|
||||
|
||||
int EXPORT_OUT_API ENR_close(ENR_Handle* p_handle_out);
|
||||
|
||||
void EXPORT_OUT_API ENR_free(void** array);
|
||||
|
||||
void EXPORT_OUT_API ENR_clearError(ENR_Handle p_handle_in);
|
||||
|
||||
int EXPORT_OUT_API ENR_checkError(ENR_Handle p_handle_in, char** msg_buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EPANET_OUTPUT_H_ */
|
||||
79
src/outfile/include/epanet_output_enums.h
Normal file
79
src/outfile/include/epanet_output_enums.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* epanet_output_enums.h - EPANET Output API enums
|
||||
*
|
||||
* Created on: March 11, 2019
|
||||
*
|
||||
* Author: Michael E. Tryby
|
||||
* US EPA - ORD/NRMRL
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EPANET_OUTPUT_ENUMS_H_
|
||||
#define EPANET_OUTPUT_ENUMS_H_
|
||||
|
||||
|
||||
typedef enum {
|
||||
ENR_node = 1,
|
||||
ENR_link = 2
|
||||
} ENR_ElementType;
|
||||
|
||||
typedef enum {
|
||||
ENR_flowUnits = 1,
|
||||
ENR_pressUnits = 2,
|
||||
ENR_qualUnits = 3
|
||||
} ENR_Units;
|
||||
|
||||
typedef enum {
|
||||
ENR_CFS = 0,
|
||||
ENR_GPM = 1,
|
||||
ENR_MGD = 2,
|
||||
ENR_IMGD = 3,
|
||||
ENR_AFD = 4,
|
||||
ENR_LPS = 5,
|
||||
ENR_LPM = 6,
|
||||
ENR_MLD = 7,
|
||||
ENR_CMH = 8,
|
||||
ENR_CMD = 9
|
||||
} ENR_FlowUnits;
|
||||
|
||||
typedef enum {
|
||||
ENR_PSI = 0,
|
||||
ENR_MTR = 1,
|
||||
ENR_KPA = 2
|
||||
} ENR_PressUnits;
|
||||
|
||||
typedef enum {
|
||||
ENR_NONE = 0,
|
||||
ENR_MGL = 1,
|
||||
ENR_UGL = 2,
|
||||
ENR_HOURS = 3,
|
||||
ENR_PRCNT = 4
|
||||
} ENR_QualUnits;
|
||||
|
||||
typedef enum {
|
||||
ENR_reportStart = 1,
|
||||
ENR_reportStep = 2,
|
||||
ENR_simDuration = 3,
|
||||
ENR_numPeriods = 4
|
||||
}ENR_Time;
|
||||
|
||||
typedef enum {
|
||||
ENR_demand = 1,
|
||||
ENR_head = 2,
|
||||
ENR_pressure = 3,
|
||||
ENR_quality = 4
|
||||
} ENR_NodeAttribute;
|
||||
|
||||
typedef enum {
|
||||
ENR_flow = 1,
|
||||
ENR_velocity = 2,
|
||||
ENR_headloss = 3,
|
||||
ENR_avgQuality = 4,
|
||||
ENR_status = 5,
|
||||
ENR_setting = 6,
|
||||
ENR_rxRate = 7,
|
||||
ENR_frctnFctr = 8
|
||||
} ENR_LinkAttribute;
|
||||
|
||||
|
||||
#endif /* EPANET_OUTPUT_ENUMS_H_ */
|
||||
939
src/outfile/src/epanet_output.c
Normal file
939
src/outfile/src/epanet_output.c
Normal file
@@ -0,0 +1,939 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// epanet_output.c -- API for reading results from EPANET binary output file
|
||||
//
|
||||
// Version: 0.40
|
||||
// Date 04/02/2019
|
||||
// 09/06/2017
|
||||
// 06/17/2016
|
||||
// 08/05/2014
|
||||
// 05/21/2014
|
||||
//
|
||||
// Author: Michael E. Tryby
|
||||
// US EPA - ORD/NRMRL
|
||||
//
|
||||
// Modified: Maurizio Cingi
|
||||
// University of Modena
|
||||
//
|
||||
// Purpose: Output API provides an interface for retrieving results from an
|
||||
// EPANET binary output file.
|
||||
//
|
||||
// Output data in the binary file are aligned on a 4 byte word size.
|
||||
// Therefore all values both integers and reals are 32 bits in length.
|
||||
//
|
||||
// All values returned by the output API are indexed from 0 to n-1. This
|
||||
// differs from how node and link elements are indexed by the binary file
|
||||
// writer found in EPANET. Times correspond to reporting periods are indexed
|
||||
// from 0 to number of reporting periods minus one. Node and link elements
|
||||
// are indexed from 0 to nodeCount minus one and 0 to linkCount minus one
|
||||
// respectively.
|
||||
//
|
||||
// The Output API functions provide a convenient way to select "slices" of
|
||||
// data from the output file. As such they return arrays of data. The API
|
||||
// functions automatically allocate memory for the array to be returned. The
|
||||
// caller is responsible for deallocating memory. The function ENR_free() is
|
||||
// provided for that purpose.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/errormanager.h"
|
||||
#include "util/filemanager.h"
|
||||
|
||||
#include "epanet_output.h"
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
// NOTE: These depend on machine data model and may change when porting
|
||||
#define INT4 int // Must be a 4 byte / 32 bit integer type
|
||||
#define REAL4 float // Must be a 4 byte / 32 bit real type
|
||||
#define WORDSIZE 4 // Memory alignment 4 byte word size for both int and real
|
||||
|
||||
#define MINNREC 14 // Minimum allowable number of records
|
||||
#define PROLOGUE 884 // Preliminary fixed length section of header
|
||||
#define MAXID_P1 32 // EPANET max characters in ID name PLUS 1
|
||||
#define MAXMSG_P1 80 // EPANET max characters in message text PLUS 1
|
||||
|
||||
#define NELEMENTTYPES 5 // Number of element types
|
||||
#define NENERGYRESULTS 6 // Number of energy results
|
||||
#define NNODERESULTS 4 // number of result fields for nodes
|
||||
#define NLINKRESULTS 8 // number of result fields for links
|
||||
#define NREACTRESULTS 4 // number of net reaction results
|
||||
|
||||
#define MEMCHECK(x) (((x) == NULL) ? 411 : 0 )
|
||||
|
||||
// Typedefs for opaque pointer
|
||||
typedef struct data_s {
|
||||
INT4 nodeCount, tankCount, linkCount, pumpCount, valveCount, nPeriods;
|
||||
F_OFF outputStartPos; // starting file position of output data
|
||||
F_OFF bytesPerPeriod; // bytes saved per simulation time period
|
||||
|
||||
error_handle_t *error_handle;
|
||||
file_handle_t *file_handle;
|
||||
} data_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Local functions
|
||||
//-----------------------------------------------------------------------------
|
||||
void errorLookup(int errcode, char* errmsg, int length);
|
||||
int validateFile(ENR_Handle);
|
||||
float getNodeValue(ENR_Handle, int, int, int);
|
||||
float getLinkValue(ENR_Handle, int, int, int);
|
||||
|
||||
float *newFloatArray(int n);
|
||||
int *newIntArray(int n);
|
||||
char *newCharArray(int n);
|
||||
|
||||
|
||||
int EXPORT_OUT_API ENR_init(ENR_Handle *dp_handle)
|
||||
// Purpose: Initialized pointer for the opaque ENR_Handle.
|
||||
//
|
||||
// Returns: Error code 0 on success, -1 on failure
|
||||
//
|
||||
// Note: The existence of this function has been carefully considered.
|
||||
// Don't change it.
|
||||
//
|
||||
{
|
||||
int errorcode = 0;
|
||||
data_t* p_data;
|
||||
|
||||
// Allocate memory for private data
|
||||
p_data = (data_t*)calloc(1, sizeof(data_t));
|
||||
|
||||
if (p_data != NULL){
|
||||
p_data->error_handle = create_error_manager(&errorLookup);
|
||||
p_data->file_handle = create_file_manager();
|
||||
*dp_handle = p_data;
|
||||
}
|
||||
else
|
||||
errorcode = -1;
|
||||
|
||||
// TODO: Need to handle errors during initialization better.
|
||||
return errorcode;
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_close(ENR_Handle *p_handle)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: *p_handle = pointer to ENR_Handle struct
|
||||
**
|
||||
** Returns: Error code 0 on success, -1 on failure
|
||||
**
|
||||
** Purpose: Close the output binary file, dellocate ENR_Handle struc
|
||||
** and nullify pointer to ENR_Handle struct
|
||||
**
|
||||
** NOTE: ENR_close must be called before program end
|
||||
** after calling ENR_close data in ENR_Handle struct are no more
|
||||
** accessible
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
data_t* p_data;
|
||||
int errorcode = 0;
|
||||
|
||||
p_data = (data_t*)(*p_handle);
|
||||
|
||||
if (p_data == NULL || p_data->file_handle == NULL)
|
||||
errorcode = -1;
|
||||
|
||||
else
|
||||
{
|
||||
close_file(p_data->file_handle);
|
||||
|
||||
delete_error_manager(p_data->error_handle);
|
||||
delete_file_manager(p_data->file_handle);
|
||||
|
||||
free(p_data);
|
||||
|
||||
*p_handle = NULL;
|
||||
}
|
||||
|
||||
return errorcode;
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_open(ENR_Handle p_handle, const char* path)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: path
|
||||
** Output: p_handle = pointer to ENR_Handle struct
|
||||
** Returns: warning / error code
|
||||
** Purpose: Opens the output binary file and reads prologue and epilogue
|
||||
**
|
||||
** NOTE: ENR_init must be called before anyother ENR_* functions
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int err, errorcode = 0;
|
||||
F_OFF bytecount;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else
|
||||
{
|
||||
// Attempt to open binary output file for reading only
|
||||
if ((open_file(p_data->file_handle, path, "rb")) != 0)
|
||||
errorcode = 434;
|
||||
|
||||
// Perform checks to insure the file is valid
|
||||
else if ((err = validateFile(p_data)) != 0) errorcode = err;
|
||||
|
||||
// If a warning is encountered read file header
|
||||
if (errorcode < 400 ) {
|
||||
// read network size
|
||||
seek_file(p_data->file_handle, 2*WORDSIZE, SEEK_SET);
|
||||
read_file(&(p_data->nodeCount), WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(&(p_data->tankCount), WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(&(p_data->linkCount), WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(&(p_data->pumpCount), WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(&(p_data->valveCount), WORDSIZE, 1, p_data->file_handle);
|
||||
|
||||
// Compute positions and offsets for retrieving data
|
||||
// fixed portion of header + title section + filenames + chem names
|
||||
bytecount = PROLOGUE;
|
||||
// node names + link names
|
||||
bytecount += MAXID_P1*p_data->nodeCount + MAXID_P1*p_data->linkCount;
|
||||
// network connectivity + tank nodes + tank areas
|
||||
bytecount += 3*WORDSIZE*p_data->linkCount + 2*WORDSIZE*p_data->tankCount;
|
||||
// node elevations + link lengths and link diameters
|
||||
bytecount += WORDSIZE*p_data->nodeCount + 2*WORDSIZE*p_data->linkCount;
|
||||
// pump energy summary
|
||||
bytecount += 7*WORDSIZE*p_data->pumpCount + WORDSIZE;
|
||||
p_data->outputStartPos= bytecount;
|
||||
|
||||
p_data->bytesPerPeriod = NNODERESULTS*WORDSIZE*p_data->nodeCount +
|
||||
NLINKRESULTS*WORDSIZE*p_data->linkCount;
|
||||
}
|
||||
}
|
||||
// If error close the binary file
|
||||
if (errorcode > 400) {
|
||||
set_error(p_data->error_handle, errorcode);
|
||||
ENR_close(&p_handle);
|
||||
}
|
||||
|
||||
return errorcode;
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getVersion(ENR_Handle p_handle, int* version)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: p_handle = pointer to ENR_Handle struct
|
||||
** Output: version Epanet version
|
||||
** Returns: error code
|
||||
**
|
||||
** Purpose: Returns Epanet version that wrote EBOFile
|
||||
**--------------element codes-------------------------------------------
|
||||
*/
|
||||
{
|
||||
int errorcode = 0;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else
|
||||
{
|
||||
seek_file(p_data->file_handle, 1*WORDSIZE, SEEK_SET);
|
||||
if (read_file(version, WORDSIZE, 1, p_data->file_handle) != 1)
|
||||
errorcode = 436;
|
||||
}
|
||||
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getNetSize(ENR_Handle p_handle, int** elementCount, int* length)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: p_handle = pointer to ENR_Handle struct
|
||||
** Output: array of element counts (nodes, tanks, links, pumps, valves)
|
||||
** Returns: error code
|
||||
** Purpose: Returns an array of count values
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int errorcode = 0;
|
||||
int* temp = newIntArray(NELEMENTTYPES);
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else
|
||||
{
|
||||
temp[0] = p_data->nodeCount;
|
||||
temp[1] = p_data->tankCount;
|
||||
temp[2] = p_data->linkCount;
|
||||
temp[3] = p_data->pumpCount;
|
||||
temp[4] = p_data->valveCount;
|
||||
|
||||
*elementCount = temp;
|
||||
*length = NELEMENTTYPES;
|
||||
}
|
||||
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getUnits(ENR_Handle p_handle, ENR_Units code, int* unitFlag)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: p_handle = pointer to ENR_Handle struct
|
||||
** code
|
||||
** Output: count
|
||||
** Returns: unitFlag
|
||||
** Purpose: Returns pressure or flow unit flag
|
||||
**--------------pressure unit flags----------------------------------------
|
||||
** 0 = psi
|
||||
** 1 = meters
|
||||
** 2 = kPa
|
||||
**------------------flow unit flags----------------------------------------
|
||||
** 0 = cubic feet/second
|
||||
** 1 = gallons/minute
|
||||
** 2 = million gallons/day
|
||||
** 3 = Imperial million gallons/day
|
||||
** 4 = acre-ft/day
|
||||
** 5 = liters/second
|
||||
** 6 = liters/minute
|
||||
** 7 = megaliters/day
|
||||
** 8 = cubic meters/hour
|
||||
** 9 = cubic meters/day
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int errorcode = 0;
|
||||
F_OFF offset;
|
||||
char temp[MAXID_P1];
|
||||
data_t* p_data;
|
||||
|
||||
*unitFlag = -1;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case ENR_flowUnits:
|
||||
seek_file(p_data->file_handle, 9*WORDSIZE, SEEK_SET);
|
||||
read_file(unitFlag, WORDSIZE, 1, p_data->file_handle);
|
||||
break;
|
||||
|
||||
case ENR_pressUnits:
|
||||
seek_file(p_data->file_handle, 10*WORDSIZE, SEEK_SET);
|
||||
read_file(unitFlag, WORDSIZE, 1, p_data->file_handle);
|
||||
break;
|
||||
|
||||
case ENR_qualUnits:
|
||||
offset = 7*WORDSIZE;
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(unitFlag, WORDSIZE, 1, p_data->file_handle);
|
||||
|
||||
if (*unitFlag == 0) *unitFlag = ENR_NONE;
|
||||
|
||||
else if (*unitFlag == 1) {
|
||||
offset = 15*WORDSIZE + 3*MAXMSG_P1 + 2*(MAXFNAME+1) + MAXID_P1;
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(temp, MAXID_P1, 1, p_data->file_handle);
|
||||
|
||||
if (!strcmp(temp, "mg/L")) *unitFlag = ENR_MGL;
|
||||
else *unitFlag = ENR_UGL;
|
||||
}
|
||||
|
||||
else if (*unitFlag == 2) *unitFlag = ENR_HOURS;
|
||||
|
||||
else *unitFlag = ENR_PRCNT;
|
||||
|
||||
break;
|
||||
|
||||
default: errorcode = 421;
|
||||
}
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getTimes(ENR_Handle p_handle, ENR_Time code, int* time)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: p_handle = pointer to ENR_Handle struct
|
||||
** code = element code
|
||||
** Output: time
|
||||
** Returns: error code
|
||||
** Purpose: Returns report and simulation time related parameters.
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
int errorcode = 0;
|
||||
data_t* p_data;
|
||||
|
||||
*time = -1;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case ENR_reportStart:
|
||||
seek_file(p_data->file_handle, 12*WORDSIZE, SEEK_SET);
|
||||
read_file(time, WORDSIZE, 1, p_data->file_handle);
|
||||
break;
|
||||
|
||||
case ENR_reportStep:
|
||||
seek_file(p_data->file_handle, 13*WORDSIZE, SEEK_SET);
|
||||
read_file(time, WORDSIZE, 1, p_data->file_handle);
|
||||
break;
|
||||
|
||||
case ENR_simDuration:
|
||||
seek_file(p_data->file_handle, 14*WORDSIZE, SEEK_SET);
|
||||
read_file(time, WORDSIZE, 1, p_data->file_handle);
|
||||
break;
|
||||
|
||||
case ENR_numPeriods:
|
||||
*time = p_data->nPeriods;
|
||||
break;
|
||||
|
||||
default:
|
||||
errorcode = 421;
|
||||
}
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getChemData(ENR_Handle p_handle, char** name, int* length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getElementName(ENR_Handle p_handle, ENR_ElementType type,
|
||||
int elementIndex, char** name, int* length)
|
||||
/*------------------------------------------------------------------------
|
||||
** Input: p_handle = pointer to ENR_Handle struct
|
||||
** type = ENR_node or ENR_link
|
||||
** elementIndex from 1 to nodeCount or 1 to linkCount
|
||||
** Output: name = elementName
|
||||
** Returns: error code
|
||||
** Purpose: Retrieves Name of a specified node or link element
|
||||
** NOTE: 'name' must be able to hold MAXID characters
|
||||
** TODO: Takes EPANET indexing from 1 to n not 0 to n-1
|
||||
**-------------------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
F_OFF offset;
|
||||
int errorcode = 0;
|
||||
char* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
/* Allocate memory for name */
|
||||
else if MEMCHECK(temp = newCharArray(MAXID_P1)) errorcode = 411;
|
||||
|
||||
else
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ENR_node:
|
||||
if (elementIndex < 1 || elementIndex > p_data->nodeCount)
|
||||
errorcode = 423;
|
||||
else offset = PROLOGUE + (elementIndex - 1)*MAXID_P1;
|
||||
break;
|
||||
|
||||
case ENR_link:
|
||||
if (elementIndex < 1 || elementIndex > p_data->linkCount)
|
||||
errorcode = 423;
|
||||
else
|
||||
offset = PROLOGUE + p_data->nodeCount*MAXID_P1 +
|
||||
(elementIndex - 1)*MAXID_P1;
|
||||
break;
|
||||
|
||||
default:
|
||||
errorcode = 421;
|
||||
}
|
||||
|
||||
if (!errorcode)
|
||||
{
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(temp, 1, MAXID_P1, p_data->file_handle);
|
||||
|
||||
*name = temp;
|
||||
*length = MAXID_P1;
|
||||
}
|
||||
}
|
||||
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getEnergyUsage(ENR_Handle p_handle, int pumpIndex,
|
||||
int* linkIndex, float** outValues, int* length)
|
||||
/*
|
||||
* Purpose: Returns pump energy usage statistics.
|
||||
*
|
||||
* Energy usage statistics:
|
||||
* 0 = pump utilization
|
||||
* 1 = avg. efficiency
|
||||
* 2 = avg. kW/flow
|
||||
* 3 = avg. kwatts
|
||||
* 4 = peak kwatts
|
||||
* 5 = cost/day
|
||||
*/
|
||||
{
|
||||
F_OFF offset;
|
||||
int errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
// Check for valid pump index
|
||||
else if (pumpIndex < 1 || pumpIndex > p_data->pumpCount) errorcode = 423;
|
||||
// Check memory for outValues
|
||||
else if MEMCHECK(temp = newFloatArray(NENERGYRESULTS)) errorcode = 411;
|
||||
|
||||
else
|
||||
{
|
||||
// Position offset to start of pump energy summary
|
||||
offset = p_data->outputStartPos - (p_data->pumpCount*(WORDSIZE + 6*WORDSIZE) + WORDSIZE);
|
||||
// Adjust offset by pump index
|
||||
offset += (pumpIndex - 1)*(WORDSIZE + 6*WORDSIZE);
|
||||
|
||||
// Power summary is 1 int and 6 floats for each pump
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(linkIndex, WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(temp, WORDSIZE, 6, p_data->file_handle);
|
||||
|
||||
*outValues = temp;
|
||||
*length = NENERGYRESULTS;
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getNetReacts(ENR_Handle p_handle, float** outValues, int* length)
|
||||
/*
|
||||
* Purpose: Returns network wide average reaction rates and average
|
||||
* source mass inflow:
|
||||
* 0 = bulk
|
||||
* 1 = wall
|
||||
* 2 = tank
|
||||
* 3 = source
|
||||
*/
|
||||
{
|
||||
F_OFF offset;
|
||||
int errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
// Check memory for outValues
|
||||
else if MEMCHECK(temp = newFloatArray(NREACTRESULTS)) errorcode = 411;
|
||||
|
||||
else
|
||||
{
|
||||
// Reaction summary is 4 floats located right before epilogue.
|
||||
// This offset is relative to the end of the file.
|
||||
offset = - 3*WORDSIZE - 4*WORDSIZE;
|
||||
seek_file(p_data->file_handle, offset, SEEK_END);
|
||||
read_file(temp, WORDSIZE, 4, p_data->file_handle);
|
||||
|
||||
*outValues = temp;
|
||||
*length = NREACTRESULTS;
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
void EXPORT_OUT_API ENR_free(void** array)
|
||||
//
|
||||
// Purpose: Frees memory allocated by API calls
|
||||
//
|
||||
{
|
||||
if (array != NULL) {
|
||||
free(*array);
|
||||
*array = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getNodeSeries(ENR_Handle p_handle, int nodeIndex, ENR_NodeAttribute attr,
|
||||
int startPeriod, int endPeriod, float** outValueSeries, int* dim)
|
||||
//
|
||||
// Purpose: Get time series results for particular attribute. Specify series
|
||||
// start and length using seriesStart and seriesLength respectively.
|
||||
//
|
||||
// NOTE: The node index argument corresponds to the EPANET node index from 1 to
|
||||
// nnodes. The series returned is indexed from 0 to nperiods - 1.
|
||||
//
|
||||
{
|
||||
int k, length, errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else if (nodeIndex < 1 || nodeIndex > p_data->nodeCount) errorcode = 423;
|
||||
else if (startPeriod < 0 || endPeriod >= p_data->nPeriods ||
|
||||
endPeriod <= startPeriod) errorcode = 422;
|
||||
// Check memory for outValues
|
||||
else if MEMCHECK(temp = newFloatArray(length = endPeriod - startPeriod)) errorcode = 411;
|
||||
else
|
||||
{
|
||||
// loop over and build time series
|
||||
for (k = 0; k < length; k++)
|
||||
temp[k] = getNodeValue(p_handle, startPeriod + k,
|
||||
nodeIndex, attr);
|
||||
|
||||
*outValueSeries = temp;
|
||||
*dim = length;
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getLinkSeries(ENR_Handle p_handle, int linkIndex, ENR_LinkAttribute attr,
|
||||
int startPeriod, int endPeriod, float** outValueSeries, int* dim)
|
||||
//
|
||||
// Purpose: Get time series results for particular attribute. Specify series
|
||||
// start and length using seriesStart and seriesLength respectively.
|
||||
//
|
||||
// NOTE:
|
||||
// The link index argument corresponds to the EPANET link index from 1 to
|
||||
// nlinks. The series returned is indexed from 0 to nperiods - 1.
|
||||
//
|
||||
{
|
||||
int k, length, errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else if (linkIndex < 1 || linkIndex > p_data->linkCount) errorcode = 423;
|
||||
else if (startPeriod < 0 || endPeriod >= p_data->nPeriods ||
|
||||
endPeriod <= startPeriod) errorcode = 422;
|
||||
// Check memory for outValues
|
||||
else if MEMCHECK(temp = newFloatArray(length = endPeriod - startPeriod)) errorcode = 411;
|
||||
else
|
||||
{
|
||||
// loop over and build time series
|
||||
for (k = 0; k < length; k++)
|
||||
temp[k] = getLinkValue(p_handle, startPeriod + k, linkIndex, attr);
|
||||
|
||||
*outValueSeries = temp;
|
||||
*dim = length;
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getNodeAttribute(ENR_Handle p_handle, int periodIndex,
|
||||
ENR_NodeAttribute attr, float** outValueArray, int* length)
|
||||
//
|
||||
// Purpose:
|
||||
// For all nodes at given time, get a particular attribute
|
||||
//
|
||||
// Returns:
|
||||
// Error code
|
||||
// OutValueArray of results is indexed from 0 to nodeCount
|
||||
//
|
||||
// Warning:
|
||||
// Caller must free memory allocated for outValueArray
|
||||
//
|
||||
// NOTE:
|
||||
// The array returned is indexed from 0 to nnodes - 1. So to access
|
||||
// node values by their EPANET index, the index value must be
|
||||
// decremented by one.
|
||||
//
|
||||
{
|
||||
F_OFF offset;
|
||||
int errorcode = 0;
|
||||
float * temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
// if the time index is out of range return an error
|
||||
else if (periodIndex < 0 || periodIndex >= p_data->nPeriods) errorcode = 422;
|
||||
// Check memory for outValues
|
||||
else if MEMCHECK(temp = newFloatArray(p_data->nodeCount)) errorcode = 411;
|
||||
|
||||
else
|
||||
{
|
||||
// calculate byte offset to start time for series
|
||||
offset = p_data->outputStartPos + (periodIndex)*p_data->bytesPerPeriod;
|
||||
// add offset for node and attribute
|
||||
offset += ((attr - 1)*p_data->nodeCount)*WORDSIZE;
|
||||
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(temp, WORDSIZE, p_data->nodeCount, p_data->file_handle);
|
||||
|
||||
*outValueArray = temp;
|
||||
*length = p_data->nodeCount;
|
||||
}
|
||||
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getLinkAttribute(ENR_Handle p_handle, int periodIndex,
|
||||
ENR_LinkAttribute attr, float** outValueArray, int* length)
|
||||
//
|
||||
// Purpose:
|
||||
// For all links at given time, get a particular attribute
|
||||
//
|
||||
// Returns:
|
||||
// Error code
|
||||
// OutValueArray of results is indexed from 0 to linkCount
|
||||
//
|
||||
// Warning:
|
||||
// Caller must free memory allocated for outValueArray
|
||||
//
|
||||
// NOTE:
|
||||
// The array returned is indexed from 0 to nlinks - 1. So to access
|
||||
// link values by their EPANET index, the index value must be
|
||||
// decremented by one.
|
||||
//
|
||||
{
|
||||
F_OFF offset;
|
||||
int errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
// if the time index is out of range return an error
|
||||
else if (periodIndex < 0 || periodIndex >= p_data->nPeriods) errorcode = 422;
|
||||
// Check memory for outValues
|
||||
else if MEMCHECK(temp = newFloatArray(p_data->linkCount)) errorcode = 411;
|
||||
|
||||
else
|
||||
{
|
||||
// calculate byte offset to start time for series
|
||||
offset = p_data->outputStartPos + (periodIndex)*p_data->bytesPerPeriod
|
||||
+ (NNODERESULTS*p_data->nodeCount)*WORDSIZE;
|
||||
// add offset for link and attribute
|
||||
offset += ((attr - 1)*p_data->linkCount)*WORDSIZE;
|
||||
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(temp, WORDSIZE, p_data->linkCount, p_data->file_handle);
|
||||
|
||||
*outValueArray = temp;
|
||||
*length = p_data->linkCount;
|
||||
}
|
||||
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
|
||||
int nodeIndex, float** outValueArray, int* length)
|
||||
//
|
||||
// Purpose: For a node at given time, get all attributes.
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
{
|
||||
int j, errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else if (periodIndex < 0 || periodIndex >= p_data->nPeriods) errorcode = 422;
|
||||
else if (nodeIndex < 1 || nodeIndex > p_data->nodeCount) errorcode = 423;
|
||||
else if MEMCHECK(temp = newFloatArray(NNODERESULTS)) errorcode = 411;
|
||||
else
|
||||
{
|
||||
for (j = 0; j < NNODERESULTS; j++)
|
||||
temp[j] = getNodeValue(p_handle, periodIndex, nodeIndex, j);
|
||||
|
||||
*outValueArray = temp;
|
||||
*length = NNODERESULTS;
|
||||
}
|
||||
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
|
||||
int linkIndex, float** outValueArray, int* length)
|
||||
//
|
||||
// Purpose: For a link at given time, get all attributes
|
||||
//
|
||||
{
|
||||
int j, errorcode = 0;
|
||||
float* temp;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
else if (periodIndex < 0 || periodIndex >= p_data->nPeriods) errorcode = 422;
|
||||
else if (linkIndex < 1 || linkIndex > p_data->linkCount) errorcode = 423;
|
||||
else if MEMCHECK(temp = newFloatArray(NLINKRESULTS)) errorcode = 411;
|
||||
else
|
||||
{
|
||||
for (j = 0; j < NLINKRESULTS; j++)
|
||||
temp[j] = getLinkValue(p_handle, periodIndex, linkIndex, j);
|
||||
|
||||
*outValueArray = temp;
|
||||
*length = NLINKRESULTS;
|
||||
}
|
||||
return set_error(p_data->error_handle, errorcode);
|
||||
}
|
||||
|
||||
void EXPORT_OUT_API ENR_clearError(ENR_Handle p_handle)
|
||||
{
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
clear_error(p_data->error_handle);
|
||||
}
|
||||
|
||||
int EXPORT_OUT_API ENR_checkError(ENR_Handle p_handle, char** msg_buffer)
|
||||
{
|
||||
data_t* p_data;
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
if (p_data == NULL) return -1;
|
||||
|
||||
return check_error(p_data->error_handle, msg_buffer);
|
||||
}
|
||||
|
||||
|
||||
void errorLookup(int errcode, char* dest_msg, int dest_len)
|
||||
//
|
||||
// Purpose: takes error code returns error message
|
||||
//
|
||||
{
|
||||
const char* msg;
|
||||
|
||||
switch (errcode)
|
||||
{
|
||||
case 10: msg = WARN10;
|
||||
break;
|
||||
case 411: msg = ERR411;
|
||||
break;
|
||||
case 412: msg = ERR412;
|
||||
break;
|
||||
case 421: msg = ERR421;
|
||||
break;
|
||||
case 422: msg = ERR422;
|
||||
break;
|
||||
case 423: msg = ERR423;
|
||||
break;
|
||||
case 434: msg = ERR434;
|
||||
break;
|
||||
case 435: msg = ERR435;
|
||||
break;
|
||||
case 436: msg = ERR436;
|
||||
break;
|
||||
default: msg = ERRERR;
|
||||
}
|
||||
|
||||
strncpy(dest_msg, msg, MSG_MAXLEN);
|
||||
}
|
||||
|
||||
int validateFile(ENR_Handle p_handle)
|
||||
// Returns:
|
||||
// Error code: 435, 436
|
||||
// Warning code: 10
|
||||
{
|
||||
INT4 magic1, magic2, hydcode;
|
||||
int errorcode = 0;
|
||||
F_OFF filepos;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
// Read magic number from beginning of file
|
||||
seek_file(p_data->file_handle, 0L, SEEK_SET);
|
||||
read_file(&magic1, WORDSIZE, 1, p_data->file_handle);
|
||||
|
||||
// Fast forward to end and read file epilogue
|
||||
seek_file(p_data->file_handle, -3*WORDSIZE, SEEK_END);
|
||||
read_file(&(p_data->nPeriods), WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(&hydcode, WORDSIZE, 1, p_data->file_handle);
|
||||
read_file(&magic2, WORDSIZE, 1, p_data->file_handle);
|
||||
|
||||
filepos = tell_file(p_data->file_handle);
|
||||
|
||||
// Is the file an EPANET binary file?
|
||||
if (magic1 != magic2) errorcode = 435;
|
||||
// Does the binary file contain results?
|
||||
else if (filepos < MINNREC*WORDSIZE || p_data->nPeriods == 0)
|
||||
errorcode = 436;
|
||||
// Issue warning if there were problems with the model run.
|
||||
else if (hydcode != 0) errorcode = 10;
|
||||
|
||||
return errorcode;
|
||||
}
|
||||
|
||||
float getNodeValue(ENR_Handle p_handle, int periodIndex, int nodeIndex,
|
||||
int attr)
|
||||
//
|
||||
// Purpose: Retrieves an attribute value at a specified node and time
|
||||
//
|
||||
{
|
||||
F_OFF offset;
|
||||
REAL4 y;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
// calculate byte offset to start time for series
|
||||
offset = p_data->outputStartPos + periodIndex*p_data->bytesPerPeriod;
|
||||
// add byte position for attribute and node
|
||||
offset += ((attr - 1)*p_data->nodeCount + (nodeIndex - 1))*WORDSIZE;
|
||||
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(&y, WORDSIZE, 1, p_data->file_handle);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
float getLinkValue(ENR_Handle p_handle, int periodIndex, int linkIndex,
|
||||
int attr)
|
||||
//
|
||||
// Purpose: Retrieves an attribute value at a specified link and time
|
||||
//
|
||||
{
|
||||
F_OFF offset;
|
||||
REAL4 y;
|
||||
data_t* p_data;
|
||||
|
||||
p_data = (data_t*)p_handle;
|
||||
|
||||
// Calculate byte offset to start time for series
|
||||
offset = p_data->outputStartPos + periodIndex*p_data->bytesPerPeriod
|
||||
+ (NNODERESULTS*p_data->nodeCount)*WORDSIZE;
|
||||
// add byte position for attribute and link
|
||||
offset += ((attr - 1)*p_data->linkCount + (linkIndex - 1))*WORDSIZE;
|
||||
|
||||
seek_file(p_data->file_handle, offset, SEEK_SET);
|
||||
read_file(&y, WORDSIZE, 1, p_data->file_handle);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
float* newFloatArray(int n)
|
||||
//
|
||||
// Warning: Caller must free memory allocated by this function.
|
||||
//
|
||||
{
|
||||
return (float*) malloc((n)*sizeof(float));
|
||||
}
|
||||
|
||||
int* newIntArray(int n)
|
||||
//
|
||||
// Warning: Caller must free memory allocated by this function.
|
||||
//
|
||||
{
|
||||
return (int*) malloc((n)*sizeof(int));
|
||||
}
|
||||
|
||||
char* newCharArray(int n)
|
||||
//
|
||||
// Warning: Caller must free memory allocated by this function.
|
||||
//
|
||||
{
|
||||
return (char*) malloc((n)*sizeof(char));
|
||||
}
|
||||
29
src/outfile/src/messages.h
Normal file
29
src/outfile/src/messages.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* messages.h - EPANET
|
||||
*
|
||||
* Created on: June 1, 2017
|
||||
*
|
||||
* Author: Michael E. Tryby
|
||||
* US EPA - ORD/NRMRL
|
||||
*/
|
||||
|
||||
#ifndef MESSAGES_H_
|
||||
#define MESSAGES_H_
|
||||
/*------------------- Error Messages --------------------*/
|
||||
#define MSG_MAXLEN 53
|
||||
|
||||
#define WARN10 "Warning: model run issued warnings"
|
||||
|
||||
#define ERR411 "Input Error 411: no memory allocated for results"
|
||||
#define ERR412 "Input Error 412: binary file hasn't been opened"
|
||||
#define ERR421 "Input Error 421: invalid parameter code"
|
||||
#define ERR422 "Input Error 422: reporting period index out of range"
|
||||
#define ERR423 "Input Error 423: element index out of range"
|
||||
|
||||
#define ERR434 "File Error 434: unable to open binary file"
|
||||
#define ERR435 "File Error 435: invalid binary file type"
|
||||
#define ERR436 "File Error 436: no results in binary file"
|
||||
|
||||
#define ERRERR "Error: An unknown error has occurred"
|
||||
|
||||
#endif /* MESSAGES_H_ */
|
||||
1564
src/output.c
Executable file → Normal file
1564
src/output.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1192
src/project.c
Normal file
1192
src/project.c
Normal file
File diff suppressed because it is too large
Load Diff
2348
src/quality.c
Executable file → Normal file
2348
src/quality.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
749
src/qualreact.c
Normal file
749
src/qualreact.c
Normal file
@@ -0,0 +1,749 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: qualreact.c
|
||||
Description: computes water quality reactions within pipes and tanks
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "types.h"
|
||||
|
||||
// Exported functions
|
||||
char setreactflag(Project *);
|
||||
double getucf(double);
|
||||
void ratecoeffs(Project *);
|
||||
void reactpipes(Project *, long);
|
||||
void reacttanks(Project *, long);
|
||||
double mixtank(Project *, int, double, double ,double);
|
||||
|
||||
// Imported functions
|
||||
extern void addseg(Project *, int, double, double);
|
||||
extern void reversesegs(Project *, int);
|
||||
|
||||
// Local functions
|
||||
static double piperate(Project *, int);
|
||||
static double pipereact(Project *, int, double, double, long);
|
||||
static double tankreact(Project *, double, double, double, long);
|
||||
static double bulkrate(Project *, double, double, double);
|
||||
static double wallrate(Project *, double, double, double, double);
|
||||
|
||||
static void tankmix1(Project *, int, double, double, double);
|
||||
static void tankmix2(Project *, int, double, double, double);
|
||||
static void tankmix3(Project *, int, double, double, double);
|
||||
static void tankmix4(Project *, int, double, double, double);
|
||||
|
||||
|
||||
char setreactflag(Project *pr)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns 1 for reactive WQ constituent, 0 otherwise
|
||||
** Purpose: checks if reactive chemical being simulated
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
int i;
|
||||
|
||||
if (pr->quality.Qualflag == TRACE) return 0;
|
||||
else if (pr->quality.Qualflag == AGE) return 1;
|
||||
else
|
||||
{
|
||||
for (i = 1; i <= net->Nlinks; i++)
|
||||
{
|
||||
if (net->Link[i].Type <= PIPE)
|
||||
{
|
||||
if (net->Link[i].Kb != 0.0 || net->Link[i].Kw != 0.0) return 1;
|
||||
}
|
||||
}
|
||||
for (i = 1; i <= net->Ntanks; i++)
|
||||
{
|
||||
if (net->Tank[i].Kb != 0.0) return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
double getucf(double order)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: order = bulk reaction order
|
||||
** Output: returns a unit conversion factor
|
||||
** Purpose: converts bulk reaction rates from per Liter to
|
||||
** per FT3 basis
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
if (order < 0.0) order = 0.0;
|
||||
if (order == 1.0) return (1.0);
|
||||
else return (1. / pow(LperFT3, (order - 1.0)));
|
||||
}
|
||||
|
||||
|
||||
void ratecoeffs(Project *pr)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: none
|
||||
** Purpose: determines wall reaction coeff. for each pipe
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k;
|
||||
double kw;
|
||||
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
kw = net->Link[k].Kw;
|
||||
if (kw != 0.0) kw = piperate(pr, k);
|
||||
net->Link[k].Rc = kw;
|
||||
qual->PipeRateCoeff[k] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void reactpipes(Project *pr, long dt)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: dt = time step
|
||||
** Output: none
|
||||
** Purpose: reacts water within each pipe over a time step.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k;
|
||||
Pseg seg;
|
||||
double cseg, rsum, vsum;
|
||||
|
||||
// Examine each link in network
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
// Skip non-pipe links (pumps & valves)
|
||||
if (net->Link[k].Type != PIPE) continue;
|
||||
rsum = 0.0;
|
||||
vsum = 0.0;
|
||||
|
||||
// Examine each segment of the pipe
|
||||
seg = qual->FirstSeg[k];
|
||||
while (seg != NULL)
|
||||
{
|
||||
// React segment over time dt
|
||||
cseg = seg->c;
|
||||
seg->c = pipereact(pr, k, seg->c, seg->v, dt);
|
||||
|
||||
// Update reaction component of mass balance
|
||||
qual->MassBalance.reacted += (cseg - seg->c) * seg->v;
|
||||
|
||||
// Accumulate volume-weighted reaction rate
|
||||
if (qual->Qualflag == CHEM)
|
||||
{
|
||||
rsum += fabs(seg->c - cseg) * seg->v;
|
||||
vsum += seg->v;
|
||||
}
|
||||
seg = seg->prev;
|
||||
}
|
||||
|
||||
// Normalize volume-weighted reaction rate
|
||||
if (vsum > 0.0) qual->PipeRateCoeff[k] = rsum / vsum / dt * SECperDAY;
|
||||
else qual->PipeRateCoeff[k] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void reacttanks(Project *pr, long dt)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: dt = time step
|
||||
** Output: none
|
||||
** Purpose: reacts water within each tank over a time step.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int i, k;
|
||||
double c;
|
||||
Pseg seg;
|
||||
Stank *tank;
|
||||
|
||||
// Examine each tank in network
|
||||
for (i = 1; i <= net->Ntanks; i++)
|
||||
{
|
||||
// Skip reservoirs
|
||||
tank = &net->Tank[i];
|
||||
if (tank->A == 0.0) continue;
|
||||
|
||||
// k is segment chain belonging to tank i
|
||||
k = net->Nlinks + i;
|
||||
|
||||
// React each volume segment in the chain
|
||||
seg = qual->FirstSeg[k];
|
||||
while (seg != NULL)
|
||||
{
|
||||
c = seg->c;
|
||||
seg->c = tankreact(pr, seg->c, seg->v, tank->Kb, dt);
|
||||
qual->MassBalance.reacted += (c - seg->c) * seg->v;
|
||||
seg = seg->prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double piperate(Project *pr, int k)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** Output: returns reaction rate coeff. for 1st-order wall
|
||||
** reactions or mass transfer rate coeff. for 0-order
|
||||
** reactions
|
||||
** Purpose: finds wall reaction rate coeffs.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double a, d, u, q, kf, kw, y, Re, Sh;
|
||||
|
||||
d = net->Link[k].Diam; // Pipe diameter, ft
|
||||
|
||||
// Ignore mass transfer if Schmidt No. is 0
|
||||
if (qual->Sc == 0.0)
|
||||
{
|
||||
if (qual->WallOrder == 0.0) return BIG;
|
||||
else return (net->Link[k].Kw * (4.0 / d) / pr->Ucf[ELEV]);
|
||||
}
|
||||
|
||||
// Compute Reynolds No.
|
||||
// Flow rate made consistent with how its saved to hydraulics file
|
||||
q = (hyd->LinkStatus[k] <= CLOSED) ? 0.0 : hyd->LinkFlow[k];
|
||||
a = PI * d * d / 4.0; // pipe area
|
||||
u = fabs(q) / a; // flow velocity
|
||||
Re = u * d / hyd->Viscos; // Reynolds number
|
||||
|
||||
// Compute Sherwood No. for stagnant flow
|
||||
// (mass transfer coeff. = Diffus./radius)
|
||||
if (Re < 1.0) Sh = 2.0;
|
||||
|
||||
// Compute Sherwood No. for turbulent flow using the Notter-Sleicher formula.
|
||||
else if (Re >= 2300.0) Sh = 0.0149 * pow(Re, 0.88) * pow(qual->Sc, 0.333);
|
||||
|
||||
// Compute Sherwood No. for laminar flow using Graetz solution formula.
|
||||
else
|
||||
{
|
||||
y = d / net->Link[k].Len * Re * qual->Sc;
|
||||
Sh = 3.65 + 0.0668 * y / (1.0 + 0.04 * pow(y, 0.667));
|
||||
}
|
||||
|
||||
// Compute mass transfer coeff. (in ft/sec)
|
||||
kf = Sh * qual->Diffus / d;
|
||||
|
||||
// For zero-order reaction, return mass transfer coeff.
|
||||
if (qual->WallOrder == 0.0) return kf;
|
||||
|
||||
// For first-order reaction, return apparent wall coeff.
|
||||
kw = net->Link[k].Kw / pr->Ucf[ELEV]; // Wall coeff, ft/sec
|
||||
kw = (4.0 / d) * kw * kf / (kf + fabs(kw)); // Wall coeff, 1/sec
|
||||
return kw;
|
||||
}
|
||||
|
||||
|
||||
double pipereact(Project *pr, int k, double c, double v, long dt)
|
||||
/*
|
||||
**------------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** c = current quality in segment
|
||||
** v = segment volume
|
||||
** dt = time step
|
||||
** Output: returns new WQ value
|
||||
** Purpose: computes new quality in a pipe segment after
|
||||
** reaction occurs
|
||||
**------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double cnew, dc, dcbulk, dcwall, rbulk, rwall;
|
||||
|
||||
// For water age (hrs), update concentration by timestep
|
||||
if (qual->Qualflag == AGE)
|
||||
{
|
||||
dc = (double)dt / 3600.0;
|
||||
cnew = c + dc;
|
||||
cnew = MAX(0.0, cnew);
|
||||
return cnew;
|
||||
}
|
||||
|
||||
// Otherwise find bulk & wall reaction rates
|
||||
rbulk = bulkrate(pr, c, net->Link[k].Kb, qual->BulkOrder) * qual->Bucf;
|
||||
rwall = wallrate(pr, c, net->Link[k].Diam, net->Link[k].Kw, net->Link[k].Rc);
|
||||
|
||||
// Find change in concentration over timestep
|
||||
dcbulk = rbulk * (double)dt;
|
||||
dcwall = rwall * (double)dt;
|
||||
|
||||
// Update cumulative mass reacted
|
||||
if (pr->times.Htime >= pr->times.Rstart)
|
||||
{
|
||||
qual->Wbulk += fabs(dcbulk) * v;
|
||||
qual->Wwall += fabs(dcwall) * v;
|
||||
}
|
||||
|
||||
// Update concentration
|
||||
dc = dcbulk + dcwall;
|
||||
cnew = c + dc;
|
||||
cnew = MAX(0.0, cnew);
|
||||
return cnew;
|
||||
}
|
||||
|
||||
|
||||
double tankreact(Project *pr, double c, double v, double kb, long dt)
|
||||
/*
|
||||
**-------------------------------------------------------
|
||||
** Input: c = current quality in tank
|
||||
** v = tank volume
|
||||
** kb = reaction coeff.
|
||||
** dt = time step
|
||||
** Output: returns new WQ value
|
||||
** Purpose: computes new quality in a tank after
|
||||
** reaction occurs
|
||||
**-------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double cnew, dc, rbulk;
|
||||
|
||||
// For water age, update concentration by timestep
|
||||
if (qual->Qualflag == AGE)
|
||||
{
|
||||
dc = (double)dt / 3600.0;
|
||||
}
|
||||
|
||||
// For chemical analysis apply bulk reaction rate
|
||||
else
|
||||
{
|
||||
// Find bulk reaction rate
|
||||
rbulk = bulkrate(pr, c, kb, qual->TankOrder) * qual->Tucf;
|
||||
|
||||
// Find concentration change & update quality
|
||||
dc = rbulk * (double)dt;
|
||||
if (pr->times.Htime >= pr->times.Rstart)
|
||||
{
|
||||
qual->Wtank += fabs(dc) * v;
|
||||
}
|
||||
}
|
||||
cnew = c + dc;
|
||||
cnew = MAX(0.0, cnew);
|
||||
return cnew;
|
||||
}
|
||||
|
||||
|
||||
double bulkrate(Project *pr, double c, double kb, double order)
|
||||
/*
|
||||
**-----------------------------------------------------------
|
||||
** Input: c = current WQ concentration
|
||||
** kb = bulk reaction coeff.
|
||||
** order = bulk reaction order
|
||||
** Output: returns bulk reaction rate
|
||||
** Purpose: computes bulk reaction rate (mass/volume/time)
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double c1;
|
||||
|
||||
// Find bulk reaction potential taking into account
|
||||
// limiting potential & reaction order.
|
||||
|
||||
// Zero-order kinetics:
|
||||
if (order == 0.0) c = 1.0;
|
||||
|
||||
// Michaelis-Menton kinetics:
|
||||
else if (order < 0.0)
|
||||
{
|
||||
c1 = qual->Climit + SGN(kb) * c;
|
||||
if (fabs(c1) < TINY) c1 = SGN(c1) * TINY;
|
||||
c = c / c1;
|
||||
}
|
||||
|
||||
// N-th order kinetics:
|
||||
else
|
||||
{
|
||||
// Account for limiting potential
|
||||
if (qual->Climit == 0.0) c1 = c;
|
||||
else c1 = MAX(0.0, SGN(kb) * (qual->Climit - c));
|
||||
|
||||
// Compute concentration potential
|
||||
if (order == 1.0) c = c1;
|
||||
else if (order == 2.0) c = c1 * c;
|
||||
else c = c1 * pow(MAX(0.0, c), order - 1.0);
|
||||
}
|
||||
|
||||
// Reaction rate = bulk coeff. * potential
|
||||
if (c < 0) c = 0;
|
||||
return kb * c;
|
||||
}
|
||||
|
||||
|
||||
double wallrate(Project *pr, double c, double d, double kw, double kf)
|
||||
/*
|
||||
**------------------------------------------------------------
|
||||
** Input: c = current WQ concentration
|
||||
** d = pipe diameter
|
||||
** kw = intrinsic wall reaction coeff.
|
||||
** kf = mass transfer coeff. for 0-order reaction
|
||||
** (ft/sec) or apparent wall reaction coeff.
|
||||
** for 1-st order reaction (1/sec)
|
||||
** Output: returns wall reaction rate in mass/ft3/sec
|
||||
** Purpose: computes wall reaction rate
|
||||
**------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
if (kw == 0.0 || d == 0.0) return (0.0);
|
||||
|
||||
if (qual->WallOrder == 0.0) // 0-order reaction */
|
||||
{
|
||||
kf = SGN(kw) * c * kf; //* Mass transfer rate (mass/ft2/sec)
|
||||
kw = kw * SQR(pr->Ucf[ELEV]); // Reaction rate (mass/ft2/sec)
|
||||
if (fabs(kf) < fabs(kw)) kw = kf; // Reaction mass transfer limited
|
||||
return (kw * 4.0 / d); // Reaction rate (mass/ft3/sec)
|
||||
}
|
||||
else return (c * kf); // 1st-order reaction
|
||||
}
|
||||
|
||||
|
||||
double mixtank(Project *pr, int n, double volin, double massin, double volout)
|
||||
/*
|
||||
**------------------------------------------------------------
|
||||
** Input: n = node index
|
||||
** volin = inflow volume to tank over time step
|
||||
** massin = mass inflow to tank over time step
|
||||
** volout = outflow volume from tank over time step
|
||||
** Output: returns new quality for tank
|
||||
** Purpose: mixes inflow with tank's contents to update its quality.
|
||||
**------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
|
||||
int i;
|
||||
double vnet;
|
||||
i = n - net->Njuncs;
|
||||
vnet = volin - volout;
|
||||
switch (net->Tank[i].MixModel)
|
||||
{
|
||||
case MIX1: tankmix1(pr, i, volin, massin, vnet); break;
|
||||
case MIX2: tankmix2(pr, i, volin, massin, vnet); break;
|
||||
case FIFO: tankmix3(pr, i, volin, massin, vnet); break;
|
||||
case LIFO: tankmix4(pr, i, volin, massin, vnet); break;
|
||||
}
|
||||
return net->Tank[i].C;
|
||||
}
|
||||
|
||||
|
||||
void tankmix1(Project *pr, int i, double vin, double win, double vnet)
|
||||
/*
|
||||
**---------------------------------------------
|
||||
** Input: i = tank index
|
||||
** vin = inflow volume
|
||||
** win = mass inflow
|
||||
** vnet = inflow - outflow
|
||||
** Output: none
|
||||
** Purpose: updates quality in a complete mix tank model
|
||||
**---------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k;
|
||||
double vnew;
|
||||
Pseg seg;
|
||||
Stank *tank = &net->Tank[i];
|
||||
|
||||
k = net->Nlinks + i;
|
||||
seg = qual->FirstSeg[k];
|
||||
if (seg)
|
||||
{
|
||||
vnew = seg->v + vin;
|
||||
if (vnew > 0.0) seg->c = (seg->c * seg->v + win) / vnew;
|
||||
seg->v += vnet;
|
||||
seg->v = MAX(0.0, seg->v);
|
||||
tank->C = seg->c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tankmix2(Project *pr, int i, double vin, double win, double vnet)
|
||||
/*
|
||||
**------------------------------------------------
|
||||
** Input: i = tank index
|
||||
** vin = inflow volume
|
||||
** win = mass inflow
|
||||
** vnet = inflow - outflow
|
||||
** Output: none
|
||||
** Purpose: updates quality in a 2-compartment tank model
|
||||
**------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k;
|
||||
double vt, // Transferred volume
|
||||
vmz; // Full mixing zone volume
|
||||
Pseg mixzone, // Mixing zone segment
|
||||
stagzone; // Stagnant zone segment
|
||||
Stank *tank = &pr->network.Tank[i];
|
||||
|
||||
// Identify segments for each compartment
|
||||
k = net->Nlinks + i;
|
||||
mixzone = qual->LastSeg[k];
|
||||
stagzone = qual->FirstSeg[k];
|
||||
if (mixzone == NULL || stagzone == NULL) return;
|
||||
|
||||
// Full mixing zone volume
|
||||
vmz = tank->V1max;
|
||||
|
||||
// Tank is filling
|
||||
vt = 0.0;
|
||||
if (vnet > 0.0)
|
||||
{
|
||||
vt = MAX(0.0, (mixzone->v + vnet - vmz));
|
||||
if (vin > 0.0)
|
||||
{
|
||||
mixzone->c = ((mixzone->c) * (mixzone->v) + win) /
|
||||
(mixzone->v + vin);
|
||||
}
|
||||
if (vt > 0.0)
|
||||
{
|
||||
stagzone->c = ((stagzone->c) * (stagzone->v) +
|
||||
(mixzone->c) * vt) / (stagzone->v + vt);
|
||||
}
|
||||
}
|
||||
|
||||
// Tank is emptying
|
||||
else if (vnet < 0.0)
|
||||
{
|
||||
if (stagzone->v > 0.0) vt = MIN(stagzone->v, (-vnet));
|
||||
if (vin + vt > 0.0)
|
||||
{
|
||||
mixzone->c = ((mixzone->c) * (mixzone->v) + win +
|
||||
(stagzone->c) * vt) / (mixzone->v + vin + vt);
|
||||
}
|
||||
}
|
||||
|
||||
// Update segment volumes
|
||||
if (vt > 0.0)
|
||||
{
|
||||
mixzone->v = vmz;
|
||||
if (vnet > 0.0) stagzone->v += vt;
|
||||
else stagzone->v = MAX(0.0, ((stagzone->v) - vt));
|
||||
}
|
||||
else
|
||||
{
|
||||
mixzone->v += vnet;
|
||||
mixzone->v = MIN(mixzone->v, vmz);
|
||||
mixzone->v = MAX(0.0, mixzone->v);
|
||||
stagzone->v = 0.0;
|
||||
}
|
||||
|
||||
// Use quality of mixing zone to represent quality of
|
||||
// tank since this is where outflow begins to flow from
|
||||
tank->C = mixzone->c;
|
||||
}
|
||||
|
||||
|
||||
void tankmix3(Project *pr, int i, double vin, double win, double vnet)
|
||||
/*
|
||||
**----------------------------------------------------------
|
||||
** Input: i = tank index
|
||||
** vin = inflow volume
|
||||
** win = mass inflow
|
||||
** vnet = inflow - outflow
|
||||
** Output: none
|
||||
** Purpose: Updates quality in a First-In-First-Out (FIFO) tank model.
|
||||
**----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k;
|
||||
double vout, vseg;
|
||||
double cin, vsum, wsum;
|
||||
Pseg seg;
|
||||
Stank *tank = &pr->network.Tank[i];
|
||||
|
||||
k = net->Nlinks + i;
|
||||
if (qual->LastSeg[k] == NULL || qual->FirstSeg[k] == NULL) return;
|
||||
|
||||
// Add new last segment for flow entering the tank
|
||||
if (vin > 0.0)
|
||||
{
|
||||
// ... increase segment volume if inflow has same quality as segment
|
||||
cin = win / vin;
|
||||
seg = qual->LastSeg[k];
|
||||
if (fabs(seg->c - cin) < qual->Ctol) seg->v += vin;
|
||||
|
||||
// ... otherwise add a new last segment to the tank
|
||||
else addseg(pr, k, vin, cin);
|
||||
}
|
||||
|
||||
// Withdraw flow from first segment
|
||||
vsum = 0.0;
|
||||
wsum = 0.0;
|
||||
vout = vin - vnet;
|
||||
while (vout > 0.0)
|
||||
{
|
||||
seg = qual->FirstSeg[k];
|
||||
if (seg == NULL) break;
|
||||
vseg = seg->v; // Flow volume from leading seg
|
||||
vseg = MIN(vseg, vout);
|
||||
if (seg == qual->LastSeg[k]) vseg = vout;
|
||||
vsum += vseg;
|
||||
wsum += (seg->c) * vseg;
|
||||
vout -= vseg; // Remaining flow volume
|
||||
if (vout >= 0.0 && vseg >= seg->v) // Seg used up
|
||||
{
|
||||
if (seg->prev)
|
||||
{
|
||||
qual->FirstSeg[k] = seg->prev;
|
||||
seg->prev = qual->FreeSeg;
|
||||
qual->FreeSeg = seg;
|
||||
}
|
||||
}
|
||||
else seg->v -= vseg; // Remaining volume in segment
|
||||
}
|
||||
|
||||
// Use quality withdrawn from 1st segment
|
||||
// to represent overall quality of tank
|
||||
if (vsum > 0.0) tank->C = wsum / vsum;
|
||||
else if (qual->FirstSeg[k] == NULL) tank->C = 0.0;
|
||||
else tank->C = qual->FirstSeg[k]->c;
|
||||
}
|
||||
|
||||
|
||||
void tankmix4(Project *pr, int i, double vin, double win, double vnet)
|
||||
/*
|
||||
**----------------------------------------------------------
|
||||
** Input: i = tank index
|
||||
** vin = inflow volume
|
||||
** win = mass inflow
|
||||
** vnet = inflow - outflow
|
||||
** Output: none
|
||||
** Purpose: Updates quality in a Last In-First Out (LIFO) tank model.
|
||||
**----------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k;
|
||||
double cin, vsum, wsum, vseg;
|
||||
Pseg seg;
|
||||
Stank *tank = &pr->network.Tank[i];
|
||||
|
||||
k = net->Nlinks + i;
|
||||
if (qual->LastSeg[k] == NULL || qual->FirstSeg[k] == NULL) return;
|
||||
|
||||
// Find inflows & outflows
|
||||
if (vin > 0.0) cin = win / vin;
|
||||
else cin = 0.0;
|
||||
|
||||
// If tank filling, then create new last seg
|
||||
tank->C = qual->LastSeg[k]->c;
|
||||
seg = qual->LastSeg[k];
|
||||
if (vnet > 0.0)
|
||||
{
|
||||
// ... inflow quality is same as last segment's quality,
|
||||
// so just add inflow volume to last segment
|
||||
if (fabs(seg->c - cin) < qual->Ctol) seg->v += vnet;
|
||||
|
||||
// ... otherwise add a new last segment with inflow quality
|
||||
else addseg(pr, k, vnet, cin);
|
||||
|
||||
// Update reported tank quality
|
||||
tank->C = qual->LastSeg[k]->c;
|
||||
}
|
||||
|
||||
// If tank emptying then remove last segments until vnet consumed
|
||||
else if (vnet < 0.0)
|
||||
{
|
||||
vsum = 0.0;
|
||||
wsum = 0.0;
|
||||
vnet = -vnet;
|
||||
|
||||
// Reverse segment chain so segments are processed from last to first
|
||||
reversesegs(pr, k);
|
||||
|
||||
// While there is still volume to remove
|
||||
while (vnet > 0.0)
|
||||
{
|
||||
// ... start with reversed first segment
|
||||
seg = qual->FirstSeg[k];
|
||||
if (seg == NULL) break;
|
||||
|
||||
// ... find volume to remove from it
|
||||
vseg = seg->v;
|
||||
vseg = MIN(vseg, vnet);
|
||||
if (seg == qual->LastSeg[k]) vseg = vnet;
|
||||
|
||||
// ... update total volume & mass removed
|
||||
vsum += vseg;
|
||||
wsum += (seg->c) * vseg;
|
||||
|
||||
// ... update remiaing volume to remove
|
||||
vnet -= vseg;
|
||||
|
||||
// ... if no more volume left in current segment
|
||||
if (vnet >= 0.0 && vseg >= seg->v)
|
||||
{
|
||||
// ... replace current segment with previous one
|
||||
if (seg->prev)
|
||||
{
|
||||
qual->FirstSeg[k] = seg->prev;
|
||||
seg->prev = qual->FreeSeg;
|
||||
qual->FreeSeg = seg;
|
||||
}
|
||||
}
|
||||
|
||||
// ... otherwise reduce volume of current segment
|
||||
else seg->v -= vseg;
|
||||
}
|
||||
|
||||
// Restore original orientation of segment chain
|
||||
reversesegs(pr, k);
|
||||
|
||||
// Reported tank quality is mixture of flow released and any inflow
|
||||
tank->C = (wsum + win) / (vsum + vin);
|
||||
}
|
||||
}
|
||||
701
src/qualroute.c
Normal file
701
src/qualroute.c
Normal file
@@ -0,0 +1,701 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
Project: OWA EPANET
|
||||
Version: 2.2
|
||||
Module: qualroute.c
|
||||
Description: computes water quality transport over a single time step
|
||||
Authors: see AUTHORS
|
||||
Copyright: see AUTHORS
|
||||
License: see LICENSE
|
||||
Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "mempool.h"
|
||||
#include "types.h"
|
||||
|
||||
// Macro to compute the volume of a link
|
||||
#define LINKVOL(k) (0.785398 * net->Link[(k)].Len * SQR(net->Link[(k)].Diam))
|
||||
|
||||
// Macro to get link flow compatible with flow saved to hydraulics file
|
||||
#define LINKFLOW(k) ((hyd->LinkStatus[k] <= CLOSED) ? 0.0 : hyd->LinkFlow[k])
|
||||
|
||||
// Exported functions
|
||||
int sortnodes(Project *);
|
||||
void transport(Project *, long);
|
||||
void initsegs(Project *);
|
||||
void reversesegs(Project *, int);
|
||||
void addseg(Project *, int, double, double);
|
||||
|
||||
// Imported functions
|
||||
extern double findsourcequal(Project *, int, double, long);
|
||||
extern void reactpipes(Project *, long);
|
||||
extern void reacttanks(Project *, long);
|
||||
extern double mixtank(Project *, int, double, double, double);
|
||||
|
||||
// Local functions
|
||||
static void evalnodeinflow(Project *, int, long, double *, double *);
|
||||
static void evalnodeoutflow(Project *, int, double, long);
|
||||
static double findnodequal(Project *, int, double, double, double, long);
|
||||
static double noflowqual(Project *, int);
|
||||
static void updatemassbalance(Project *, int, double, double, long);
|
||||
static int selectnonstacknode(Project *, int, int *);
|
||||
|
||||
|
||||
void transport(Project *pr, long tstep)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: tstep = length of current time step
|
||||
** Output: none
|
||||
** Purpose: transports constituent mass through the pipe network
|
||||
** under a period of constant hydraulic conditions.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int j, k, m, n;
|
||||
double volin, massin, volout, nodequal;
|
||||
Padjlist alink;
|
||||
|
||||
// React contents of each pipe and tank
|
||||
if (qual->Reactflag)
|
||||
{
|
||||
reactpipes(pr, tstep);
|
||||
reacttanks(pr, tstep);
|
||||
}
|
||||
|
||||
// Analyze each node in topological order
|
||||
for (j = 1; j <= net->Nnodes; j++)
|
||||
{
|
||||
// ... index of node to be processed
|
||||
n = qual->SortedNodes[j];
|
||||
|
||||
// ... zero out mass & flow volumes for this node
|
||||
volin = 0.0;
|
||||
massin = 0.0;
|
||||
volout = 0.0;
|
||||
|
||||
// ... examine each link with flow into the node
|
||||
for (alink = net->Adjlist[n]; alink != NULL; alink = alink->next)
|
||||
{
|
||||
// ... k is index of next link incident on node n
|
||||
k = alink->link;
|
||||
|
||||
// ... link has flow into node - add it to node's inflow
|
||||
// (m is index of link's downstream node)
|
||||
m = net->Link[k].N2;
|
||||
if (qual->FlowDir[k] < 0) m = net->Link[k].N1;
|
||||
if (m == n)
|
||||
{
|
||||
evalnodeinflow(pr, k, tstep, &volin, &massin);
|
||||
}
|
||||
|
||||
// ... link has flow out of node - add it to node's outflow
|
||||
else volout += fabs(LINKFLOW(k));
|
||||
}
|
||||
|
||||
// ... if node is a junction, add on any external outflow (e.g., demands)
|
||||
if (net->Node[n].Type == JUNCTION)
|
||||
{
|
||||
volout += MAX(0.0, hyd->NodeDemand[n]);
|
||||
}
|
||||
|
||||
// ... convert from outflow rate to volume
|
||||
volout *= tstep;
|
||||
|
||||
// ... find the concentration of flow leaving the node
|
||||
nodequal = findnodequal(pr, n, volin, massin, volout, tstep);
|
||||
|
||||
// ... examine each link with flow out of the node
|
||||
for (alink = net->Adjlist[n]; alink != NULL; alink = alink->next)
|
||||
{
|
||||
// ... link k incident on node n has upstream node m equal to n
|
||||
k = alink->link;
|
||||
m = net->Link[k].N1;
|
||||
if (qual->FlowDir[k] < 0) m = net->Link[k].N2;
|
||||
if (m == n)
|
||||
{
|
||||
// ... send flow at new node concen. into link
|
||||
evalnodeoutflow(pr, k, nodequal, tstep);
|
||||
}
|
||||
}
|
||||
updatemassbalance(pr, n, massin, volout, tstep);
|
||||
}
|
||||
}
|
||||
|
||||
void evalnodeinflow(Project *pr, int k, long tstep, double *volin,
|
||||
double *massin)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** tstep = quality routing time step
|
||||
** Output: volin = flow volume entering a node
|
||||
** massin = constituent mass entering a node
|
||||
** Purpose: adds the contribution of a link's outflow volume
|
||||
** and constituent mass to the total inflow into its
|
||||
** downstream node over a time step.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double q, v, vseg;
|
||||
Pseg seg;
|
||||
|
||||
// Get flow rate (q) and flow volume (v) through link
|
||||
q = LINKFLOW(k);
|
||||
v = fabs(q) * tstep;
|
||||
|
||||
// Transport flow volume v from link's leading segments into downstream
|
||||
// node, removing segments once their full volume is consumed
|
||||
while (v > 0.0)
|
||||
{
|
||||
seg = qual->FirstSeg[k];
|
||||
if (!seg) break;
|
||||
|
||||
// ... volume transported from first segment is smaller of
|
||||
// remaining flow volume & segment volume
|
||||
vseg = seg->v;
|
||||
vseg = MIN(vseg, v);
|
||||
|
||||
// ... update total volume & mass entering downstream node
|
||||
*volin += vseg;
|
||||
*massin += vseg * seg->c;
|
||||
|
||||
// ... reduce remaining flow volume by amount transported
|
||||
v -= vseg;
|
||||
|
||||
// ... if all of segment's volume was transferred
|
||||
if (v >= 0.0 && vseg >= seg->v)
|
||||
{
|
||||
// ... replace this leading segment with the one behind it
|
||||
qual->FirstSeg[k] = seg->prev;
|
||||
if (qual->FirstSeg[k] == NULL) qual->LastSeg[k] = NULL;
|
||||
|
||||
// ... recycle the used up segment
|
||||
seg->prev = qual->FreeSeg;
|
||||
qual->FreeSeg = seg;
|
||||
}
|
||||
|
||||
// ... otherwise just reduce this segment's volume
|
||||
else seg->v -= vseg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double findnodequal(Project *pr, int n, double volin,
|
||||
double massin, double volout, long tstep)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: n = node index
|
||||
** volin = flow volume entering node
|
||||
** massin = mass entering node
|
||||
** volout = flow volume leaving node
|
||||
** tstep = length of current time step
|
||||
** Output: returns water quality in a node's outflow
|
||||
** Purpose: computes a node's new quality from its inflow
|
||||
** volume and mass, including any source contribution.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
// Node is a junction - update its water quality
|
||||
if (net->Node[n].Type == JUNCTION)
|
||||
{
|
||||
// ... dilute inflow with any external negative demand
|
||||
volin -= MIN(0.0, hyd->NodeDemand[n]) * tstep;
|
||||
|
||||
// ... new concen. is mass inflow / volume inflow
|
||||
if (volin > 0.0) qual->NodeQual[n] = massin / volin;
|
||||
|
||||
// ... if no inflow adjust quality for reaction in connecting pipes
|
||||
else if (qual->Reactflag) qual->NodeQual[n] = noflowqual(pr, n);
|
||||
}
|
||||
|
||||
// Node is a tank - use its mixing model to update its quality
|
||||
else if (net->Node[n].Type == TANK)
|
||||
{
|
||||
qual->NodeQual[n] = mixtank(pr, n, volin, massin, volout);
|
||||
}
|
||||
|
||||
// Add any external quality source onto node's concen.
|
||||
qual->SourceQual = 0.0;
|
||||
|
||||
// For source tracing analysis find tracer added at source node
|
||||
if (qual->Qualflag == TRACE)
|
||||
{
|
||||
if (n == qual->TraceNode)
|
||||
{
|
||||
// ... quality added to network is difference between tracer
|
||||
// concentration (100 mg/L) and current node quality
|
||||
if (net->Node[n].Type == RESERVOIR) qual->SourceQual = 100.0;
|
||||
else qual->SourceQual = MAX(100.0 - qual->NodeQual[n], 0.0);
|
||||
qual->NodeQual[n] = 100.0;
|
||||
}
|
||||
return qual->NodeQual[n];
|
||||
}
|
||||
|
||||
// Find quality contribued by any external chemical source
|
||||
else qual->SourceQual = findsourcequal(pr, n, volout, tstep);
|
||||
if (qual->SourceQual == 0.0) return qual->NodeQual[n];
|
||||
|
||||
// Combine source quality with node quality
|
||||
switch (net->Node[n].Type)
|
||||
{
|
||||
case JUNCTION:
|
||||
qual->NodeQual[n] += qual->SourceQual;
|
||||
return qual->NodeQual[n];
|
||||
|
||||
case TANK:
|
||||
return qual->NodeQual[n] + qual->SourceQual;
|
||||
|
||||
case RESERVOIR:
|
||||
qual->NodeQual[n] = qual->SourceQual;
|
||||
return qual->SourceQual;
|
||||
}
|
||||
return qual->NodeQual[n];
|
||||
}
|
||||
|
||||
|
||||
double noflowqual(Project *pr, int n)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: n = node index
|
||||
** Output: quality for node n
|
||||
** Purpose: sets the quality for a junction node that has no
|
||||
** inflow to the average of the quality in its
|
||||
** adjoining link segments.
|
||||
** Note: this function is only used for reactive substances.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int k, inflow, kount = 0;
|
||||
double c = 0.0;
|
||||
FlowDirection dir;
|
||||
Padjlist alink;
|
||||
|
||||
// Examine each link incident on the node
|
||||
for (alink = net->Adjlist[n]; alink != NULL; alink = alink->next)
|
||||
{
|
||||
// ... index of an incident link
|
||||
k = alink->link;
|
||||
dir = qual->FlowDir[k];
|
||||
|
||||
// Node n is link's downstream node - add quality
|
||||
// of link's first segment to average
|
||||
if (net->Link[k].N2 == n && dir >= 0) inflow = TRUE;
|
||||
else if (net->Link[k].N1 == n && dir < 0) inflow = TRUE;
|
||||
else inflow = FALSE;
|
||||
if (inflow == TRUE && qual->FirstSeg[k] != NULL)
|
||||
{
|
||||
c += qual->FirstSeg[k]->c;
|
||||
kount++;
|
||||
}
|
||||
|
||||
// Node n is link's upstream node - add quality
|
||||
// of link's last segment to average
|
||||
else if (inflow == FALSE && qual->LastSeg[k] != NULL)
|
||||
{
|
||||
c += qual->LastSeg[k]->c;
|
||||
kount++;
|
||||
}
|
||||
}
|
||||
if (kount > 0) c = c / (double)kount;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void evalnodeoutflow(Project *pr, int k, double c, long tstep)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** c = quality from upstream node
|
||||
** tstep = time step
|
||||
** Output: none
|
||||
** Purpose: releases flow volume and mass from the upstream
|
||||
** node of a link over a time step.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double v;
|
||||
Pseg seg;
|
||||
|
||||
// Find flow volume (v) released over time step
|
||||
v = fabs(LINKFLOW(k)) * tstep;
|
||||
if (v == 0.0) return;
|
||||
|
||||
// Release flow and mass into upstream end of the link
|
||||
|
||||
// ... case where link has a last (most upstream) segment
|
||||
seg = qual->LastSeg[k];
|
||||
if (seg)
|
||||
{
|
||||
// ... if node quality close to segment quality then mix
|
||||
// the nodal outflow volume with the segment's volume
|
||||
if (fabs(seg->c - c) < qual->Ctol)
|
||||
{
|
||||
seg->c = (seg->c*seg->v + c*v) / (seg->v + v);
|
||||
seg->v += v;
|
||||
}
|
||||
|
||||
// ... otherwise add a new segment at upstream end of link
|
||||
else addseg(pr, k, v, c);
|
||||
}
|
||||
|
||||
// ... link has no segments so add one
|
||||
else addseg(pr, k, v, c);
|
||||
}
|
||||
|
||||
|
||||
void updatemassbalance(Project *pr, int n, double massin,
|
||||
double volout, long tstep)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: n = node index
|
||||
** massin = mass inflow to node
|
||||
** volout = outflow volume from node
|
||||
** Output: none
|
||||
** Purpose: Adds a node's external mass inflow and outflow
|
||||
** over the current time step to the network's
|
||||
** overall mass balance.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Hydraul *hyd = &pr->hydraul;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
double masslost = 0.0,
|
||||
massadded = 0.0;
|
||||
|
||||
switch (net->Node[n].Type)
|
||||
{
|
||||
// Junctions lose mass from outflow demand & gain it from source inflow
|
||||
case JUNCTION:
|
||||
masslost = MAX(0.0, hyd->NodeDemand[n]) * tstep * qual->NodeQual[n];
|
||||
massadded = qual->SourceQual * volout;
|
||||
break;
|
||||
|
||||
// Reservoirs add mass from quality source if specified or from a fixed
|
||||
// initial quality
|
||||
case RESERVOIR:
|
||||
masslost = massin;
|
||||
if (qual->SourceQual > 0.0) massadded = qual->SourceQual * volout;
|
||||
else massadded = qual->NodeQual[n] * volout;
|
||||
break;
|
||||
|
||||
// Tanks add mass only from external source inflow
|
||||
case TANK:
|
||||
massadded = qual->SourceQual * volout;
|
||||
break;
|
||||
}
|
||||
qual->MassBalance.outflow += masslost;
|
||||
qual->MassBalance.inflow += massadded;
|
||||
}
|
||||
|
||||
|
||||
int sortnodes(Project *pr)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: returns an error code
|
||||
** Purpose: topologically sorts nodes from upstream to downstream.
|
||||
** Note: links with negligible flow are ignored since they can
|
||||
** create spurious cycles that cause the sort to fail.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int i, j, k, n;
|
||||
int *indegree = NULL;
|
||||
int *stack = NULL;
|
||||
int stacksize = 0;
|
||||
int numsorted = 0;
|
||||
int errcode = 0;
|
||||
FlowDirection dir;
|
||||
Padjlist alink;
|
||||
|
||||
// Allocate an array to count # links with inflow to each node
|
||||
// and for a stack to hold nodes waiting to be processed
|
||||
indegree = (int *)calloc(net->Nnodes + 1, sizeof(int));
|
||||
stack = (int *)calloc(net->Nnodes + 1, sizeof(int));
|
||||
if (indegree && stack)
|
||||
{
|
||||
// Count links with "non-negligible" inflow to each node
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
dir = qual->FlowDir[k];
|
||||
if (dir == POSITIVE) n = net->Link[k].N2;
|
||||
else if (dir == NEGATIVE) n = net->Link[k].N1;
|
||||
else continue;
|
||||
indegree[n]++;
|
||||
}
|
||||
|
||||
// Place nodes with no inflow onto a stack
|
||||
for (i = 1; i <= net->Nnodes; i++)
|
||||
{
|
||||
if (indegree[i] == 0)
|
||||
{
|
||||
stacksize++;
|
||||
stack[stacksize] = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Examine each node on the stack until none are left
|
||||
while (numsorted < net->Nnodes)
|
||||
{
|
||||
// ... if stack is empty then a cycle exists
|
||||
if (stacksize == 0)
|
||||
{
|
||||
// ... add a non-sorted node connected to a sorted one to stack
|
||||
j = selectnonstacknode(pr, numsorted, indegree);
|
||||
if (j == 0) break; // This shouldn't happen.
|
||||
indegree[j] = 0;
|
||||
stacksize++;
|
||||
stack[stacksize] = j;
|
||||
}
|
||||
|
||||
// ... make the last node added to the stack the next
|
||||
// in sorted order & remove it from the stack
|
||||
i = stack[stacksize];
|
||||
stacksize--;
|
||||
numsorted++;
|
||||
qual->SortedNodes[numsorted] = i;
|
||||
|
||||
// ... for each outflow link from this node reduce the in-degree
|
||||
// of its downstream node
|
||||
for (alink = net->Adjlist[i]; alink != NULL; alink = alink->next)
|
||||
{
|
||||
// ... k is the index of the next link incident on node i
|
||||
k = alink->link;
|
||||
|
||||
// ... skip link if flow is negligible
|
||||
if (qual->FlowDir[k] == 0) continue;
|
||||
|
||||
// ... link has flow out of node (downstream node n not equal to i)
|
||||
n = net->Link[k].N2;
|
||||
if (qual->FlowDir[k] < 0) n = net->Link[k].N1;
|
||||
|
||||
// ... reduce degree of node n
|
||||
if (n != i && indegree[n] > 0)
|
||||
{
|
||||
indegree[n]--;
|
||||
|
||||
// ... no more degree left so add node n to stack
|
||||
if (indegree[n] == 0)
|
||||
{
|
||||
stacksize++;
|
||||
stack[stacksize] = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else errcode = 101;
|
||||
if (numsorted < net->Nnodes) errcode = 120;
|
||||
FREE(indegree);
|
||||
FREE(stack);
|
||||
return errcode;
|
||||
}
|
||||
|
||||
|
||||
int selectnonstacknode(Project *pr, int numsorted, int *indegree)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: numsorted = number of nodes that have been sorted
|
||||
** indegree = number of inflow links to each node
|
||||
** Output: returns a node index
|
||||
** Purpose: selects a next node for sorting when a cycle exists.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int i, m, n;
|
||||
Padjlist alink;
|
||||
|
||||
// Examine each sorted node in last in - first out order
|
||||
for (i = numsorted; i > 0; i--)
|
||||
{
|
||||
// For each link connected to the sorted node
|
||||
m = qual->SortedNodes[i];
|
||||
for (alink = net->Adjlist[m]; alink != NULL; alink = alink->next)
|
||||
{
|
||||
// ... n is the node of link k opposite to node m
|
||||
n = alink->node;
|
||||
|
||||
// ... select node n if it still has inflow links
|
||||
if (indegree[n] > 0) return n;
|
||||
}
|
||||
}
|
||||
|
||||
// If no node was selected by the above process then return the
|
||||
// first node that still has inflow links remaining
|
||||
for (i = 1; i <= net->Nnodes; i++)
|
||||
{
|
||||
if (indegree[i] > 0) return i;
|
||||
}
|
||||
|
||||
// If all else fails return 0 indicating that no node was selected
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void initsegs(Project *pr)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: none
|
||||
** Output: none
|
||||
** Purpose: initializes water quality volume segments in each
|
||||
** pipe and tank.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Network *net = &pr->network;
|
||||
Quality *qual = &pr->quality;
|
||||
|
||||
int j, k;
|
||||
double c, v, v1;
|
||||
|
||||
// Add one segment with assigned downstream node quality to each pipe
|
||||
for (k = 1; k <= net->Nlinks; k++)
|
||||
{
|
||||
qual->FirstSeg[k] = NULL;
|
||||
qual->LastSeg[k] = NULL;
|
||||
if (net->Link[k].Type == PIPE)
|
||||
{
|
||||
v = LINKVOL(k);
|
||||
j = net->Link[k].N2;
|
||||
c = qual->NodeQual[j];
|
||||
addseg(pr, k, v, c);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize segments in tanks
|
||||
for (j = 1; j <= net->Ntanks; j++)
|
||||
{
|
||||
// Skip reservoirs
|
||||
if (net->Tank[j].A == 0.0) continue;
|
||||
|
||||
// Establish initial tank quality & volume
|
||||
k = net->Tank[j].Node;
|
||||
c = net->Node[k].C0;
|
||||
v = net->Tank[j].V0;
|
||||
|
||||
// Create one volume segment for entire tank
|
||||
k = net->Nlinks + j;
|
||||
qual->FirstSeg[k] = NULL;
|
||||
qual->LastSeg[k] = NULL;
|
||||
addseg(pr, k, v, c);
|
||||
|
||||
// Create a 2nd segment for the 2-compartment tank model
|
||||
if (net->Tank[j].MixModel == MIX2)
|
||||
{
|
||||
// ... mixing zone segment
|
||||
v1 = MAX(0, v - net->Tank[j].V1max);
|
||||
qual->FirstSeg[k]->v = v1;
|
||||
|
||||
// ... stagnant zone segment
|
||||
v = v - v1;
|
||||
addseg(pr, k, v, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void reversesegs(Project *pr, int k)
|
||||
/*
|
||||
**--------------------------------------------------------------
|
||||
** Input: k = link index
|
||||
** Output: none
|
||||
** Purpose: re-orients a link's segments when flow reverses.
|
||||
**--------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Quality *qual = &pr->quality;
|
||||
Pseg seg, nseg, pseg;
|
||||
|
||||
seg = qual->FirstSeg[k];
|
||||
qual->FirstSeg[k] = qual->LastSeg[k];
|
||||
qual->LastSeg[k] = seg;
|
||||
pseg = NULL;
|
||||
while (seg != NULL)
|
||||
{
|
||||
nseg = seg->prev;
|
||||
seg->prev = pseg;
|
||||
pseg = seg;
|
||||
seg = nseg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void addseg(Project *pr, int k, double v, double c)
|
||||
/*
|
||||
**-------------------------------------------------------------
|
||||
** Input: k = segment chain index
|
||||
** v = segment volume
|
||||
** c = segment quality
|
||||
** Output: none
|
||||
** Purpose: adds a segment to the start of a link
|
||||
** upstream of its current last segment.
|
||||
**-------------------------------------------------------------
|
||||
*/
|
||||
{
|
||||
Quality *qual = &pr->quality;
|
||||
Pseg seg;
|
||||
|
||||
// Grab the next free segment from the segment pool if available
|
||||
if (qual->FreeSeg != NULL)
|
||||
{
|
||||
seg = qual->FreeSeg;
|
||||
qual->FreeSeg = seg->prev;
|
||||
}
|
||||
|
||||
// Otherwise allocate a new segment
|
||||
else
|
||||
{
|
||||
seg = (struct Sseg *) mempool_alloc(qual->SegPool, sizeof(struct Sseg));
|
||||
if (seg == NULL)
|
||||
{
|
||||
qual->OutOfMemory = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Assign volume and quality to the segment
|
||||
seg->v = v;
|
||||
seg->c = c;
|
||||
|
||||
// Add the new segment to the end of the segment chain
|
||||
seg->prev = NULL;
|
||||
if (qual->FirstSeg[k] == NULL) qual->FirstSeg[k] = seg;
|
||||
if (qual->LastSeg[k] != NULL) qual->LastSeg[k]->prev = seg;
|
||||
qual->LastSeg[k] = seg;
|
||||
}
|
||||
2690
src/report.c
Executable file → Normal file
2690
src/report.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
2319
src/rules.c
Executable file → Normal file
2319
src/rules.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
1632
src/smatrix.c
1632
src/smatrix.c
File diff suppressed because it is too large
Load Diff
1024
src/text.h
1024
src/text.h
File diff suppressed because it is too large
Load Diff
255
src/toolkit.h
255
src/toolkit.h
@@ -1,255 +0,0 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
|
||||
TOOLKIT.H - Prototypes for EPANET Functions Exported to DLL Toolkit
|
||||
|
||||
VERSION: 2.00
|
||||
DATE: 5/8/00
|
||||
10/25/00
|
||||
3/1/01
|
||||
8/15/07 (2.00.11)
|
||||
2/14/08 (2.00.12)
|
||||
AUTHOR: L. Rossman
|
||||
US EPA - NRMRL
|
||||
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DLLEXPORT
|
||||
#ifdef DLL
|
||||
#ifdef __cplusplus
|
||||
#define DLLEXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define DLLEXPORT __declspec(dllexport) __stdcall
|
||||
#endif
|
||||
#elif defined(CYGWIN)
|
||||
#define DLLEXPORT __stdcall
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
#define DLLEXPORT
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// --- Define the EPANET toolkit constants
|
||||
|
||||
#define EN_ELEVATION 0 /* Node parameters */
|
||||
#define EN_BASEDEMAND 1
|
||||
#define EN_PATTERN 2
|
||||
#define EN_EMITTER 3
|
||||
#define EN_INITQUAL 4
|
||||
#define EN_SOURCEQUAL 5
|
||||
#define EN_SOURCEPAT 6
|
||||
#define EN_SOURCETYPE 7
|
||||
#define EN_TANKLEVEL 8
|
||||
#define EN_DEMAND 9
|
||||
#define EN_HEAD 10
|
||||
#define EN_PRESSURE 11
|
||||
#define EN_QUALITY 12
|
||||
#define EN_SOURCEMASS 13
|
||||
#define EN_INITVOLUME 14
|
||||
#define EN_MIXMODEL 15
|
||||
#define EN_MIXZONEVOL 16
|
||||
|
||||
#define EN_TANKDIAM 17
|
||||
#define EN_MINVOLUME 18
|
||||
#define EN_VOLCURVE 19
|
||||
#define EN_MINLEVEL 20
|
||||
#define EN_MAXLEVEL 21
|
||||
#define EN_MIXFRACTION 22
|
||||
#define EN_TANK_KBULK 23
|
||||
#define EN_TANKVOLUME 24
|
||||
#define EN_MAXVOLUME 25
|
||||
|
||||
#define EN_DIAMETER 0 /* Link parameters */
|
||||
#define EN_LENGTH 1
|
||||
#define EN_ROUGHNESS 2
|
||||
#define EN_MINORLOSS 3
|
||||
#define EN_INITSTATUS 4
|
||||
#define EN_INITSETTING 5
|
||||
#define EN_KBULK 6
|
||||
#define EN_KWALL 7
|
||||
#define EN_FLOW 8
|
||||
#define EN_VELOCITY 9
|
||||
#define EN_HEADLOSS 10
|
||||
#define EN_STATUS 11
|
||||
#define EN_SETTING 12
|
||||
#define EN_ENERGY 13
|
||||
#define EN_LINKQUAL 14 /* TNT */
|
||||
#define EN_LINKPATTERN 15
|
||||
|
||||
#define EN_DURATION 0 /* Time parameters */
|
||||
#define EN_HYDSTEP 1
|
||||
#define EN_QUALSTEP 2
|
||||
#define EN_PATTERNSTEP 3
|
||||
#define EN_PATTERNSTART 4
|
||||
#define EN_REPORTSTEP 5
|
||||
#define EN_REPORTSTART 6
|
||||
#define EN_RULESTEP 7
|
||||
#define EN_STATISTIC 8
|
||||
#define EN_PERIODS 9
|
||||
#define EN_STARTTIME 10 /* Added TNT 10/2/2009 */
|
||||
#define EN_HTIME 11
|
||||
#define EN_HALTFLAG 12
|
||||
#define EN_NEXTEVENT 13
|
||||
|
||||
#define EN_ITERATIONS 0
|
||||
#define EN_RELATIVEERROR 1
|
||||
|
||||
#define EN_NODECOUNT 0 /* Component counts */
|
||||
#define EN_TANKCOUNT 1
|
||||
#define EN_LINKCOUNT 2
|
||||
#define EN_PATCOUNT 3
|
||||
#define EN_CURVECOUNT 4
|
||||
#define EN_CONTROLCOUNT 5
|
||||
|
||||
#define EN_JUNCTION 0 /* Node types */
|
||||
#define EN_RESERVOIR 1
|
||||
#define EN_TANK 2
|
||||
|
||||
#define EN_CVPIPE 0 /* Link types. */
|
||||
#define EN_PIPE 1 /* See LinkType in TYPES.H */
|
||||
#define EN_PUMP 2
|
||||
#define EN_PRV 3
|
||||
#define EN_PSV 4
|
||||
#define EN_PBV 5
|
||||
#define EN_FCV 6
|
||||
#define EN_TCV 7
|
||||
#define EN_GPV 8
|
||||
|
||||
#define EN_NONE 0 /* Quality analysis types. */
|
||||
#define EN_CHEM 1 /* See QualType in TYPES.H */
|
||||
#define EN_AGE 2
|
||||
#define EN_TRACE 3
|
||||
|
||||
#define EN_CONCEN 0 /* Source quality types. */
|
||||
#define EN_MASS 1 /* See SourceType in TYPES.H. */
|
||||
#define EN_SETPOINT 2
|
||||
#define EN_FLOWPACED 3
|
||||
|
||||
#define EN_CFS 0 /* Flow units types. */
|
||||
#define EN_GPM 1 /* See FlowUnitsType */
|
||||
#define EN_MGD 2 /* in TYPES.H. */
|
||||
#define EN_IMGD 3
|
||||
#define EN_AFD 4
|
||||
#define EN_LPS 5
|
||||
#define EN_LPM 6
|
||||
#define EN_MLD 7
|
||||
#define EN_CMH 8
|
||||
#define EN_CMD 9
|
||||
|
||||
#define EN_TRIALS 0 /* Misc. options */
|
||||
#define EN_ACCURACY 1
|
||||
#define EN_TOLERANCE 2
|
||||
#define EN_EMITEXPON 3
|
||||
#define EN_DEMANDMULT 4
|
||||
|
||||
#define EN_LOWLEVEL 0 /* Control types. */
|
||||
#define EN_HILEVEL 1 /* See ControlType */
|
||||
#define EN_TIMER 2 /* in TYPES.H. */
|
||||
#define EN_TIMEOFDAY 3
|
||||
|
||||
#define EN_AVERAGE 1 /* Time statistic types. */
|
||||
#define EN_MINIMUM 2 /* See TstatType in TYPES.H */
|
||||
#define EN_MAXIMUM 3
|
||||
#define EN_RANGE 4
|
||||
|
||||
#define EN_MIX1 0 /* Tank mixing models */
|
||||
#define EN_MIX2 1
|
||||
#define EN_FIFO 2
|
||||
#define EN_LIFO 3
|
||||
|
||||
#define EN_NOSAVE 0 /* Save-results-to-file flag */
|
||||
#define EN_SAVE 1
|
||||
|
||||
#define EN_INITFLOW 10 /* Re-initialize flows flag */
|
||||
|
||||
#define EN_CONST_HP 0 /* constant horsepower */
|
||||
#define EN_POWER_FUNC 1 /* power function */
|
||||
#define EN_CUSTOM 2 /* user-defined custom curve */
|
||||
|
||||
// --- Declare the EPANET toolkit functions
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *));
|
||||
|
||||
int DLLEXPORT ENopen(char *, char *, char *);
|
||||
int DLLEXPORT ENsaveinpfile(char *);
|
||||
int DLLEXPORT ENclose(void);
|
||||
|
||||
int DLLEXPORT ENsolveH(void);
|
||||
int DLLEXPORT ENsaveH(void);
|
||||
int DLLEXPORT ENopenH(void);
|
||||
int DLLEXPORT ENinitH(int);
|
||||
int DLLEXPORT ENrunH(long *);
|
||||
int DLLEXPORT ENnextH(long *);
|
||||
int DLLEXPORT ENcloseH(void);
|
||||
int DLLEXPORT ENsavehydfile(char *);
|
||||
int DLLEXPORT ENusehydfile(char *);
|
||||
|
||||
int DLLEXPORT ENsolveQ(void);
|
||||
int DLLEXPORT ENopenQ(void);
|
||||
int DLLEXPORT ENinitQ(int);
|
||||
int DLLEXPORT ENrunQ(long *);
|
||||
int DLLEXPORT ENnextQ(long *);
|
||||
int DLLEXPORT ENstepQ(long *);
|
||||
int DLLEXPORT ENcloseQ(void);
|
||||
|
||||
int DLLEXPORT ENwriteline(char *);
|
||||
int DLLEXPORT ENreport(void);
|
||||
int DLLEXPORT ENresetreport(void);
|
||||
int DLLEXPORT ENsetreport(char *);
|
||||
|
||||
int DLLEXPORT ENgetcontrol(int, int *, int *, float *,
|
||||
int *, float *);
|
||||
int DLLEXPORT ENgetcount(int, int *);
|
||||
int DLLEXPORT ENgetoption(int, float *);
|
||||
int DLLEXPORT ENgettimeparam(int, long *);
|
||||
int DLLEXPORT ENgetflowunits(int *);
|
||||
int DLLEXPORT ENgetpatternindex(char *, int *);
|
||||
int DLLEXPORT ENgetpatternid(int, char *);
|
||||
int DLLEXPORT ENgetpatternlen(int, int *);
|
||||
int DLLEXPORT ENgetpatternvalue(int, int, float *);
|
||||
int DLLEXPORT ENgetqualtype(int *, int *);
|
||||
int DLLEXPORT ENgeterror(int, char *, int);
|
||||
int DLLEXPORT ENgetstatistic(int code, int* value);
|
||||
|
||||
int DLLEXPORT ENgetnodeindex(char *, int *);
|
||||
int DLLEXPORT ENgetnodeid(int, char *);
|
||||
int DLLEXPORT ENgetnodetype(int, int *);
|
||||
int DLLEXPORT ENgetnodevalue(int, int, float *);
|
||||
|
||||
int DLLEXPORT ENgetnumdemands(int, int *);
|
||||
int DLLEXPORT ENgetbasedemand(int, int, float *);
|
||||
int DLLEXPORT ENgetdemandpattern(int, int, int *);
|
||||
|
||||
int DLLEXPORT ENgetlinkindex(char *, int *);
|
||||
int DLLEXPORT ENgetlinkid(int, char *);
|
||||
int DLLEXPORT ENgetlinktype(int, int *);
|
||||
int DLLEXPORT ENgetlinknodes(int, int *, int *);
|
||||
int DLLEXPORT ENgetlinkvalue(int, int, float *);
|
||||
|
||||
int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float **yValues);
|
||||
int DLLEXPORT ENgetheadcurve(int, char *);
|
||||
int DLLEXPORT ENgetpumptype(int, int *);
|
||||
|
||||
int DLLEXPORT ENgetversion(int *);
|
||||
|
||||
int DLLEXPORT ENsetcontrol(int, int, int, float, int, float);
|
||||
int DLLEXPORT ENsetnodevalue(int, int, float);
|
||||
int DLLEXPORT ENsetlinkvalue(int, int, float);
|
||||
int DLLEXPORT ENaddpattern(char *);
|
||||
int DLLEXPORT ENsetpattern(int, float *, int);
|
||||
int DLLEXPORT ENsetpatternvalue(int, int, float);
|
||||
int DLLEXPORT ENsettimeparam(int, long);
|
||||
int DLLEXPORT ENsetoption(int, float);
|
||||
int DLLEXPORT ENsetstatusreport(int);
|
||||
int DLLEXPORT ENsetqualtype(int, char *, char *, char *);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user