3

I try to run a Monte Carlo analysis with uncertainty on characterization factor. The code is running well (no error) but the results for each iteration are always the same. Calculation works with just LCA simulation.

Here is the code:

Definition of a sample LCIA method

some_exchange = bw.Database('biosphere3').random()
my_cf = [(some_exchange.key,
      {"amount": 10,
       "uncertainty_type": 4,
       "minimum": 0,
       "maximum": 20}
     )]
uncertain_method = bw.Method(("fake", "method", "with uncertainty"))
uncertain_method.write(my_cf)

Definition of an simple activity

simple_LCI_db = bw.Database('simple LCI db')
simple_LCI_db.write(
    {('simple LCI db', 'some_code'): 
        {'name': 'fake activity',
         'unit': 'amount',
         'exchanges': 
            [
                {'input': ('simple LCI db', 'some_code'),
                 'amount': 1,
                 'type': 'production'},
                {'input': some_exchange.key,
                 'amount': 1,
                 'type': 'biosphere'},                
            ]
        },

})

Monte Carlo code

mc = bw.MonteCarloLCA({('simple LCI db', 'some_code'):1}, ('fake', 'method', 'with uncertainty'))
next(mc)

Is there something wrong with the uncertainty definition?

Thank for your help!

1 Answers1

1

You simply need to define your uncertainty dictionary slightly differently: in Brightway, the uncertainty type is written without the _, i.e.

my_cf = [(some_exchange.key,
      {"amount": 10,
       "uncertainty type": 4, #and not "uncertainty_type"
       "minimum": 0,
       "maximum": 20}
     )]

You can see the schema for the uncertainty dictionary in the Brightway framework in the Brightway documentation

You wrote it like it is defined in the stats_arrays documentation. I do not know why they are different, i.e. why in one case we have uncertainty type and in the other uncertainty_type, but just remove your _ and your code will work.

MPa
  • 1,086
  • 1
  • 10
  • 25