HydroTrek_Energy_Optimization_Functionality_RMX
HydroTrek OPX II Design Specifications
1.Goal
Develop HydroTrek's energy optimization and operational efficiency functionality. Use HydroTrek AquaQConsole app to run RMX and gather its output for multiple operational scenarios, and then use OPX to derive results for different objective functions. These results will be then used to genetically evolve (keeping in mind the objectives) pump operation strategies.
The way RMX currently runs in RMR mode, the STATUS value of pumps do not affect total SCADA System Input flow value and thus SCADA System Demand value. That is, if FLOW for a pump is more than 0 but Status of the same pump is CLOSED, RMX will derive SCADA System Demand as if the pump status is OPEN. However, RMX will still try to update this status (CLOSED status) back in to the epanet, that is try to CLOSE the corresponding pump in model. Therefore, we get benefits of running the model with pattern derived from SCADA values but still make runs for different pump operating scenarios. Therefore, theoretically we are not running RMX in RMR mode but in "Pump Optimization Mode".
2.Objective Functions
The following documents the original work that went into creating energy optimization runs and calcluating objectives:
- Manual Energy Optimization Experiment and Objective Function Formulation: https://www.dropbox.com/s/l3v4dg9d9foukwz/Energy%20Optimization%20Experiment%20Results%20v2.docx
- Revised description, calculation, and categorization of objective functions: https://www.dropbox.com/s/h8en4kd83gtcfzz/Energy%20Optimization%20-%20Obj%20Func%20Revised.docx
- Testing doc with OPX - II objective function results from Net3 Master Scenario: https://www.dropbox.com/s/hgpt4epr0fbjsgx/Results%20for%20OPX%20II%20one%20Run%20Only.docx
Objective functions are calculated in following manner. Each of these objective functions will be minimized using optimization algorithm.
Model Value for each type is from the tblRMRDetailedOutput table. However, some aggregate values are already available in tblRMRSummaryOutput table. HYDRAULIC_TIME_STEP value will be a constant - 5 (in minutes) for initial prototype. Later, this value will be configurable and can be obtained from a table which has the information on last run. The rate (cents/kwh) value will be obtained from Rate table. The resultant value of each objective function will be stored in the Run table. The corresponding pump operation scenario for this run will be stored in PumpOperation table. Each of these objectives with their ID and description can be stored in a separate master table called Objective table. Each of these tables are described in detail in 3.Database Tables section
NOTE: the Hydraulic_Time_Step is in seconds
The Objectives are grouped by Category.
Hydraulic
2.1 Produced (MG)
Total Model System Input Pumps Produced expressed in millions of gallons
Sum[All summary output ModelProduced]*(HYDRAULIC_TIME_STEP / 60 seconds per minute)/(10^6 conversion rate for gallons to million gallons)
- Net3 Master Value: 16.2 MG
- LWC Master Value: 100.1677
- Mt. Washington Master Value: 2.002762
- Model produced from the Summary Output Table
2.2 Maximum Tank Level Drop (Ft)
The maximum Tank level drop over all of the tanks in the network. Tank drop is calculated by the tank level of the first timestep from the tank level at the last timestep.
Max(over all tanks)[[Model Value of data type "Level" of Tank at first timestep]
- [Model value of data type "Level" of Tank at last timestep]]
Net3 Master Value: -0.06 feet
LWC Master Value: 53.873
Mt. Washington Master Value: 5.193
For each tank find the difference TD=[Final Tank Level - Initial Tank Level] then find the Max across all of the TD's.
Positive/negative difference consideration?
ON the Net3 Database the DetailedSummary.DataType should be LEVEL as it is in XRef table for corresponding Model ID.
Table tblRMRDetailedOutput last column is renamed to ModelDataTypeID. This means that Model ID's data type from XRef table will be used when loggin detailed output
2.3 Model Stability (number)
This is a number that denotes how stable the network model is (EPANET warnings) with the current OPX simulation.
- 1 System hydraulically unbalanced - convergence to a hydraulic solution was not achieved in the allowed number of trials
- 2 System may be hydraulically unstable - hydraulic convergence was only achieved after the status of all links was held fixed
- 3 System disconnected - one or more nodes with positive demands were disconnected from all supply sources
- 4 Pumps cannot deliver enough flow or head - one or more pumps were forced to either shut down (due to insufficient head) or operate beyond the maximum rated flow
- 5 Valves cannot deliver enough flow - one or more flow control valves could not deliver the required flow even when fully open
- 6 System has negative pressures - negative pressures occurred at one or more junctions with positive demand
Epanet Warning Code of 0,4 & 5 is acceptable and therefore objective value for that result will be 0. Rest of them will be marked by 1. If any one one run in the entire scenario is 1, then corresponding objective (epanet warning code) for that scenario is marked 1.
- Net3 Master value: 0
- LWC Master Value: 0
- Mt. Washington Master Value: 0
2.4 Worst Tank Turnover (ratio)
The worst tank turnover rate of all tanks (turnover rate of 0.25 equivalent to complete recycle in 4 days).
Min(over all tanks)[ [∑(over time)[model value of data type "DEMAND" which is less than 0] * -1 * (HYDRAULIC_TIME_STEP/60 seconds per minute)] + [∑(over time)[model value of data type "DEMAND" which is more than 0] * (HYDRAULIC_TIME_STEP/60 seconds per minute)]]
- Net3 Master Value: - 0.43
- LWC Master Value: 0.147251
- Mt. Washington Master Value: 0.686245
- Idea is to Maximize Tank Turnover Rate.
2.5 Pump Duty Cycle (number)
How many times any pumps are turned on in a given run (Note this does not include the initial status turning on).
∑(over all pumps)[Count(over time)[previous value (of data type "STATUS") of a Pump is OFF && current value (of data type "STATUS") of a Pump is ON]]
We also need to capture initial on/off status and count that as a pump turning on
We should derive the model value of STATUS from FLOW value of Pump. FLOW > 1GPM => STATUS OPEN
Idea is to reduce the duty cycle
Net3 Master Value: 2 (not counting initial status ON)
LWC Master Value: 119
Mt. Washington Master Value: 2
2.6 Tank Demand (MG)
Total Network Model Tank Demand expressed in millions of gallons
Sum[All summary output ModelTankDemand]*(HYDRAULIC_TIME_STEP / 60 seconds per minute)/(10^6 conversion rate for gallons to million gallons)
- Net3 Master value: 0.45
- LWC Master Value: -14.1591
- Mt. Washington Master Value: 0.504585
- Model tank demand from the Summary Output Table
- Positive/negative difference consideration?
2.7 Pumping Cost per MG ($/MG)
How much it cost to pump a million gallons of water (Total pumping Cost / Produced) .
- Net3 Master value: 15.97
- LWC Master Value: 110.9603
- Mt. Washington Master Value: 124.5893
2.8 Final Storage (Ft)
What is the final volume of storage of water available in the tanks at the end of the simulation.
- Net3 Master value: 5.20
- LWC Master Value: 34.04283
- Mt. Washington Master Value: 1.461731
Energy
2.9 Total Energy (kW-hr)
Calculated as total Energy that is used to operate all pumps during the simulation.
[∑(over time and all pumps)[model value of data type "ENERGY" for time and pump]]/12 five minute timesteps in one hour]
- Net3 Master Value: 3,002 kW-hr
- LWC Master Value: 120190
- Mt. Washington Master Value: 2813.38
2.10 Average Power (kW)
Calculated as average power (Energy / Time) is used to operate all pumps during the simulation.
[∑(over time and all pumps)[model value (only if greater than 0) of data type "ENERGY" for a time and pump]/count(over time and all pumps)[model values (only if greater than 0) of data type "ENERGY" for a time and pump]
- Net3 Master Value: 125 kw
- LWC Master Value: 5025.376
- Mt. Washington Master Value: 117.6326
2.11 Maximum Instantaneous Power (kW)
What is the highest use of power at any given timestep.
Max(over all times)[∑(all pumps)[model value of data type "ENERGY" for time]]
- Net3 Master Value: 372.3 kW
- LWC Master Value: 28218.45
- Mt. Washington Master Value: 174.297
- Maximum instantaneous power usage for system
- The maximum total power (sum of 'energy' from each pump) occurring at any timestep
2.12 Pumping Cost ($)
Total cost to run the entire model over the simulation period.
∑(over all pumps)[∑(over time)[model value of data type "ENERGY" for time and a pump] * (HYDRAULIC_TIME_STEP/60 seconds per min/60 min per hour) * (Rate at time / 100 cents per $)]
- Net3 Master Value: $ 259 ($ 246 via excel rate structure)
- LWC Master Value: 11114.64
- Mt. Washington Master Value: 249.5228
2.13 Total Energy per MG (kW-hr/MG)
Total amount of Energy used in pumping 1 million gallons of water (Total energy / produced).
- Net3 Master Value: 185
- LWC Master Value: 1199.89
- Mt. Washington Master Value:1404.75
Quality
2.14 Minimum Tank Chlorine (MG/L)
Shows the lowest concentration of chlorine over all of the tanks in the network at any point during the simulation.
Min(over time and all tanks)[model value of data type "CHLORINE" for time and a tank]
- Net3 Master Value: 0.50 mg/l
- LWC Master Value: 2.12
- Mt. Washington Master Value: 0.562
2.15 Maximum Tank Age Increase (Hrs)
Shows the largest increase in tank age between the start and any given time during the simulation
Max(over all tanks)[Max(over time)[model value of data type "AGE" for time and a tank] - [model value of data type "AGE" for time 0 for any tank]]
- Net3 Master Value: 11.16 hours
- LWC Master Value: NOT COMPUTED YET
- Mt. Washington Master Value: 17.5611
2.16 Maximum Tank Age (Hrs)
The age of water that has been in the tanks the longest. (This is used by looking at the tank age.)
Max(over all tanks)[Max(over time)[model value of data type "AGE" for time and a tank]]
- Net3 Master Value: 83.16 hours
- LWC Master Value: NOT COMPUTED YET
- Mt. Washington Master Value: 89.5611
Fitness
2.17 Fitness (number)
The fitness value is based on the compare column in the objectives table. After the first run the values of the last run are compared to the current run to see if the current run is a valuable run. (Currently if 1 or more objective is better than the last run we set this as a 1)
- Net3 Master Value: 1
- LWC Master Value: 1
- Mt. Washington Master Value: 1
3.Database Tables
3.1.ScenarioObjective
Columns
- RunDateTimeOffset - VARCHAR(255),PK
- ObjectiveID - VARCHAR(255),PK
- ObjectiveValue - DOUBLE, NOT NULL
3.2.Objective
Columns
- ObjectiveID - VARCHAR(255),PK
- Description - VARCHAR(255)
- Category - VARCHAR(255)
- Compare - BOOLEAN
This table can be used to describe all the Objectives. Not required right away. This collection will be derived from enum collection in code.
3.3.PumpOperation
Columns
- RunDateTimeOffset - VARCHAR(255), PK
- ModelUnixTimestamp - Integer, PK
- PumpStatus_SCADATagID - VARCHAR(255), PK
- StatusValue - Double, NOT NULL
3.4.Rate
Columns
- StartTime - DateTime, PK, ASCENDING ORDER
- Value - DOUBLE, NOT NULL
4. Batch Run
OPX can run in a batch of iterations for OPX-I and OPX-II.
The run a batch, the following files are needed (for Net3):
- Net3-Composite Chlorine-Conductivity-Age – THM.msx
- Net3-RMX_April2014_Bypass.inp
- opx.bat
- OPX_Net3 - MSX_GeoA.xml
These files are located on dropbox:
https://www.dropbox.com/home/Project/HydroTrek%20Input%20Files/Net3/OPX
The SCADA database that is required is the same as RMX:
- SCADA_Net3
Net3 file can be found here:
Both OPX-I and OPX-II need to be installed prior to running a batch.
The .bat file has the format below. It contains parameters for the number of iterations (i), program exe file paths, and input file paths (xml and db3).
echo off SET /a i=0
:loop IF %i%==5 GOTO END echo This is iteration %i%. SET /a i=%i%+1 "C:\Program Files\GQC\HydroTrek-OPX-I\HydroTrek-OPX-I.exe" "C:\Users\gqc\Downloads\OPX\OPX_Net3 - MSX_GeoA.xml" echo second phase "C:\Program Files (x86)\GQC\HydroTrek-OPX-II\HydroTrek-OPX-II.exe" "C:\Users\gqc\Downloads\OPX\SCADA_Net3.db3" 7200 -9 109 15 GOTO LOOP
:end echo DONE!
OPX-II has some optional parameters that influence the random pump status vector creation during new iterations. These are located after the db3 file path and are detailed below:
- Pump Minimum Operation Time Stamp (7200 seconds)
- Minimum Random Number (-9)
- Maximum Random Number (109)
- Delta Random (15)
Other than the first parameter, the rest deal with how the next iteration of pump status vectors are generated for the following scenario. Using these parameters can adjust the amount that pumps are operated on/off. Parameters are described in more detail in the figure below. If excluded, default values will be used.
BEFORE RUNNING THE BAT FILE PLEASE DOUBLE CHECK ALL 4 Locations and Names in the Bat File against the files you need it to read. Additionally open The XML file and Check the name of the INP file. This is especially important on the larger networks such as LWC network where it will take a long time to run OPXI and OXPII .
5. Objectives
This is a list of all of the objectives that we are currently calculating.
- Produced
- Max_Tank_Level_Change
- Model_Stability
- Min_Tank_Chlorine
- Max_Tank_Age_Increase
- Fitness
- Max_Tank_Age
- Worst_Tank_Turnover
- Pump_Duty_Cycle
- Total_Energy
- Average_Power
- Tank_Demand
- Max_Inst_Power
- Pumping_Cost
- Total_Energy_per_MG
- Pumping_Cost_per_MG
- Final_Storage
6. Old Objectives
These are old Objectives that we are not currently using:
6.1.Calculate absolute value of Net Tank Demand (MG)
ABS(∑(over all tanks)[(HYDRAULIC_TIME_STEP / 60 min per second) * ∑(over time)[model value of data type "DEMAND" for time and a tank] /10^6 conversion rate from gallons to million gallons]
Net3 Master Value: 0.45 MG
Idea is that Total Net Tank Demand should be Zero that is maintain the total amount of storage in the tanks
6.2.Calculate Maximum Tank Chlorine Percentage Drop (%)
Max(over all tanks)[[[Model Value of data type "CHLORINE" of Tank at first time-step]
- Min(over time)[Model value of data type "CHLORINE" at time and a tank]] / [Model Value of data type "CHLORINE" of Tank at first time-step]]
- Net3 Master Value: .17 (17%)
6.3.Calculate each Pump's operation cost ($)
∑(over time)[model value of data type "ENERGY" for time and pump P * [HYDRAULIC_TIME_STEP / 60 seconds/Min] * (Rate at time / 100 cents/dollars)]
This will not be calculated now. It will be calculated when more detailed operational information is desired.
6.4.Calculate Maximum Absolute Net Tank Demand (MG)
Max(over all tanks)[Abs[(HYDRAULIC_TIME_STEP / 60 seconds per minute) * [∑(over time)[model value of data type "DEMAND" for time and a tank]]/ (10^6 conversion rate from gallons to million gallons)]]
- Net3 Master Value: 0.33 MG