EPANET Programmer’s Toolkit

I have mentioned the EPANET toolkit several times before but didn’t post any information about it yet. The following info is from the toolkit readme file:

EPANET is a program that analyzes the hydraulic and water quality behavior of water distribution systems. The EPANET Programmer’s Toolkit is a dynamic link library (DLL) of functions that allows developers to customize EPANET’s computational engine for their own specific needs. The functions can be incorporated into 32-bit Windows applications written in C/C++, Delphi Pascal, Visual Basic, or any other language that can call functions within a Windows DLL. The Toolkit DLL file is named EPANET2.DLL and is distributed with EPANET. The Toolkit comes with several different header files, function definition files, and .lib files that simplify the task of interfacing it with C/C++, Delphi, and Visual Basic code.

The freeware FireFlow utility was written using the EPANET toolkit.

For more information and download see EPANET web page.

76 comments on “EPANET Programmer’s Toolkit
  1. P.Sivakumar says:

    How can I start modifying the source code of EPANET and retrieve the result of hydraulic head available at the demand node by using the toolkit functions of the EPANET for Head Driven Analysis ?

  2. witsarut says:

    I want to write program of EPANET with visual basic 2008 but i don’t know function So I think you has example for program of EPANET with visual basic 2008. Can you sent for me?

  3. P.Sivakumar says:

    How can I start modifying the source code of EPANET and retrieve the result of hydraulic head available at the demand node by using the toolkit functions of the EPANET for Head Driven Analysis ?And I could not run the program also.

  4. Lucas Vasconcelos says:

    The toolkit functions allow you to call an entire simulation through the ENepanet method, or run a time step by time step simulation. The toolkit does not allow you to change the time step!

    The toolkit is quite well documented. For hydraulic analysis, you can use the loop (First declare longs t and tstep).
    while tstep 0
    ENrunH( pointer to t)
    (some toolkit functions to read or set the characteristics you want and handle it with your algorithm)
    ENnextH(pointer to tstep)

    The only language I’m confident to know enough to take less time coding than thinking of algorithms (when it comes to math only!) is c#.net, so this is how the loop looks on c# given that the wrapper class is called EpanetHandler.

    EpanetHandler.ENopen(@”file.inp”, @”file.rpt”, @”file.out”);
    while (tstep != 0)
    EpanetHandler.ENrunH(ref t);
    EpanetHandler.ENnextH(ref tstep);

    The native function changes the values of tstep and t regardless of what I do. This was a real moodkiller for me! 🙂

  5. omar says:

    i am a student and i try to understand with a program how the toolkit epanet work with matlab

  6. mohand says:

    i am a student and i try to understand with a program how the toolkit epanet work with matlab

  7. bcoelho says:


    When making multiple hydraulic analyses on the same network (iterative procedure), is there any way to obtain the pumping costs (cost associated to each pump or even total cost) after each iteration?

    The only way I know to obtain that costs is by reading the Report File. However, in iterative processes is not possible to use repeated calls to ENsolveH and, consequently, saving the hydraulic results and generating a report is also not possible (Am I correct?)

    B. Coelho

  8. Jiva says:

    Helo Sir,
    I am trying to create a web based decision support system using Gis and Epanet. It involves creation of a customer complaint management wherein, the nonavailability of water for a customer is modelled by keeping pipe status closed in epanet. When a customer registers a complaint of non-availability, the possible reasons are to be evaluated using the epanet model. Is it possible to use epanet programming toolkit using php scripting language? If yes how?

  9. Herman says:


    I want to interface between MATLAB2014b 64bit and EPANET 64bit, but unfortunately failed to loadlibrary epanet2.dll, and epanet2.h, could some one help kindly and give the detail procedure how to load interface between them!!

  10. kouadio toussaint says:

    help me to find solution about epanet error 203.

  11. B. Coelho says:

    This may also help you with other errors:


  12. Shekh Shamsuzzaman says:

    Hello ELad,
    Thanks for such nice post which make our first step easy to run EPANet dll to get output file for simulation. But I am in trouble to get it running from my ARCMap Addin (C#.NetAPI). The same source for dll function calling is working in a console application but when I do the same calling from ArcMap Addin button click, it returns error 305. Do you have any clue regarding this?


  13. Brett says:

    I have just discovered that for some reason the total head for tanks is slightly different for my code compared to what EPANET directly calculates.

    It seems the heads for all my other junctions are correct as well as the flows in pipes. Because of this error with the tanks I sometimes get flows going from a node with lower total head to a tank with higher total head (if it had the total head that EPAnet calculated than the flows would be correct). Anyone know why this would be occurring?

    The code I am using to grab head for tanks is below:

    Call ENgetnodevalue(j_NUMNODES, EN_HEAD, Junction2(j_NUMNODES, Hour).Hydraulic_Head)



  14. ali says:

    Hello Mr ELad.
    I am student want to do simulation for my model can you help me.

  15. Mathumitha says:


    My epanet program is getting executed without errors.

    I need to input my data set in the file in visual c/c++…

    can you tell me how to do it from the programming perspective

  16. sarah says:

    Hi, i tried to install this add-in in Windows 8 64 bit. I had 3 different system folders. I copy in all, but when i tried to open Example 1, the error says i need to update the version for 64 bits (visual).
    Can you help me with that?

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.