File size: 19,099 Bytes
a5a3b00 | 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 | from biosteam import units
import json
import biosteam as bst
from biosteam import settings
import numpy as np
import cond
"""
Import file Setup.py with all common settings for the
simulation (chemicals, utilities, prices, etc.)
Additional settings must be added there instead of here
"""
# General commments:
# I tried to generalize the solvent variable, only when it is "" we need to specify the solvent
# For this script, we are using dodecane
#this function is used to run the process two times
def run_simulation(input_data, price_solvent):
#impact factors from openLCA
#electricity: Electricity grid mix 1kV-60kV , consumption mix, to consumer, AC, technology mix, 1kV - 60kV
impact_elec = 0.152997222 #kg CO2-eq/MJ
#steam: steam production, in chemical industry
impact_steam = 0.123945455 #kg CO2-eq/MJ
#cooling water: tap water production, artificial recharged wells
impact_water = 0.42 #kg CO2-eq/m3
input_data["Price"]["solvent"] = price_solvent
chemicals = bst.Chemicals(
["Dodecane", "DMSO", bst.Chemical(
"C2H4", phase="s"), "Water", "glucose", "N2", "O2", "CH4", "CO2", "C5H8O2"]
)
bst.settings.set_thermo(chemicals)
bst.CE = input_data['CE']
bst.PowerUtility.price = input_data["power_utility_price"]
HeatUtility = bst.HeatUtility
steam_utility1 = HeatUtility.get_agent("high_pressure_steam")
steam_utility2 = HeatUtility.get_agent("low_pressure_steam")
steam_utility3 = HeatUtility.get_agent("medium_pressure_steam")
# HeatUtility.heating_agents([steam_utility1,steam_utility2])
steam_utility1.heat_transfer_efficiency = 0.85
steam_utility1.regeneration_price = 0.08064
steam_utility1.T = 529.2
steam_utility1.P = 44e5
steam_utility2.heat_transfer_efficiency = 0.85
steam_utility2.regeneration_price = 0.06768
steam_utility2.T = 428.6
steam_utility2.P = 55e4
steam_utility3.heat_transfer_efficiency = 0.85
steam_utility3.regeneration_price = 0.07974
steam_utility3.T = 480.3
steam_utility3.P = 18e5
product_stream = bst.Stream(
"PROD",
price=2.4023,
)
# Solvent Feed tank
V100 = units.MixTank(
"V100", tau=input_data["tau_solv_feed_tank"], vessel_material="Carbon steel"
)
# new mixer for output solvent streams of dryer
M101 = units.Mixer("M101")
# Feeder
FE101 = units.StorageTank(
"FE101", tau=input_data["tau_feeder"], vessel_material="Carbon steel"
)
# process_units["FE101"] = FE101
# Dissolution vessel
V101 = units.MixTank(
"V101", vessel_material="Carbon steel", tau=input_data["tau_dissolution_vessel"]
)
# process_units["V101"] = V101
# Heater
E101 = units.HXutility(
"E101", T=input_data["heating_temp_after_dissolution"])
# process_units["E101"] = E101
# Hot filtration
FHOT = units.RVF("FHOT", moisture_content=0,
split=input_data["splits_hot_filter"])
# process_units["FHOT"] = FHOT
# Pump 1
P101 = units.Pump("P101")
# process_units["P101"] = P101
# Precipitation vessel
V102 = units.MixTank(
"V102",
vessel_material="Carbon steel",
tau=input_data["tau_precipitation_vessel"],
)
# process_units["V102"] = V102
# Cooler
E102 = units.HXutility(
"E102", T=input_data["cooling_temp_after_precipitation"])
# process_units["E102"] = E102
# Pump 2
P102 = units.Pump("P102")
# process_units["P102"] = P102
# Filtration #tol_44%
F101 = units.RVF("F101", moisture_content=0,
split=input_data["splits_filter"])
# process_units["F101"] = F101
# Dryer
H101 = units.DrumDryer(
ID="H101",
ins=("Mix_s6"),
outs=("dry_P1", "solvent_out_1"),
thermo=None,
split=input_data["splits_dryer"],
R=1.4,
H=20,
length_to_diameter=25,
T=input_data["temp_dryer"],
moisture_content=0,
utility_agent="Natural gas",
)
# process_units["H101"] = H101
# # Condenser
# E103 = units.HXutility("E103", T=input_data["temp_condenser"], rigorous=True)
# process_units["E103"] = E103
# # Condenser
E103 = units.HXutility("E103", T=cond.Temp, rigorous=True)
# process_units["E103"] = E103
# Splitter
S101 = units.PhaseSplitter("S101", outs=("gas", "liquid_solvent"))
# process_units["S101"] = S101
# top gas
@S101.add_specification(run=True)
def phases():
S101.ins[0].phases = "gl"
# Pump 6
P106 = units.Pump("P106")
# process_units["P106"] = P106
# Mixer
M100 = units.Mixer("M100")
# process_units["M100"] = M100
# Dryer
H1012 = units.DrumDryer(
ID="H1012",
ins=("Mix_s6"),
outs=("dry_P2", "solvent_out_2"),
thermo=None,
split=input_data["splits_dryer_EVOH"],
R=1.4,
H=20,
length_to_diameter=25,
T=input_data["temp_dryer"],
moisture_content=0,
utility_agent="Natural gas",
)
# Mixer
# we need this mixer for the outputs and then estimate the MSP with product_stream-"PROD"
M1003 = units.Mixer("M1003", outs=product_stream)
# process_units["M1003"] = M1003
inlet_pe = input_data["total_PE"]
inlet_solvent = input_data["total_solvent"]
N_runs = 10
class STRAPTEA(bst.TEA):
"""
Create a STRAPTEA object for techno-economic analysis.
Parameters
----------
system : System
Should contain feed and product streams.
IRR : float
Internal rate of return (fraction).
duration : tuple[int, int]
Start and end year of venture (e.g. (2018, 2038)).
depreciation : str
'MACRS' + number of years (e.g. 'MACRS7').
operating_days : float
Number of operating days per year.
income_tax : float
Combined federal and state income tax rate (fraction).
lang_factor : float
Lang factor for getting fixed capital investment from
total purchase cost. If no lang factor, estimate capital investment
using bare module factors.
startup_schedule : tuple[float]
Startup investment fractions per year
(e.g. (0.5, 0.5) for 50% capital investment in the first year and 50%
investment in the second).
WC_over_FCI : float
Working capital as a fraction of fixed capital investment.
labor_cost : float
Total labor cost (USD/yr).
fringe_benefits : float
Cost of fringe benefits as a fraction of labor cost.
property_tax : float
Fee as a fraction of fixed capital investment.
property_insurance : float
Fee as a fraction of fixed capital investment.
supplies : float
Yearly fee as a fraction of labor cost.
maintenance : float
Yearly fee as a fraction of fixed capital investment.
administration : float
Yearly fee as a fraction of fixed capital investment.
References
----------
.. [1] Huang, H., Long, S., & Singh, V. (2016). Techno-economic analysis of biodiesel
and ethanol co-production from lipid-producing sugarcane. Biofuels, Bioproducts
and Biorefining, 10(3), 299–315. https://doi.org/10.1002/bbb.1640
"""
__slots__ = (
"labor_cost",
"fringe_benefits",
"maintenance",
"property_tax",
"property_insurance",
"_FCI_cached",
"supplies",
"maintanance",
"administration",
)
def __init__(
self,
system,
IRR,
duration,
depreciation,
income_tax,
operating_days,
lang_factor,
construction_schedule,
WC_over_FCI,
labor_cost,
fringe_benefits,
property_tax,
property_insurance,
supplies,
maintenance,
administration,
):
super().__init__(
system,
IRR,
duration,
depreciation,
income_tax,
operating_days,
lang_factor,
construction_schedule,
startup_months=0,
startup_FOCfrac=0,
startup_VOCfrac=0,
startup_salesfrac=0,
finance_interest=0,
finance_years=0,
finance_fraction=0,
WC_over_FCI=WC_over_FCI,
)
self.labor_cost = labor_cost
self.fringe_benefits = fringe_benefits
self.property_tax = property_tax
self.property_insurance = property_insurance
self.supplies = supplies
self.maintenance = maintenance
self.administration = administration
# This returns the ISBL
def _ENG(self, installed_equipment_cost):
return (
installed_equipment_cost
+ installed_equipment_cost * input_data["OSBL_factor"]
) * input_data["Engineering"]
def _CON(self, installed_equipment_cost):
return (
installed_equipment_cost
+ installed_equipment_cost * input_data["OSBL_factor"]
) * input_data["Contingency"]
def _DPI(self, installed_equipment_cost):
return (
installed_equipment_cost
+ installed_equipment_cost * input_data["OSBL_factor"]
+ (
installed_equipment_cost
+ installed_equipment_cost * input_data["OSBL_factor"]
)
* input_data["Engineering"]
+ (
installed_equipment_cost
+ installed_equipment_cost * input_data["OSBL_factor"]
)
* input_data["Contingency"]
)
def _TDC(self, DPI):
return DPI
def _FCI(self, TDC):
self._FCI_cached = TDC
return TDC
def _FOC(self, FCI):
return FCI * (
self.property_tax
+ self.property_insurance
+ self.maintenance
+ self.administration
) + self.labor_cost + (self.fringe_benefits * self.labor_cost + self.supplies)
# this stream include the two polymers (film)
film = bst.Stream("film", C2H4=inlet_pe, units="kg/hr")
solvent_flow = bst.Stream(
"solvent_in",
Dodecane=inlet_solvent,
units="kg/hr",
price=input_data["Price"]["solvent"],
)
# P1 sep
(film) - FE101
(solvent_flow) - V100
(FE101 - 0, V100 - 0) - V101
(V101 - 0) - E101
(E101 - 0) - FHOT
(FHOT - 0) - P101
(P101 - 0) - V102
(V102 - 0) - E102
(E102 - 0) - P102
(P102 - 0) - F101
(F101 - 0) - H101
(S101 - 1, F101 - 1) - M100
(M100 - 0) - P106
# P2 SEP
(FHOT - 1) - H1012
(H101 - 1, H1012 - 1) - M101
(M101 - 0) - E103
(E103 - 0) - S101
(H101 - 0, H1012 - 0) - M1003
pp_sep_sys = bst.System(
"PP_Recovery_norecycle",
path=(
[
FE101,
V100,
V101,
E101,
FHOT,
P101,
V102,
E102,
P102,
F101,
H101,
M101,
E103,
S101,
H101,
M100,
P106,
H1012,
M1003,
]
),
N_runs=N_runs,
)
pp_sep_sys.simulate()
pp_sep_sys.save_report('results_n.xlsx')
bst.main_flowsheet.diagram(file='FlowDiagram', format='png', number=True)
pe_recovered_mass_flow = H1012.outs[0].get_flow("kg/hr", "C2H4")
evoh_recovered_mass_flow = H101.outs[0].get_flow("kg/hr", "C2H4")
solvent_dissoltion_tank = V101.outs[0].get_flow("kg/hr", "Dodecane")
plastic_dissolution_tank = V101.outs[0].get_flow("kg/hr", "C2H4")
solvent_plastic_ratio = solvent_dissoltion_tank/(plastic_dissolution_tank)
print("===============================")
print("Process completed.")
print("Solvent/plastic ratio at dissolution tank: ", solvent_plastic_ratio)
print("Recovered pe: ", pe_recovered_mass_flow, "kg/hr")
print("Recovered evoh: ", evoh_recovered_mass_flow, "kg/hr")
print("===============================")
strap_tea = STRAPTEA(
system=pp_sep_sys,
IRR=input_data["IRR"],
duration=input_data["duration"],
depreciation="MACRS7",
income_tax=input_data["Tax_rate"],
operating_days=input_data["year_operation_hours"]/24,
lang_factor=input_data["Lang_factor"],
construction_schedule=(0.4, 0.6),
WC_over_FCI=0.10,
labor_cost=input_data["Shift_operators"] *
input_data["Salariy_per_operator"],
fringe_benefits=input_data["Benefits_and_overhead"],
property_tax=0,
property_insurance=input_data["Insurance"],
supplies=0,
maintenance=input_data["Maintenance"],
administration=0.00,
)
feed = bst.main_flowsheet("PROD")
msp = strap_tea.solve_price(feed) # USD/kg
print("Minimum Selling price: ", int(msp * 1000), "USD/TON")
print("Total purchase cost: ", int(strap_tea.purchase_cost), "USD")
print("Total utility cost: ", int(strap_tea.utility_cost), "USD/y")
# cost of makeup solvent
solvent_cost = (
input_data["Price"]["solvent"]
* inlet_solvent
* input_data["year_operation_hours"]
)
installed_equipment_cost = strap_tea.installed_equipment_cost
DPI = strap_tea._DPI(installed_equipment_cost)
TDC = strap_tea._TDC(DPI)
FCI = strap_tea._FCI(TDC)
FOC = strap_tea._FOC(FCI)
# AOC = strap_tea._AOC(AOC)
ISBL = installed_equipment_cost
OSBL = installed_equipment_cost * input_data["OSBL_factor"]
ENG = strap_tea._ENG(installed_equipment_cost)
CON = strap_tea._CON(installed_equipment_cost)
electricity = pp_sep_sys.get_electricity_consumption()
# print("Total electricity consumption (kW-h/y): ", electricity)
cooling = pp_sep_sys.get_cooling_duty()
# print("Total cooling duty (kJ/y): ", cooling)
heating = pp_sep_sys.get_heating_duty()
# print("Total heating duty (kJ/y): ", heating)
results = {}
results["Processing capacity (ton/y)"] = (
(inlet_pe) * input_data["year_operation_hours"] / 1000
)
results['Solvent-plastic ratio at dissolution'] = solvent_plastic_ratio
# results['Solvent-plastic ratio at dissolution_2'] = solvent_plastic_ratio_2
# results["Recovered plastic PE (kg/hr)"] = round(PE, 4)
# results["Recovered plastic PE (kg/hr)"] = round(PE2, 4)
results["Solvent cost (USD/y)"] = round(solvent_cost, 2)
# results["Solvent recovery (%)"] = 100-solvent_p_loss
results["Minimum selling price (USD/kg)"] = round(msp, 4)
results["ISBL"] = ISBL
results["installed_equipment_cost"] = installed_equipment_cost
results["OSBL"] = OSBL
results["Engineering"] = ENG
results["Contingency"] = CON
results["Fixed capital investment"] = FCI
results["Fixed operating cost"] = FOC
# results["operating cost"] = AOC
# changes
# variable_cost = results["Solvent cost (USD/y)"] + results["Solvent cost_2 (USD/y)"] + results["Solvent cost_3 (USD/y)"] + strap_tea.utility_cost
variable_cost = results["Solvent cost (USD/y)"] + strap_tea.utility_cost
results["Variable operating cost"] = variable_cost
results["Total electricity consumption (kW-h/y)"] = electricity
results["Total cooling duty (kJ/y)"] = cooling
results["Total heating duty (kJ/y)"] = heating
print("Fixed capital investment: {:.2f} USD".format(FCI))
print("Fixed operating cost: {:.2f} USD/y".format(FOC))
print("Variable operating cost : {:.2f} USD/y".format(variable_cost))
print(
"Contribution of solvent to variable cost: ",
round(100 * (results["Solvent cost (USD/y)"]) / variable_cost, 2),
"%",
)
makeup_stream = inlet_solvent - P106.outs[0].get_flow("kg/hr", "Dodecane")
results['Solvent makeup flow (kg/hr)'] = makeup_stream
print('Solvent makeup flow (kg/hr)', makeup_stream)
adjusted_solvent_price = makeup_stream * \
input_data["Price"]["solvent"]/inlet_solvent
# print('Adjusted solvent price ($/kg)', adjusted_solvent_price)
#######LCA
functional_unit = (
inlet_pe * input_data["year_operation_hours"]
)
#Total electricity in MJ/y
El = electricity * 3.6
#Generated emissions due to electricity
Em_electricity = impact_elec * El / functional_unit
#kg CO2-eq/MJ * MJ/y / kg CO2/y
results['Climate change impact-electricity (kg CO2-eq/kg polymer)'] = Em_electricity
print ('Climate change impact-electricity (kg CO2-eq/kg polymer)', Em_electricity)
#Total steam in MJ/y
St = heating / 1000
#Generated emissions due to steam
Em_steam = impact_steam * St / functional_unit
#kg CO2-eq/MJ * MJ/y / kg CO2/y
results['Climate change impact-steam (kg CO2-eq/kg polymer)'] = Em_steam
print ('Climate change impact-steam (kg CO2-eq/kg polymer)', Em_steam)
# flow rate of chilled water in kmol/yr
flow_water = pp_sep_sys.get_utility_flow("chilled_water")
# flow rate of chilled brine in kmol/yr
flow_brine = pp_sep_sys.get_utility_flow("chilled_brine")
#Total water in m3/y
Wa = (flow_water+flow_brine) * 18 / 1000
#Generated emissions due to water consumption (assuming 20% make up)
Em_wa = impact_water * Wa * 0.02 / functional_unit
results['Climate change impact-water (kg CO2-eq/kg polymer)'] = Em_wa
print ('Climate change impact-water (kg CO2-eq/kg polymer)', Em_wa)
#Total climate change impact in kg CO2-eq/kg film
Emissions = Em_electricity + Em_steam + Em_wa
results['Climate change impact (kg CO2-eq/kg polymer)'] = Emissions
print ('Climate change impact (kg CO2-eq/kg polymer)', Emissions)
with open("_results_simulation.json", "w") as fp:
json.dump(results, fp, indent=4)
return adjusted_solvent_price
def main_simulation(input_data, real_price):
# calculate adjusted price using real price
adjusted_price = run_simulation(input_data, real_price)
# re-calculate costs with adjusted price
run_simulation(input_data, adjusted_price)
# ====================================================== run simulation
# Import input_data.json with main information about the process.
with open('input_data.json', 'r') as f:
input_data = json.load(f)
main_simulation(input_data, input_data["Price"]["solvent"])
|