-
Notifications
You must be signed in to change notification settings - Fork 1
/
Uncertainty_TEA.py
574 lines (562 loc) · 53.9 KB
/
Uncertainty_TEA.py
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
import numpy as np
import math as math
import lhs_python as lhs
from scipy import stats
import pandas as pd
import xlsxwriter
#%% Conversions
m3_L= 1000
m_ft = 3.28084
M_mm = 1000
M_in = 39.37
Years_Days = 365
Days_Hours = 24
Hours_Min = 60
Min_Sec = 60
Watts_HP = 745.7
kW_W = 1000
m3_Gal = 264.172
Gal_L = 3.785
Hours_Sec = 3600
m_bar = 0.09804
L_Oz = 33.814
Watts_HP = 745.7
kg_g = 1000
#%% Assumed Parameter Distributions
nsamples = 10000
Daily_Flushes = lhs.lhs_uniform(1,7,nsamples) #flushes/user/day
Flush_Volume = lhs.lhs_uniform(6,10,nsamples) #L blackwater/flush
Membrane_Flux = lhs.lhs_uniform(114,171,nsamples) #L/m2*hr
Velocity_Crossflow = lhs.lhs_uniform(3.5,5.6,nsamples) #m/s
Pressure_Membrane = lhs.lhs_uniform(0,3.5,nsamples) #bar
Fill_Fraction_GAC_Column = lhs.lhs_uniform(.75,.85,nsamples) #%
#UF_GAC_N_P_Removal = lhs.lhs_uniform(0.3,0.5,nsamples) #%
#Clinoptilolite_Cost = lhs.lhs_uniform(1.08*0.9,1.08*1.1,nsamples) #$/kg
#Polonite_Cost = lhs.lhs_uniform(1.37*0.9,1.37*1.1, nsamples) #$/kg
#Clinoptilolite_Capacity = lhs.lhs_uniform(10*0.9,10*1.1,nsamples) #mg NH3/g
#Polonite_Capacity = lhs.lhs_uniform(10*0.9,10*1.1,nsamples) #mg PO4/g
#N_Content_Protein = lhs.lhs_uniform(.13,.19,nsamples) #% nitrogen in protein
#N_P_Excretion = lhs.lhs_uniform(.99,1,nsamples) #% intake nitrogen excreted in urine and feces
#N_Urine = lhs.lhs_triangle(.86*.9,.86,.86*1.1,nsamples) #% excreted nitrogen in urine
#P_Content_A_Protein = lhs.lhs_triangle(.004,0.022,0.048,nsamples) #%phosphorus in animal protein
#P_Content_V_Protein = lhs.lhs_triangle(.002,0.011,0.032,nsamples) #% phosphorus in vegetal protein
#P_Urine = lhs.lhs_triangle(.67*.9,.67,.67*1.1,nsamples) #% excreted phosphorus in urine
#Seperation_Efficiency = lhs.lhs_uniform(0.8,0.9,nsamples)
Density_GAC = lhs.lhs_uniform(400,500,nsamples) #kg/m3
#Lifetime_GAC = lhs.lhs_uniform(48,81,nsamples) #flushes/kg GAC
Lifetime_GAC = lhs.lhs_triangle(4500,9000,13500,nsamples) #L treated
Power_Required_Treatment_EC = lhs.lhs_uniform(5.6,6.4,nsamples) #Wh/L
Current_EC = lhs.lhs_triangle(4,4,8,nsamples) # A
Power_Stirrer = lhs.lhs_uniform(18,30,nsamples) #W
Flowrate_Discharge = lhs.lhs_uniform(8,16,nsamples) #L/min
Pump_UF_Lifetime = lhs.lhs_triangle(10*.75,10,10*1.25,nsamples) #years
Membrane_UF_Lifetime = lhs.lhs_triangle(3*.9,3,3*1.1,nsamples) #years
Switch_Lifetime = lhs.lhs_triangle(10*.75,10,10*1.25,nsamples) #years
Valve_UF_Lifetime = lhs.lhs_triangle(5*.5,5,5*1.5,nsamples) #years
Electrode_EC_Lifetime = lhs.lhs_triangle(2*.9,2,2*1.1,nsamples) #years
Stirrer_Lifetime = lhs.lhs_triangle(5*.5,5,5*1.5,nsamples) #years
U_Pump_Misc_Lifetime = lhs.lhs_triangle(10*.9,10,10*1.1,nsamples) #years
Discount_Rate = lhs.lhs_uniform(0.03,0.06,nsamples) #%
U_Pump_UF = lhs.lhs_uniform(150,200,nsamples) #$
U_Membrane_UF = lhs.lhs_triangle(212*.9,212,212*1.1,nsamples) #$
U_Valve_UF = lhs.lhs_triangle(100.5*.9,100.5,100.5*1.1,nsamples) #$
U_Switch = lhs.lhs_triangle(110*.9,110,110*1.1,nsamples) #$
U_Tank_UF = lhs.lhs_triangle(549.76*.9,549.76,549.76*1.1,nsamples) #$
U_Column_GAC = lhs.lhs_triangle(16.19*.75,16.19,16.19*1.25,nsamples) #$/ft
U_Stirrer_EC = lhs.lhs_triangle(151.02*.9,151.02,151.02*1.1,nsamples)#$
U_Electrode_EC = lhs.lhs_triangle(99.45*.9,99.45,99.45*1.1,nsamples) #$
U_Pump_Misc = lhs.lhs_triangle(175*.9,175,175*1.1,nsamples) #$
US_Initial_Unit_Cost_UF = lhs.lhs_triangle(875.5*.9,875.5,875.5*1.1,nsamples)
InCountry_Initial_Unit_Cost_UF = lhs.lhs_triangle(601.31*.9,601.31,601.31*1.1,nsamples)
US_Initial_Unit_Cost_GAC = lhs.lhs_triangle(88.20*.9,88.20,88.2*1.1,nsamples)
InCountry_Initial_Unit_Cost_GAC = lhs.lhs_triangle(211.5*.9,211.5,211.5*1.1,nsamples)
US_Initial_Unit_Cost_EC = lhs.lhs_triangle(470.47*.9,470.47,470.47*1.1,nsamples)
InCountry_Initial_Unit_Cost_EC = lhs.lhs_triangle(247.43*.9,247.43,247.43*1.1,nsamples)
US_Initial_Unit_Cost_Controls = lhs.lhs_triangle(575.34*.9,575.34,575.34*1.1,nsamples)
InCountry_Initial_Unit_Cost_Controls = lhs.lhs_triangle(985.57*.9,985.57,985.57*1.1,nsamples)
US_Initial_Unit_Cost_Misc = lhs.lhs_triangle(387.78*.9,387.78,387.78*1.1,nsamples)
InCountry_Initial_Unit_Cost_Misc = lhs.lhs_triangle(1828.41*.9,1828.41,1828.41*1.1,nsamples)
U_Media_GAC = lhs.lhs_uniform(0.29,1,nsamples) #$/kg
#Waste = lhs.lhs_triangle(0.001,0.125,0.25,nsamples)
Waste = lhs.lhs_triangle(0.01,0.03,0.07,nsamples) #India
#Total_Protein=lhs.lhs_uniform(51.66,133.54,nsamples)
Total_Protein=lhs.lhs_uniform(60.25*.9,60.25*1.1,nsamples) #India
#Total_Protein_A=lhs.lhs_uniform(7.69,37.06,nsamples)
Total_Protein_A=lhs.lhs_uniform(11.99*.9,11.99*1.1,nsamples) #India
#Total_Protein_V=lhs.lhs_uniform(29.42,76.9,nsamples)
Total_Protein_V=lhs.lhs_uniform(48.26*.9,48.26*1.1,nsamples) #India
#PLR = lhs.lhs_uniform(.206,1.63,nsamples)
PLR = lhs.lhs_uniform(.26*.9,.26*1.1,nsamples) #India
#U_Electricity = lhs.lhs_uniform(0.02,0.4,nsamples) #$/kWh
#U_Electricity = lhs.lhs_triangle(0.04,0.06,0.1,nsamples) #$/kWh
U_Electricity = lhs.lhs_uniform(0.08*.9,0.08*1.1,nsamples) #India
Monthly_Construction_Wage=lhs.lhs_triangle(27.01,3314,6655.2,nsamples) #$/month
Monthly_Maintenance_Wage=lhs.lhs_triangle(70.64,3738.63,7547.9,nsamples) #$/month
#Income_Tax=lhs.lhs_uniform(0,0.35,nsamples)
Income_Tax=lhs.lhs_uniform(0.25*.9,0.25*1.1,nsamples) #India
Monthly_Work_Days = lhs.lhs_uniform(20,25,nsamples) #days/month
Construction_Time=lhs.lhs_uniform(2,4,nsamples) #days/toilet assembly
Maintenance_Frequency = lhs.lhs_uniform(1,2,nsamples) #times/year
Maintenance_Time = lhs.lhs_uniform(0.25,1,nsamples) #days/maintenance
#%% Decision Variables
U = 20 #users
D = 4 #in
V = 5 #gal/batch
L = 20 #years
#%% Fixed Parameters
Membrane_Surface_Area = 0.07 #m2
Nominal_Internal_Diameter = 12.77 #mm
Area_Concentrate = ((math.pi/4)*(Nominal_Internal_Diameter)**2)*(1/M_mm)**2 #m2
Volume_GAC = 7.7 #L
Voltage_Discharge_Pump = 12 #V
Current_Discharge_Pump = 6 #A
Voltage_EC = 12 #V
#%% Equations
Required_User_Fee_UF = np.full([10000,1], 0.0)
Required_User_Fee_Initial_UF = np.full([10000,1], 0.0)
Required_User_Fee_OM_UF = np.full([10000,1], 0.0)
Required_User_Fee_Energy_UF = np.full([10000,1], 0.0)
Required_User_Fee_GAC=np.full([10000,1], 0.0)
Required_User_Fee_Initial_GAC=np.full([10000,1], 0.0)
Required_User_Fee_OM_GAC=np.full([10000,1], 0.0)
Required_User_Fee_EC=np.full([10000,1], 0.0)
Required_User_Fee_Initial_EC=np.full([10000,1], 0.0)
Required_User_Fee_OM_EC=np.full([10000,1], 0.0)
Required_User_Fee_Energy_EC=np.full([10000,1], 0.0)
Required_User_Fee_Misc=np.full([10000,1], 0.0)
Required_User_Fee_Initial_Misc=np.full([10000,1], 0.0)
Required_User_Fee_OM_Misc=np.full([10000,1], 0.0)
Required_User_Fee_Energy_Misc=np.full([10000,1], 0.0)
Required_User_Fee_Controls=np.full([10000,1], 0.0)
Required_User_Fee_Initial_Controls=np.full([10000,1], 0.0)
Required_User_Fee_OM_Controls=np.full([10000,1], 0.0)
Required_User_Fee_Energy_Controls=np.full([10000,1], 0.0)
Required_User_Fee_Overall = np.full([10000,1], 0.0)
Required_User_Fee_Initial_Overall=np.full([10000,1], 0.0)
Required_User_Fee_OM_Overall = np.full([10000,1], 0.0)
Required_User_Fee_Energy_Overall=np.full([10000,1], 0.0)
Percent_UF_Total=np.full([10000,1], 0.0)
Percent_GAC_Total=np.full([10000,1], 0.0)
Percent_EC_Total=np.full([10000,1], 0.0)
Percent_Controls_Total=np.full([10000,1], 0.0)
Percent_Misc_Total=np.full([10000,1], 0.0)
Percent_Initial_Total=np.full([10000,1], 0.0)
Percent_OM_Total=np.full([10000,1], 0.0)
Perent_Energy_Total=np.full([10000,1], 0.0)
Percent_UF_Initial=np.full([10000,1], 0.0)
Percent_UF_OM=np.full([10000,1], 0.0)
Percent_UF_Energy=np.full([10000,1], 0.0)
Percent_GAC_Initial=np.full([10000,1], 0.0)
Percent_GAC_OM=np.full([10000,1], 0.0)
Percent_EC_Initial=np.full([10000,1], 0.0)
Percent_EC_OM=np.full([10000,1], 0.0)
Percent_EC_Energy=np.full([10000,1], 0.0)
Percent_Controls_Initial=np.full([10000,1], 0.0)
Percent_Controls_OM=np.full([10000,1], 0.0)
Percent_Controls_Energy=np.full([10000,1], 0.0)
Percent_Misc_Initial=np.full([10000,1], 0.0)
Percent_Misc_OM=np.full([10000,1], 0.0)
Percent_Misc_Energy=np.full([10000,1], 0.0)
Flowrate_Users=np.full([10000,1], 0.0)
Energy_Annual_UF=np.full([10000,1], 0.0)
Energy_Annual_EC=np.full([10000,1], 0.0)
for i in range(0, nsamples):
Flowrate_Users[i,0] = U*Daily_Flushes[i,0]*Flush_Volume[i,0]*(1/Days_Hours) #L/hr
Flowrate_Permeate = Flowrate_Users[i,0] #assume continuous pumping
Required_Membrane_Area = Flowrate_Permeate/Membrane_Flux[i,0] #m2
Membranes_Required = math.ceil(Required_Membrane_Area/Membrane_Surface_Area) #units
Flowrate_Permeate_Membrane = Flowrate_Permeate/Membranes_Required #L/hr/membrane
Flowrate_Concentrate_Membrane = Velocity_Crossflow[i,0]*Area_Concentrate*m3_L*Hours_Sec #L/hr
Flowrate_Feed = ((Flowrate_Permeate_Membrane+Flowrate_Concentrate_Membrane)*Membranes_Required)/m3_L #m3/hr
Head = ((-4.346*Flowrate_Feed)+40.8)*m_bar #bar
Pump_Power = 0.5 #horsepower
if Head <= Pressure_Membrane[i,0]:
Head = ((-5.588*Flowrate_Feed)+53.6)*m_bar #bar
Pump_Power = 0.75 #horsepower
if Head <= Pressure_Membrane[i,0]:
Head = ((-5.588*Flowrate_Feed)+58.8)*m_bar #bar
Pump_Power = 1.0 #horsepower
Time_Daily_Pump = (Daily_Flushes[i,0]*Flush_Volume[i,0]*U)/(Flowrate_Permeate) #hours/day
Energy_Annual_UF = Pump_Power*Time_Daily_Pump*Years_Days*Watts_HP*(1/kW_W) #kWh/year
#Energy_Annual_Cost_UF = Energy_Annual_UF*U_Electricity[i,0]
Area_GAC_Column = (math.pi/4)*((D)**2)
Volume_GAC_Column = Volume_GAC/Fill_Fraction_GAC_Column[i,0] #L
Length_GAC_Column = ((Volume_GAC_Column/Area_GAC_Column)*((M_in)**2)*m_ft)/m3_L #ft
Mass_GAC_Total = (Volume_GAC*(Density_GAC[i,0]))/m3_L #kg
Replacement_Period_GAC = (Lifetime_GAC[i,0]/Flowrate_Users[i,0])*(1/Days_Hours)*(1/Years_Days) #yr
Annual_GAC_Required = Mass_GAC_Total/Replacement_Period_GAC #kg/year
#Annual_GAC_Required = (U*Daily_Flushes[i,0]*Years_Days)/Lifetime_GAC[i,0] #kg/years
#N_Feces = 1-N_Urine[i,0]
#P_Feces = 1-P_Urine[i,0]
#N_Concentration = (Total_Protein[i,0]*N_Content_Protein[i,0]*(1-Waste[i,0])*N_P_Excretion[i,0])*(N_Urine[i,0]+((1-Seperation_Efficiency[i,0])*N_Feces)) #g/person/day
#P_Concentration = (((Total_Protein_A[i,0]*P_Content_A_Protein[i,0])+(Total_Protein_V[i,0]*P_Content_V_Protein[i,0]))*(1-Waste[i,0])*N_P_Excretion[i,0])*(P_Urine[i,0]+((1-Seperation_Efficiency[i,0])*P_Feces)) #g/person/day
#N_Removal_Cost = N_Concentration*(1-UF_GAC_N_P_Removal[i,0])*(Clinoptilolite_Cost[i,0]/Clinoptilolite_Capacity[i,0])*(Years_Days) #$/year
#P_Removal_Cost = P_Concentration*(1-UF_GAC_N_P_Removal[i,0])*(Polonite_Cost[i,0]/Polonite_Capacity[i,0])*(Years_Days) #$/year
Annual_GAC_Cost=Annual_GAC_Required*U_Media_GAC[i,0] #$/year
Batch_Daily_EC = (U*Daily_Flushes[i,0]*Flush_Volume[i,0])/(V*Gal_L) #Batches/Day
Time_Batch_EC = (Power_Required_Treatment_EC[i,0]*V*Gal_L)/(Voltage_EC*Current_EC[i,0]) #hours/batch
Time_Daily_EC = Time_Batch_EC*Batch_Daily_EC #hours/day
Energy_EC_Treatment = Current_EC[i,0]*Voltage_EC*Time_Daily_EC*(1/kW_W)*(Years_Days) #kWh/year
Energy_Annual_Stirrer = Power_Stirrer[i,0]*Time_Daily_EC*(1/kW_W)*(Years_Days) #kWh/year
Energy_Annual_EC = Energy_EC_Treatment+Energy_Annual_Stirrer #kWh/year
#Energy_Annual_Cost_EC = Energy_Annual_EC*U_Electricity[i,0]
Time_Batch_Discharge = (V*Gal_L)/Flowrate_Discharge[i,0] #min/batch
Time_Daily_Discharge = Time_Batch_Discharge*Batch_Daily_EC*(1/Hours_Min) #hours/day
Energy_Annual_Misc = Voltage_Discharge_Pump*Current_Discharge_Pump*Time_Daily_Discharge*(1/kW_W)*(Years_Days) #kWh/year
Energy_Annual_Cost_Misc = Energy_Annual_Misc*U_Electricity[i,0]
#if Pump_Power == 0.5:
#U_Base_UF = lhs.lhs_triangle(927.05*.9,927.05,927.05*1.1,nsamples)+(U_Membrane_UF[i,0]*(Membranes_Required-1)) #$
#if Pump_Power == 0.75:
#U_Base_UF = lhs.lhs_triangle(927.05*.9,927.05,927.05*1.1,nsamples)+(U_Membrane_UF[i,0]*(Membranes_Required-1)) #$
#if Pump_Power == 1:
#U_Base_UF = lhs.lhs_triangle(927.05*.9,927.05,927.05*1.1,nsamples)+(U_Membrane_UF[i,0]*(Membranes_Required-1)) #$
Initial_Unit_Cost_UF = US_Initial_Unit_Cost_UF[i,0]+(InCountry_Initial_Unit_Cost_UF[i,0]*PLR[i,0])
Initial_Unit_Cost_GAC = US_Initial_Unit_Cost_GAC[i,0]+((InCountry_Initial_Unit_Cost_GAC[i,0]+(Length_GAC_Column*U_Column_GAC[i,0]))*PLR[i,0])
Initial_Unit_Cost_EC = US_Initial_Unit_Cost_EC[i,0]+(InCountry_Initial_Unit_Cost_EC[i,0]*PLR[i,0])
Initial_Unit_Cost_Misc = US_Initial_Unit_Cost_Misc[i,0]+(InCountry_Initial_Unit_Cost_Misc[i,0]*PLR[i,0])
Initial_Unit_Cost_Controls = US_Initial_Unit_Cost_Controls[i,0]+(InCountry_Initial_Unit_Cost_Controls[i,0]*PLR[i,0])
Initial_Unit_Cost_Overall = Initial_Unit_Cost_UF + Initial_Unit_Cost_GAC + Initial_Unit_Cost_EC + Initial_Unit_Cost_Misc + Initial_Unit_Cost_Controls
Daily_Construction_Wage=Monthly_Construction_Wage[i,0]/Monthly_Work_Days[i,0] #$/day
Labor_Construction_Cost_Overall = Daily_Construction_Wage*Construction_Time[i,0] #$
Labor_Construction_Cost_UF = Labor_Construction_Cost_Overall * (Initial_Unit_Cost_UF/Initial_Unit_Cost_Overall)
Labor_Construction_Cost_GAC = Labor_Construction_Cost_Overall * (Initial_Unit_Cost_GAC/Initial_Unit_Cost_Overall) #$
Labor_Construction_Cost_EC = Labor_Construction_Cost_Overall * (Initial_Unit_Cost_EC/Initial_Unit_Cost_Overall) #$
Labor_Construction_Cost_Misc = Labor_Construction_Cost_Overall * (Initial_Unit_Cost_Misc/Initial_Unit_Cost_Overall) #$
Labor_Construction_Cost_Controls = Labor_Construction_Cost_Overall * (Initial_Unit_Cost_Controls/Initial_Unit_Cost_Overall) #$
U_Pump_UF_Replacement = U_Pump_UF[i,0]*((L/Pump_UF_Lifetime[i,0])-1)
if (U_Pump_UF_Replacement+U_Pump_UF[i,0]) <= U_Pump_UF[i,0]:
U_Pump_UF_Replacement = 0
U_Membrane_UF_Replacement = U_Membrane_UF[i,0]*Membranes_Required*((L/Membrane_UF_Lifetime[i,0])-1)
if (U_Membrane_UF_Replacement+U_Membrane_UF[i,0]*Membranes_Required) <= U_Membrane_UF[i,0]:
U_Membrane_UF_Replacement = 0
U_Switch_Replacement = U_Switch[i,0]*3*((L/Switch_Lifetime[i,0])-1)
if (U_Switch_Replacement+(U_Switch[i,0]*3)) <= U_Switch[i,0]*3:
U_Switch_Replacement = 0
U_Valve_UF_Replacement = U_Valve_UF[i,0]*((L/Valve_UF_Lifetime[i,0])-1)
if (U_Valve_UF_Replacement+U_Valve_UF[i,0]) <= U_Valve_UF[i,0]:
U_Valve_UF_Replacement = 0
Replacement_Cost_UF = (U_Pump_UF_Replacement+(U_Membrane_UF_Replacement)+U_Switch_Replacement+U_Valve_UF_Replacement)/L #$/year
Pump_UF_Percent_Replacement = ((U_Pump_UF_Replacement)/L)/Replacement_Cost_UF
Membrane_UF_Percent_Replacement = ((U_Membrane_UF_Replacement)/L)/Replacement_Cost_UF
U_Switch_Percent_Replacement = ((U_Switch_Replacement)/L)/Replacement_Cost_UF
U_Valve_UF_Percent_Replacement = ((U_Valve_UF_Replacement)/L)/Replacement_Cost_UF
#Media_Cost = Annual_GAC_Required*U_Media_GAC[i,0]+N_Removal_Cost+P_Removal_Cost #$/year
Media_Cost = Annual_GAC_Required*U_Media_GAC[i,0] #$/year
U_Electrode_EC_Replacement = U_Electrode_EC[i,0]*((L/Electrode_EC_Lifetime[i,0])-1)
if (U_Electrode_EC_Replacement+U_Electrode_EC[i,0]) <= U_Electrode_EC[i,0]:
U_Electrode_EC_Replacement = 0
U_Stirrer_EC_Replacement = U_Stirrer_EC[i,0]*((L/Stirrer_Lifetime[i,0])-1)
if (U_Stirrer_EC_Replacement+U_Stirrer_EC[i,0]) <= U_Stirrer_EC[i,0]:
U_Stirrer_EC_Replacement = 0
U_Switch_Replacement = U_Switch[i,0]*2*((L/Switch_Lifetime[i,0])-1)
if (U_Switch_Replacement+(U_Switch[i,0]*2)) <= U_Switch[i,0]*2:
U_Switch_Replacement = 0
Replacement_Cost_EC = ((U_Electrode_EC_Replacement+U_Stirrer_EC_Replacement+U_Switch_Replacement))/L #/year
U_Pump_Misc_Replacement = U_Pump_Misc[i,0]*((L/U_Pump_Misc_Lifetime[i,0])-1)
if (U_Pump_Misc_Replacement+U_Pump_Misc[i,0]) <= U_Pump_Misc[i,0]:
U_Pump_Misc_Replacement = 0
Replacement_Cost_Misc = (U_Pump_Misc_Replacement)/L #/year
Replacement_Cost_Total = Replacement_Cost_UF+Media_Cost+Replacement_Cost_EC+Replacement_Cost_Misc
Daily_Maintenance_Wage=Monthly_Maintenance_Wage[i,0]/Monthly_Work_Days[i,0]
Operation_Maintenance_Cost_Overall = Daily_Maintenance_Wage*Maintenance_Frequency[i,0]*Maintenance_Time[i,0]#$/year
Operation_Maintenance_Cost_UF = Operation_Maintenance_Cost_Overall*(Replacement_Cost_UF/Replacement_Cost_Total)#$/year
Operation_Maintenance_Cost_GAC = Operation_Maintenance_Cost_Overall*(Media_Cost/Replacement_Cost_Total)#$/year
Operation_Maintenance_Cost_EC = Operation_Maintenance_Cost_Overall*(Replacement_Cost_EC/Replacement_Cost_Total) #$/year
Operation_Maintenance_Cost_Misc = Operation_Maintenance_Cost_Overall*(Replacement_Cost_Misc/Replacement_Cost_Total) #$/year
Operation_Maintenance_Cost_Controls = 0
Initial_Construction_Cost_UF = Initial_Unit_Cost_UF+Labor_Construction_Cost_UF #$
#Annual_Capital_Cost_UF = Initial_Construction_Cost_UF*((Discount_Rate[i,0]*(1+Discount_Rate[i,0])**L)/(((1+Discount_Rate[i,0])**L)-1)) #$/year
#Percent_Replacement_UF = Replacement_Cost_UF/(Replacement_Cost_UF+Operation_Maintenance_Cost_UF)
#Percent_OM_UF = Operation_Maintenance_Cost_UF/(Replacement_Cost_UF+Operation_Maintenance_Cost_UF)
Energy_Cost_UF = Energy_Annual_UF*U_Electricity[i,0] #$/year
Ongoing_Cost_UF = Energy_Cost_UF+Operation_Maintenance_Cost_UF+Replacement_Cost_UF #$/year
Depreciation_Cost_UF = ((Initial_Unit_Cost_UF-U_Pump_UF[i,0]-U_Membrane_UF[i,0]-(U_Switch[i,0]*3)-U_Valve_UF[i,0])/L)+(U_Pump_UF[i,0]/Pump_UF_Lifetime[i,0])+(U_Membrane_UF[i,0]/Membrane_UF_Lifetime[i,0])+((U_Switch[i,0]*3)/Switch_Lifetime[i,0])+(U_Valve_UF[i,0]/Valve_UF_Lifetime[i,0])
Cost_UF = 0
Profits_UF = 0
Prelim_Present_OM_Replacement_Cost_UF = 0
Present_Energy_Cost_UF = 0
Present_Depreciation_Cost_UF = 0
t = 1
while t <= L:
Required_User_Fee_newterm_Cost_UF = (1/((1+Discount_Rate[i,0])**t))*(((Ongoing_Cost_UF+Depreciation_Cost_UF)*(1-Income_Tax[i,0]))-Depreciation_Cost_UF) #summation[di((Ei-Di(1-t))-Di)]
Required_User_Fee_newterm_Profits_UF = (1/((1+Discount_Rate[i,0])**t))*365*U*(1-Income_Tax[i,0]) #profit from daily user fee minus taxes summation[di*365*users*(1-t)]
Cost_UF = Cost_UF+Required_User_Fee_newterm_Cost_UF #summation operation
Profits_UF = Profits_UF+Required_User_Fee_newterm_Profits_UF #summation operation
Prelim_Present_OM_Replacement_newterm_Cost_UF = (1/((1+Discount_Rate[i,0])**t))*((Operation_Maintenance_Cost_UF+Replacement_Cost_UF)*(1-Income_Tax[i,0])) #same as Required_User_Fee_newterm_Cost_UF, but excludes the cost of energy from the ongoing costs and does not factor in depreciation
Prelim_Present_OM_Replacement_Cost_UF = Prelim_Present_OM_Replacement_Cost_UF+Prelim_Present_OM_Replacement_newterm_Cost_UF #summation operation
Present_Energy_newterm_Cost_UF = (1/((1+Discount_Rate[i,0])**t))*(Energy_Cost_UF*(1-Income_Tax[i,0])) #same as Prelim_Present_OM_Replacement_newterm_Cost_UF, but only includes the energy cost in the ongoing costs
Present_Energy_Cost_UF = Present_Energy_Cost_UF+Present_Energy_newterm_Cost_UF #summation operation
Present_Depreciation_newterm_Cost_UF = (1/((1+Discount_Rate[i,0])**t))*(((Depreciation_Cost_UF)*(1-Income_Tax[i,0]))-Depreciation_Cost_UF) #depreciation calculation--negative result
Present_Depreciation_Cost_UF = Present_Depreciation_Cost_UF+Present_Depreciation_newterm_Cost_UF #summation operation
t = t+1
Prelim_Present_Initial_OM_Cost_UF = Initial_Construction_Cost_UF+Prelim_Present_OM_Replacement_Cost_UF #calculates the total cost of the two depreciating categories, assuming energy does not depreciate
Depreciation_Portion_Initial_Construction_Cost_UF = Initial_Construction_Cost_UF/Prelim_Present_Initial_OM_Cost_UF #assume each cost category depreciates proportionately
Depreciation_Portion_OM_Replacement_Cost_UF = Prelim_Present_OM_Replacement_Cost_UF/Prelim_Present_Initial_OM_Cost_UF
Present_Initial_Construction_Cost_UF = Initial_Construction_Cost_UF+(Present_Depreciation_Cost_UF*Depreciation_Portion_Initial_Construction_Cost_UF) #present initial construction cost after depreciation
Present_OM_Replacement_Cost_UF = Prelim_Present_OM_Replacement_Cost_UF+(Present_Depreciation_Cost_UF*Depreciation_Portion_OM_Replacement_Cost_UF) #present OM & Replacement cost after depreciation
Present_Total_Cost_UF = Present_Initial_Construction_Cost_UF+Present_OM_Replacement_Cost_UF+Present_Energy_Cost_UF #Present total cost after depreciation
Portion_Initial_Construction_Cost_UF = Present_Initial_Construction_Cost_UF/Present_Total_Cost_UF
Portion_OM_Replacement_Cost_UF = Present_OM_Replacement_Cost_UF/Present_Total_Cost_UF
Portion_Energy_Cost_UF = Present_Energy_Cost_UF/Present_Total_Cost_UF
Required_User_Fee_UF[i,0] = (Initial_Construction_Cost_UF+Cost_UF)/Profits_UF #$/user/year
Required_User_Fee_Initial_UF[i,0]=Required_User_Fee_UF[i,0]*Portion_Initial_Construction_Cost_UF
Required_User_Fee_OM_UF[i,0]=Required_User_Fee_UF[i,0]*Portion_OM_Replacement_Cost_UF
Required_User_Fee_Energy_UF[i,0]=Required_User_Fee_UF[i,0]*Portion_Energy_Cost_UF
#Annualized_Cost_UF = (Annual_Capital_Cost_UF+((Ongoing_Cost_UF+Depreciation_Cost_UF)*(1-Income_Tax[i,0]))-Depreciation_Cost_UF)/(1-Income_Tax[i,0]) #$/year
#Annualized_Cost_Initial_UF=Annualized_Cost_UF*Portion_Initial_Construction_Cost_UF
#Annualized_Cost_OM_UF = Annualized_Cost_UF*Portion_OM_Replacement_Cost_UF
#Annualized_Cost_Energy_UF = Annualized_Cost_UF*Portion_Energy_Cost_UF
#if D == 3:
#U_Column_GAC = lhs.lhs_triangle(10.85*.75,10.85,10.85*1.25,nsamples) #$/ft
#if D == 4:
#U_Column_GAC = lhs.lhs_triangle(16.19*.75,16.19,16.19*1.25,nsamples) #$/ft
#if D == 6:
#U_Column_GAC = lhs.lhs_triangle(28.57*.75,28.57,28.57*1.25,nsamples) #$/ft
Initial_Construction_Cost_GAC = Initial_Unit_Cost_GAC+Labor_Construction_Cost_GAC #$
#Annual_Capital_Cost_GAC = Initial_Construction_Cost_GAC*((Discount_Rate[i,0]*(1+Discount_Rate[i,0])**L)/(((1+Discount_Rate[i,0])**L)-1)) #$/year
Media_Cost_GAC = Annual_GAC_Required*U_Media_GAC[i,0] #$/year
#Ongoing_Cost_GAC = Media_Cost_GAC+Operation_Maintenance_Cost_GAC+N_Removal_Cost+P_Removal_Cost #$/year
Ongoing_Cost_GAC = Media_Cost_GAC+Operation_Maintenance_Cost_GAC #$/year
Depreciation_Cost_GAC = Initial_Unit_Cost_GAC/L #$/year
Cost_GAC = 0
Profits_GAC = 0
Prelim_Present_OM_Replacement_Cost_GAC = 0
Present_Depreciation_Cost_GAC = 0
n = 1
while n <= L:
Required_User_Fee_newterm_Cost_GAC = (1/((1+Discount_Rate[i,0])**n))*(((Ongoing_Cost_GAC+Depreciation_Cost_GAC)*(1-Income_Tax[i,0]))-Depreciation_Cost_GAC)
Cost_GAC = Cost_GAC+Required_User_Fee_newterm_Cost_GAC
Prelim_Present_OM_Replacement_newterm_Cost_GAC = (1/((1+Discount_Rate[i,0])**n))*((Media_Cost_GAC+Operation_Maintenance_Cost_GAC)*(1-Income_Tax[i,0]))
Prelim_Present_OM_Replacement_Cost_GAC = Prelim_Present_OM_Replacement_Cost_GAC+Prelim_Present_OM_Replacement_newterm_Cost_GAC
Present_Depreciation_newterm_Cost_GAC = (1/((1+Discount_Rate[i,0])**n))*(((Depreciation_Cost_GAC)*(1-Income_Tax[i,0]))-Depreciation_Cost_GAC)
Present_Depreciation_Cost_GAC = Present_Depreciation_Cost_GAC+Present_Depreciation_newterm_Cost_GAC
Required_User_Fee_newterm_Profits_GAC = (1/((1+Discount_Rate[i,0])**n))*365*U*(1-Income_Tax[i,0])
Profits_GAC = Profits_GAC+Required_User_Fee_newterm_Profits_GAC
n = n+1
Prelim_Present_Initial_OM_Cost_GAC = Initial_Construction_Cost_GAC+Prelim_Present_OM_Replacement_Cost_GAC
Depreciation_Portion_Initial_Construction_Cost_GAC = Initial_Construction_Cost_GAC/Prelim_Present_Initial_OM_Cost_GAC
Depreciation_Portion_OM_Replacement_Cost_GAC = Prelim_Present_OM_Replacement_Cost_GAC/Prelim_Present_Initial_OM_Cost_GAC
Present_Initial_Construction_Cost_GAC = Initial_Construction_Cost_GAC+(Present_Depreciation_Cost_GAC*Depreciation_Portion_Initial_Construction_Cost_GAC)
Present_OM_Replacement_Cost_GAC = Prelim_Present_OM_Replacement_Cost_GAC+(Present_Depreciation_Cost_GAC*Depreciation_Portion_OM_Replacement_Cost_GAC)
Present_Total_Cost_GAC = Present_Initial_Construction_Cost_GAC+Present_OM_Replacement_Cost_GAC
Portion_Initial_Construction_Cost_GAC = Present_Initial_Construction_Cost_GAC/Present_Total_Cost_GAC
Portion_OM_Replacement_Cost_GAC = Present_OM_Replacement_Cost_GAC/Present_Total_Cost_GAC
Required_User_Fee_GAC[i,0] = (Initial_Construction_Cost_GAC+Cost_GAC)/Profits_GAC #$/user/year
Required_User_Fee_Initial_GAC[i,0]=Required_User_Fee_GAC[i,0]*Portion_Initial_Construction_Cost_GAC
Required_User_Fee_OM_GAC[i,0]=Required_User_Fee_GAC[i,0]*Portion_OM_Replacement_Cost_GAC
#Annualized_Cost_GAC = (Annual_Capital_Cost_GAC+((Ongoing_Cost_GAC+Depreciation_Cost_GAC)*(1-Income_Tax[i,0]))-Depreciation_Cost_GAC)/(1-Income_Tax[i,0]) #$/year
#Annualized_Cost_Initial_GAC=Annualized_Cost_GAC*Portion_Initial_Construction_Cost_GAC
#Annualized_Cost_OM_GAC = Annualized_Cost_GAC*Portion_OM_Replacement_Cost_GAC
#if V == 5:
#U_Tank_EC = lhs.lhs_triangle(406.84*.9,406.84,406.84*1.1,nsamples) #$
#if V == 10:
#U_Tank_EC = lhs.lhs_triangle(429.52*.9,429.52,429.52*1.1,nsamples) #$
#if V == 15:
#U_Tank_EC = lhs.lhs_triangle(448.08*.9,448.08,448.08*1.1,nsamples) #$
Initial_Construction_Cost_EC = Initial_Unit_Cost_EC+Labor_Construction_Cost_EC #$
Annual_Capital_Cost_EC = Initial_Construction_Cost_EC*((Discount_Rate[i,0]*(1+Discount_Rate[i,0])**L)/(((1+Discount_Rate[i,0])**L)-1)) #$/year
Energy_Cost_EC = Energy_Annual_EC*U_Electricity[i,0] #$/year
Ongoing_Cost_EC = Energy_Cost_EC+Operation_Maintenance_Cost_EC+Replacement_Cost_EC #$/year
Depreciation_Cost_EC = ((Initial_Unit_Cost_EC-U_Electrode_EC[i,0]-U_Stirrer_EC[i,0]-(U_Switch[i,0]*2))/L)+(U_Electrode_EC[i,0]/Electrode_EC_Lifetime[i,0])+(U_Stirrer_EC[i,0]/Stirrer_Lifetime[i,0])+((U_Switch[i,0]*2)/Switch_Lifetime[i,0]) #$/year
Cost_EC = 0
Profits_EC = 0
Prelim_Present_OM_Replacement_Cost_EC = 0
Present_Depreciation_Cost_EC = 0
Present_Energy_Cost_EC = 0
j = 1
while j <= L:
Required_User_Fee_newterm_Cost_EC = (1/((1+Discount_Rate[i,0])**j))*(((Ongoing_Cost_EC+Depreciation_Cost_EC)*(1-Income_Tax[i,0]))-Depreciation_Cost_EC)
Cost_EC = Cost_EC+Required_User_Fee_newterm_Cost_EC
Prelim_Present_OM_Replacement_newterm_Cost_EC = (1/((1+Discount_Rate[i,0])**j))*((Operation_Maintenance_Cost_EC+Replacement_Cost_EC)*(1-Income_Tax[i,0]))
Prelim_Present_OM_Replacement_Cost_EC = Prelim_Present_OM_Replacement_Cost_EC+Prelim_Present_OM_Replacement_newterm_Cost_EC
Present_Energy_newterm_Cost_EC = (1/((1+Discount_Rate[i,0])**j))*(Energy_Cost_EC*(1-Income_Tax[i,0]))
Present_Depreciation_newterm_Cost_EC = (1/((1+Discount_Rate[i,0])**j))*(((Depreciation_Cost_EC)*(1-Income_Tax[i,0]))-Depreciation_Cost_EC)
Present_Depreciation_Cost_EC = Present_Depreciation_Cost_EC+Present_Depreciation_newterm_Cost_EC
Present_Energy_Cost_EC = Present_Energy_Cost_EC+Present_Energy_newterm_Cost_EC
Required_User_Fee_newterm_Profits_EC = (1/((1+Discount_Rate[i,0])**j))*365*U*(1-Income_Tax[i,0])
Profits_EC = Profits_EC+Required_User_Fee_newterm_Profits_EC
j = j+1
Prelim_Present_Initial_OM_Cost_EC = Initial_Construction_Cost_EC+Prelim_Present_OM_Replacement_Cost_EC
Depreciation_Portion_Initial_Construction_Cost_EC = Initial_Construction_Cost_EC/Prelim_Present_Initial_OM_Cost_EC
Depreciation_Portion_OM_Replacement_Cost_EC = Prelim_Present_OM_Replacement_Cost_EC/Prelim_Present_Initial_OM_Cost_EC
Present_Initial_Construction_Cost_EC = Initial_Construction_Cost_EC+(Present_Depreciation_Cost_EC*Depreciation_Portion_Initial_Construction_Cost_EC)
Present_OM_Replacement_Cost_EC = Prelim_Present_OM_Replacement_Cost_EC+(Present_Depreciation_Cost_EC*Depreciation_Portion_OM_Replacement_Cost_EC)
Present_Total_Cost_EC = Present_Initial_Construction_Cost_EC+Present_OM_Replacement_Cost_EC+Present_Energy_Cost_EC
Portion_Initial_Construction_Cost_EC = Present_Initial_Construction_Cost_EC/Present_Total_Cost_EC
Portion_OM_Replacement_Cost_EC = Present_OM_Replacement_Cost_EC/Present_Total_Cost_EC
Portion_Energy_Cost_EC = Present_Energy_Cost_EC/Present_Total_Cost_EC
Required_User_Fee_EC[i,0] = (Initial_Construction_Cost_EC+Cost_EC)/Profits_EC #$/user/year
Required_User_Fee_Initial_EC[i,0]=Required_User_Fee_EC[i,0]*Portion_Initial_Construction_Cost_EC
Required_User_Fee_OM_EC[i,0]=Required_User_Fee_EC[i,0]*Portion_OM_Replacement_Cost_EC
Required_User_Fee_Energy_EC[i,0]=Required_User_Fee_EC[i,0]*Portion_Energy_Cost_EC
#Annualized_Cost_EC = (Annual_Capital_Cost_EC+((Ongoing_Cost_EC+Depreciation_Cost_EC)*(1-Income_Tax[i,0]))-Depreciation_Cost_EC)/(1-Income_Tax[i,0]) #$/year
#Annualized_Cost_Initial_EC=Annualized_Cost_EC*Portion_Initial_Construction_Cost_EC
#Annualized_Cost_OM_EC = Annualized_Cost_EC*Portion_OM_Replacement_Cost_EC
#Annualized_Cost_Energy_EC = Annualized_Cost_EC*Portion_Energy_Cost_EC
Initial_Construction_Cost_Misc = Initial_Unit_Cost_Misc+Labor_Construction_Cost_Misc #$
Annual_Capital_Cost_Misc = Initial_Construction_Cost_Misc*((Discount_Rate[i,0]*(1+Discount_Rate[i,0])**L)/(((1+Discount_Rate[i,0])**L)-1)) #$/year
Energy_Cost_Misc = Energy_Annual_Misc*U_Electricity[i,0] #$/year
Ongoing_Cost_Misc = Energy_Cost_Misc+Operation_Maintenance_Cost_Misc+Replacement_Cost_Misc #$/year
Depreciation_Cost_Misc = Initial_Unit_Cost_Misc/L #$/year
Cost_Misc = 0
Profits_Misc = 0
Prelim_Present_OM_Replacement_Cost_Misc = 0
Present_Depreciation_Cost_Misc = 0
Present_Energy_Cost_Misc = 0
g = 1
while g <= L:
Required_User_Fee_newterm_Cost_Misc = (1/((1+Discount_Rate[i,0])**g))*(((Ongoing_Cost_Misc+Depreciation_Cost_Misc)*(1-Income_Tax[i,0]))-Depreciation_Cost_Misc)
Cost_Misc = Cost_Misc+Required_User_Fee_newterm_Cost_Misc
Prelim_Present_OM_Replacement_newterm_Cost_Misc = (1/((1+Discount_Rate[i,0])**g))*((Operation_Maintenance_Cost_Misc)*(1-Income_Tax[i,0]))
Prelim_Present_OM_Replacement_Cost_Misc = Prelim_Present_OM_Replacement_Cost_Misc+Prelim_Present_OM_Replacement_newterm_Cost_Misc
Present_Energy_newterm_Cost_Misc = (1/((1+Discount_Rate[i,0])**g))*(Energy_Cost_Misc*(1-Income_Tax[i,0]))
Present_Energy_Cost_Misc = Present_Energy_Cost_Misc+Present_Energy_newterm_Cost_EC
Present_Depreciation_newterm_Cost_Misc = (1/((1+Discount_Rate[i,0])**g))*(((Depreciation_Cost_Misc)*(1-Income_Tax[i,0]))-Depreciation_Cost_Misc)
Present_Depreciation_Cost_Misc = Present_Depreciation_Cost_Misc+Present_Depreciation_newterm_Cost_Misc
Required_User_Fee_newterm_Profits_Misc = (1/((1+Discount_Rate[i,0])**g))*365*U*(1-Income_Tax[i,0])
Profits_Misc = Profits_Misc+Required_User_Fee_newterm_Profits_Misc
g = g+1
Prelim_Present_Initial_OM_Cost_Misc = Initial_Construction_Cost_Misc+Prelim_Present_OM_Replacement_Cost_Misc
Depreciation_Portion_Initial_Construction_Cost_Misc = Initial_Construction_Cost_Misc/Prelim_Present_Initial_OM_Cost_Misc
Depreciation_Portion_OM_Replacement_Cost_Misc = Prelim_Present_OM_Replacement_Cost_Misc/Prelim_Present_Initial_OM_Cost_Misc
Present_Initial_Construction_Cost_Misc = Initial_Construction_Cost_Misc+(Present_Depreciation_Cost_Misc*Depreciation_Portion_Initial_Construction_Cost_Misc)
Present_OM_Replacement_Cost_Misc = Prelim_Present_OM_Replacement_Cost_Misc+(Present_Depreciation_Cost_Misc*Depreciation_Portion_OM_Replacement_Cost_Misc)
Present_Total_Cost_Misc = Present_Initial_Construction_Cost_Misc+Present_OM_Replacement_Cost_Misc+Present_Energy_Cost_Misc
Portion_Initial_Construction_Cost_Misc = Present_Initial_Construction_Cost_Misc/Present_Total_Cost_Misc
Portion_OM_Replacement_Cost_Misc = Present_OM_Replacement_Cost_Misc/Present_Total_Cost_Misc
Portion_Energy_Cost_Misc = Present_Energy_Cost_Misc/Present_Total_Cost_Misc
Required_User_Fee_Misc[i,0] = (Initial_Construction_Cost_Misc+Cost_Misc)/Profits_Misc #$/user/year
Required_User_Fee_Initial_Misc[i,0]=Required_User_Fee_Misc[i,0]*Portion_Initial_Construction_Cost_Misc
Required_User_Fee_OM_Misc[i,0]=Required_User_Fee_Misc[i,0]*Portion_OM_Replacement_Cost_Misc
Required_User_Fee_Energy_Misc[i,0]=Required_User_Fee_Misc[i,0]*Portion_Energy_Cost_Misc
#Annualized_Cost_Misc = (Annual_Capital_Cost_Misc+((Ongoing_Cost_Misc+Depreciation_Cost_Misc)*(1-Income_Tax[i,0]))-Depreciation_Cost_Misc)/(1-Income_Tax[i,0]) #$/year
#Annualized_Cost_Initial_Misc=Annualized_Cost_Misc*Portion_Initial_Construction_Cost_Misc
#Annualized_Cost_OM_Misc = Annualized_Cost_Misc*Portion_OM_Replacement_Cost_Misc
Initial_Construction_Cost_Controls = Initial_Unit_Cost_Controls+Labor_Construction_Cost_Controls #$
#Annual_Capital_Cost_Controls = Initial_Construction_Cost_Controls*((Discount_Rate[i,0]*(1+Discount_Rate[i,0])**L)/(((1+Discount_Rate[i,0])**L)-1)) #$/year
Energy_Cost_Controls = ((25*24*365)/1000)*U_Electricity[i,0] #kWh/yr
Ongoing_Cost_Controls = Energy_Cost_Controls #$/year
Depreciation_Cost_Controls = Initial_Unit_Cost_Controls/L #$/year
Cost_Controls = 0
Profits_Controls = 0
Prelim_Present_OM_Replacement_Cost_Controls = 0
Present_Energy_Cost_Controls = 0
Present_Depreciation_Cost_Controls = 0
h = 1
while h <= L:
Required_User_Fee_newterm_Cost_Controls = (1/((1+Discount_Rate[i,0])**h))*(((Ongoing_Cost_Controls+Depreciation_Cost_Controls)*(1-Income_Tax[i,0]))-Depreciation_Cost_Controls)
Cost_Controls = Cost_Controls+Required_User_Fee_newterm_Cost_Controls
Prelim_Present_OM_Replacement_newterm_Cost_Controls = (1/((1+Discount_Rate[i,0])**h))*((Operation_Maintenance_Cost_Controls)*(1-Income_Tax[i,0]))
Prelim_Present_OM_Replacement_Cost_Controls = Prelim_Present_OM_Replacement_Cost_Controls+Prelim_Present_OM_Replacement_newterm_Cost_Controls
Present_Energy_newterm_Cost_Controls = (1/((1+Discount_Rate[i,0])**h))*(Energy_Cost_Controls*(1-Income_Tax[i,0]))
Present_Energy_Cost_Controls = Present_Energy_Cost_Controls+Present_Energy_newterm_Cost_Controls
Present_Depreciation_newterm_Cost_Controls = (1/((1+Discount_Rate[i,0])**h))*(((Depreciation_Cost_Controls)*(1-Income_Tax[i,0]))-Depreciation_Cost_Controls)
Present_Depreciation_Cost_Controls = Present_Depreciation_Cost_Controls+Present_Depreciation_newterm_Cost_Controls
Required_User_Fee_newterm_Profits_Controls = (1/((1+Discount_Rate[i,0])**h))*365*U*(1-Income_Tax[i,0])
Profits_Controls = Profits_Controls+Required_User_Fee_newterm_Profits_Controls
h = h+1
Prelim_Present_Initial_OM_Cost_Controls = Initial_Construction_Cost_Controls+Prelim_Present_OM_Replacement_Cost_Controls
Depreciation_Portion_Initial_Construction_Cost_Controls = Initial_Construction_Cost_GAC/Prelim_Present_Initial_OM_Cost_Controls
Depreciation_Portion_OM_Replacement_Cost_Controls = Prelim_Present_OM_Replacement_Cost_Controls/Prelim_Present_Initial_OM_Cost_Controls
Present_Initial_Construction_Cost_Controls = Initial_Construction_Cost_Controls+(Present_Depreciation_Cost_Controls*Depreciation_Portion_Initial_Construction_Cost_Controls)
Present_OM_Replacement_Cost_Controls = Prelim_Present_OM_Replacement_Cost_Controls+(Present_Depreciation_Cost_Controls*Depreciation_Portion_OM_Replacement_Cost_Controls)
Present_Total_Cost_Controls = Present_Initial_Construction_Cost_Controls+Present_OM_Replacement_Cost_Controls+Present_Energy_Cost_Controls
Portion_Initial_Construction_Cost_Controls = Present_Initial_Construction_Cost_Controls/Present_Total_Cost_Controls
Portion_OM_Replacement_Cost_Controls = Present_OM_Replacement_Cost_Controls/Present_Total_Cost_Controls
Portion_Energy_Cost_Controls = Present_Energy_Cost_Controls/Present_Total_Cost_Controls
Required_User_Fee_Controls[i,0] = (Initial_Construction_Cost_Controls+Cost_Controls)/Profits_Controls #$/user/year
Required_User_Fee_Initial_Controls[i,0]=Required_User_Fee_Controls[i,0]*Portion_Initial_Construction_Cost_Controls
Required_User_Fee_OM_Controls[i,0]=Required_User_Fee_Controls[i,0]*Portion_OM_Replacement_Cost_Controls
Required_User_Fee_Energy_Controls[i,0]=Required_User_Fee_Controls[i,0]*Portion_Energy_Cost_Controls
#Annualized_Cost_Controls = (Annual_Capital_Cost_Controls+((Ongoing_Cost_Controls+Depreciation_Cost_Controls)*(1-Income_Tax[i,0]))-Depreciation_Cost_Controls)/(1-Income_Tax[i,0]) #$/year
#Annualized_Cost_Initial_Controls=Annualized_Cost_Controls*Portion_Initial_Construction_Cost_Controls
#Annualized_Cost_OM_Controls = Annualized_Cost_Controls*Portion_OM_Replacement_Cost_Controls
Energy_Cost_Overall = Energy_Cost_UF+Energy_Cost_EC+Energy_Cost_Misc+Energy_Cost_Controls
Initial_Construction_Cost_Overall = Initial_Unit_Cost_Overall+Labor_Construction_Cost_Overall #$
Replacement_Cost_Overall = Replacement_Cost_UF+Replacement_Cost_EC+Replacement_Cost_Misc #$/year
#Annual_Capital_Cost_Overall = Initial_Construction_Cost_Overall*((Discount_Rate[i,0]*(1+Discount_Rate[i,0])**L)/(((1+Discount_Rate[i,0])**L)-1)) #$/year
Ongoing_Cost_Overall = Energy_Cost_Overall+Media_Cost_GAC+Operation_Maintenance_Cost_Overall+Replacement_Cost_Overall #$/year
Depreciation_Cost_Overall = Depreciation_Cost_UF+Depreciation_Cost_GAC+Depreciation_Cost_EC+Depreciation_Cost_Misc+Depreciation_Cost_Controls #$/year
Cost_Overall = 0
Profits_Overall = 0
Prelim_Present_OM_Replacement_Cost_Overall = 0
Present_Energy_Cost_Overall = 0
Present_Depreciation_Cost_Overall = 0
p = 1
while p <= L:
Required_User_Fee_newterm_Cost_Overall = (1/((1+Discount_Rate[i,0])**p))*(((Ongoing_Cost_Overall+Depreciation_Cost_Overall)*(1-Income_Tax[i,0]))-Depreciation_Cost_Overall)
Required_User_Fee_newterm_Profits_Overall = (1/((1+Discount_Rate[i,0])**p))*365*U*(1-Income_Tax[i,0])
Cost_Overall = Cost_Overall+Required_User_Fee_newterm_Cost_Overall
Profits_Overall = Profits_Overall+Required_User_Fee_newterm_Profits_Overall
Prelim_Present_OM_Replacement_newterm_Cost_Overall = (1/((1+Discount_Rate[i,0])**p))*((Operation_Maintenance_Cost_Overall+Replacement_Cost_Overall+Media_Cost_GAC)*(1-Income_Tax[i,0]))
Prelim_Present_OM_Replacement_Cost_Overall = Prelim_Present_OM_Replacement_Cost_Overall+Prelim_Present_OM_Replacement_newterm_Cost_Overall
Present_Energy_newterm_Cost_Overall = (1/((1+Discount_Rate[i,0])**p))*(Energy_Cost_Overall*(1-Income_Tax[i,0]))
Present_Energy_Cost_Overall = Present_Energy_Cost_Overall+Present_Energy_newterm_Cost_Overall
Present_Depreciation_newterm_Cost_Overall = (1/((1+Discount_Rate[i,0])**p))*(((Depreciation_Cost_Overall)*(1-Income_Tax[i,0]))-Depreciation_Cost_Overall)
Present_Depreciation_Cost_Overall = Present_Depreciation_Cost_Overall+Present_Depreciation_newterm_Cost_Overall
p = p+1
Prelim_Present_Initial_OM_Cost_Overall = Initial_Construction_Cost_Overall+Prelim_Present_OM_Replacement_Cost_Overall
Depreciation_Portion_Initial_Construction_Cost_Overall = Initial_Construction_Cost_Overall/Prelim_Present_Initial_OM_Cost_Overall
Depreciation_Portion_OM_Replacement_Cost_Overall = Prelim_Present_OM_Replacement_Cost_Overall/Prelim_Present_Initial_OM_Cost_Overall
Present_Initial_Construction_Cost_Overall = Initial_Construction_Cost_Overall+(Present_Depreciation_Cost_Overall*Depreciation_Portion_Initial_Construction_Cost_Overall)
Present_OM_Replacement_Cost_Overall = Prelim_Present_OM_Replacement_Cost_Overall+(Present_Depreciation_Cost_Overall*Depreciation_Portion_OM_Replacement_Cost_Overall)
Present_Total_Cost_Overall = Present_Initial_Construction_Cost_Overall+Present_OM_Replacement_Cost_Overall+Present_Energy_Cost_Overall
Portion_Initial_Construction_Cost_Overall = Present_Initial_Construction_Cost_Overall/Present_Total_Cost_Overall
Portion_OM_Replacement_Cost_Overall = Present_OM_Replacement_Cost_Overall/Present_Total_Cost_Overall
Portion_Energy_Cost_Overall = Present_Energy_Cost_Overall/Present_Total_Cost_Overall
Required_User_Fee_Overall[i,0] = (Initial_Construction_Cost_Overall+Cost_Overall)/Profits_Overall #$/user/year
Required_User_Fee_Initial_Overall[i,0]=Required_User_Fee_Overall[i,0]*Portion_Initial_Construction_Cost_Overall
Required_User_Fee_OM_Overall[i,0]=Required_User_Fee_Overall[i,0]*Portion_OM_Replacement_Cost_Overall
Required_User_Fee_Energy_Overall[i,0]=Required_User_Fee_Overall[i,0]*Portion_Energy_Cost_Overall
Percent_UF_Total[i,0]=Required_User_Fee_UF[i,0]/Required_User_Fee_Overall[i,0]
Percent_GAC_Total[i,0]=Required_User_Fee_GAC[i,0]/Required_User_Fee_Overall[i,0]
Percent_EC_Total[i,0]=Required_User_Fee_EC[i,0]/Required_User_Fee_Overall[i,0]
Percent_Controls_Total[i,0]=Required_User_Fee_Controls[i,0]/Required_User_Fee_Overall[i,0]
Percent_Misc_Total[i,0]=Required_User_Fee_Misc[i,0]/Required_User_Fee_Overall[i,0]
Percent_Initial_Total[i,0]=Required_User_Fee_Initial_Overall[i,0]/Required_User_Fee_Overall[i,0]
Percent_OM_Total[i,0]=Required_User_Fee_OM_Overall[i,0]/Required_User_Fee_Overall[i,0]
Perent_Energy_Total[i,0]=Required_User_Fee_Energy_Overall[i,0]/Required_User_Fee_Overall[i,0]
Percent_UF_Initial[i,0]=Required_User_Fee_Initial_UF[i,0]/Required_User_Fee_UF[i,0]
Percent_UF_OM[i,0]=Required_User_Fee_OM_UF[i,0]/Required_User_Fee_UF[i,0]
Percent_UF_Energy[i,0]=Required_User_Fee_Energy_UF[i,0]/Required_User_Fee_UF[i,0]
Percent_GAC_Initial[i,0]=Required_User_Fee_Initial_GAC[i,0]/Required_User_Fee_GAC[i,0]
Percent_GAC_OM[i,0]=Required_User_Fee_OM_GAC[i,0]/Required_User_Fee_GAC[i,0]
Percent_EC_Initial[i,0]=Required_User_Fee_Initial_EC[i,0]/Required_User_Fee_EC[i,0]
Percent_EC_OM[i,0]=Required_User_Fee_OM_EC[i,0]/Required_User_Fee_EC[i,0]
Percent_EC_Energy[i,0]=Required_User_Fee_Energy_EC[i,0]/Required_User_Fee_EC[i,0]
Percent_Controls_Initial[i,0]=Required_User_Fee_Initial_Controls[i,0]/Required_User_Fee_Controls[i,0]
Percent_Controls_OM[i,0]=Required_User_Fee_OM_Controls[i,0]/Required_User_Fee_Controls[i,0]
Percent_Controls_Energy[i,0]=Required_User_Fee_Energy_Controls[i,0]/Required_User_Fee_Controls[i,0]
Percent_Misc_Initial[i,0]=Required_User_Fee_Initial_Misc[i,0]/Required_User_Fee_Misc[i,0]
Percent_Misc_OM[i,0]=Required_User_Fee_OM_Misc[i,0]/Required_User_Fee_Misc[i,0]
Percent_Misc_Energy[i,0]=Required_User_Fee_Energy_Misc[i,0]/Required_User_Fee_Misc[i,0]
#Annualized_Cost_Overall = (Annual_Capital_Cost_Overall+((Ongoing_Cost_Overall+Depreciation_Cost_Overall)*(1-Income_Tax[i,0]))-Depreciation_Cost_Overall)/(1-Income_Tax[i,0]) #$/year
#Annualized_Cost_Initial_Overall=Annualized_Cost_Overall*Portion_Initial_Construction_Cost_Overall
#Annualized_Cost_OM_Overall = Annualized_Cost_Overall*Portion_OM_Replacement_Cost_Overall
#Annualized_Cost_Energy_Overall = Annualized_Cost_Overall*Portion_Energy_Cost_Overall
results = np.concatenate((Required_User_Fee_Overall, Required_User_Fee_Initial_Overall, Required_User_Fee_OM_Overall, Required_User_Fee_Energy_Overall, Required_User_Fee_UF, Required_User_Fee_Initial_UF, Required_User_Fee_OM_UF, Required_User_Fee_Energy_UF, Required_User_Fee_GAC, Required_User_Fee_Initial_GAC, Required_User_Fee_OM_GAC, Required_User_Fee_EC, Required_User_Fee_Initial_EC, Required_User_Fee_OM_EC, Required_User_Fee_Energy_EC, Required_User_Fee_Controls, Required_User_Fee_Initial_Controls, Required_User_Fee_OM_Controls, Required_User_Fee_Energy_Controls, Required_User_Fee_Misc, Required_User_Fee_Initial_Misc, Required_User_Fee_OM_Misc, Required_User_Fee_Energy_Misc, Percent_UF_Total, Percent_GAC_Total, Percent_EC_Total, Percent_Controls_Total, Percent_Misc_Total, Percent_Initial_Total, Percent_OM_Total, Perent_Energy_Total, Percent_UF_Initial, Percent_UF_OM, Percent_UF_Energy, Percent_GAC_Initial, Percent_GAC_OM, Percent_EC_Initial, Percent_EC_OM, Percent_EC_Energy, Percent_Controls_Initial, Percent_Controls_OM, Percent_Controls_Energy, Percent_Misc_Initial, Percent_Misc_OM, Percent_Misc_Energy), axis = 1)
#%% Spearman's Rank Coefficients
Results = pd.DataFrame(results, columns = ['Required_User_Fee_Overall', 'Required_User_Fee_Initial_Overall', 'Required_User_Fee_OM_Overall', 'Required_User_Fee_Energy_Overall', 'Required_User_Fee_UF', 'Required_User_Fee_Initial_UF', 'Required_User_Fee_OM_UF', 'Required_User_Fee_Energy_UF', 'Required_User_Fee_GAC', 'Required_User_Fee_Initial_GAC', 'Required_User_Fee_OM_GAC', 'Required_User_Fee_EC', 'Required_User_Fee_Initial_EC', 'Required_User_Fee_OM_EC', 'Required_User_Fee_Energy_EC', 'Required_User_Fee_Controls', 'Required_User_Fee_Initial_Controls', 'Required_User_Fee_OM_Controls', 'Required_User_Fee_Energy_Controls', 'Required_User_Fee_Misc', 'Required_User_Fee_Initial_Misc', 'Required_User_Fee_OM_Misc', 'Required_User_Fee_Energy_Misc', 'Percent_UF_Total', 'Percent_GAC_Total', 'Percent_EC_Total', 'Percent_Controls_Total', 'Percent_Misc_Total', 'Percent_Initial_Total', 'Percent_OM_Total', 'Perent_Energy_Total', 'Percent_UF_Initial', 'Percent_UF_OM', 'Percent_UF_Energy', 'Percent_GAC_Initial', 'Percent_GAC_OM', 'Percent_EC_Initial', 'Percent_EC_OM', 'Percent_EC_Energy', 'Percent_Controls_Initial', 'Percent_Controls_OM', 'Percent_Controls_Energy', 'Percent_Misc_Initial', 'Percent_Misc_OM', 'Percent_Misc_Energy'])
#Assumed_Parameters = np.concatenate((Daily_Flushes, Flush_Volume, Membrane_Flux, Velocity_Crossflow, Pressure_Membrane, Fill_Fraction_GAC_Column, UF_GAC_N_P_Removal, Clinoptilolite_Cost, Polonite_Cost, Clinoptilolite_Capacity, Polonite_Capacity, N_Content_Protein, N_P_Excretion, N_Urine, P_Content_A_Protein, P_Content_V_Protein, P_Urine, Seperation_Efficiency, Lifetime_GAC, Power_Required_Treatment_EC, Current_EC, Power_Stirrer, Flowrate_Discharge, Pump_UF_Lifetime, Membrane_UF_Lifetime, Switch_Lifetime, Valve_UF_Lifetime, Electrode_EC_Lifetime, Stirrer_Lifetime, U_Pump_Misc_Lifetime, Discount_Rate, U_Pump_UF, U_Membrane_UF, U_Valve_UF, U_Tank_UF, U_Switch, U_Column_GAC, U_Stirrer_EC, U_Electrode_EC, U_Pump_Misc, US_Initial_Unit_Cost_UF, InCountry_Initial_Unit_Cost_UF, US_Initial_Unit_Cost_GAC, InCountry_Initial_Unit_Cost_GAC, US_Initial_Unit_Cost_EC, InCountry_Initial_Unit_Cost_EC, US_Initial_Unit_Cost_Controls, InCountry_Initial_Unit_Cost_Controls, US_Initial_Unit_Cost_Misc, InCountry_Initial_Unit_Cost_Misc, U_Media_GAC, Waste, Total_Protein, Total_Protein_A, Total_Protein_V, PLR, U_Electricity, Monthly_Construction_Wage, Monthly_Maintenance_Wage, Income_Tax, Monthly_Work_Days, Construction_Time, Maintenance_Frequency, Maintenance_Time ), axis=1)
Assumed_Parameters = np.concatenate((Daily_Flushes, Flush_Volume, Membrane_Flux, Velocity_Crossflow, Pressure_Membrane, Fill_Fraction_GAC_Column, Lifetime_GAC, Power_Required_Treatment_EC, Current_EC, Power_Stirrer, Flowrate_Discharge, Pump_UF_Lifetime, Membrane_UF_Lifetime, Switch_Lifetime, Valve_UF_Lifetime, Electrode_EC_Lifetime, Stirrer_Lifetime, U_Pump_Misc_Lifetime, Discount_Rate, U_Pump_UF, U_Membrane_UF, U_Valve_UF, U_Tank_UF, U_Switch, U_Column_GAC, U_Stirrer_EC, U_Electrode_EC, U_Pump_Misc, US_Initial_Unit_Cost_UF, InCountry_Initial_Unit_Cost_UF, US_Initial_Unit_Cost_GAC, InCountry_Initial_Unit_Cost_GAC, US_Initial_Unit_Cost_EC, InCountry_Initial_Unit_Cost_EC, US_Initial_Unit_Cost_Controls, InCountry_Initial_Unit_Cost_Controls, US_Initial_Unit_Cost_Misc, InCountry_Initial_Unit_Cost_Misc, U_Media_GAC, PLR, U_Electricity, Monthly_Construction_Wage, Monthly_Maintenance_Wage, Income_Tax, Monthly_Work_Days, Construction_Time, Maintenance_Frequency, Maintenance_Time ), axis=1)
Outputs = np.concatenate((Required_User_Fee_Overall, Required_User_Fee_Initial_Overall, Required_User_Fee_OM_Overall, Required_User_Fee_Energy_Overall), axis = 1)
rho_all, p_all = stats.spearmanr(Assumed_Parameters, Outputs)
#%% Create DataFrame
#Spearmans = pd.DataFrame(rho_all, columns = ['Daily_Flushes', 'Flush_Volume', 'Membrane_Flux', 'Velocity_Crossflow', 'Pressure_Membrane', 'Fill_Fraction_GAC_Column', 'UF_GAC_N_P_Removal', 'Clinoptilolite_Cost', 'Polonite_Cost', 'Clinoptilolite_Capacity', 'Polonite_Capacity', 'N_Content_Protein', 'N_P_Excretion', 'N_Urine', 'P_Content_A_Protein', 'P_Content_V_Protein', 'P_Urine', 'Seperation_Efficiency', 'Lifetime_GAC', 'Power_Required_Treatment_EC', 'Current_EC', 'Power_Stirrer', 'Flowrate_Discharge', 'Pump_UF_Lifetime', 'Membrane_UF_Lifetime', 'Switch_Lifetime', 'Valve_UF_Lifetime', 'Electrode_EC_Lifetime', 'Stirrer_Lifetime', 'U_Pump_Misc_Lifetime', 'Discount_Rate', 'U_Pump_UF', 'U_Membrane_UF', 'U_Valve_UF', 'U_Tank_UF', 'U_Switch', 'U_Column_GAC', 'U_Stirrer_EC', 'U_Electrode_EC', 'U_Pump_Misc', 'US_Initial_Unit_Cost_UF', 'InCountry_Initial_Unit_Cost_UF', 'US_Initial_Unit_Cost_GAC', 'InCountry_Initial_Unit_Cost_GAC', 'US_Initial_Unit_Cost_EC', 'InCountry_Initial_Unit_Cost_EC', 'US_Initial_Unit_Cost_Controls', 'InCountry_Initial_Unit_Cost_Controls', 'US_Initial_Unit_Cost_Misc', 'InCountry_Initial_Unit_Cost_Misc', 'U_Media_GAC', 'Waste', 'Total_Protein', 'Total_Protein_A', 'Total_Protein_V', 'PLR', 'U_Electricity', 'Monthly_Construction_Wage', 'Monthly_Maintenance_Wage', 'Income_Tax', 'Monthly_Work_Days', 'Construction_Time', 'Maintenance_Frequency', 'Maintenance_Time', 'Required_User_Fee_Overall', 'Required_User_Fee_Initial_Overall', 'Required_User_Fee_OM_Overall', 'Required_User_Fee_Energy_Overall'], index = ['Daily_Flushes', 'Flush_Volume', 'Membrane_Flux', 'Velocity_Crossflow', 'Pressure_Membrane', 'Fill_Fraction_GAC_Column', 'UF_GAC_N_P_Removal', 'Clinoptilolite_Cost', 'Polonite_Cost', 'Clinoptilolite_Capacity', 'Polonite_Capacity', 'N_Content_Protein', 'N_P_Excretion', 'N_Urine', 'P_Content_A_Protein', 'P_Content_V_Protein', 'P_Urine', 'Seperation_Efficiency', 'Lifetime_GAC', 'Power_Required_Treatment_EC', 'Current_EC', 'Power_Stirrer', 'Flowrate_Discharge', 'Pump_UF_Lifetime', 'Membrane_UF_Lifetime', 'Switch_Lifetime', 'Valve_UF_Lifetime', 'Electrode_EC_Lifetime', 'Stirrer_Lifetime', 'U_Pump_Misc_Lifetime', 'Discount_Rate', 'U_Pump_UF', 'U_Membrane_UF', 'U_Valve_UF', 'U_Tank_UF', 'U_Switch', 'U_Column_GAC', 'U_Stirrer_EC', 'U_Electrode_EC', 'U_Pump_Misc', 'US_Initial_Unit_Cost_UF', 'InCountry_Initial_Unit_Cost_UF', 'US_Initial_Unit_Cost_GAC', 'InCountry_Initial_Unit_Cost_GAC', 'US_Initial_Unit_Cost_EC', 'InCountry_Initial_Unit_Cost_EC', 'US_Initial_Unit_Cost_Controls', 'InCountry_Initial_Unit_Cost_Controls', 'US_Initial_Unit_Cost_Misc', 'InCountry_Initial_Unit_Cost_Misc', 'U_Media_GAC', 'Waste', 'Total_Protein', 'Total_Protein_A', 'Total_Protein_V', 'PLR', 'U_Electricity', 'Monthly_Construction_Wage', 'Monthly_Maintenance_Wage', 'Income_Tax', 'Monthly_Work_Days', 'Construction_Time', 'Maintenance_Frequency', 'Maintenance_Time','Required_User_Fee_Overall', 'Required_User_Fee_Initial_Overall', 'Required_User_Fee_OM_Overall', 'Required_User_Fee_Energy_Overall'] )
Spearmans = pd.DataFrame(rho_all, columns = ['Daily_Flushes', 'Flush_Volume', 'Membrane_Flux', 'Velocity_Crossflow', 'Pressure_Membrane', 'Fill_Fraction_GAC_Column', 'Lifetime_GAC', 'Power_Required_Treatment_EC', 'Current_EC', 'Power_Stirrer', 'Flowrate_Discharge', 'Pump_UF_Lifetime', 'Membrane_UF_Lifetime', 'Switch_Lifetime', 'Valve_UF_Lifetime', 'Electrode_EC_Lifetime', 'Stirrer_Lifetime', 'U_Pump_Misc_Lifetime', 'Discount_Rate', 'U_Pump_UF', 'U_Membrane_UF', 'U_Valve_UF', 'U_Tank_UF', 'U_Switch', 'U_Column_GAC', 'U_Stirrer_EC', 'U_Electrode_EC', 'U_Pump_Misc', 'US_Initial_Unit_Cost_UF', 'InCountry_Initial_Unit_Cost_UF', 'US_Initial_Unit_Cost_GAC', 'InCountry_Initial_Unit_Cost_GAC', 'US_Initial_Unit_Cost_EC', 'InCountry_Initial_Unit_Cost_EC', 'US_Initial_Unit_Cost_Controls', 'InCountry_Initial_Unit_Cost_Controls', 'US_Initial_Unit_Cost_Misc', 'InCountry_Initial_Unit_Cost_Misc', 'U_Media_GAC', 'PLR', 'U_Electricity', 'Monthly_Construction_Wage', 'Monthly_Maintenance_Wage', 'Income_Tax', 'Monthly_Work_Days', 'Construction_Time', 'Maintenance_Frequency', 'Maintenance_Time', 'Required_User_Fee_Overall', 'Required_User_Fee_Initial_Overall', 'Required_User_Fee_OM_Overall', 'Required_User_Fee_Energy_Overall'], index = ['Daily_Flushes', 'Flush_Volume', 'Membrane_Flux', 'Velocity_Crossflow', 'Pressure_Membrane', 'Fill_Fraction_GAC_Column', 'Lifetime_GAC', 'Power_Required_Treatment_EC', 'Current_EC', 'Power_Stirrer', 'Flowrate_Discharge', 'Pump_UF_Lifetime', 'Membrane_UF_Lifetime', 'Switch_Lifetime', 'Valve_UF_Lifetime', 'Electrode_EC_Lifetime', 'Stirrer_Lifetime', 'U_Pump_Misc_Lifetime', 'Discount_Rate', 'U_Pump_UF', 'U_Membrane_UF', 'U_Valve_UF', 'U_Tank_UF', 'U_Switch', 'U_Column_GAC', 'U_Stirrer_EC', 'U_Electrode_EC', 'U_Pump_Misc', 'US_Initial_Unit_Cost_UF', 'InCountry_Initial_Unit_Cost_UF', 'US_Initial_Unit_Cost_GAC', 'InCountry_Initial_Unit_Cost_GAC', 'US_Initial_Unit_Cost_EC', 'InCountry_Initial_Unit_Cost_EC', 'US_Initial_Unit_Cost_Controls', 'InCountry_Initial_Unit_Cost_Controls', 'US_Initial_Unit_Cost_Misc', 'InCountry_Initial_Unit_Cost_Misc', 'U_Media_GAC', 'PLR', 'U_Electricity', 'Monthly_Construction_Wage', 'Monthly_Maintenance_Wage', 'Income_Tax', 'Monthly_Work_Days', 'Construction_Time', 'Maintenance_Frequency', 'Maintenance_Time','Required_User_Fee_Overall', 'Required_User_Fee_Initial_Overall', 'Required_User_Fee_OM_Overall', 'Required_User_Fee_Energy_Overall'] )
modSpearmans = Spearmans.drop(['Required_User_Fee_Overall','Required_User_Fee_Initial_Overall','Required_User_Fee_OM_Overall','Required_User_Fee_Energy_Overall'])
df1 = modSpearmans['Required_User_Fee_Overall']
df2 = modSpearmans['Required_User_Fee_Initial_Overall']
df3 = modSpearmans['Required_User_Fee_OM_Overall']
df4 = modSpearmans['Required_User_Fee_Energy_Overall']
#%% Export
writer = pd.ExcelWriter(r'Results\Spearmans.xlsx', engine = 'xlsxwriter')
export_excel = df1.to_excel(writer, sheet_name = 'Total_Overall')
export_excel = df2.to_excel(writer, sheet_name = 'Initial_Construction_Overall')
export_excel = df3.to_excel(writer, sheet_name = 'OM_Replacement_Overall')
export_excel = df4.to_excel(writer, sheet_name = 'Energy_Overall')
writer.save()
#%%
writer = pd.ExcelWriter(r'Results\ResultsTEA.xlsx', engine = 'xlsxwriter')
export_excel = Results.to_excel(writer)
writer.save()