150 lines
8.9 KiB
HTML
150 lines
8.9 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.16"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>EPANET: Network Building Example</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">EPANET
|
|
 <span id="projectnumber">2.2.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.16 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="_toolkit_examples.html">Examples</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="PageDoc"><div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Network Building Example </div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p>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.</p>
|
|
<p>Below is a schematic of the network to be built. </p><table style="border: 0px solid black">
|
|
<tr>
|
|
<td><div class="image">
|
|
<img src="Example2.png" alt=""/>
|
|
</div>
|
|
</td></tr>
|
|
</table>
|
|
<div class="fragment"><div class="line"><span class="preprocessor">#include "epanet2_2.h"</span></div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keywordtype">void</span> netbuilder()</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> <span class="comment">// Create a project that uses gpm for flow units and</span></div>
|
|
<div class="line"> <span class="comment">// the Hazen-Williams formula for head loss</span></div>
|
|
<div class="line"> <span class="keywordtype">int</span> index;</div>
|
|
<div class="line"> EN_Project ph;</div>
|
|
<div class="line"> EN_createproject(&ph);</div>
|
|
<div class="line"> EN_init(ph, <span class="stringliteral">""</span>, <span class="stringliteral">""</span>, EN_GPM, EN_HW);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Add the first junction node to the project with</span></div>
|
|
<div class="line"> <span class="comment">// an elevation of 700 ft and a demand of 0</span></div>
|
|
<div class="line"> EN_addnode(ph, <span class="stringliteral">"J1"</span>, EN_JUNCTION, &index);</div>
|
|
<div class="line"> EN_setjuncdata(ph, index, 700, 0, <span class="stringliteral">""</span>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Add the remaining two junctions with elevations of</span></div>
|
|
<div class="line"> <span class="comment">// 710 ft and demands of 250 and 500 gpm, respectively</span></div>
|
|
<div class="line"> EN_addnode(ph, <span class="stringliteral">"J2"</span>, EN_JUNCTION, &index);</div>
|
|
<div class="line"> EN_setjuncdata(ph, index, 710, 250, <span class="stringliteral">""</span>);</div>
|
|
<div class="line"> EN_addnode(ph, <span class="stringliteral">"J3"</span>, EN_JUNCTION, &index);</div>
|
|
<div class="line"> EN_setjuncdata(ph, index, 710, 500, <span class="stringliteral">""</span>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Add the reservoir at an elevation of 650 ft</span></div>
|
|
<div class="line"> EN_addnode(ph, <span class="stringliteral">"R1"</span>, EN_RESERVOIR, &index);</div>
|
|
<div class="line"> EN_setnodevalue(ph, index, EN_ELEVATION, 650);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Add the tank node at elevation of 850 ft, initial water level</span></div>
|
|
<div class="line"> <span class="comment">// at 120 ft, minimum level at 100 ft, maximum level at 150 ft</span></div>
|
|
<div class="line"> <span class="comment">// and a diameter of 50.5 ft</span></div>
|
|
<div class="line"> EN_addnode(ph, <span class="stringliteral">"T1"</span>, EN_TANK, &index);</div>
|
|
<div class="line"> EN_settankdata(ph, index, 850, 120, 100, 150, 50.5, 0, <span class="stringliteral">""</span>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Add the pipes to the project, setting their length,</span></div>
|
|
<div class="line"> <span class="comment">// diameter, and roughness values</span></div>
|
|
<div class="line"> EN_addlink(ph, <span class="stringliteral">"P1"</span>, EN_PIPE, <span class="stringliteral">"J1"</span>, <span class="stringliteral">"J2"</span>, &index);</div>
|
|
<div class="line"> EN_setpipedata(ph, index, 10560, 12, 100, 0);</div>
|
|
<div class="line"> EN_addlink(ph, <span class="stringliteral">"P2"</span>, EN_PIPE, <span class="stringliteral">"J1"</span>, <span class="stringliteral">"T1"</span>, &index);</div>
|
|
<div class="line"> EN_setpipedata(ph, index, 5280, 14, 100, 0);</div>
|
|
<div class="line"> EN_addlink(ph, <span class="stringliteral">"P3"</span>, EN_PIPE, <span class="stringliteral">"J1"</span>, <span class="stringliteral">"J3"</span>, &index);</div>
|
|
<div class="line"> EN_setpipedata(ph, index, 5280, 14, 100, 0);</div>
|
|
<div class="line"> EN_addlink(ph, <span class="stringliteral">"P4"</span>, EN_PIPE, <span class="stringliteral">"J2"</span>, <span class="stringliteral">"J3"</span>, &index);</div>
|
|
<div class="line"> EN_setpipedata(ph, index, 5280, 14, 100, 0);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Add a pump to the project</span></div>
|
|
<div class="line"> EN_addlink(ph, <span class="stringliteral">"PUMP"</span>, EN_PUMP, <span class="stringliteral">"R1"</span>, <span class="stringliteral">"J1"</span>, &index);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Create a single point head curve (index = 1) and</span></div>
|
|
<div class="line"> <span class="comment">// assign it to the pump</span></div>
|
|
<div class="line"> EN_addcurve(ph, <span class="stringliteral">"C1"</span>);</div>
|
|
<div class="line"> EN_setcurvevalue(ph, 1, 1, 1500, 250);</div>
|
|
<div class="line"> EN_setlinkvalue(ph, index, EN_PUMP_HCURVE, 1);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Save the project for future use</span></div>
|
|
<div class="line"> EN_saveinpfile(ph, <span class="stringliteral">"example2.inp"</span>);</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// Delete the project</span></div>
|
|
<div class="line"> EN_deleteproject(ph);</div>
|
|
<div class="line">}</div>
|
|
</div><!-- fragment --> </div></div><!-- contents -->
|
|
</div><!-- PageDoc -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.16
|
|
</small></address>
|
|
</body>
|
|
</html>
|