brightway-lca / brightway2-calc

The calculation engine for the Brightway2 life cycle assessment framework.
BSD 3-Clause "New" or "Revised" License
14 stars 16 forks source link

`MultiLCA` gives zero scores for single demand/multiple impact categories #107

Closed pjamesjoyce closed 2 months ago

pjamesjoyce commented 2 months ago

I understand the main use case for MultiLCA is multiple demands, multiple impact methods, but I get an odd behaviour when trying to run it for a single demand and multiple impact assessment methods. It runs with no errors or warnings, but gives a result of 0.0 every time.

For example, where EF31 is a list of the EF3.1 impact assessment methods:

EF31 = [('EF v3.1', 'acidification', 'accumulated exceedance (AE)'),
 ('EF v3.1', 'climate change', 'global warming potential (GWP100)'),
etc...

and demands consists of one item:

demands = {'isopropyl acetate production': {13507: 1}}

The following runs as a MultiLCA

method_config = {
    'impact_categories': EF31,
}

assert bc.method_config.MethodConfig(**method_config)

data_objs = bd.get_multilca_data_objs(functional_units=demands, method_config=method_config)

mlca = bc.MultiLCA(
    demands=demands,
    method_config=method_config,
    data_objs=data_objs
)
mlca.lci()
mlca.lcia()

but the results are all zero:

to_df = []
for (i, a), s in mlca.scores.items():
    to_df.append(dict(
        impact = i[1],
        activity = a,
        score = s
    ))
df = pd.DataFrame(to_df)
df
impact activity score
0 acidification isopropyl acetate production 0
1 climate change isopropyl acetate production 0
2 ecotoxicity: freshwater isopropyl acetate production 0
3 energy resources: non-renewable isopropyl acetate production 0
4 eutrophication: freshwater isopropyl acetate production 0
5 eutrophication: marine isopropyl acetate production 0
6 eutrophication: terrestrial isopropyl acetate production 0
7 human toxicity: carcinogenic isopropyl acetate production 0
8 human toxicity: non-carcinogenic isopropyl acetate production 0
9 ionising radiation: human health isopropyl acetate production 0
10 land use isopropyl acetate production 0
11 material resources: metals/minerals isopropyl acetate production 0
12 ozone depletion isopropyl acetate production 0
13 particulate matter formation isopropyl acetate production 0
14 photochemical oxidant formation: human health isopropyl acetate production 0
15 water use isopropyl acetate production 0

If you add a second item to the demands e.g.:

demands = {'isopropyl acetate production': {13507: 1},
 'potassium carbonate production, from potassium hydroxide': {7843: 1}}

and then run exactly the same code, the scores appear for the original item:

impact activity score
0 acidification isopropyl acetate production 0.0180329
1 acidification potassium carbonate production, from potassium hydroxide 0.0160523
2 climate change isopropyl acetate production 3.68333
3 climate change potassium carbonate production, from potassium hydroxide 3.07375

etc....

Is this expected behaviour? and if so, what's best practice for running multiple impact categories for one demand?

Thanks

cmutel commented 2 months ago

We have explicit tests for a single functional unit, so I'm not sure what is happening here. Can you check the same setup (same functional unit and first impact category) in the normal LCA? Otherwise, I would need more info on the way your data is setup to be able to debug anything...

pjamesjoyce commented 2 months ago

Sorry @cmutel - ignore this - whatever was causing it for me must've been been fixed between dev17 and dev21 - teach me to always update to the latest and greatest before posting an issue!