-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathSSLW.py
More file actions
1690 lines (1484 loc) · 60.9 KB
/
Copy pathSSLW.py
File metadata and controls
1690 lines (1484 loc) · 60.9 KB
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
#################################################################################
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES).
#
# Copyright (c) 2018-2026 by the software owners: The Regents of the
# University of California, through Lawrence Berkeley National Laboratory,
# National Technology & Engineering Solutions of Sandia, LLC, Carnegie Mellon
# University, West Virginia University Research Corporation, et al.
# All rights reserved. Please see the files COPYRIGHT.md and LICENSE.md
# for full copyright and license information.
#################################################################################
"""
Costing package based on methods from:
Process and Product Design Principles: Synthesis, Analysis, and
Evaluation
Seider, Seader, Lewin, Windagdo, 3rd Ed. John Wiley and Sons
Chapter 22. Cost Accounting and Capital Cost Estimation
22.2 Cost Indexes and Capital Investment
Currently, this costing package only includes methods for capital costing of
unit operations.
"""
# TODO: Missing docstrings
# pylint: disable=missing-class-docstring
import pyomo.environ as pyo
# TODO: HX1D not supported - does not define area (has shell_area & tube_area)
from idaes.models.unit_models import (
Compressor,
CSTR,
Flash,
Heater,
HeatExchanger,
HeatExchangerNTU,
PFR,
PressureChanger,
Pump,
StoichiometricReactor,
Turbine,
)
from idaes.models.unit_models.pressure_changer import ThermodynamicAssumption
from idaes.models.unit_models.heat_exchanger import HeatExchangerFlowPattern
from idaes.core import declare_process_block_class
from idaes.core.util.exceptions import ConfigurationError
from idaes.core.util.constants import Constants
from idaes.core.util.math import smooth_max
from idaes.core.util.misc import StrEnum
from idaes.core import (
FlowsheetCostingBlockData,
register_idaes_currency_units,
)
import idaes.logger as idaeslog
_log = idaeslog.getLogger(__name__)
# Some more information about this module
__author__ = "Miguel Zamarripa, Andrew Lee"
class HXType(StrEnum):
floating_head = "floating_head"
fixed_head = "fixed_head"
Utube = "Utube"
kettle_vap = "Kettle_vap"
class HXMaterial(StrEnum):
CarbonSteelCarbonSteel = "CarbonSteelCarbonSteel"
CarbonSteelBrass = "CarbonSteelBrass"
CarbonSteelStainlessSteel = "CarbonSteelStainlessSteel"
CarbonSteelMonel = "CarbonSteelMonel"
CarbonSteelTitanium = "CarbonSteelTitanium"
CarbonSteelCrMoSteel = "CarbonSteelCrMoSteel"
CrMoSteelCrMoSteel = "CrMoSteelCrMoSteel"
StainlessSteelStainlessSteel = "StainlessSteelStainlessSteel"
MonelMonel = "MonelMonel"
TitaniumTitanium = "TitaniumTitanium"
class HXTubeLength(StrEnum):
EightFoot = "8ft"
TwelveFoot = "12ft"
SixteenFoot = "16ft"
TwentyFoot = "20ft"
class VesselMaterial(StrEnum):
CarbonSteel = "Carbon_steel"
LowAlloySteel = "LowAlloySteel"
StainlessSteel304 = "StainlessSteel304"
StainlessSteel316 = "StainlessSteel316"
Carpenter20CB3 = "Carpenter20CB3"
Nickel200 = "Nickel200"
Monel400 = "Monel400"
Inconel600 = "Inconel600"
Incoloy825 = "Incoloy825"
Titanium = "Titanium"
class TrayType(StrEnum):
Sieve = "Sieve"
Valve = "Valve"
BubbleCap = "BubbleCap"
class TrayMaterial(StrEnum):
CarbonSteel = "CarbonSteel"
StainlessSteel303 = "StainlessSteel303"
StainlessSteel316 = "StainlessSteel316"
Carpenter20CB3 = "Carpenter20CB3"
Monel = "Monel"
class HeaterMaterial(StrEnum):
CarbonSteel = "CarbonSteel"
CrMoSteel = "CrMoSteel"
StainlessSteel = "StainlessSteel"
class HeaterSource(StrEnum):
Fuel = "Fuel"
Reformer = "Reformer"
Pyrolysis = "Pyrolysis"
HotWater = "HotWater"
Salts = "Salts"
DowthermA = "DowthermA"
steamBoiler = "SteamBoiler"
class CompressorType(StrEnum):
Centrifugal = "Centrifugal"
Reciprocating = "Reciprocating"
Screw = "Screw"
class CompressorDriveType(StrEnum):
ElectricMotor = "ElectricMotor"
SteamTurbine = "SteamTurbine"
gasTurbine = "GasTurbine"
class CompressorMaterial(StrEnum):
CarbonSteel = "CarbonSteel"
StainlessSteel = "StainlessSteel"
NickelAlloy = "NickelAlloy"
class PumpMaterial(StrEnum):
CastIron = "CastIron"
DuctileIron = "DuctileIron"
CastSteel = "CastSteel"
Bronze = "Bronze"
StainlessSteel = "StainlessSteel"
HastelloyC = "HastelloyC"
Monel = "Monel"
Nickel = "Nickel"
Titanium = "Titanium"
NiAlBronze = "NiAlBronze"
CarbonSteel = "CarbonSteel"
class PumpType(StrEnum):
Centrifugal = "Centrifugal"
ExternalGear = "ExternalGear"
Reciprocating = "Reciprocating"
class PumpMotorType(StrEnum):
Open = "open"
Enclosed = "enclosed"
ExplosionProof = "explosion_proof"
class FanType(StrEnum):
CentrifugalBackward = "CentrifugalBackward"
CentrifugalStraight = "CentrifugalStraight"
VaneAxial = "VaneAxial"
TubeAxial = "TubeAxial"
class FanMaterial(StrEnum):
CarbonSteel = "CarbonSteel"
Fiberglass = "Fiberglass"
StainlessSteel = "StainlessSteel"
NickelAlloy = "NickelAlloy"
class BlowerType(StrEnum):
Centrifugal = "Centrifugal"
Rotary = "Rotary"
class BlowerMaterial(StrEnum):
CarbonSteel = "CarbonSteel"
Aluminum = "Aluminum"
Fiberglass = "Fiberglass"
StainlessSteel = "StainlessSteel"
NickelAlloy = "NickelAlloy"
@declare_process_block_class("SSLWCosting")
class SSLWCostingData(FlowsheetCostingBlockData):
# Register currency and conversion rates based on CE Index
register_idaes_currency_units()
def build_global_params(self):
"""
This is where we can declare any global parameters we need, such as
Lang factors, or coefficients for costing methods that should be
shared across the process.
You can do what you want here, so you could have e.g. sub-Blocks
for each costing method to separate the parameters for each method.
"""
# Set the base year for all costs
self.base_currency = pyo.units.USD_2018
# Set a base period for all operating costs
self.base_period = pyo.units.year
def build_process_costs(self):
"""
This is where you do all your process wide costing.
This is completely up to you, but you will have access to the
following aggregate costs:
1. self.aggregate_capital_cost
2. self.aggregate_fixed_operating_cost
3. self.aggregate_variable_operating_cost
4. self.aggregate_flow_costs (indexed by flow type)
"""
# TODO: Do we have any process level methods to add here?
@staticmethod
def initialize_build(*args, **kwargs):
"""
Here we can add initialization steps for the things we built in
build_process_costs.
Note that the aggregate costs will be initialized by the framework.
"""
# TODO: For now, no additional process level costs to initialize
def cost_heat_exchanger(
blk,
hx_type=HXType.Utube,
material_type=HXMaterial.StainlessSteelStainlessSteel,
tube_length=HXTubeLength.TwelveFoot,
integer=True,
):
"""
Heat exchanger costing method.
This method computes the purchase cost (CP) for a shell and tube heat
exchanger (Eq. 22.43), the model computes the base cost (CB for 4 types
of heat exchangers, such as floating head, fixed head, U-tube, and
Kettle vaporizer), construction material factor (mat_factor),
pressure design factor (pressure_factor), and
tube length correction factor (length_factor),
using Chemical Engineering base cost index of 500.
Purchase Cost = pressure_factor *
material_factor *
length_factor *
base_cost_per_unit *
number_of_units
Args:
hx_type: HXType Enum indicating type of heat exchanger design,
default = HXType.Utube.
material_type: HXMaterial Enum indicating material of construction,
default = HXMaterial.StainlessSteelStainlessSteel.
tube_length: HXTubeLength Enum indicating length of HX tubes,
default = HXTubeLength.TwelveFoot.
integer: whether the number of units should be constrained to be
an integer or not (default = True).
"""
# Validate arguments
if hx_type not in HXType:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for hx_type:"
f" {hx_type}. Argument must be a member of the HXType Enum."
)
if material_type not in HXMaterial:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"material_type: {material_type}. Argument must be a member "
"of the HXMaterial Enum."
)
if tube_length not in HXTubeLength:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"tube_length: {tube_length}. Argument must be a member "
"of the HXTubeLength Enum."
)
# Build generic costing variables
_make_common_vars(blk, integer)
# Length correction factor
c_fl = {"8ft": 1.25, "12ft": 1.12, "16ft": 1.05, "20ft": 1.00}
blk.length_factor = pyo.Param(
mutable=True,
initialize=c_fl[tube_length],
doc="HX tube length correction factor",
)
blk.hx_oversize = pyo.Param(
mutable=True,
initialize=1.1,
doc="HX oversize factor (1.1 to 1.5)",
units=pyo.units.ft**-2,
)
# --------------------------------------------------
# Base cost calculation - based on selected heat exchanger type:
alpha_dict = {
HXType.floating_head: {1: 11.9052, 2: 0.8709, 3: 0.09005},
HXType.fixed_head: {1: 11.2927, 2: 0.8228, 3: 0.09861},
HXType.Utube: {1: 11.3852, 2: 0.9186, 3: 0.09790},
HXType.kettle_vap: {1: 12.2052, 2: 0.8709, 3: 0.09005},
}
alpha = alpha_dict[hx_type]
# Convert area to square feet
area_unit = (
pyo.units.convert(blk.unit_model.area, to_units=pyo.units.ft**2)
/ blk.number_of_units
)
@blk.Constraint()
def base_cost_per_unit_eq(blk):
return (
blk.base_cost_per_unit
== pyo.exp(
alpha[1]
- alpha[2] * pyo.log(area_unit * blk.hx_oversize)
+ alpha[3] * pyo.log(area_unit * blk.hx_oversize) ** 2
)
* pyo.units.USD_CE500
)
@blk.Expression(doc="Base cost for all installed units")
def base_cost(blk):
return blk.base_cost_per_unit * blk.number_of_units
# ------------------------------------------------------
# Material of construction factor Eq. 22.44 in the reference
blk.material_factor = pyo.Var(
initialize=3.5,
bounds=(0, None),
doc="Construction material correction factor",
)
hx_material_factor_dict = {
HXMaterial.CarbonSteelCarbonSteel: {"A": 0.00, "B": 0.00},
HXMaterial.CarbonSteelBrass: {"A": 1.08, "B": 0.05},
HXMaterial.CarbonSteelStainlessSteel: {"A": 1.75, "B": 0.13},
HXMaterial.CarbonSteelMonel: {"A": 2.10, "B": 0.13},
HXMaterial.CarbonSteelTitanium: {"A": 5.20, "B": 0.16},
HXMaterial.CarbonSteelCrMoSteel: {"A": 1.55, "B": 0.05},
HXMaterial.CrMoSteelCrMoSteel: {"A": 1.70, "B": 0.07},
HXMaterial.StainlessSteelStainlessSteel: {"A": 2.70, "B": 0.07},
HXMaterial.MonelMonel: {"A": 3.30, "B": 0.08},
HXMaterial.TitaniumTitanium: {"A": 9.60, "B": 0.06},
}
mf = hx_material_factor_dict[material_type]
@blk.Constraint()
def hx_material_eqn(self):
if material_type == HXMaterial.CarbonSteelCarbonSteel:
return blk.material_factor == 1
else:
return (
blk.material_factor
== mf["A"] + (area_unit / (100 * pyo.units.ft**2)) ** mf["B"]
)
# ------------------------------------------------------
# Pressure factor calculation
t0 = blk.unit_model.flowsheet().time.first()
# Assume higher pressure fluid is tube side
blk.pressure_factor = pyo.Var(
initialize=1, bounds=(0, None), doc="Pressure design factor"
)
try:
tube_props = blk.unit_model.hot_side.properties_in[t0]
except AttributeError:
# Assume HX1D
if blk.unit_model.config.flow_type == HeatExchangerFlowPattern.cocurrent:
inlet_x = 0
else:
inlet_x = 1
tube_props = blk.unit_model.tube.properties[0, inlet_x]
# Pressure units must be in psig
pressure = pyo.units.convert(
tube_props.pressure, to_units=pyo.units.psi
) - pyo.units.convert(1 * pyo.units.atm, to_units=pyo.units.psi)
@blk.Constraint()
def p_factor_eq(blk):
# Equation valid from 600 pisg to 3000 psig
# return self.pressure_factor == (
# 0.8510 + 0.1292*(pressure/600) + 0.0198*(pressure/600)**2)
# Equation valid from 100 pisg to 2000 psig
return blk.pressure_factor == (
0.9803
+ 0.0180 * (pressure / (100 * pyo.units.psi))
+ 0.0017 * (pressure / (100 * pyo.units.psi)) ** 2
)
# Total capital cost equation
@blk.Constraint()
def capital_cost_constraint(blk):
return blk.capital_cost == (
blk.pressure_factor
* blk.material_factor
* blk.length_factor
* blk.base_cost
)
def cost_vessel(
blk,
vertical=False,
material_type=VesselMaterial.CarbonSteel,
shell_thickness=1.25 * pyo.units.inch,
weight_limit=1,
aspect_ratio_range=1,
include_platforms_ladders=True,
vessel_diameter=None,
vessel_length=None,
number_of_units=1,
number_of_trays=None,
tray_material=TrayMaterial.CarbonSteel,
tray_type=TrayType.Sieve,
):
"""
Generic vessel costing method.
Args:
vertical: alignment of vessel; vertical if True, horizontal if
False (default=False).
material_type: VesselMaterial Enum indicating material of
construction, default = VesselMaterial.CarbonSteel.
shell_thickness: thickness of vessel shell, including pressure
allowance. Default = 1.25 inches.
weight_limit: 1: (default) 1000 to 920,000 lb, 2: 4200 to 1M lb.
Option 2 is only valid for vertical vessels.
aspect_ratio_range: vertical vessels only, default = 1;
1: 3 < D < 21 ft, 12 < L < 40 ft, 2: 3 < D < 24 ft; 27 < L < 170 ft.
include_platforms_ladders: whether to include platforms and
ladders in costing , default = True.
vessel_diameter: Pyomo component representing vessel diameter.
If not provided, assumed to be named "diameter"
vessel_length: Pyomo component representing vessel length.
If not provided, assumed to be named "length".
number_of_units: Integer or Pyomo component representing the
number of parallel units to be costed, default = 1.
number_of_trays: Pyomo component representing the number of
distillation trays in vessel (default=None)
tray_material: Only required if number_of_trays is not None.
TrayMaterial Enum indicating material of construction for
distillation trays, default = TrayMaterial.CarbonSteel.
tray_type: Only required if number_of_trays is not None.
TrayType Enum indicating type of distillation trays to use,
default = TrayMaterial.Sieve.
"""
# Build generic costing variables
blk.base_cost_per_unit = pyo.Var(
initialize=1e5,
bounds=(0, None),
units=pyo.units.USD_CE500,
doc="Base cost per unit",
)
blk.capital_cost = pyo.Var(
initialize=1e4,
bounds=(0, None),
units=pyo.units.USD_CE500,
doc="Capital cost of all units",
)
# Check arguments
if material_type not in VesselMaterial:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"material_type: {material_type}. Argument must be a member "
"of the VesselMaterial Enum."
)
if not vertical and number_of_trays is not None:
raise ConfigurationError(
f"{blk.unit_model.name} distillation trays are only supported "
"for vertical vessels."
)
if weight_limit == 2 and not vertical:
raise ConfigurationError(
f"{blk.unit_model.name} weight_limit option 2 is only valid "
"for vertical vessels."
)
elif weight_limit not in [1, 2]:
raise ConfigurationError(
f"{blk.unit_model.name} weight_limit argument must be 1 or 2;"
f" received {weight_limit}."
)
# Check references to diameter and length
if vessel_diameter is None:
try:
vessel_diameter = blk.unit_model.diameter
except AttributeError:
raise ConfigurationError(
f"{blk.unit_model.name} does not have a component named "
"diameter. Please provide a reference to the vessel "
"diameter as an argument to cost_unit."
)
if vessel_length is None:
try:
vessel_length = blk.unit_model.length
except AttributeError:
raise ConfigurationError(
f"{blk.unit_model.name} does not have a component named "
"length. Please provide a reference to the vessel "
"length as an argument to cost_unit."
)
D_in = pyo.units.convert(vessel_diameter, to_units=pyo.units.inch)
L_in = pyo.units.convert(vessel_length, to_units=pyo.units.inch)
# Material densities in lb/cubic inch
material_factor_dict = {
VesselMaterial.CarbonSteel: {"factor": 1.0, "density": 0.284},
VesselMaterial.LowAlloySteel: {"factor": 1.2, "density": 0.271},
VesselMaterial.StainlessSteel304: {"factor": 1.7, "density": 0.270},
VesselMaterial.StainlessSteel316: {"factor": 2.1, "density": 0.276},
VesselMaterial.Carpenter20CB3: {"factor": 3.2, "density": 0.29},
VesselMaterial.Nickel200: {"factor": 5.4, "density": 0.3216},
VesselMaterial.Monel400: {"factor": 3.6, "density": 0.319},
VesselMaterial.Inconel600: {"factor": 3.9, "density": 0.3071},
VesselMaterial.Incoloy825: {"factor": 3.7, "density": 0.2903},
VesselMaterial.Titanium: {"factor": 7.7, "density": 0.1628},
}
material_factors = material_factor_dict[material_type]
# Users should calculate the pressure design based shell thickness
# Pressure factor assumed to be included in thickness
blk.shell_thickness = pyo.Param(
mutable=True, doc="Shell thickness", units=pyo.units.inch
)
blk.shell_thickness.set_value(shell_thickness)
blk.material_factor = pyo.Param(
initialize=material_factors["factor"],
mutable=True,
doc="Construction material correction factor",
)
blk.material_density = pyo.Param(
initialize=material_factors["density"],
mutable=True,
doc="Density of the metal",
units=pyo.units.pound / pyo.units.inch**3,
)
# Calculate weight of vessel
blk.weight = pyo.Var(
initialize=1000,
bounds=(0, None),
doc="Weight of vessel in lb",
units=pyo.units.pound,
)
@blk.Constraint()
def weight_eq(blk):
return blk.weight == (
Constants.pi
* (D_in + blk.shell_thickness)
* (L_in + 0.8 * D_in)
* blk.shell_thickness
* blk.material_density
)
# Base Vessel cost
# Alpha factors for correlation
# 2nd key is weight_limit option
alpha_dict = {
"H": {1: {1: 8.9552, 2: -0.2330, 3: 0.04333}, 2: None},
"V": {
1: {1: 7.0132, 2: 0.18255, 3: 0.02297},
2: {1: 7.2756, 2: 0.18255, 3: 0.02297},
},
}
if vertical:
alpha = alpha_dict["V"][weight_limit]
else:
alpha = alpha_dict["H"][weight_limit]
@blk.Constraint()
def base_cost_constraint(blk):
return blk.base_cost_per_unit == (
pyo.exp(
alpha[1]
+ alpha[2] * (pyo.log(blk.weight / pyo.units.pound))
+ alpha[3] * (pyo.log(blk.weight / pyo.units.pound) ** 2)
)
* pyo.units.USD_CE500
)
# Add platform and ladder costs if required
if include_platforms_ladders:
SSLWCostingData._cost_platforms_ladders(
blk,
vertical=vertical,
aspect_ratio_range=aspect_ratio_range,
vessel_diameter=vessel_diameter,
vessel_length=vessel_length,
)
# Add distillation trays costs if required
if number_of_trays is not None:
SSLWCostingData._cost_distillation_trays(
blk,
tray_material=tray_material,
tray_type=tray_type,
vessel_diameter=vessel_diameter,
number_of_trays=number_of_trays,
)
# Total capital cost of vessel and ancillary equipment
@blk.Constraint()
def capital_cost_constraint(blk):
cost_expr = blk.material_factor * blk.base_cost_per_unit
if include_platforms_ladders:
cost_expr += blk.base_cost_platforms_ladders
if number_of_trays is not None:
cost_expr += blk.base_cost_trays
return blk.capital_cost == cost_expr * number_of_units
def _cost_platforms_ladders(
blk, vertical, aspect_ratio_range, vessel_diameter, vessel_length
):
"""
Method for calculating costs of platforms and ladders
"""
blk.base_cost_platforms_ladders = pyo.Var(
initialize=1000,
units=pyo.units.USD_CE500,
bounds=(0, None),
doc="Base cost of platforms and ladders",
)
D = pyo.units.convert(vessel_diameter, to_units=pyo.units.foot)
L = pyo.units.convert(vessel_length, to_units=pyo.units.foot)
if not vertical:
@blk.Constraint()
def cost_platforms_ladders_eq(blk):
return blk.base_cost_platforms_ladders == (
2005 * (D / pyo.units.foot) ** 0.20294 * pyo.units.USD_CE500
)
else:
@blk.Constraint()
def cost_platforms_ladders_eq(blk):
if aspect_ratio_range == 1:
return blk.base_cost_platforms_ladders == (
361.8
* (D / pyo.units.foot) ** 0.73960
* (L / pyo.units.foot) ** 0.70684
* pyo.units.USD_CE500
)
elif aspect_ratio_range == 2:
return blk.base_cost_platforms_ladders == (
309.9
* (D / pyo.units.foot) ** 0.63316
* (L / pyo.units.foot) ** 0.80161
* pyo.units.USD_CE500
)
else:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid value for "
f"aspect_ratio_range argument: {aspect_ratio_range}. "
"Value must be 1 or 2."
)
def _cost_distillation_trays(
blk, tray_material, tray_type, vessel_diameter, number_of_trays
):
# Check arguments
if tray_material not in TrayMaterial:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"tray_material: {tray_material}. Argument must be a member "
"of the TrayMaterial Enum."
)
if tray_type not in TrayType:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"tray_type: {tray_type}. Argument must be a member "
"of the TrayType Enum."
)
D = pyo.units.convert(vessel_diameter, to_units=pyo.units.foot)
blk.base_cost_trays = pyo.Var(
initialize=1e6,
units=pyo.units.USD_CE500,
bounds=(0, None),
doc="Purchase cost of trays",
)
tray_type_dict = {
TrayType.Sieve: 1,
TrayType.Valve: 1.18,
TrayType.BubbleCap: 1.87,
}
blk.tray_type_factor = pyo.Param(
initialize=tray_type_dict[tray_type], mutable=True, doc="Tray type factor"
)
blk.tray_material_factor = pyo.Var(
initialize=1.0, doc="FTM material of construction factor for trays"
)
# Alpha parameters for material factor
alpha = {
TrayMaterial.CarbonSteel: {1: 1, 2: 0},
TrayMaterial.StainlessSteel303: {1: 1.189, 2: 0.0577},
TrayMaterial.StainlessSteel316: {1: 1.401, 2: 0.0724},
TrayMaterial.Carpenter20CB3: {1: 1.525, 2: 0.0788},
TrayMaterial.Monel: {1: 2.306, 2: 0.1120},
}
# Calculating tray factor value
# Column diameter in ft, eqn. valid for 2 to 16 ft
@blk.Constraint()
def tray_material_factor_eq(blk):
return blk.tray_material_factor == (
alpha[tray_material][1] + alpha[tray_material][2] * D / pyo.units.foot
)
# Calculate cost factor for number of trays
blk.number_trays_factor = pyo.Var(
initialize=1,
units=pyo.units.dimensionless,
doc="Cost factor for number of trays",
)
@blk.Constraint()
def num_tray_factor_constraint(blk):
return blk.number_trays_factor == smooth_max(
1, 2.25 / (1.0414**number_of_trays)
)
# Calculate base cost of a single tray
blk.base_cost_per_tray = pyo.Var(
initialize=1e4,
bounds=(0, None),
units=pyo.units.USD_CE500,
doc="Base cost of a single tray",
)
@blk.Constraint()
def single_tray_cost_constraint(blk):
return blk.base_cost_per_tray == (
468.00 * pyo.exp(0.1739 * D / pyo.units.foot) * pyo.units.USD_CE500
)
# Capital cost of trays
@blk.Constraint()
def tray_costing_constraint(blk):
return blk.base_cost_trays == (
number_of_trays
* blk.number_trays_factor
* blk.tray_type_factor
* blk.tray_material_factor
* blk.base_cost_per_tray
)
def cost_vertical_vessel(
blk,
material_type=VesselMaterial.CarbonSteel,
shell_thickness=1.25 * pyo.units.inch,
weight_limit=1,
aspect_ratio_range=1,
include_platforms_ladders=True,
vessel_diameter=None,
vessel_length=None,
number_of_units=1,
number_of_trays=None,
tray_material=TrayMaterial.CarbonSteel,
tray_type=TrayType.Sieve,
):
"""
Specific case of vessel costing method for vertical vessels.
Args:
material_type: VesselMaterial Enum indicating material of
construction, default = VesselMaterial.CarbonSteel.
shell_thickness: thickness of vessel shell, including pressure
allowance. Default = 1.25 inches.
weight_limit: 1: (default) 1000 to 920,000 lb, 2: 4200 to 1M lb.
aspect_ratio_range: default = 1;
1: 3 < D < 21 ft, 12 < L < 40 ft, 2: 3 < D < 24 ft; 27 < L < 170 ft.
include_platforms_ladders: whether to include platforms and
ladders in costing , default = True.
vessel_diameter: Pyomo component representing vessel diameter.
If not provided, assumed to be named "diameter"
vessel_length: Pyomo component representing vessel length.
If not provided, assumed to be named "length".
number_of_units: Integer or Pyomo component representing the
number of parallel units to be costed, default = 1.
number_of_trays: Pyomo component representing the number of
distillation trays in vessel (default=None)
tray_material: Only required if number_of_trays is not None.
TrayMaterial Enum indicating material of construction for
distillation trays, default = TrayMaterial.CarbonSteel.
tray_type: Only required if number_of_trays is not None.
TrayType Enum indicating type of distillation trays to use,
default = TrayMaterial.Sieve.
"""
SSLWCostingData.cost_vessel(
blk,
vertical=True,
material_type=VesselMaterial.CarbonSteel,
shell_thickness=1.25 * pyo.units.inch,
weight_limit=1,
aspect_ratio_range=1,
include_platforms_ladders=True,
vessel_diameter=None,
vessel_length=None,
number_of_units=1,
number_of_trays=None,
tray_material=TrayMaterial.CarbonSteel,
tray_type=TrayType.Sieve,
)
def cost_horizontal_vessel(
blk,
material_type=VesselMaterial.CarbonSteel,
shell_thickness=1.25 * pyo.units.inch,
include_platforms_ladders=True,
vessel_diameter=None,
vessel_length=None,
number_of_units=1,
):
"""
Specific case of vessel costing method for horizontal vessels.
Arguments which do not apply to horizontal vessels are excluded.
Args:
material_type: VesselMaterial Enum indicating material of
construction, default = VesselMaterial.CarbonSteel.
shell_thickness: thickness of vessel shell, including pressure
allowance. Default = 1.25 inches.
include_platforms_ladders: whether to include platforms and
ladders in costing, default = True.
vessel_diameter: Pyomo component representing vessel diameter.
If not provided, assumed to be named "diameter"
vessel_length: Pyomo component representing vessel length.
If not provided, assumed to be named "length".
number_of_units: Integer or Pyomo component representing the
number of parallel units to be costed, default = 1.
"""
SSLWCostingData.cost_vessel(
blk,
vertical=False,
material_type=VesselMaterial.CarbonSteel,
shell_thickness=1.25 * pyo.units.inch,
weight_limit=1,
include_platforms_ladders=True,
vessel_diameter=None,
vessel_length=None,
number_of_units=1,
)
def cost_fired_heater(
blk,
heat_source=HeaterSource.Fuel,
material_type=HeaterMaterial.CarbonSteel,
integer=True,
):
"""
Generic costing method for fired heaters.
Args:
heat_source: HeaterSource Enum indicating type of source of heat,
default = HeaterSource.Fuel.
material_type: HeaterMaterial Enum indicating material of
construction, default = HeaterMaterial.CarbonSteel.
integer: whether the number of units should be constrained to be
an integer or not (default = True).
"""
# Validate arguments
if heat_source not in HeaterSource:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"heat_source: {heat_source}. Argument must be a member of "
"the HeaterSource Enum."
)
if material_type not in HeaterMaterial:
raise ConfigurationError(
f"{blk.unit_model.name} received invalid argument for "
f"material_type: {material_type}. Argument must be a member "
"of the HeaterMaterial Enum."
)
# Build generic costing variables
_make_common_vars(blk, integer)
# Convert pressure to psi,g
t0 = blk.unit_model.flowsheet().time.first()
P = pyo.units.convert(
blk.unit_model.control_volume.properties_in[t0].pressure,
to_units=pyo.units.psi,
) - pyo.units.convert(1 * pyo.units.atm, to_units=pyo.units.psi)
# Convert heat duty to BTU/hr
Q = (
pyo.units.convert(
blk.unit_model.heat_duty[t0], to_units=pyo.units.BTU / pyo.units.hr
)
/ blk.number_of_units
)
# Material factor
material_factor_dict = {
HeaterMaterial.CarbonSteel: 1.0,
HeaterMaterial.CrMoSteel: 1.4,
HeaterMaterial.StainlessSteel: 1.7,
}
blk.material_factor = pyo.Param(
initialize=material_factor_dict[material_type],
domain=pyo.NonNegativeReals,
doc="Construction material correction factor",
)
# Pressure design factor calculation
blk.pressure_factor = pyo.Var(
initialize=1.1, bounds=(0, None), doc="Pressure design factor"
)
@blk.Constraint()
def pressure_factor_eq(blk):
return blk.pressure_factor == (
0.986
- 0.0035 * (P / (500.00 * pyo.units.psi))
+ 0.0175 * (P / (500.00 * pyo.units.psi)) ** 2
)
@blk.Constraint()
def base_cost_per_unit_eq(blk):
if heat_source == HeaterSource.Fuel:
bc_expr = pyo.exp(
0.32325 + 0.766 * pyo.log(Q / pyo.units.BTU * pyo.units.hr)
)
elif heat_source == HeaterSource.Reformer:
bc_expr = 0.859 * (Q / pyo.units.BTU * pyo.units.hr) ** 0.81
elif heat_source == HeaterSource.Pyrolysis:
bc_expr = 0.650 * (Q / pyo.units.BTU * pyo.units.hr) ** 0.81
elif heat_source == HeaterSource.HotWater:
bc_expr = pyo.exp(
9.593
- 0.3769 * pyo.log((Q / pyo.units.BTU * pyo.units.hr))
+ 0.03434 * pyo.log((Q / pyo.units.BTU * pyo.units.hr)) ** 2
)
elif heat_source == HeaterSource.Salts:
bc_expr = 12.32 * (Q / pyo.units.BTU * pyo.units.hr) ** 0.64
elif heat_source == HeaterSource.DowthermA:
bc_expr = 12.74 * (Q / pyo.units.BTU * pyo.units.hr) ** 0.65
elif heat_source == HeaterSource.steamBoiler:
bc_expr = 0.367 * (Q / pyo.units.BTU * pyo.units.hr) ** 0.77
# pylint: disable-next=possibly-used-before-assignment
return blk.base_cost_per_unit == bc_expr * pyo.units.USD_CE500
@blk.Expression(doc="Base cost for all units installed")
def base_cost(blk):
return blk.base_cost_per_unit * blk.number_of_units
# Total capital cost of heater(s)
@blk.Constraint()
def capital_cost_constraint(blk):
return blk.capital_cost == (
blk.material_factor * blk.pressure_factor * blk.base_cost