Closed TimoDiepers closed 4 weeks ago
Hi Timo,
I would be interested in the solution to this, since I am facing the same problem. I assume you are using bw2calc==2.0.dev17 May I ask which version of bw2data you are using, since I dont find the function "get_multilca_data_objs" in bw2data==4.0.dev33
@transfluxus I'm on bw2data=4.0.dev45, which is currently the latest version. get_multilca_data_objs
seems to have been added with 4.0dev40 and wasn't changed since then -> https://github.com/brightway-lca/brightway2-data/blob/main/CHANGES.md#40dev40-2024-06-05
@TimoDiepers thanks, I can confirm the error :)
@TimoDiepers @transfluxus Sorry about this.
To support multiple method impact categories with a single list of data objects, we needed to filter the data objects per impact category (and normalization and weighting), which in turn meant that we needed to include the necessary information to apply filtering in the datapackage.
I just ran into the same problem, as I hadn't changed my database, so the older datapackage was still being used, but this was missing the needed "name" attribute. Long story short, do this:
import bw2data
for method in bw2data.methods:
bw2data.Method(method).process()
Thanks @cmutel , nice. It runs for me now. However, MultiLCA often results in 0 results:
# normal LCA
heat_and_power_act = db.get("b9d74efa4fd670b1977a3471ec010737")
print(heat_and_power_act)
# > 'heat and power co-generation, wood chips, 6667 kW, state-of-the-art 2014' (kilowatt hour, DK, None)
method = ('EF v3.1', 'climate change', 'global warming potential (GWP100)')
lca = LCA({heat_and_power_act: 1.0},method)
lca.lci()
lca.lcia()
print(lca.score)
# > 0.0540628976277506
# MultiLCA
demand = {"energy": {heat_and_power_act.id: 1.0}}
method_config = {
"impact_categories": [method]
}
for method in method_config["impact_categories"]:
bw2data.Method(method).process()
data_objs = bw2data.get_multilca_data_objs(functional_units=demand, method_config=method_config)
mlca = MultiLCA(demands=demand, method_config=method_config, data_objs=data_objs)
mlca.lci()
mlca.lcia()
print(mlca.scores)
# > {(('EF v3.1', 'climate change', 'global warming potential (GWP100)'), 'energy'): 0.0}
@transfluxus @cmutel My original example works now, but I could also reproduce the zero value above. However, I've come to notice that this only occurs if only one entry is in functional units. If there are two, it seems to work:
heat_and_power_act = bd.get_node(database="ecoinvent-3.10-cutoff", name="heat and power co-generation, wood chips, 6667 kW, state-of-the-art 2014", location="DK", unit="kilowatt hour")
functional_units = {
"one": {heat_and_power_act.id: 1},
"two": {heat_and_power_act.id: 1}, # leaving this out results in a score of 0
}
config = {
"impact_categories": [
("EF v3.1", "climate change", "global warming potential (GWP100)"),
],
}
data_objs = bd.get_multilca_data_objs(
functional_units=functional_units, method_config=config
)
mlca = bc.MultiLCA(demands=functional_units, method_config=config, data_objs=data_objs)
mlca.lci()
mlca.lcia()
mlca.scores
# > {(('EF v3.1', 'climate change', 'global warming potential (GWP100)'),
# > 'one'): 0.05507812866658305,
# > (('EF v3.1', 'climate change', 'global warming potential (GWP100)'),
# > 'two'): 0.05507812866658305}
And I think the problem lies here: https://github.com/brightway-lca/brightway2-calc/blob/ef9bac1565488290ccaf5c02e0d09798a9345725/bw2calc/multi_lca.py#L351-L354
I'm not sure if this is an actual issue of bw2calc or even an issue at all (maybe I just don't fully understand how the new MultiLCA implementation works, sorry in that case), but I tried using the new MultiLCA calculation and keep getting an AllArraysEmpty Error - for the characterization matrix as it seems. What I did:
If I do a normal LCA with this same data it works just fine.
I tried to look into this but couldn't figure out why this part here in MultiLCA.load_lcia_data returned no values in the arrays: https://github.com/brightway-lca/brightway2-calc/blob/ef9bac1565488290ccaf5c02e0d09798a9345725/bw2calc/multi_lca.py#L254C1-L260C15
Also, here's the complete error message I get when calling MultiLCA.lcia():