/
cost_equations_v2.sql
4124 lines (3391 loc) · 215 KB
/
cost_equations_v2.sql
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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
DROP FUNCTION IF EXISTS public.get_cost_expressions(integer, integer, boolean, character varying(64), character varying(64), character varying(64), character varying(64), character varying(64), character varying(64), character varying(64), character varying(64), character varying(64), double precision);
CREATE OR REPLACE FUNCTION public.get_cost_expressions(
int_control_strategy_id integer,
int_input_dataset_id integer,
use_override_dataset boolean,
inv_table_alias character varying(64),
control_measure_table_alias character varying(64),
equation_type_table_alias character varying(64),
control_measure_equation_table_alias character varying(64),
control_measure_efficiencyrecord_table_alias character varying(64),
control_strategy_measure_table_alias character varying(64),
gdplev_table_alias character varying(64),
inv_override_table_alias character varying(64),
gdplev_incr_table_alias character varying(64),
control_measure_sccs_table_alias character varying(64),
discount_rate double precision,
OUT annual_cost_expression text,
OUT capital_cost_expression text,
OUT operation_maintenance_cost_expression text,
OUT fixed_operation_maintenance_cost_expression text,
OUT variable_operation_maintenance_cost_expression text,
OUT annualized_capital_cost_expression text,
OUT computed_ctl_cost_per_ton_expression text,
OUT computed_cost_per_ton_expression text,
OUT actual_equation_type_expression text) AS $$
DECLARE
-- annualized_uncontrolled_emis_sql character varying;
inv_table_name character varying;
uncontrolled_emis_sql character varying;
emis_sql character varying;
percent_reduction_sql character varying;
remaining_emis_sql character varying;
emis_reduction_sql character varying;
get_strategty_ceff_equation_sql character varying;
measures_count integer := 0;
dataset_month smallint := 0;
no_days_in_month smallint := 31;
no_days_in_year smallint := 365;
use_cost_equations boolean;
is_point_table boolean := false;
has_design_capacity_columns boolean := false;
has_rpen_column boolean := false;
-- has_cpri_column boolean := false;
-- has_primary_device_type_code_column boolean := false;
ref_cost_year integer := 2013;
cost_year_deflator_gdp double precision := null;
ref_cost_year_deflator_gdp double precision := null;
deflator_gdp_adjustment_factor double precision := null;
cost_year integer := null;
inventory_year integer := null;
--FOR NOW CONVERT all stack flow rates to cfm, all applicable equations are expecting these units!
stkflow_expression text := '(' || public.get_stkflow_expression(inv_table_alias) || ' * 60)';
convert_design_capacity_expression text;
convert_design_capacity_expression_default_MW_units text;
capital_recovery_factor_expression text;
inv_ceff_expression varchar(69) := inv_table_alias || '.ceff';
deflator_gdp_adjustment_factor_expression text;
--support for flat file ds types...
dataset_type_name character varying(255) := '';
fips_expression character varying(64) := 'fips';
plantid_expression character varying(64) := 'plantid';
pointid_expression character varying(64) := 'pointid';
stackid_expression character varying(64) := 'stackid';
segment_expression character varying(64) := 'segment';
is_flat_file_inventory boolean := false;
inv_pct_red_expression character varying(256);
annualized_emis_sql character varying;
design_capacity_units_expression character varying(64) := 'design_capacity_unit_numerator,design_capacity_unit_denominator';
so2_emis_sql text;
--type 14 variables
t14_use_equation text;
t14_fa text;
t14_fd text;
t14_noducts text;
t14_cpm text;
t14_tci text;
t14_tac text;
--type 15 variables
t15_use_equation text;
t15_fa text;
t15_noducts text;
t15_ec1 text;
t15_ec2 text;
t15_pm_emis_rate text;
t15_tci text;
t15_tac text;
--type 16 variables
t16_use_equation text;
t16_fa text;
t16_noscrubbers text;
t16_so2_mole_conc text;
t16_tci text;
t16_tac text;
--type 17 variables
t17_use_equation text;
t17_fa text;
t17_fd text;
t17_noducts text;
t17_pm_conc text;
t17_so2_conc text;
t17_tci text;
t17_tac text;
--type 18 variables
t18_use_equation text;
t18_fa text;
t18_fd text;
t18_so2_conc text;
t18_tci text;
t18_tac text;
--type 19 variables
t19_use_equation text;
t19_fa text;
t19_fd text;
t19_noducts text;
t19_so2_conc text;
t19_tci text;
t19_tac text;
BEGIN
-- see if control strategy has only certain measures specified
SELECT count(id)
FROM emf.control_strategy_measures
where control_strategy_measures.control_strategy_id = int_control_strategy_id
INTO measures_count;
-- get the input dataset info
select lower(i.table_name)
from emf.internal_sources i
where i.dataset_id = int_input_dataset_id
into inv_table_name;
--get dataset type name
select dataset_types."name"
from emf.datasets
inner join emf.dataset_types
on datasets.dataset_type = dataset_types.id
where datasets.id = int_input_dataset_id
into dataset_type_name;
--if Flat File 2010 Types then change primary key field expression variables...
IF dataset_type_name = 'Flat File 2010 Point' or dataset_type_name = 'Flat File 2010 Nonpoint' or dataset_type_name = 'Flat File 2010 Merged' THEN
fips_expression := 'region_cd';
plantid_expression := 'facility_id';
pointid_expression := 'unit_id';
stackid_expression := 'rel_point_id';
segment_expression := 'process_id';
inv_ceff_expression := 'ann_pct_red';
design_capacity_units_expression := 'design_capacity_units';
is_flat_file_inventory := true;
convert_design_capacity_expression := public.get_convert_design_capacity_expression(inv_table_alias, control_measure_sccs_table_alias, '');
convert_design_capacity_expression_default_MW_units := public.get_convert_design_capacity_expression(inv_table_alias, control_measure_sccs_table_alias, 'MW');
ELSE
fips_expression := 'fips';
plantid_expression := 'plantid';
pointid_expression := 'pointid';
stackid_expression := 'stackid';
segment_expression := 'segment';
inv_ceff_expression := 'ceff';
design_capacity_units_expression := 'design_capacity_unit_numerator,design_capacity_unit_denominator';
convert_design_capacity_expression := public.get_convert_design_capacity_expression(inv_table_alias, control_measure_sccs_table_alias, '', '');
convert_design_capacity_expression_default_MW_units := public.get_convert_design_capacity_expression(inv_table_alias, control_measure_sccs_table_alias, 'MW', '');
END If;
-- get target pollutant, inv filter, and county dataset info if specified
SELECT cs.use_cost_equations,
cs.cost_year,
cs.analysis_year
FROM emf.control_strategies cs
where cs.id = int_control_strategy_id
INTO use_cost_equations,
cost_year,
inventory_year;
capital_recovery_factor_expression := public.get_capital_recovery_factor_expression(control_measure_table_alias, control_measure_efficiencyrecord_table_alias, discount_rate);
-- see if there are point specific columns in the inventory
is_point_table := public.check_table_for_columns(inv_table_name, '' || plantid_expression || ',' || pointid_expression || ',' || stackid_expression || ',' || segment_expression || '', ',');
-- see if there is a rpen column in the inventory
has_rpen_column := public.check_table_for_columns(inv_table_name, 'rpen', ',');
-- see if there is design capacity columns in the inventory
has_design_capacity_columns := public.check_table_for_columns(inv_table_name, 'design_capacity,' || design_capacity_units_expression, ',');
-- see if there is plant column in the inventory
--has_cpri_column := public.check_table_for_columns(inv_table_name, 'cpri', ',');
-- see if there is primary_device_type_code column in the inventory
--has_primary_device_type_code_column := public.check_table_for_columns(inv_table_name, 'primary_device_type_code', ',');
-- get month of the dataset, 0 (Zero) indicates an annual inventory
select public.get_dataset_month(int_input_dataset_id)
into dataset_month;
select public.get_days_in_month(dataset_month::smallint, inventory_year::smallint)
into no_days_in_month;
select public.get_days_in_year(inventory_year::smallint)
into no_days_in_year;
-- get gdp price deflator values
SELECT deflator_gdp
FROM reference.gdplev
where annual = cost_year
INTO cost_year_deflator_gdp;
SELECT deflator_gdp
FROM reference.gdplev
where annual = ref_cost_year
INTO ref_cost_year_deflator_gdp;
deflator_gdp_adjustment_factor := cost_year_deflator_gdp / ref_cost_year_deflator_gdp;
deflator_gdp_adjustment_factor_expression := '(' || deflator_gdp_adjustment_factor || ' * ' || ref_cost_year_deflator_gdp || ' / cast(' || gdplev_table_alias || '.deflator_gdp as double precision))';
IF NOT is_flat_file_inventory THEN
inv_pct_red_expression := 'coalesce(' || inv_table_alias || '.ceff, ' || inv_override_table_alias || '.ceff) * coalesce(coalesce(' || inv_table_alias || '.reff, ' || inv_override_table_alias || '.reff) / 100, 1.0)' || case when has_rpen_column then ' * coalesce(coalesce(' || inv_table_alias || '.rpen, ' || inv_override_table_alias || '.rpen) / 100, 1.0)' else '' end;
emis_sql := public.get_ann_emis_expression(inv_table_alias, no_days_in_month);
annualized_emis_sql := case when dataset_month != 0 then 'coalesce(inv.avd_emis * ' || no_days_in_year || ', inv.ann_emis)' else 'inv.ann_emis' end;
ELSE
inv_pct_red_expression := 'coalesce(inv.ann_pct_red, ' || inv_override_table_alias || '.ceff)';
emis_sql := 'inv.ann_value';
annualized_emis_sql := 'inv.ann_value';
END IF;
so2_emis_sql := inv_override_table_alias || '.so2_ann_value';
-- uncontrolled_emis_sql := public.get_uncontrolled_ann_emis_expression(inv_table_alias, no_days_in_month, inv_override_table_alias, has_rpen_column);
uncontrolled_emis_sql := public.get_uncontrolled_emis_expression(inv_pct_red_expression, emis_sql);
-- emis_sql := public.get_ann_emis_expression(inv_table_alias, no_days_in_month);
-- build sql that calls ceff SQL equation
/* get_strategty_ceff_equation_sql := public.get_ceff_equation_expression(
int_input_dataset_id, -- int_input_dataset_id
inventory_year, -- inventory_year
inv_table_alias, --inv_table_alias character varying(64),
control_measure_efficiencyrecord_table_alias);*/
get_strategty_ceff_equation_sql := public.get_ceff_equation_expression(
annualized_emis_sql,
inv_table_alias,
control_measure_efficiencyrecord_table_alias,
is_point_table);
/* percent_reduction_sql := public.get_control_percent_reduction_expression(int_input_dataset_id,
inventory_year,
inv_table_alias,
no_days_in_month,
inv_override_table_alias,
measures_count,
control_strategy_measure_table_alias,
control_measure_efficiencyrecord_table_alias);*/
percent_reduction_sql := public.get_control_percent_reduction_expression(
emis_sql,
inv_table_alias,
control_measure_efficiencyrecord_table_alias,
is_point_table,
measures_count,
control_strategy_measure_table_alias);
-- percent_reduction_sql := 'er.efficiency * ' || case when measures_count > 0 then 'coalesce(' || control_strategy_measure_table_alias || '.rule_effectiveness, er.rule_effectiveness)' else 'er.rule_effectiveness' end || ' * ' || case when measures_count > 0 then 'coalesce(' || control_strategy_measure_table_alias || '.rule_penetration, er.rule_penetration)' else 'er.rule_penetration' end || ' / 100 / 100';
/* remaining_emis_sql := public.get_remaining_emis_expression(int_input_dataset_id,
inventory_year,
inv_table_alias,
no_days_in_month,
inv_override_table_alias,
measures_count,
control_strategy_measure_table_alias,
control_measure_efficiencyrecord_table_alias,
has_rpen_column);*/
remaining_emis_sql := public.get_remaining_emis_expression(
emis_sql,
inv_pct_red_expression,
inv_table_alias,
control_measure_efficiencyrecord_table_alias,
is_point_table,
measures_count,
control_strategy_measure_table_alias);
/* emis_reduction_sql := public.get_emis_reduction_expression(int_input_dataset_id,
inventory_year,
inv_table_alias,
no_days_in_month,
inv_override_table_alias,
measures_count,
control_strategy_measure_table_alias,
control_measure_efficiencyrecord_table_alias,
has_rpen_column);*/
emis_reduction_sql := public.get_emis_reduction_expression(
emis_sql,
inv_pct_red_expression,
percent_reduction_sql,
control_measure_efficiencyrecord_table_alias);
-- '(case when coalesce(' || control_measure_efficiencyrecord_table_alias || '.existing_measure_abbr, '''') <> '''' or ' || control_measure_efficiencyrecord_table_alias || '.existing_dev_code <> 0 then ' || emis_sql || ' else ' || uncontrolled_emis_sql || ' end * ' || percent_reduction_sql || ' / 100)::double precision';
/*raise notice '%', uncontrolled_emis_sql;
raise notice '%', emis_sql;
raise notice '%', get_strategty_ceff_equation_sql;
raise notice '%', percent_reduction_sql;
raise notice '%', remaining_emis_sql;
raise notice '%', emis_reduction_sql;
*/
-- TYPE 14 definition Fabric Filter ---------------
/*
F_a=(V_Exhaust )(DC)/60 Equation 1
Where:
Fa = Exhaust flowrate, ACFM
VExhaust = Relative Exhaust Volume, ACF/MMBtu --> ' || control_measure_equation_table_alias || '.value1
DC = Design Capacity of Unit, MMBtu/hr --> convert_design_capacity_expression
t14_fa := '(' || control_measure_equation_table_alias || '.value5 * (' || convert_design_capacity_expression || ') / 60.0 || ')';
F_a = ' || control_measure_equation_table_alias || '.value5 * (' || convert_design_capacity_expression || ') / 60.0
F_d=F_a ((460+68)/(460+T))(1-%_Moist/100) Equation 2
t14_fd := '((' || t14_fa || ') * ((460.0 + 68.0)/(460.0 + ' || inv_table_alias || '.stktemp)) * (1.0 - ' || control_measure_equation_table_alias || '.value2 / 100.0))';
F_d = (' || control_measure_equation_table_alias || '.value5 * (' || convert_design_capacity_expression || ') / 60.0) * ((460.0 + 68.0)/(460.0 + ' || inv_table_alias || '.stktemp)) * (1.0 - ' || control_measure_equation_table_alias || '.value2 / 100.0)
Where:
Fd = Exhaust flowrate, DSCFM
Fa = Exhaust flowrate, ACFM
T = Assumed Stack Gas Temperature, °F --> ' || inv_table_alias || '.stktemp
%Moist = Assumed Stack Gas Moisture Content, % --> ' || control_measure_equation_table_alias || '.value1
t14_noducts := '(case when ' || t14_fd || ' <= 154042.0 then 1 else ceiling(' || t14_fd || ' / 154042.0) end)';
TCI=(105.91)(F_d )+(699754.7)+[(0.560) (√(F_a )/#_Ducts )^2 ]+[(1096.141) e^(0.017)(√(F_a )/#_Ducts ) ]+[(33.977) e^(0.014)(√(F_a )/#_Ducts ) ]
t14_tci := '((105.91) * (' || t14_fd || ')+(699754.7)+((0.560) * (sqrt(' || t14_fa || ')/' || t14_noducts || ' )^2) + ((1096.141) * exp((0.017) * (sqrt(' || t14_fa || ')/' || t14_noducts || ' ))) + ((33.977) * exp((0.014) * (sqrt(' || t14_fa || ')/' || t14_noducts || ' ))))';
Where:
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
#Ducts = If Fd ≤ 154042, #Ducts = 1;
If Fd > 154042, #Ducts = Fd / 154042
select case when 154044.0 <= 154042.0 then 1 else ceiling(1540404.0 / 154042.0) end
B-1b: TOTAL ANNUALIZED COSTS (TAC)
TAC=[(17.44)(〖Op〗_Hrs )]+{(TCI)[(0.072)+(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1))]}+{(F_a )[(4.507)+(0.0000124)(〖Op〗_Hrs )-(4.184)(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1))]}+{(F_d )(〖Op〗_Hrs )[(0.00376)+(0.00181)(C_PM )]}
t14_tac := '[(17.44)(' || inv_table_alias || '.annual_avg_hours_per_year || ')]+{(' || t14_tci || ')[(0.072)+(' || capital_recovery_factor_expression || ')]}+{(' || t14_fa || ')[(4.507)+(0.0000124)(' || inv_table_alias || '.annual_avg_hours_per_year || ')-(4.184)(' || capital_recovery_factor_expression || ')]}+{(' || t14_fd || ')(' || inv_table_alias || '.annual_avg_hours_per_year || ')[(0.00376)+(0.00181)(C_PM )]}';
Where:
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
OpHrs = Annual operating hours of unit (hrs/yr)
TCI = Total Capital Investment ($)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
CPM = Concentration of PM in stack gas, grains per dry standard cubic foot (gr/dscf)
i = Interest rate expressed as a fraction of 1 (percentage divided by 100)
EqLife = Estimated equipment life, years
Equation Type Definition:
Measure Specific Equation Type Variable Inputs: value1 --> % Moisture
Inventory Inputs:
design capacity
design capacity units
stack temperature
stack flow rate (in cfm)
operating hours (in hrs/yr)
Questions:
Is PM emission rate based on pm2_5 or pm10?
Is PM emission rate based on measure inlet or outlet rate?
*/
t14_use_equation := 'coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 14'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 and coalesce(' || inv_table_alias || '.stktemp, 0) <> 0 and coalesce(' || stkflow_expression || ', 0) <> 0 and coalesce(' || inv_table_alias || '.annual_avg_hours_per_year, 0.0) <> 0.0';
--use brenda shines approach
t14_fa := '(' || stkflow_expression || ')';
t14_fd := '((' || t14_fa || ') * ((460.0 + 68.0)/(460.0 + ' || inv_table_alias || '.stktemp)) * (1.0 - ' || control_measure_equation_table_alias || '.value1 / 100.0))';
t14_noducts := '(case when ' || t14_fd || ' <= 154042.0 then 1 else round(' || t14_fd || ' / 154042.0) end)';
t14_cpm := '(' || emis_sql || ') * 1.725 * 15.4323584 / (' || t14_fd || ')'; /*1 ton/year = 1.725 grams/minute (from David) 1 gram = 15.4323584 grains */
t14_tci := '((105.91) * (' || t14_fd || ')+(699754.7)+((0.560) * (sqrt(' || t14_fa || ')/' || t14_noducts || ' )^2) + ((1096.141) * exp((0.017) * (sqrt(' || t14_fa || ')/' || t14_noducts || ' ))) + ((33.977) * exp((0.014) * (sqrt(' || t14_fa || ')/' || t14_noducts || ' ))))';
t14_tac := '((17.44) * (' || inv_table_alias || '.annual_avg_hours_per_year))+((' || t14_tci || ') * ((0.072)+(' || capital_recovery_factor_expression || ')))+((' || t14_fa || ') * ((4.507)+(0.0000124) * (' || inv_table_alias || '.annual_avg_hours_per_year)-(4.184) * (' || capital_recovery_factor_expression || ')))+((' || t14_fd || ') * (' || inv_table_alias || '.annual_avg_hours_per_year) * ((0.00376)+(0.00181) * (' || t14_cpm || ')))';
-- TYPE 15 definition Electrostatic Precipitator ---------------
/*
TCI={(12.265)(〖EC〗_1 ) [(5.266)(F_a )]^(〖EC〗_2 ) }+[(0.784)(F_a/#_Ducts )]+(#_Ducts ){[(2237.13)(e^(0.017)(√(F_a )/#_Ducts ) )]+[(69.345)(e^(0.014)(√(F_a )/#_Ducts ) )]+(17588.69)}
Where:
EC1 = First equipment cost factor for ESP;
If Fa ≥ 9495, EC1 = 57.87;
If Fa < 9495, EC1 = 614.55
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
EC2 = Second equipment cost factor for ESP;
If Fa ≥ 9495, EC2 = 0.8431;
If Fa < 9495, EC2 = 0.6276
#Ducts = If Fa < 308084, #Ducts = 1;
If 308084 ≤ Fa < 462126, #Ducts = 2;
If 462126 ≤ Fa < 616168, #Ducts = 3;
If Fa ≥ 616168, #Ducts = 4
B-2b: TOTAL ANNUALIZED COSTS (TAC)
TAC=[(10.074)(〖Op〗_Hrs )]+[(0.052)(F_a )]+{(0.00656)(1.04+(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1)))((〖EC〗_1 ) [(5.266)(F_a )]^(〖EC〗_2 ) )}+[(0.021)(〖Op〗_Hrs )(E_PM )(DC)]+{(0.0000117)(F_a )(〖Op〗_Hrs )[(1.895)+((479.85) (1/√(F_a ))^1.18 )]}+[(0.000715)(〖Op〗_Hrs )(F_a )]+{(0.04+(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1)))(#_Ducts )[(0.783) (√(F_a )/#_Ducts )^2+(2237.44)(e^(0.0165)(√(F_a )/#_Ducts ) )+(69.355)(e^(0.0140)(√(F_a )/#_Ducts ) )+(17591.15)]}
Where:
OpHrs = Annual operating hours of unit (hrs/yr)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
i = Interest rate expressed as a fraction of 1 (percentage divided by 100)
EqLife = Estimated equipment life, years
EC1 = First equipment cost factor for ESP;
If Fa ≥ 9495, EC1 = 57.87;
If Fa < 9495, EC1 = 614.55
EC2 = Second equipment cost factor for ESP;
If Fa ≥ 9495, EC2 = 0.8431;
If Fa < 9495, EC2 = 0.6276
EPM = PM emission rate, pounds per million British thermal units (lb/MMBtu)
DC = Design capacity of boiler, million British thermal units per hour (MMBtu/hr)
#Ducts = If Fa < 308084, #Ducts = 1;
If 308084 ≤ Fa < 462126, #Ducts = 2;
If 462126 ≤ Fa < 616168, #Ducts = 3;
If Fa ≥ 616168, #Ducts = 4
Equation Type Definition:
Measure Specific Equation Type Variable Inputs: value1 --> % Moisture
Inventory Inputs:
design capacity
design capacity units
stack temperature
stack flow rate (in cfm)
operating hours (in hrs/yr)
Questions:
Is PM emission rate based on pm2_5 or pm10?
Is PM emission rate based on measure inlet or outlet rate?
*/
t15_use_equation := 'coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 15'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 and coalesce(' || inv_table_alias || '.stktemp, 0) <> 0 and coalesce(' || stkflow_expression || ', 0) <> 0 and coalesce(' || inv_table_alias || '.annual_avg_hours_per_year, 0.0) <> 0.0';
--use brenda shines approach
t15_fa := '(' || stkflow_expression || ')';
t15_ec1 := '(case when ' || t15_fa || ' < 9495.0 then 614.55 else 57.87 end)';
t15_ec2 := '(case when ' || t15_fa || ' < 9495.0 then 0.6276 else 0.8431 end)';
t15_noducts := '(case when ' || t15_fa || ' < 308084.0 then 1 when ' || t15_fa || ' >= 308084.0 and ' || t15_fa || ' < 462126.0 then 2 when ' || t15_fa || ' >= 462126.0 and ' || t15_fa || ' < 616168.0 then 3 else 4 end)';
t15_pm_emis_rate := '(' || emis_sql || ') * 2000.0 / 365.0 / 24.0 / (3.412 * ' || convert_design_capacity_expression || ')';
t15_tci := '((12.265) * (' || t15_ec1 || ') * ((5.266) * (' || t15_fa || ' ))^(' || t15_ec2 || ') )+((0.784) * (' || t15_fa || '/' || t15_noducts || '))+(' || t15_noducts || ') * (((2237.13) * (exp((0.017) * (sqrt(' || t15_fa || ')/' || t15_noducts || '))))+((69.345) * (exp((0.014) * (sqrt(' || t15_fa || ')/' || t15_noducts || '))))+(17588.69))';
t15_tac := '((10.074) * (' || inv_table_alias || '.annual_avg_hours_per_year))+((0.052) * (' || t15_fa || '))+((0.00656) * (1.04+((' || capital_recovery_factor_expression || '))) * ((' || t15_ec1 || ') * ((5.266) * (' || t15_fa || '))^(' || t15_ec2 || ') ))+((0.021) * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t15_pm_emis_rate || ') * (3.412 * ' || convert_design_capacity_expression || '))+((0.0000117) * (' || t15_fa || ') * (' || inv_table_alias || '.annual_avg_hours_per_year) * ((1.895)+((479.85) * (1/sqrt(' || t15_fa || '))^1.18 )))+((0.000715) * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t15_fa || '))+((0.04+((' || capital_recovery_factor_expression || '))) * (' || t15_noducts || ') * ((0.783) * (sqrt(' || t15_fa || ')/(' || t15_noducts || '))^2+(2237.44) * (exp((0.0165) * (sqrt(' || t15_fa || ')/(' || t15_noducts || '))))+(69.355) * (exp((0.0140) * (sqrt(' || t15_fa || ')/(' || t15_noducts || '))))+(17591.15)))';
-- TYPE 16 definition WET SCRUBBER ---------------
/*
APPENDIX B-3: WET SCRUBBER COST EQUATIONS
________________________________________
B-3a: TOTAL CAPITAL INVESTMENT (TCI)
TCI=[(2.88)(#_Scrub )(F_a )]+[(1076.54)(#_Scrub ) √((F_a ) )]+[(9.759)(F_a )]+[(360.463) √((F_a ) )]
Where:
#Scrub = If Fa < 149602, #Scrub = 1;
If 149602 ≤ Fa < 224403, #Scrub = 2;
If 224403 ≤ Fa < 299204, #Scrub = 3;
If 299204 ≤ Fa < 374005, #Scrub = 4;
If Fa ≥ 374005, #Scrub = 5
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
B-3b: TOTAL ANNUALIZED COSTS (TAC)
TAC=[(#_Scrub )(TCI)(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1))]+[(0.04)(TCI)]+{(20.014)(#_Scrub )(F_a )(〖Op〗_Hrs )[C_SO2-(C_SO2 )((100-98)/(100-(98)(C_SO2 ) ))]}+[(16.147)(#_Scrub )(〖Op〗_Hrs )]+{(0.0000117)(F_a )(〖Op〗_Hrs )(#_Scrub )[((479.85) (1/√(F_a ))^1.18 )+(6.895)]}+[(0.0000133)(〖Op〗_Hrs )(#_Scrub )(F_a )]
Where:
#Scrub = If Fa < 149602, #Scrub = 1;
If 149602 ≤ Fa < 224403, #Scrub = 2;
If 224403 ≤ Fa < 299204, #Scrub = 3;
If 299204 ≤ Fa < 374005, #Scrub = 4;
If Fa ≥ 374005, #Scrub = 5
TCI = Total Capital Investment ($)
i = Interest rate expressed as a fraction of 1 (percentage divided by 100)
EqLife = Estimated equipment life, years
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
CSO2 = Mole fraction of SO2 in exhaust gas
OpHrs = Annual operating hours of unit (hrs/yr)
CSO2 calculation:
Calculate volume (ft3/lb-mole) of NOx in gaseous form under standard conditions (60 F, 1 atm) using Ideal Gas Law, pV = nRT or V/n = RT/p, where:
V = volume in ft3
n = molecular weight of SO2 (64.06 lb/lb-mole)
R = gas constant (0.7302 atm-ft3/lb-mole R)
T = absolute temperature in Rankin (F + 460) = 60 + 460 = (520 R)
p = pressure in atmospheres (1 atm)
Ideal Gas Law approximates the volume of a gas under certain conditions.
V/n = (0.7302 x 520) / (1) = 379.7 ft3/lb-mole
Calculate SO2 emissions (lb-mole/yr):
n = 53.33 tons/yr SO2 x 2000 lb/ton x 1 lb-mole / 64.06 lbs SO2 = 1,665 lb-mole/yr
Convert SO2 emissions (lb-mole/yr) to SO2 volumetric flowrate (ft3/min):
1,665 lb-mole/yr x 1 yr/8736 hrs x 1 hr/60 min x 379.7ft3/lb-mole = 1.206 ft3/min
Calculate outlet concentration of SO2 (ppmv):
ppmv SO2 = ( SO2 emissions (ft3/min) / Stack vol flow rate scfm ) x 10^6
ppmv SO2 = ( 1.206 ft3/min / 20,170 ft3/min ) x 10^6 = 59.79 ppmv
mole fraction SO2 = 59.79 ppmv / 10^6 = 5.979e-5 mole fraction SO2
Equation Type Definition:
Measure Specific Equation Type Variable Inputs: NONE
Inventory Inputs:
stack flow rate (in cfm)
operating hours (in hrs/yr)
Questions:
Is SO2 concentration based on measure inlet or outlet rate?
*/
t16_use_equation := 'coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 16'' and coalesce(' || stkflow_expression || ', 0) <> 0 and coalesce(' || inv_table_alias || '.annual_avg_hours_per_year, 0.0) <> 0.0';
t16_fa := '(' || stkflow_expression || ')';
t16_noscrubbers := '(case when ' || t16_fa || ' < 149602.0 then 1 when ' || t16_fa || ' >= 149602.0 and ' || t16_fa || ' < 224403.0 then 2 when ' || t16_fa || ' >= 224403.0 and ' || t16_fa || ' < 299204.0 then 3 when ' || t16_fa || ' >= 299204.0 and ' || t16_fa || ' < 374005.0 then 4 else 5 end)';
t16_so2_mole_conc := '((' || emis_sql || ') * 2000.0 / (64.06) / ' || inv_table_alias || '.annual_avg_hours_per_year / 60 * ((0.7302 * 520) / (1.0)) / ( (' || t16_fa || ') * 520 / ((' || inv_table_alias || '.stktemp) + 460.0)))';
t16_tci := '((2.88) * (' || t16_noscrubbers || ') * (' || t16_fa || '))+((1076.54) * (' || t16_noscrubbers || ') * sqrt(' || t16_fa || '))+((9.759) * (' || t16_fa || '))+((360.463) * sqrt(' || t16_fa || '))';
t16_tac := '((' || t16_noscrubbers || ') * (' || t16_tci || ') * (' || capital_recovery_factor_expression || '))+((0.04) * (' || t16_tci || '))+((20.014) * (' || t16_noscrubbers || ') * (' || t16_fa || ') * (' || inv_table_alias || '.annual_avg_hours_per_year) * ((' || t16_so2_mole_conc || ')-(' || t16_so2_mole_conc || ') * ((100.0-98.0)/(100.0-(98.0) * (' || t16_so2_mole_conc || ') ))))+((16.147) * (' || t16_noscrubbers || ') * (' || inv_table_alias || '.annual_avg_hours_per_year))+((0.0000117) * (' || t16_fa || ') * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t16_noscrubbers || ') * (((479.85) * (1/sqrt(' || t16_fa || '))^1.18 )+(6.895)))+((0.0000133) * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t16_noscrubbers || ') * (' || t16_fa || '))';
-- TYPE 17 definition WET SCRUBBER ---------------
/*
APPENDIX B-4: DRY INJECTION/FABRIC FILTER SYSTEM (DIFF) COST EQUATIONS
________________________________________
B-4a: TOTAL CAPITAL INVESTMENT (TCI)
TCI=[(143.76)(F_d )]+[(0.610) (√(F_a )/#_Ducts )^2 ]+[(1757.65) e^(0.017)(√(F_a )/#_Ducts ) ]+[(59.973) e^(0.014)(√(F_a )/#_Ducts ) ]+(931911.04)
Where:
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
#Ducts = If Fd ≤ 154042, #Ducts = 1;
If Fd > 154042, #Ducts = Fd / 154042
B-4b: TOTAL ANNUALIZED COSTS (TAC)
TAC=[(0.00162)(〖Op〗_Hrs )(F_d )]+[(17.314)(〖Op〗_Hrs )]+[(0.00000105)(C_SO2 )(F_d )(〖Op〗_Hrs )]+[(0.0000372)(〖Op〗_Hrs )(F_a )]+[(0.000181)(〖Op〗_Hrs )(C_PM )(F_d )]+[(0.847)(1-(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1)))(F_a )]+[(0.04)+(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1))]{[(0.032)(TCI)]+[(0.606) (√(F_a )/#_Ducts )^2 ]+[(1757.65) e^(0.017)(√(F_a )/#_Ducts ) ]+[(53.973) e^(0.014)(√(F_a )/#_Ducts ) ]+(13689.81)}
Where:
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
OpHrs = Annual operating hours of unit (hrs/yr)
CSO2 = Concentration of SO2 in stack gas, dry parts per million by volume (ppmvd)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
CPM = Concentration of PM in stack gas, grains per dry standard cubic foot (gr/dscf)
i = Interest rate expressed as a fraction of 1 (percentage divided by 100)
EqLife = Estimated equipment life, years
#Ducts = If Fd ≤ 154042, #Ducts = 1;
If Fd > 154042, #Ducts = Fd / 154042
Equation Type Definition:
Measure Specific Equation Type Variable Inputs: value1 --> % Moisture
Inventory Inputs:
stack temperature
stack flow rate (in cfm)
operating hours (in hrs/yr)
Questions:
Is SO2 and PM (also which PM) concentration based on measure inlet or outlet rate?
*/
t17_use_equation := 'coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 17'' and coalesce(' || inv_table_alias || '.stktemp, 0) <> 0 and coalesce(' || stkflow_expression || ', 0) <> 0 and coalesce(' || inv_table_alias || '.annual_avg_hours_per_year, 0.0) <> 0.0';
--use brenda shines approach
t17_fa := '(' || stkflow_expression || ')';
t17_fd := '((' || t17_fa || ') * ((460.0 + 68.0)/(460.0 + ' || inv_table_alias || '.stktemp)) * (1.0 - ' || control_measure_equation_table_alias || '.value1 / 100.0))';
t17_noducts := '(case when ' || t17_fd || ' <= 154042.0 then 1 else round(' || t17_fd || ' / 154042.0) end)';
t17_pm_conc := '(' || emis_sql || ') * 1.725 * 15.4323584 / (' || t17_fd || ')'; /*1 ton/year = 1.725 grams/minute (from David) 1 gram = 15.4323584 grains */
t17_so2_conc := '((' || so2_emis_sql || ') * 2000.0 / (64.06) / ' || inv_table_alias || '.annual_avg_hours_per_year / 60 * ((0.7302 * 520) / (1.0)) / ( (' || t17_fa || ') * 520 / ((' || inv_table_alias || '.stktemp) + 460.0))) * 10^6';
t17_tci := '((143.76) * (' || t17_fd || '))+((0.610) * (sqrt(' || t17_fa || ')/' || t17_noducts || ')^2 )+((1757.65) * exp((0.017) * (sqrt(' || t17_fa || ')/' || t17_noducts || ')))+((59.973) * exp((0.014) * (sqrt(' || t17_fa || ')/' || t17_noducts || ')))+(931911.04)';
t17_tac := '((0.00162) * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t17_fd || '))+((17.314) * (' || inv_table_alias || '.annual_avg_hours_per_year))+((0.00000105) * (' || t17_so2_conc || ' ) * (' || t17_fd || ') * (' || inv_table_alias || '.annual_avg_hours_per_year))+((0.0000372) * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t17_fa || '))+((0.000181) * (' || inv_table_alias || '.annual_avg_hours_per_year) * (' || t17_pm_conc || ') * (' || t17_fd || '))+((0.847) * (1-(' || capital_recovery_factor_expression || ')) * (' || t17_fa || '))+((0.04)+(' || capital_recovery_factor_expression || ')) * (((0.032) * (' || t17_tci || '))+((0.606) * (sqrt(' || t17_fa || ')/' || t17_noducts || ')^2 )+((1757.65) * exp((0.017) * (sqrt(' || t17_fa || ')/' || t17_noducts || ')))+((53.973) * exp((0.014) * (sqrt(' || t17_fa || ')/' || t17_noducts || ')))+(13689.81))';
-- TYPE 18 definition INCREASED CAUSTIC INJECTION RATE FOR EXISTING DRY INJECTION CONTROL ---------------
/*
APPENDIX B-5: INCREASED CAUSTIC INJECTION RATE FOR EXISTING DRY INJECTION CONTROL COST EQUATIONS
________________________________________
B-5a: TOTAL CAPITAL INVESTMENT (TCI)
TCI=0
Where:
N/A
B-5b: TOTAL ANNUALIZED COSTS (TAC)
TAC=(0.00000387)(C_SO2 )(F_d )(〖Op〗_Hrs )
Where:
CSO2 = Concentration of SO2 in stack gas, dry parts per million by volume (ppmvd)
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
OpHrs = Annual operating hours of unit (hrs/yr)
Equation Type Definition:
Measure Specific Equation Type Variable Inputs: value1 --> % Moisture
Inventory Inputs:
stack temperature
stack flow rate (in cfm)
operating hours (in hrs/yr)
Questions:
Is SO2 concentration based on measure inlet or outlet rate?
*/
t18_use_equation := 'coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 18'' and coalesce(' || inv_table_alias || '.stktemp, 0) <> 0 and coalesce(' || stkflow_expression || ', 0) <> 0 and coalesce(' || inv_table_alias || '.annual_avg_hours_per_year, 0.0) <> 0.0';
--use brenda shines approach
t18_fa := '(' || stkflow_expression || ')';
t18_fd := '((' || t18_fa || ') * ((460.0 + 68.0)/(460.0 + ' || inv_table_alias || '.stktemp)) * (1.0 - ' || control_measure_equation_table_alias || '.value1 / 100.0))';
t18_so2_conc := '((' || emis_sql || ') * 2000.0 / (64.06) / ' || inv_table_alias || '.annual_avg_hours_per_year / 60 * ((0.7302 * 520) / (1.0)) / ( (' || t18_fa || ') * 520 / ((' || inv_table_alias || '.stktemp) + 460.0))) * 10^6';
t18_tci := '0.0';
t18_tac := '(0.00000387) * (' || t18_so2_conc || ') * (' || t18_fd || ') * (' || inv_table_alias || '.annual_avg_hours_per_year)';
-- TYPE 19 definition SPRAY DRYER ABSORBER ---------------
/*
APPENDIX B-6: SPRAY DRYER ABSORBER COST EQUATIONS
________________________________________
B-6a: TOTAL CAPITAL INVESTMENT (TCI)
TCI=[(143.76)(F_d )]+[(0.610) (√(F_a )/#_Ducts )^2 ]+[(17412.26) e^(0.017)(√(F_a )/#_Ducts ) ]+[(53.973) e^(0.014)(√(F_a )/#_Ducts ) ]+(931911.04)
Where:
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
#Ducts = If Fd ≤ 154042, #Ducts = 1;
If Fd > 154042, #Ducts = Fd / 154042
B-6b: TOTAL ANNUALIZED COSTS (TAC)
TAC=(〖Op〗_Hrs ){[(0.00162)(F_d )]+[(0.000000684)(C_SO2 )(F_d )]+[(0.0000372)(F_a )]+(21.157)}+{[0.072+(((i) (1+i)^(〖Eq〗_Life ))/((1+i)^(〖Eq〗_Life )-1))](TCI)}
Where:
Fd = Exhaust Flowrate, dry standard cubic feet per minute (DSCFM)
Fa = Exhaust Flowrate, actual cubic feet per minute (ACFM)
OpHrs = Annual operating hours of unit (hrs/yr)
CSO2 = Concentration of SO2 in stack gas, dry parts per million by volume (ppmvd)
TCI = Total Capital Investment ($)
i = Interest rate expressed as a fraction of 1 (percentage divided by 100)
EqLife = Estimated equipment life, years
Equation Type Definition:
Measure Specific Equation Type Variable Inputs: value1 --> % Moisture
Inventory Inputs:
stack temperature
stack flow rate (in cfm)
operating hours (in hrs/yr)
Questions:
Is SO2 concentration based on measure inlet or outlet rate?
*/
t19_use_equation := 'coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 19'' and coalesce(' || inv_table_alias || '.stktemp, 0) <> 0 and coalesce(' || stkflow_expression || ', 0) <> 0 and coalesce(' || inv_table_alias || '.annual_avg_hours_per_year, 0.0) <> 0.0';
--use brenda shines approach
t19_fa := '(' || stkflow_expression || ')';
t19_fd := '((' || t19_fa || ') * ((460.0 + 68.0)/(460.0 + ' || inv_table_alias || '.stktemp)) * (1.0 - ' || control_measure_equation_table_alias || '.value1 / 100.0))';
t19_noducts := '(case when ' || t19_fd || ' <= 154042.0 then 1 else round(' || t19_fd || ' / 154042.0) end)';
t19_so2_conc := '((' || emis_sql || ') * 2000.0 / (64.06) / ' || inv_table_alias || '.annual_avg_hours_per_year / 60 * ((0.7302 * 520) / (1.0)) / ( (' || t19_fa || ') * 520 / ((' || inv_table_alias || '.stktemp) + 460.0))) * 10^6';
t19_tci := '((143.76) * (' || t19_fd || '))+((0.610) * (sqrt(' || t19_fa || ')/' || t19_noducts || ')^2 )+((17412.26) * exp((0.017) * (sqrt(' || t19_fa || ')/' || t19_noducts || ')))+((53.973) * exp((0.014) * (sqrt(' || t19_fa || ')/' || t19_noducts || ')))+(931911.04)';
t19_tac := '(' || inv_table_alias || '.annual_avg_hours_per_year) * (((0.00162) * (' || t19_fd || '))+((0.000000684) * (' || t19_so2_conc || ') * (' || t19_fd || '))+((0.0000372) * (' || t19_fa || '))+(21.157))+((0.072+(' || capital_recovery_factor_expression || ')) * (' || t19_tci || '))';
----- END of equation definitions -----
-- prepare annual_cost_expression
annual_cost_expression := '(' ||
case
when use_cost_equations then
'case
' || case when not has_design_capacity_columns then '' else '
--Equation Type 1
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 1'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 then '
/*
annual_cost := annualized_capital_cost + operation_maintenance_cost
annualized_capital_cost := capital_cost * cap_recovery_factor
capital_cost := capital_cost_multiplier * design_capacity * scaling_factor * 1000
operation_maintenance_cost := coalesce(fixed_operation_maintenance_cost, 0) + coalesce(variable_operation_maintenance_cost, 0)
fixed_operation_maintenance_cost := fixed_om_cost_multiplier * design_capacity * scaling_factor * 1000;
variable_operation_maintenance_cost := variable_om_cost_multiplier * design_capacity * capacity_factor * 8760;
scaling_factor := (scaling_factor_model_size / design_capacity) ^ scaling_factor_exponent;
IF coalesce(' || discount_rate || ', 0) != 0 and coalesce(' || control_measure_table_alias || '.equipment_life, 0) != 0 THEN
cap_recovery_factor := public.calculate_capital_recovery_factor(' || discount_rate || ', ' || control_measure_table_alias || '.equipment_life);
END IF;
*/|| deflator_gdp_adjustment_factor_expression || ' * ' || '
(
/*annualized_capital_cost*/
(' || control_measure_equation_table_alias || '.value1/*capital_cost_multiplier*/ * ' || convert_design_capacity_expression || '
* ((' || control_measure_equation_table_alias || '.value4/*scaling_factor_model_size*/ / ' || convert_design_capacity_expression || ') ^ ' || control_measure_equation_table_alias || '.value5/*scaling_factor_exponent*/) /*scaling_factor*/
* 1000) /*capital_cost*/
* ' || capital_recovery_factor_expression || '
+
/*operation_maintenance_cost*/
coalesce(' || control_measure_equation_table_alias || '.value2/*fixed_om_cost_multiplier*/ * ' || convert_design_capacity_expression || ' * ((' || control_measure_equation_table_alias || '.value4/*scaling_factor_model_size*/ / ' || convert_design_capacity_expression || ') ^ ' || control_measure_equation_table_alias || '.value5/*scaling_factor_exponent*/) /*scaling_factor*/ * 1000/*fixed_operation_maintenance_cost*/, 0)
+ coalesce(' || control_measure_equation_table_alias || '.value3/*variable_om_cost_multiplier*/ * ' || convert_design_capacity_expression || ' * ' || control_measure_equation_table_alias || '.value6/*capacity_factor*/ * 8760/*variable_operation_maintenance_cost*/, 0)
)
--Equation Type 2
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 2'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 and coalesce(3.412 * ' || convert_design_capacity_expression || ', 0) <= 2000.0 then '
/*
-- calculate capital cost
capital_cost := capital_cost_multiplier * (design_capacity ^ capital_cost_exponent) + capital_cost_base;
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- calculate annual cost
annual_cost := annual_cost_multiplier * design_capacity ^ annual_cost_exponent + annual_cost_base;
-- calculate operation maintenance cost
operation_maintenance_cost := annual_cost - annualized_capital_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then ' || control_measure_equation_table_alias || '.value3 else ' || control_measure_equation_table_alias || '.value7 end)/*annual_cost_multiplier*/ *
((3.412 * ' || convert_design_capacity_expression || '/*design_capacity*/) ^ (case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then ' || control_measure_equation_table_alias || '.value4 else ' || control_measure_equation_table_alias || '.value8 end)/*annual_cost_exponent*/) +
(case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then coalesce(' || control_measure_equation_table_alias || '.value10, 0.0) else coalesce(' || control_measure_equation_table_alias || '.value12, 0.0) end)/*annual_cost_base*/
)
--Equation Type 2a
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 2a'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 and coalesce(3.412 * ' || convert_design_capacity_expression || ', 0) <= 2000.0 then '
/*
-- calculate capital cost
capital_cost := capital_cost_multiplier * (emis_reduction ^ capital_cost_exponent) + capital_cost_base;
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- calculate annual cost
annual_cost := annual_cost_multiplier * emis_reduction ^ annual_cost_exponent + annual_cost_base;
-- calculate operation maintenance cost
operation_maintenance_cost := annual_cost - annualized_capital_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then ' || control_measure_equation_table_alias || '.value3 else ' || control_measure_equation_table_alias || '.value7 end)/*annual_cost_multiplier*/ *
((' || emis_reduction_sql || ' / 365) ^ (case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then ' || control_measure_equation_table_alias || '.value4 else ' || control_measure_equation_table_alias || '.value8 end)/*annual_cost_exponent*/) +
(case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then coalesce(' || control_measure_equation_table_alias || '.value10, 0.0) else coalesce(' || control_measure_equation_table_alias || '.value12, 0.0) end)/*annual_cost_base*/
)
--Equation Type 2b
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 2b'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 and coalesce(1341.022 * ' || convert_design_capacity_expression || ', 0) <= 1500.0 then '
/*
-- calculate capital cost
capital_cost := capital_cost_multiplier * e ^ (design_capacity * capital_cost_exponent);
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- calculate annual cost
annual_cost := annual_cost_multiplier * e ^ (design_capacity * annual_cost_exponent);
-- calculate operation maintenance cost
operation_maintenance_cost := annual_cost - annualized_capital_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
' || control_measure_equation_table_alias || '.value3/*annual_cost_multiplier*/ *
exp((1341.022 * ' || convert_design_capacity_expression || '/*design_capacity*/) * (' || control_measure_equation_table_alias || '.value4)/*annual_cost_exponent*/)
)
--Equation Type 2c
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 2c'' and coalesce(' || convert_design_capacity_expression || ', 0) > 0.1 and coalesce(1341.022 * ' || convert_design_capacity_expression || ', 0) < 1500.0 then '
/*
-- calculate capital cost
capital_cost := capital_cost_multiplier * (design_capacity [in HP] ^ capital_cost_exponent) + capital_cost_base;
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- calculate annual cost
annual_cost := annual_cost_multiplier * design_capacity [in HP] ^ annual_cost_exponent + annual_cost_base;
-- calculate operation maintenance cost
operation_maintenance_cost := annual_cost - annualized_capital_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then ' || control_measure_equation_table_alias || '.value3 else ' || control_measure_equation_table_alias || '.value7 end)/*annual_cost_multiplier*/ *
((1341.022 * ' || convert_design_capacity_expression || '/*design_capacity*/) ^ (case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then ' || control_measure_equation_table_alias || '.value4 else ' || control_measure_equation_table_alias || '.value8 end)/*annual_cost_exponent*/) +
(case when coalesce(' || inv_table_alias || '.' || inv_ceff_expression || ', 0.0) = 0.0 then coalesce(' || control_measure_equation_table_alias || '.value10, 0.0) else coalesce(' || control_measure_equation_table_alias || '.value12, 0.0) end)/*annual_cost_base*/
)
' end || '
' || case when not is_point_table then '' else '
--Equation Type 3
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 3'' and coalesce(' || stkflow_expression || ', 0) <> 0 then '
/*
cap_recovery_factor double precision := capital_recovery_factor;
capital_cost_factor double precision := 192;
gas_flow_rate_factor double precision := 0.486;
retrofit_factor double precision := 1.1;
-- calculate capital cost
capital_cost :=
case
when stack_flow_rate < 1028000 then
(1028000/ stack_flow_rate) ^ 0.6 * capital_cost_factor * gas_flow_rate_factor * retrofit_factor * stack_flow_rate
else
capital_cost_factor * gas_flow_rate_factor * retrofit_factor * stack_flow_rate
end * 0.9383;
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- Fixed O&M = Gas Flow Rate Factor * Fixed O&M Rate
-- where Gas Flow Rate Factor = 0.486 kW/acfm and Fixed O&M Rate = $6.9/kW-yr.
fixed_operation_maintenance_cost := 0.486 * 6.9 * stack_flow_rate;
-- Variable O&M = Gas Flow Rate Factor * Variable O&M Rate * Hours per Year * STKFLOW * 60
-- where Gas Flow Rate Factor = 0.486 kW/acf; Variable O&M Rate = $0.0015/kWh;
-- Hours per Year = 8,736 hours, STKFLOW is the stack gas flow rate (ft3/s) from the emissions inventory,
-- and 60 is a conversion factor to convert STKFLOW to ft3/min.
variable_operation_maintenance_cost := 0.486 * 0.0015 * 8736 * stack_flow_rate;
-- calculate operation maintenance cost
-- operation_maintenance_cost := (3.35 + (0.000729 * 8736)) * stack_flow_rate * 0.9383; (previous equation)
operation_maintenance_cost := fixed_operation_maintenance_cost + variable_operation_maintenance_cost;
-- calculate annual cost
annual_cost := annualized_capital_cost + operation_maintenance_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(
case
when ' || stkflow_expression || ' < 1028000 then (1028000/ ' || stkflow_expression || ') ^ 0.6
else 1.0
end * 192/*capital_cost_factor*/ * 0.486/*gas_flow_rate_factor*/ * 1.1/*retrofit_factor*/ * ' || stkflow_expression || ' * 0.9383/*capital_cost*/
*
' || capital_recovery_factor_expression || ')/*annualized_capital_cost*/
+ (
(0.486 * 6.9 * ' || stkflow_expression || ')/*fixed_operation_maintenance_cost*/
+ (0.486 * 0.0015 * 8736 * ' || stkflow_expression || ')/*variable_operation_maintenance_cost*/
)/*operation_maintenance_cost*/
)
--Equation Type 4
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 4'' and coalesce(' || stkflow_expression || ', 0) <> 0 then '
/*
-- calculate capital cost
capital_cost := (990000 + 9.836 * stack_flow_rate);
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- Fixed O&M = $75,800
-- where $75,800 is the fixed O&M cost based on model plant data
fixed_operation_maintenance_cost := 75800;
-- Variable O&M = $12.82 * STKFLOW * 60
-- where $12.82 is the variable O&M cost based on model plant data,
-- STKFLOW is the stack gas flow rate (ft3/s) from the emissions inventory,
-- and 60 is a conversion factor to convert STKFLOW to ft3/min.
-- Darin says that the seconds to minutes conversion is not necessary
variable_operation_maintenance_cost := 12.82 * stack_flow_rate;
-- calculate operation maintenance cost
-- operation_maintenance_cost := (75800 + 12.82 * stack_flow_rate); (previous equation)
operation_maintenance_cost := fixed_operation_maintenance_cost + variable_operation_maintenance_cost;
-- calculate annual cost
annual_cost := annualized_capital_cost + operation_maintenance_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(990000 + 9.836 * ' || stkflow_expression || ')/*capital_cost*/
* ' || capital_recovery_factor_expression || '/*annualized_capital_cost*/
+ (
75800/*fixed_operation_maintenance_cost*/ + (12.82 * ' || stkflow_expression || ')/*variable_operation_maintenance_cost*/
)/*operation_maintenance_cost*/
)
--Equation Type 5
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 5'' and coalesce(' || stkflow_expression || ', 0) <> 0 then '
/*
-- calculate capital cost
capital_cost := (2882540 + 244.74 * stack_flow_rate);
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- Fixed O&M = $749,170
-- where $749,170 is the fixed O&M cost based on model plant data,
fixed_operation_maintenance_cost := 749170;
-- Variable O&M=$148.4 * STKFLOW * 60
-- where $148.4 is the variable O&M data based on model plant data and credit for recovered product,
-- STKFLOW is the stack gas flow rate (ft3/s) from the emissions inventory,
-- and 60 is a conversion factor to convert STKFLOW to ft3/min.
-- Darin says that the seconds to minutes conversion is not necessary
variable_operation_maintenance_cost := 148.40 * stack_flow_rate;
-- calculate operation maintenance cost
-- operation_maintenance_cost := (749170 + 148.40 * stack_flow_rate); (previous equation)
operation_maintenance_cost := fixed_operation_maintenance_cost + variable_operation_maintenance_cost;
-- calculate annual cost
annual_cost := annualized_capital_cost + operation_maintenance_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(2882540 + 244.74 * ' || stkflow_expression || ')/*capital_cost*/
* ' || capital_recovery_factor_expression || '/*annualized_capital_cost*/
+ (
749170/*fixed_operation_maintenance_cost*/ + (148.40 * ' || stkflow_expression || ')/*variable_operation_maintenance_cost*/
)/*operation_maintenance_cost*/
)
--Equation Type 6
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 6'' and coalesce(' || stkflow_expression || ', 0) <> 0 then '
/*
-- calculate capital cost
capital_cost := (3449803 + 135.86 * stack_flow_rate);
-- calculate annualized capital cost
annualized_capital_cost := capital_cost * cap_recovery_factor;
-- Fixed O&M = $797,667
-- where $797,667 is the fixed O&M cost derived from model plant data
fixed_operation_maintenance_cost := 797667;
-- Variable O&M = $58.84 * STKFLOW * 60
-- where $58.84 is the variable O&M cost derived from model plant data,
-- STKFLOW is the stack gas flow rate (ft3/s) from the emissions inventory,
-- and 60 is a conversion factor to convert STKFLOW to ft3/min.
-- Darin says that the seconds to minutes conversion is not necessary
variable_operation_maintenance_cost := 58.84 * stack_flow_rate;
-- calculate operation maintenance cost
-- operation_maintenance_cost := (797667 + 58.84 * stack_flow_rate); (previous equation)
operation_maintenance_cost := fixed_operation_maintenance_cost + variable_operation_maintenance_cost;
-- calculate annual cost
annual_cost := annualized_capital_cost + operation_maintenance_cost;
*/|| deflator_gdp_adjustment_factor_expression || ' *
(
(3449803 + 135.86 * ' || stkflow_expression || ')/*capital_cost*/
* ' || capital_recovery_factor_expression || '/*annualized_capital_cost*/
+ (
797667/*fixed_operation_maintenance_cost*/ + (58.84 * ' || stkflow_expression || ')/*variable_operation_maintenance_cost*/
)/*operation_maintenance_cost*/
)
--Equation Type 7
when coalesce(' || equation_type_table_alias || '.name,'''') = ''Type 7'' and coalesce(' || stkflow_expression || ', 0) <> 0 then '
/*
-- calculate capital cost
capital_cost :=
case
when stack_flow_rate < 1028000 then
(2882540 + (244.74 * stack_flow_rate) + (((1028000 / stack_flow_rate) ^ 0.6)) * 93.3 * 1.1 * stack_flow_rate * 0.9383)
else