Skip to content

Commit

Permalink
add toolkit example 4 - network building
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariosmsk committed Aug 16, 2021
1 parent c7a7049 commit 00bbbb6
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 45 deletions.
93 changes: 48 additions & 45 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
<a href="http://www.kios.ucy.ac.cy"><img src="http://www.kios.ucy.ac.cy/templates/favourite/images/kios_logo_hover.png"/><a>


EPANET-MATLAB-Toolkit - Examples
==================================

## Table of Contents

- [Examples](#examples)

## Examples
- [Example 0:](./EX0_CCWI2016_contamination_simulation.m) Arsenite contamination simulator based on EPANET andEPANET-MSX using the EPANET-MATLAB Toolkit.
- [Example 1:](./EX1_Plot_network_topology.m) Plot network topology.
- [Example 2:](./EX2_Hydraulic_analysis.m) Hydraulic analysis.
- [Example 3:](./EX3_Quality_analysis.m) Quality analysis.
- [Example 4:](./EX4_Plot_time_series.m) Plot time series.
- [Example 5:](./EX5_Plot_values_parameters.m) Plot values parameters.
- [Example 6:](./EX6_load_two_inp_files.m) Load two inp files.
- [Example 7:](./EX7_set_pump_curves.m) Set pump curves.
- [Example 8:](./EX8_tanks_to_reservoirs.m) Tanks to reservoirs.
- [Example 9:](./EX9_compare_simulations.m) Compare Simulations.
- [Example 10:](./EX10_close_pipes_during_sim.m) Close pipes during simulation.
- [Example 11:](./EX11_assing_new_curve_pump.m) Assign a new curve to a pump.
- [Example 12:](./EX12_add_multiple_controlpatterns_bin.m) Add multiple control patterns.
- [Example 13a:](./EX13a_add_cvpipe_junction.m) Add pipe and junction via bin function.
- [Example 13b:](./EX13b_add_cvpipe_bin.m) Add pipe via bin function.
- [Example 13c:](./EX13c_add_cvpipe.m) Add pipe via normal function.
- [Example 14:](./EX14_hydraulic_and_quality_analysis.m) Hydraulic and Quality analysis.
- [Example 15:](./EX15_write_msx_file.m) Write MSX file.
- [Example 16:](./EX16_create_multiple_scenarios.m) Creating scenarios.
- [Example 17a:](./EX17a_add_multiple_controls_pipestatus_bin.m) Add controls via bin functions.
- [Example 17b:](./EX17b_add_multiple_controls_pipestatus.m) Add controls via normal functions.
- [Example 18:](./EX18_change_status_pipes.m) Change status of pipe during simulation.
- [Example 19:](./EX19_rotate_network.m) Rotate network.
- [Example 20a:](./EX20a_external_controls.m) Change of external Controls.
- [Example 20b:](./EX20b_external_controls.m) Addition of external Controls.
- [Example 21:](./EX21_Pressure_driven_analysis_option.m) Pressure driven analysis.
- [Example 22:](./EX22_Overflow_option_for_tanks.m) Overflow of tanks.
- [Example 23:](./EX23_Change_connection_links.m) Change connection of the links.
- [Example 24:](./EX24_delete_all_patterns.m) Delete all patterns.
- [Example 25:](./EX25_set_node_name_ids.m) Set node name IDs.

&uparrow; [Back to top](#table-of-contents)


<a href="http://www.kios.ucy.ac.cy"><img src="http://www.kios.ucy.ac.cy/templates/favourite/images/kios_logo_hover.png"/><a>


EPANET-MATLAB-Toolkit - Examples
==================================

## Table of Contents

- [Examples](#examples)

## Examples
- [Toolkit Example 2:](./Toolkit_EX2_Hydrant_rating_curve.m) Hydrant rating curve
- [Toolkit Example 3:](./Toolkit_EX3_Minimum_chlorine_residual.m) Minimum chlorine residual.
- [Toolkit Example 4:](./Toolkit_EX4_Network_Building.m) Network building.
- [Example 0:](./EX0_CCWI2016_contamination_simulation.m) Arsenite contamination simulator based on EPANET andEPANET-MSX using the EPANET-MATLAB Toolkit.
- [Example 1:](./EX1_Plot_network_topology.m) Plot network topology.
- [Example 2:](./EX2_Hydraulic_analysis.m) Hydraulic analysis.
- [Example 3:](./EX3_Quality_analysis.m) Quality analysis.
- [Example 4:](./EX4_Plot_time_series.m) Plot time series.
- [Example 5:](./EX5_Plot_values_parameters.m) Plot values parameters.
- [Example 6:](./EX6_load_two_inp_files.m) Load two inp files.
- [Example 7:](./EX7_set_pump_curves.m) Set pump curves.
- [Example 8:](./EX8_tanks_to_reservoirs.m) Tanks to reservoirs.
- [Example 9:](./EX9_compare_simulations.m) Compare Simulations.
- [Example 10:](./EX10_close_pipes_during_sim.m) Close pipes during simulation.
- [Example 11:](./EX11_assing_new_curve_pump.m) Assign a new curve to a pump.
- [Example 12:](./EX12_add_multiple_controlpatterns_bin.m) Add multiple control patterns.
- [Example 13a:](./EX13a_add_cvpipe_junction.m) Add pipe and junction via bin function.
- [Example 13b:](./EX13b_add_cvpipe_bin.m) Add pipe via bin function.
- [Example 13c:](./EX13c_add_cvpipe.m) Add pipe via normal function.
- [Example 14:](./EX14_hydraulic_and_quality_analysis.m) Hydraulic and Quality analysis.
- [Example 15:](./EX15_write_msx_file.m) Write MSX file.
- [Example 16:](./EX16_create_multiple_scenarios.m) Creating scenarios.
- [Example 17a:](./EX17a_add_multiple_controls_pipestatus_bin.m) Add controls via bin functions.
- [Example 17b:](./EX17b_add_multiple_controls_pipestatus.m) Add controls via normal functions.
- [Example 18:](./EX18_change_status_pipes.m) Change status of pipe during simulation.
- [Example 19:](./EX19_rotate_network.m) Rotate network.
- [Example 20a:](./EX20a_external_controls.m) Change of external Controls.
- [Example 20b:](./EX20b_external_controls.m) Addition of external Controls.
- [Example 21:](./EX21_Pressure_driven_analysis_option.m) Pressure driven analysis.
- [Example 22:](./EX22_Overflow_option_for_tanks.m) Overflow of tanks.
- [Example 23:](./EX23_Change_connection_links.m) Change connection of the links.
- [Example 24:](./EX24_delete_all_patterns.m) Delete all patterns.
- [Example 25:](./EX25_set_node_name_ids.m) Set node name IDs.

&uparrow; [Back to top](#table-of-contents)


70 changes: 70 additions & 0 deletions examples/Toolkit_EX4_Network_Building.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
% 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.
%
% http://wateranalytics.org/EPANET/_example2.html

%Clear
clear; close('all'); clc;
start_toolkit;

% Create an empty INP file
testinp = 'TESTING.inp';
d = epanet(testinp, 'CREATE');

% Initialize epanet flow units
d.initializeEPANET(d.ToolkitConstants.EN_GPM, d.ToolkitConstants.EN_HW);

% an elevation of 700 ft and a demand of 0
index = d.addNodeJunction('J1');
d.setNodeJunctionData(index, 700, 0, '');
d.setNodeCoordinates(index, [10 20])

% Add the remaining two junctions with elevations of
% 710 ft and demands of 250 and 500 gpm, respectively
index = d.addNodeJunction('J2');
d.setNodeJunctionData(index, 710, 250, '');
d.setNodeCoordinates(index, [20 30])

index = d.addNodeJunction('J3');
d.setNodeJunctionData(index, 710, 500, '');
d.setNodeCoordinates(index, [30 30])

% Add the reservoir at an elevation of 650 ft
index = d.addNodeReservoir('R1');
d.setNodeElevations(index, 650);
d.setNodeCoordinates(index, [10 25])

% 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
% index = d.addNodeTank('T1'); % bug check
% d.setNodeTankData(index, 850, 120, 100, 150, 50.5, 0, '');

% Add the pipes to the project, setting their length,
% diameter, and roughness values

index = d.addLinkPipe('P1', 'J1', 'J2');
d.setLinkPipeData(index, 10560, 12, 100, 0);
index = d.addLinkPipe('P2', 'J1', 'T1');
d.setLinkPipeData(index, 5280, 14, 100, 0);
index = d.addLinkPipe('P3', 'J1', 'J3');
d.setLinkPipeData(index, 5280, 14, 100, 0);
index = d.addLinkPipe('P4', 'J2', 'J3');
d.setLinkPipeData(index, 5280, 14, 100, 0);

% Add a pump to the project
index = d.addLinkPump('PUMP', 'R1', 'J1');

% Create a single point head curve (index = 1) and
% assign it to the pump
d.addCurve('C1');
d.setCurveValue(1, 1, [1500, 250]);
d.setLinkPumpHCurve(index, 1);

% Save the project for future use
d.saveInputFile(testinp);
d = epanet(testinp);
d.plot;

d.unload;

0 comments on commit 00bbbb6

Please sign in to comment.