Skip to content

Commit

Permalink
MMBTUs, flow characterization depends on context, tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bkuczenski committed Dec 24, 2024
1 parent 97d49ab commit d4adcc0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions antelope_core/archives/data/elcd_reference_quantities.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@
"MWh": 0.0002777777777777778,
"TCE": 3.412084237535657e-05,
"TOE": 2.3884589662749594e-05,
"btu": 947.8169879134379,
"Btu": 947.8169879134379,
"MMBtu": 9.478169879134379e-04,
"mmBtu": 9.478169879134379e-04,
"kWh": 0.2777777777777778,
"kcal": 238.85160149998808
},
Expand Down Expand Up @@ -671,7 +673,9 @@
"MWh": 0.0002777777777777778,
"TCE": 3.412084237535657e-05,
"TOE": 2.3884589662749594e-05,
"btu": 947.8169879134379,
"Btu": 947.8169879134379,
"MMBtu": 9.478169879134379e-04,
"mmBtu": 9.478169879134379e-04,
"kWh": 0.2777777777777778,
"kcal": 238.85160149998808
},
Expand Down
3 changes: 3 additions & 0 deletions antelope_core/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def __iter__(self):
for k in self.as_list():
yield k

def __bool__(self):
return not self.is_null

def __hash__(self):
return hash(self._id) # don't mess with the hash

Expand Down
9 changes: 7 additions & 2 deletions antelope_core/entities/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ def __str__(self):

def characterize(self, quantity, value, context=None, origin=None, location='GLO', **kwargs):
if context is None:
context = self.context
flowable = self.name
if bool(self.context):
context = self.context
flowable = self.name
else:
flowable = self.link
else:
flowable = self.name
if origin is None:
origin = self.origin
self.pop_char(quantity, context, location)
Expand Down
4 changes: 2 additions & 2 deletions antelope_core/fragment_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ def from_process_inventory(cls, query, process, ref_flow, elementary=False, exte
exchange_value=1.0, observe=True)
node = parent.observe_anchor(None, process, anchor_flow=rx.flow)
ff = [cls(parent, 1.0, 1.0, node, False)]
for ex in process.ad(ref_flow): # returns exchangevalues
for ex in process.dependencies(ref_flow): # returns exchangevalues
n = query.get(ex.termination)
cf = Fragment(n.external_ref, ex.flow, ex.direction, exchange_value=ex.value, observe=True,
parent=parent, anchor=n, anchor_flow=ex.flow)

ff.append(cls(cf, ex.value, ex.value, cf.anch, False))
if exterior:
for ex in process.bf(ref_flow=ref_flow):
for ex in process.emissions(ref_flow=ref_flow):
if ex.termination.elementary and not elementary:
continue
# still include non-elementary cutoffs
Expand Down
2 changes: 2 additions & 0 deletions antelope_core/lcia_engine/clookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,7 @@ def add(self, value, key=None):
print('Collision with context: %s' % repr(key))
print(repr(value))
print('%s current' % repr(existing))
print(existing.value)
print(value.value)
raise FactorCollision('This context already has a CF defined!')
super(SCLookup, self).add(value, key)

0 comments on commit d4adcc0

Please sign in to comment.