-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdhwsave.rexx
290 lines (290 loc) · 10.4 KB
/
dhwsave.rexx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/* REXX */
/* D O M E S T I C H O T W A T E R S A V I N G S C A L C */
clrscn
say 'Domestic Hot Water Savings Calculator'
say 'Written by Clifford A. Chipman, EMIT on'
say 'February 3, 2021'
say 'in z/OS REXX'
call setConstants
call CWTempDataEntry
call initFuelDataEntry
call initHWTempDataEntry
call initFlowRateDataEntry
call initShwrTimeDataEntry
call initCombEffDataEntry
call newFuelDataEntry
call newHWTempDataEntry
call newFlowRateDataEntry
call newShwrTimeDataEntry
call newCombEffDataEntry
/* */
/* Calculate initial energy consumption & display report for user */
/* */
say 'Cold Water Inlet Temperature: 'CWTemp' degF'
say ' '
say 'Initial Hot Water Temperature: 'initHWTemp' degF'
say 'Initial Flow Rate: 'initFlowRate' GPM'
say 'Initial Shower Time: 'initShwrTime' minutes'
say 'Initial Combustion Efficiency: 'initCombEff'%'
initCombEff = initCombEff / 100
initUsage = initFlowRate * initShwrTime
say 'Initial Water Consumption: 'initUsage' gallons'
initEnergy = 8.33 * initUsage * (initHWTemp - CWTemp) / initCombEff
say 'Initial Energy Consumption: 'initEnergy' BTUs'
/* */
/* Convert BTUs to fuel unit, calculate fuel consumption, & fuel cost */
/* */
initFuelConsumed = initEnergy / initConvUnit
initFuelCost = initFuelConsumed * initFuelPrice
/* */
say 'Initial Fuel Consumption: 'initFuelConsumed' 'initFuelUnit
say 'Initial Fuel Price: $'initFuelPrice' per 'initFuelUnit
say 'Initial Fuel Cost: $'initFuelCost
/* */
/* Calculate new energy consumption & display report for user */
/* */
say ' '
say 'New Hot Water Temperature: 'newHWTemp' degF'
say 'New Flow Rate: 'newFlowRate' GPM'
say 'New Shower Time: 'newShwrTime' minutes'
say 'New Combustion Efficiency: 'newCombEff'%'
newCombEff = newCombEff / 100
newUsage = newFlowRate * newShwrTime
say 'New Water Consumption: 'newUsage' gallons'
newEnergy = 8.33 * newUsage * (newHWTemp - CWTemp) / newCombEff
say 'New Energy Consumption: 'newEnergy' BTUs'
/* */
/* Convert BTUs to fuel unit, calculate fuel consumption, & fuel cost */
/* */
newFuelConsumed = newEnergy / newConvUnit
newFuelCost = newFuelConsumed * newFuelPrice
/* */
say 'New Fuel Consumption: 'newFuelConsumed' 'newFuelUnit
say 'New Fuel Price: $'newFuelPrice' per 'newFuelUnit
say 'New Fuel Cost: $'NewFuelCost
/* */
/* Calculate savings & display report for user */
/* */
say ' '
waterSaved = initUsage - newUsage
say 'Water Saved: 'waterSaved' gallons'
energySaved = initEnergy - newEnergy
say 'Energy Saved: 'energySaved' BTUs'
/* */
/* if initFuel = newFuel calculate & display fuel savings */
if initFuel = newFuel then
do
fuelSaved = initFuelConsumed - newFuelConsumed
say 'Fuel Saved: 'fuelSaved' 'initFuelUnit
end
else nop
/* */
costSaved = initFuelCost - newFuelCost
say 'Cost Saved: $'costSaved
/* */
exit 0
/* */
/* * * * * * * * * * * * E N D P R O G R A M * * * * * * * * * * */
/* */
/* Subroutines */
fuelMenu:
say ' '
say '1...Electric @$'priceElectric' per kWh'
say '2...Natural Gas @$'priceNatGas' per ccf'
say '3...Propane @$'pricePropane' per gallon'
return
/* */
initFuelElectric:
initFuelUnit = 'kWh'
initConvUnit = btu2kwh
initFuelPrice = priceElectric
return
/* */
initFuelNatGas:
initFuelUnit = 'ccf'
initConvUnit = btu2ccf
initFuelPrice = priceNatGas
return
/* */
initFuelPropane:
initFuelUnit = 'gallons'
initConvUnit = btu2gal
initFuelPrice = pricePropane
return
/* */
newFuelElectric:
newFuelUnit = 'kWh'
newConvUnit = btu2kwh
newFuelPrice = priceElectric
return
/* */
newFuelNatGas:
newFuelUnit = 'ccf'
newConvUnit = btu2ccf
newFuelPrice = priceNatGas
return
/* */
newFuelPropane:
newFuelUnit = 'gallons'
newConvUnit = btu2gal
newFuelPrice = pricePropane
return
setConstants:
/* */
/* Constants */
/* */
/* Water Temperature Limits in degF */
lowerCWTemp = 33
upperCWTemp = 79
lowerHWTemp = 80
upperHWTemp = 211
/* */
/* Showerhead Flow Rate Limits in GPM */
minFlowRate = 1
maxFlowRate = 2.5
/* */
/* Shower Time Limits in minutes */
minShwrTime = 1
maxShwrTime = 60
/* */
/* Combustion Efficiency Limits in % */
minEff = 1
maxEff = 100
/* */
/* Conversion Factors */
btu2kwh = 3412
btu2ccf = 103700
btu2gallons = 91452
/* */
/* Fuel Prices */
priceElectric = 0.13
priceNatGas = 1.18
pricePropane = 2.66
return
/* */
/* Data Entry */
/* */
CWTempDataEntry:
do until CWTemp >= lowerCWTemp & CWTemp <= upperCWTemp
say ' '
say 'Enter cold water temperature in degF'
say '('lowerCWTemp'-'upperCWTemp')'
parse pull CWTemp
end
return
/* */
initFuelDataEntry:
clrscn
do until initFuel = 1 | initFuel = 2 | initFuel = 3
call fuelMenu
say 'Enter initial fuel'
parse pull initFuel
select
when initFuel = 1 then call initFuelElectric
when initFuel = 2 then call initFuelNatGas
when initFuel = 3 then call initFuelPropane
otherwise nop
end
end
/* say initfuelUnit */
/* say initconvUnit */
/* say initfuelPrice */
return
/* */
initHWTempDataEntry:
clrscn
do until initHWTemp >= lowerHWTemp & initHWTemp <= upperHWTemp
say ' '
say 'Enter initial hot water temperature in degF'
say '('lowerHWTemp'-'upperHWTemp')'
parse pull initHWTemp
end
return
/* */
initFlowRateDataEntry:
clrscn
do until initFlowRate >= minFlowRate & initFlowRate <= maxFlowRate
say ' '
say 'Enter initial flow rate in GPM'
say '('minFlowRate'-'maxFlowRate')'
parse pull initFlowRate
end
return
/* */
initShwrTimeDataEntry:
clrscn
do until initShwrTime >= minShwrTime & initShwrTime <= maxShwrTime
say ' '
say 'Enter initial shower time in minutes'
say '('minShwrTime'-'maxShwrTime')'
parse pull initShwrTime
end
return
/* */
initCombEffDataEntry:
clrscn
do until initCombEff >= minEff & initCombEff <= maxEff
say ' '
say 'Enter initial combustion efficiency in %'
say '('minEff'-'maxEff')'
parse pull initCombEff
end
return
/* */
newFuelDataEntry:
clrscn
do until newFuel = 1 | newFuel = 2 | newFuel = 3
call fuelMenu
say 'Enter new fuel'
parse pull newFuel
select
when newFuel = 1 then call newFuelElectric
when newFuel = 2 then call newFuelNatGas
when newFuel = 3 then call newFuelPropane
otherwise nop
end
end
/* say newfuelUnit */
/* say newconvUnit */
/* say newfuelPrice */
return
/* */
newHWTempDataEntry:
clrscn
do until newHWTemp >= lowerHWTemp & newHWTemp <= upperHWTemp
say ' '
say 'Enter new hot water temperature in degF'
say '('lowerHWTemp'-'upperHWTemp')'
parse pull newHWTemp
end
return
/* */
newFlowRateDataEntry:
clrscn
do until newFlowRate >= minFlowRate & newFlowRate <= maxFlowRate
say ' '
say 'Enter new flow rate in GPM'
say '('minFlowRate'-'maxFlowRate')'
parse pull newFlowRate
end
return
/* */
newShwrTimeDataEntry:
clrscn
do until newShwrTime >= minShwrTime & newShwrTime <= maxShwrTime
say ' '
say 'Enter new shower time in minutes'
say '('minShwrTime'-'maxShwrTime')'
parse pull newShwrTime
end
return
/* */
newCombEffDataEntry:
clrscn
do until newCombEff >= minEff & newCombEff <= maxEff
say ' '
say 'Enter new combustion efficiency in %'
say '('minEff'-'maxEff')'
parse pull newCombEff
end
return