0

我无法成功应用于switch_methodmontecarlo 对象。我尝试从具有不确定性的方法切换到没有不确定性的产品系统中的方法,但我仍然得到不确定的结果。

特此举个例子:

pm25_key=('biosphere3', '051aaf7a-6c1a-4e86-999f-85d5f0830df6')

# uncertain method

cfs=[(pm25_key,{"amount": 10,
       "uncertainty type": 4,
       "minimum": 0,
       "maximum": 20}),]

test_method_name_1=('test method Stackoverflow','1 unspecified')
test_method_1=bw.Method(test_method_name_1)
metadata_test_method={'description':'method with 1 uncertain CF',
 'unit':'DALY'}
test_method_1.register(**metadata_test_method)
test_method_1.write(cfs)

# static method

cfs2=[(pm25_key,10)]
test_method_name_2=('test method Stackoverflow','0 unspecified')
test_method_2=bw.Method(test_method_name_2)
metadata_test_method={'description':'method with 0 uncertain CF',
 'unit':'DALY'}
test_method_2.register(**metadata_test_method)
test_method_2.write(cfs2)

定义一个没有不确定性的简单产品系统

# test activities 

act1_key=('test_so','activity_1')


biosphere_exchange_1={'amount':1,
                    'input':pm25_key,
                    'output':act1_key,
                    'type':'biosphere',
                    'uncertainty type': 0}

production_exchange_1={'amount':1,
                     'input':act1_key,
                     'output':act1_key,
                     'type':'production',
                     'uncertainty type':0}

act_1_dict={'name':'test_activity_1',
             'unit':'megajoule',
             'exchanges':[production_exchange_1,biosphere_exchange_1]}

# activity 2


act2_key=('test_so','activity_2')

production_exchange_2={'amount':1,
                     'input':act2_key,
                     'output':act2_key,
                     'type':'production',
                     'uncertainty type':0}

technosphere_exchange_1={'amount':10, 
'input':act1_key,
'output':act2_key,
'type':'technosphere',
'uncertainty type':0}

act_2_dict={'name':'test_activity_2',
            'unit':'megajoule',
            'exchanges':[production_exchange_2,technosphere_exchange_1]}

database_dict={act1_key:act_1_dict,
               act2_key:act_2_dict}

db=bw.Database('test_so')
db.write(database_dict)
mc=bw.MonteCarloLCA({('test_so','activity_2'):1},('test method Stackoverflow','1 unspecified'))
next(mc)
next(mc)

我得到不同的结果,好的

# now try to switch method
mc.switch_method(('test method Stackoverflow','0 unspecified'))
next(mc)
next(mc)

我仍然得到不同的结果

mc.redo_lcia() 

next(mc) # still uncertain


mc.load_lcia_data()
mc.characterization_matrix.toarray() # this shows a CF of 10 (as expected)

但我一直在做next(mc)我一直得到不同的结果,理论上我已经切换到一种没有不确定性的方法并且我在 A 或 B 矩阵中没有不确定性..你知道问题出在哪里吗?我正在使用 Brightway 版本 2,3 。bw2data 3.6.2 版和 bw2calc 1.8.0 版

4

0 回答 0