Skip to content

Commit

Permalink
improve setting in CHP utility stream prices
Browse files Browse the repository at this point in the history
  • Loading branch information
yalinli2 committed Oct 21, 2024
1 parent 0164999 commit 5e2d8f0
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions qsdsan/sanunits/_combustion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

# %%

import biosteam as bst
from warnings import warn
from flexsolve import IQ_interpolation
from biosteam import HeatUtility, Facility
Expand Down Expand Up @@ -302,7 +303,10 @@ def _cost(self):
unit_CAPEX = self.unit_CAPEX
unit_CAPEX /= 3600 # convert to $ per kJ/hr
self.baseline_purchase_costs['CHP'] = unit_CAPEX * self.H_net_feeds

# Update biosteam utility costs
uprices = bst.stream_utility_prices
uprices['Fuel'] = uprices['Natural gas'] = self.ins[1].price
uprices['Ash disposal'] = self.outs[1].price

def _refresh_sys(self):
sys = self._system
Expand All @@ -311,10 +315,33 @@ def _refresh_sys(self):
hu_dct = self._sys_heating_utilities = {}
pu_dct = self._sys_power_utilities = {}
for u in units:
hu_dct[u.ID] = tuple([i for i in u.heat_utilities if i.duty*i.flow>0])
hu_dct[u.ID] = tuple([i for i in u.heat_utilities if (
i.duty*i.flow>0 and i.agent.F_mass==i.agent.imass['H2O'])]
)
pu_dct[u.ID] = u.power_utility


@property
def fuel_price(self):
'''
[Float] Price of fuel (natural gas), set to be the same as the price of ins[1]
and `bst.stream_utility_prices['Natural gas']`.
'''
return self.ins[1].price

natural_gas_price = fuel_price

@property
def ash_disposal_price(self):
'''
[Float] Price of ash disposal, set to be the same as the price of outs[1]
and `bst.stream_utility_prices['Ash disposal']`.
Negative means need to pay for ash disposal.
'''

"""[Float] Price of ash disposal, same as `bst.stream_utility_prices['Ash disposal']`."""
return self.outs[1].price

@property
def CHP_type(self):
'''
Expand Down

4 comments on commit 5e2d8f0

@yalinli2
Copy link
Member Author

@yalinli2 yalinli2 commented on 5e2d8f0 Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jiananf2 FYI, this will increase price (almost $1/gal), I think it's because the change in new lines 318-320. Because now biosteam has natural_gas as a utility stream, CHP cannot offset natural_gas but the previous codes couldn't differentiate natural_gas from steams.

Let me know if you see problems, otherwise I'll update the test results when I merge my recent changes into main.

Image

@jiananf2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yalinli2, did you remove the natural gas price in systems.py (CHP.ins[1].price = 0.1685)?

@yalinli2
Copy link
Member Author

@yalinli2 yalinli2 commented on 5e2d8f0 Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jiananf2 no I didn't, I made sure it's the same across the system, regardless of you set it through:

  1. ```biosteam.stream_utility_prices`
  2. CHP.ins[0].price
  3. CHP.fuel_price
  4. CHP.natural_gas_price

additionally, I found that when biosteam calculating the natural gas costs, it'll look like whether you accounted for it as a chemical so it won't double-count

also, (I forgot what else bugs I fixed) now results are closer prior to the changes
pfas branch
https://github.com/QSD-Group/EXPOsan/blob/2a95b70f89623b12ace86cdd83a793614d1394aa/tests/test_htl.py#L38-L51
Image

current simulation
Image

@jiananf2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Please sign in to comment.