Skip to content

Commit 00bbbb6

Browse files
committed
add toolkit example 4 - network building
1 parent c7a7049 commit 00bbbb6

File tree

2 files changed

+118
-45
lines changed

2 files changed

+118
-45
lines changed

examples/README.md

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
1-
<a href="http://www.kios.ucy.ac.cy"><img src="http://www.kios.ucy.ac.cy/templates/favourite/images/kios_logo_hover.png"/><a>
2-
3-
4-
EPANET-MATLAB-Toolkit - Examples
5-
==================================
6-
7-
## Table of Contents
8-
9-
- [Examples](#examples)
10-
11-
## Examples
12-
- [Example 0:](./EX0_CCWI2016_contamination_simulation.m) Arsenite contamination simulator based on EPANET andEPANET-MSX using the EPANET-MATLAB Toolkit.
13-
- [Example 1:](./EX1_Plot_network_topology.m) Plot network topology.
14-
- [Example 2:](./EX2_Hydraulic_analysis.m) Hydraulic analysis.
15-
- [Example 3:](./EX3_Quality_analysis.m) Quality analysis.
16-
- [Example 4:](./EX4_Plot_time_series.m) Plot time series.
17-
- [Example 5:](./EX5_Plot_values_parameters.m) Plot values parameters.
18-
- [Example 6:](./EX6_load_two_inp_files.m) Load two inp files.
19-
- [Example 7:](./EX7_set_pump_curves.m) Set pump curves.
20-
- [Example 8:](./EX8_tanks_to_reservoirs.m) Tanks to reservoirs.
21-
- [Example 9:](./EX9_compare_simulations.m) Compare Simulations.
22-
- [Example 10:](./EX10_close_pipes_during_sim.m) Close pipes during simulation.
23-
- [Example 11:](./EX11_assing_new_curve_pump.m) Assign a new curve to a pump.
24-
- [Example 12:](./EX12_add_multiple_controlpatterns_bin.m) Add multiple control patterns.
25-
- [Example 13a:](./EX13a_add_cvpipe_junction.m) Add pipe and junction via bin function.
26-
- [Example 13b:](./EX13b_add_cvpipe_bin.m) Add pipe via bin function.
27-
- [Example 13c:](./EX13c_add_cvpipe.m) Add pipe via normal function.
28-
- [Example 14:](./EX14_hydraulic_and_quality_analysis.m) Hydraulic and Quality analysis.
29-
- [Example 15:](./EX15_write_msx_file.m) Write MSX file.
30-
- [Example 16:](./EX16_create_multiple_scenarios.m) Creating scenarios.
31-
- [Example 17a:](./EX17a_add_multiple_controls_pipestatus_bin.m) Add controls via bin functions.
32-
- [Example 17b:](./EX17b_add_multiple_controls_pipestatus.m) Add controls via normal functions.
33-
- [Example 18:](./EX18_change_status_pipes.m) Change status of pipe during simulation.
34-
- [Example 19:](./EX19_rotate_network.m) Rotate network.
35-
- [Example 20a:](./EX20a_external_controls.m) Change of external Controls.
36-
- [Example 20b:](./EX20b_external_controls.m) Addition of external Controls.
37-
- [Example 21:](./EX21_Pressure_driven_analysis_option.m) Pressure driven analysis.
38-
- [Example 22:](./EX22_Overflow_option_for_tanks.m) Overflow of tanks.
39-
- [Example 23:](./EX23_Change_connection_links.m) Change connection of the links.
40-
- [Example 24:](./EX24_delete_all_patterns.m) Delete all patterns.
41-
- [Example 25:](./EX25_set_node_name_ids.m) Set node name IDs.
42-
43-
&uparrow; [Back to top](#table-of-contents)
44-
45-
1+
<a href="http://www.kios.ucy.ac.cy"><img src="http://www.kios.ucy.ac.cy/templates/favourite/images/kios_logo_hover.png"/><a>
2+
3+
4+
EPANET-MATLAB-Toolkit - Examples
5+
==================================
6+
7+
## Table of Contents
8+
9+
- [Examples](#examples)
10+
11+
## Examples
12+
- [Toolkit Example 2:](./Toolkit_EX2_Hydrant_rating_curve.m) Hydrant rating curve
13+
- [Toolkit Example 3:](./Toolkit_EX3_Minimum_chlorine_residual.m) Minimum chlorine residual.
14+
- [Toolkit Example 4:](./Toolkit_EX4_Network_Building.m) Network building.
15+
- [Example 0:](./EX0_CCWI2016_contamination_simulation.m) Arsenite contamination simulator based on EPANET andEPANET-MSX using the EPANET-MATLAB Toolkit.
16+
- [Example 1:](./EX1_Plot_network_topology.m) Plot network topology.
17+
- [Example 2:](./EX2_Hydraulic_analysis.m) Hydraulic analysis.
18+
- [Example 3:](./EX3_Quality_analysis.m) Quality analysis.
19+
- [Example 4:](./EX4_Plot_time_series.m) Plot time series.
20+
- [Example 5:](./EX5_Plot_values_parameters.m) Plot values parameters.
21+
- [Example 6:](./EX6_load_two_inp_files.m) Load two inp files.
22+
- [Example 7:](./EX7_set_pump_curves.m) Set pump curves.
23+
- [Example 8:](./EX8_tanks_to_reservoirs.m) Tanks to reservoirs.
24+
- [Example 9:](./EX9_compare_simulations.m) Compare Simulations.
25+
- [Example 10:](./EX10_close_pipes_during_sim.m) Close pipes during simulation.
26+
- [Example 11:](./EX11_assing_new_curve_pump.m) Assign a new curve to a pump.
27+
- [Example 12:](./EX12_add_multiple_controlpatterns_bin.m) Add multiple control patterns.
28+
- [Example 13a:](./EX13a_add_cvpipe_junction.m) Add pipe and junction via bin function.
29+
- [Example 13b:](./EX13b_add_cvpipe_bin.m) Add pipe via bin function.
30+
- [Example 13c:](./EX13c_add_cvpipe.m) Add pipe via normal function.
31+
- [Example 14:](./EX14_hydraulic_and_quality_analysis.m) Hydraulic and Quality analysis.
32+
- [Example 15:](./EX15_write_msx_file.m) Write MSX file.
33+
- [Example 16:](./EX16_create_multiple_scenarios.m) Creating scenarios.
34+
- [Example 17a:](./EX17a_add_multiple_controls_pipestatus_bin.m) Add controls via bin functions.
35+
- [Example 17b:](./EX17b_add_multiple_controls_pipestatus.m) Add controls via normal functions.
36+
- [Example 18:](./EX18_change_status_pipes.m) Change status of pipe during simulation.
37+
- [Example 19:](./EX19_rotate_network.m) Rotate network.
38+
- [Example 20a:](./EX20a_external_controls.m) Change of external Controls.
39+
- [Example 20b:](./EX20b_external_controls.m) Addition of external Controls.
40+
- [Example 21:](./EX21_Pressure_driven_analysis_option.m) Pressure driven analysis.
41+
- [Example 22:](./EX22_Overflow_option_for_tanks.m) Overflow of tanks.
42+
- [Example 23:](./EX23_Change_connection_links.m) Change connection of the links.
43+
- [Example 24:](./EX24_delete_all_patterns.m) Delete all patterns.
44+
- [Example 25:](./EX25_set_node_name_ids.m) Set node name IDs.
45+
46+
&uparrow; [Back to top](#table-of-contents)
47+
48+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
% 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.
2+
%
3+
% Below is a schematic of the network to be built.
4+
%
5+
% http://wateranalytics.org/EPANET/_example2.html
6+
7+
%Clear
8+
clear; close('all'); clc;
9+
start_toolkit;
10+
11+
% Create an empty INP file
12+
testinp = 'TESTING.inp';
13+
d = epanet(testinp, 'CREATE');
14+
15+
% Initialize epanet flow units
16+
d.initializeEPANET(d.ToolkitConstants.EN_GPM, d.ToolkitConstants.EN_HW);
17+
18+
% an elevation of 700 ft and a demand of 0
19+
index = d.addNodeJunction('J1');
20+
d.setNodeJunctionData(index, 700, 0, '');
21+
d.setNodeCoordinates(index, [10 20])
22+
23+
% Add the remaining two junctions with elevations of
24+
% 710 ft and demands of 250 and 500 gpm, respectively
25+
index = d.addNodeJunction('J2');
26+
d.setNodeJunctionData(index, 710, 250, '');
27+
d.setNodeCoordinates(index, [20 30])
28+
29+
index = d.addNodeJunction('J3');
30+
d.setNodeJunctionData(index, 710, 500, '');
31+
d.setNodeCoordinates(index, [30 30])
32+
33+
% Add the reservoir at an elevation of 650 ft
34+
index = d.addNodeReservoir('R1');
35+
d.setNodeElevations(index, 650);
36+
d.setNodeCoordinates(index, [10 25])
37+
38+
% Add the tank node at elevation of 850 ft, initial water level
39+
% at 120 ft, minimum level at 100 ft, maximum level at 150 ft
40+
% and a diameter of 50.5 ft
41+
% index = d.addNodeTank('T1'); % bug check
42+
% d.setNodeTankData(index, 850, 120, 100, 150, 50.5, 0, '');
43+
44+
% Add the pipes to the project, setting their length,
45+
% diameter, and roughness values
46+
47+
index = d.addLinkPipe('P1', 'J1', 'J2');
48+
d.setLinkPipeData(index, 10560, 12, 100, 0);
49+
index = d.addLinkPipe('P2', 'J1', 'T1');
50+
d.setLinkPipeData(index, 5280, 14, 100, 0);
51+
index = d.addLinkPipe('P3', 'J1', 'J3');
52+
d.setLinkPipeData(index, 5280, 14, 100, 0);
53+
index = d.addLinkPipe('P4', 'J2', 'J3');
54+
d.setLinkPipeData(index, 5280, 14, 100, 0);
55+
56+
% Add a pump to the project
57+
index = d.addLinkPump('PUMP', 'R1', 'J1');
58+
59+
% Create a single point head curve (index = 1) and
60+
% assign it to the pump
61+
d.addCurve('C1');
62+
d.setCurveValue(1, 1, [1500, 250]);
63+
d.setLinkPumpHCurve(index, 1);
64+
65+
% Save the project for future use
66+
d.saveInputFile(testinp);
67+
d = epanet(testinp);
68+
d.plot;
69+
70+
d.unload;

0 commit comments

Comments
 (0)