使用 brightway 在 multiLCA 计算中表征库存矩阵
characterised inventory matrix in multiLCA calculations with brightway
multiLCA 对象的特征库存矩阵在 Brightway2 中表示什么?我本希望在对象中找到几个这样的矩阵,代表不同活动和不同影响评估方法的特征清单。
对于一个简单的 LCA 对象,已表征库存矩阵的所有元素的总和给出了该 activity 的总影响。但似乎不是 MultiLCA 对象的情况(例如)
#impact assessment method
i2002=[('IMPACT 2002+ (Endpoint)', 'resources', 'total'),
('IMPACT 2002+ (Endpoint)', 'climate change', 'climate change'),
('IMPACT 2002+ (Endpoint)', 'human health', 'total'),
('IMPACT 2002+ (Endpoint)', 'ecosystem quality', 'total')
]
fu=[]
for j in range(1,11):
fu.append({bw.Database('ei_33c').random():1})
testsetup_i2002 ={'inv': fu, 'ia':i2002}
bw.calculation_setups['testsetup_i2002'] = testsetup_i2002
mlca_test=bw.MultiLCA('testsetup_i2002')
result=mlca_test.lca.characterized_inventory.sum()
结果与从
获得的分数或分数总和不同
mlca_test.results()
大家可以看看MultiLCA
source code,比较简单。它会为计算的每一步覆盖 characterized_inventory
矩阵,并且只将结果存储在一个 Numpy 数组中:self.results = np.zeros((len(self.func_units), len(self.methods)))
。为了得到你想要的——为功能单元和 LCIA 方法的每个组合单独的特征化库存矩阵——你将不得不编写你自己的子类。这是一个例子:
from bw2calc.multi_lca import *
class PersistentMultiLCA(MultiLCA):
def __init__(self, cs_name):
if not calculation_setups:
raise ImportError
assert cs_name in calculation_setups
try:
cs = calculation_setups[cs_name]
except KeyError:
raise ValueError(
"{} is not a known `calculation_setup`.".format(cs_name)
)
self.func_units = cs['inv']
self.methods = cs['ia']
self.lca = LCA(demand=self.all, method=self.methods[0])
self.lca.lci(factorize=True)
self.method_matrices = []
self.results = {}
for method in self.methods:
self.lca.switch_method(method)
self.method_matrices.append(self.lca.characterization_matrix)
for row, func_unit in enumerate(self.func_units):
self.lca.redo_lci(func_unit)
for col, cf_matrix in enumerate(self.method_matrices):
self.lca.characterization_matrix = cf_matrix
self.lca.lcia_calculation()
self.results[row, col] = self.lca.characterized_inventory.copy()
multiLCA 对象的特征库存矩阵在 Brightway2 中表示什么?我本希望在对象中找到几个这样的矩阵,代表不同活动和不同影响评估方法的特征清单。
对于一个简单的 LCA 对象,已表征库存矩阵的所有元素的总和给出了该 activity 的总影响。但似乎不是 MultiLCA 对象的情况(例如)
#impact assessment method
i2002=[('IMPACT 2002+ (Endpoint)', 'resources', 'total'),
('IMPACT 2002+ (Endpoint)', 'climate change', 'climate change'),
('IMPACT 2002+ (Endpoint)', 'human health', 'total'),
('IMPACT 2002+ (Endpoint)', 'ecosystem quality', 'total')
]
fu=[]
for j in range(1,11):
fu.append({bw.Database('ei_33c').random():1})
testsetup_i2002 ={'inv': fu, 'ia':i2002}
bw.calculation_setups['testsetup_i2002'] = testsetup_i2002
mlca_test=bw.MultiLCA('testsetup_i2002')
result=mlca_test.lca.characterized_inventory.sum()
结果与从
获得的分数或分数总和不同mlca_test.results()
大家可以看看MultiLCA
source code,比较简单。它会为计算的每一步覆盖 characterized_inventory
矩阵,并且只将结果存储在一个 Numpy 数组中:self.results = np.zeros((len(self.func_units), len(self.methods)))
。为了得到你想要的——为功能单元和 LCIA 方法的每个组合单独的特征化库存矩阵——你将不得不编写你自己的子类。这是一个例子:
from bw2calc.multi_lca import *
class PersistentMultiLCA(MultiLCA):
def __init__(self, cs_name):
if not calculation_setups:
raise ImportError
assert cs_name in calculation_setups
try:
cs = calculation_setups[cs_name]
except KeyError:
raise ValueError(
"{} is not a known `calculation_setup`.".format(cs_name)
)
self.func_units = cs['inv']
self.methods = cs['ia']
self.lca = LCA(demand=self.all, method=self.methods[0])
self.lca.lci(factorize=True)
self.method_matrices = []
self.results = {}
for method in self.methods:
self.lca.switch_method(method)
self.method_matrices.append(self.lca.characterization_matrix)
for row, func_unit in enumerate(self.func_units):
self.lca.redo_lci(func_unit)
for col, cf_matrix in enumerate(self.method_matrices):
self.lca.characterization_matrix = cf_matrix
self.lca.lcia_calculation()
self.results[row, col] = self.lca.characterized_inventory.copy()