0

我对 bw2 很陌生,我正在尝试在不使用数据库的情况下制作一个简单的 LCA,而只是使用手动定义的库存和 LCIA 方法。我使用了“生命周期评估的计算结构”一书第 11 章中示例中的值。

我能够创建库存并运行 LCI 计算:

t_db = Database("testdb")

t_db.write({
    ("testdb", "Electricity production"):{
        'name':'Electricity production',
        'unit': 'kWh', 
        'exchanges': [{
                'input': ('testdb', 'Fuel production'),
                'amount': 2,
                'unit': 'kg',
                'type': 'technosphere'
            },{
                'input': ('testdb', 'Carbon dioxide'),
                'amount': 1,
                'unit': 'kg',
                'type': 'biosphere'
            },{
                'input': ('testdb', 'Sulphur dioxide'),
                'amount': 0.1,
                'unit': 'kg',
                'type': 'biosphere'
            },{
                'input': ('testdb', 'Electricity production'), #important to write the same process name in output
                'amount': 10,
                'unit': 'kWh',
                'type': 'production'
            }]
        },
    ('testdb', 'Fuel production'):{
        'name': 'Fuel production',
        'unit': 'kg',
        'exchanges':[{
                'input': ('testdb', 'Carbon dioxide'),
                'amount': 10,
                'unit': 'kg',
                'type': 'biosphere'
            },{
                'input': ('testdb', 'Sulphur dioxide'),
                'amount': 2,
                'unit': 'kg',
                'type': 'biosphere'
            },{
                'input': ('testdb', 'Crude oil'),
                'amount': -50,
                'unit': 'kg',
                'type': 'biosphere'
            },{
                'input': ('testdb', 'Fuel production'),
                'amount': 100,
                'unit': 'kg',
                'type': 'production'
            }]
    },
    ('testdb', 'Carbon dioxide'):{'name': 'Carbon dioxide', 'unit':'kg', 'type': 'biosphere'},
    ('testdb', 'Sulphur dioxide'):{'name': 'Sulphur dioxide', 'unit':'kg', 'type': 'biosphere'},
    ('testdb', 'Crude oil'):{'name': 'Crude oil', 'unit':'kg', 'type': 'biosphere'}

    })

functional_unit = {t_db.get("Electricity production") : 1000}
lca = LCA(functional_unit) 
lca.lci()
print(lca.inventory)

然而,当我创建虚构的 LCIA 方法时问题就开始了(为简单起见,所有 CF 都设置为 1)。这是我使用的代码,但显然它不起作用。关键问题似乎是未能将清单中的交换与 LCIA 方法联系起来。

myLCIAdata = [[('biosphere', 'Carbon dioxide'), 1.0], 
         [('biosphere', 'Sulphur dioxide'), 1.0],
         [('biosphere', 'Crude oil'), 1.0]]

method_key = ('simplemethod', 'imaginaryendpoint', 'imaginarymidpoint')
Method(method_key).validate(myLCIAdata) #returns "TRUE"
Method(method_key).register() 
Method(method_key).write(myLCIAdata)
Method(method_key).load() #check everything works
lca = LCA(functional_unit, method_key) #run LCA calculations again with method
lca.characterized_inventory

结果是<3x2 sparse matrix of type '<class 'numpy.float64'>' with 0 stored elements in Compressed Sparse Row format> 一个空矩阵。知道我犯了什么错误吗?我是否应该像在现有数据库中一样为每个交易所获取一个唯一标识符?我检查了本网站上的 bw2 教程、文档和以前的问题,但找不到答案。提前致谢。

4

1 回答 1

0

你很亲密。在定义 CF 时,请执行以下操作:

myLCIAdata = [[('biosphere', 'Carbon dioxide'), 1.0], 
              [('biosphere', 'Sulphur dioxide'), 1.0],
              [('biosphere', 'Crude oil'), 1.0]]

以第一行为例,这意味着在数据库biosphere中,将有一个带有代码的流程Carbon dioxide。但是您没有biosphere数据库,您将所有内容放入名为的数据库中testdb

    ('testdb', 'Carbon dioxide'):{'name': 'Carbon dioxide', 'unit':'kg', 'type': 'biosphere'},

因此,要么在特征因子列表中使用正确的数据库名称,要么创建一个单独的生物圈数据库,名为biosphere.

还要注意,而不是这个:

method_key = ('simplemethod', 'imaginaryendpoint', 'imaginarymidpoint')
Method(method_key).validate(myLCIAdata) #returns "TRUE"
Method(method_key).register() 
Method(method_key).write(myLCIAdata)

你应该做这个:

method_key = ('simplemethod', 'imaginaryendpoint', 'imaginarymidpoint')
my_method = Method(method_key)
my_method.validate(myLCIAdata)
my_method.register() 
my_method.write(myLCIAdata)

(您的代码没有损坏,但可能更优雅)。

于 2017-01-04T16:40:37.273 回答