Advertisement
 

Samples and libraries for EPANET developers (C, C++, C#, Haskell, Java, JavaScript, MATLAB, Python, Visual Basic)

The EPANET Toolkit supports many programming languages:

EPANET and C

Sample Projects

Sample projects illustrating how to compile EPANET and related software using a variety of different compilers.

Orwell Dev-C++ Projects

Orwell Dev-C++ is a popular open source C/C++ IDE for Windows.

Dev-C++ EPANET Toolkit example (C)

A very simple example that illustrates how to import the 32-bit EPANET Toolkit DLL into a Dev-C++ project and link a console application against it.

Simply download and unzip epanet_toolkit_example_devcpp_c.zip. Open the Dev-C++ project, build and run. Sample INP file and relevant EPANET Toolkit files are included. Note how Net1.txt and Net1.inp are generated in the build folder when running the application.

Build the EPANET toolkit DLL

epanet2.dev is a Dev-C++ project to build the EPANET toolkit dll.

Simply install Dev-C++ and copy epanet2.dev into the folder containing the EPANET sources.

Build epanet2.exe

epanet2exe.dev is a Dev-C++ project to build epanet2.exe.

Simply install Dev-C++ and copy epanet2exe.dev into the folder containing the EPANET sources.

EPANET Patches

Patches to the EPANET C sources.

epanet_pump.diff is a unified diff file against epanet.c and toolkit.h that adds the following functions, allowing to access pump data through the toolkit:

  • int ENgetheadcurve(int, char *);
  • int ENgetpumptype(int, int *);

Likewise, epanet_toolkit_pump.diff is a unified diff file against epanet2.h that adds the two functions.

The unified diff format is self explanatory. Further reference can be found in Wikipedia's unified diff format entry.

The patch command can be used to apply the source code changes. Windows users can download a version of the patch program from the GNUWin32 project: patch.

To apply the patch(es), follow the steps below:

  • Copy epanet_pump.diff to the folder containing your EPANET sources
  • Make sure that the patch command is in the PATH
  • Run the following command: patch < epanet_pump.diff

Python

Visual Basic Solution

epanet_toolkit_example_vb.zip - Simple Visual Basic Express Edition 2010 project that illustrates how to use the EPANET Toolkit DLL in Visual Basic.

You should extract the files to c:\tmp in order to compile it successfully.

64-bit

64-bit version of the EPANET toolkit.

Advertisement