私はbw2の新機能を使用しています。データベースを使用せずに手動で定義されたインベントリとLCIAメソッドを使用するだけで簡単なLCAを作成しようとしています。第11章の例の値を「ライフサイクルアセスメントの計算構造」の本から引用しました。brightway2で非常に簡単なLCIAメソッドを作成する
私は、インベントリを作成して、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)
私は(簡単にするために1に設定されているすべてのCFSとの)仮想LCIAメソッドを作成するときしかし、問題は開始します。これは私が使用したコードですが、明らかに動作しません。重要な問題は、取引所を在庫から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チュートリアル、ドキュメンテーション、および以前の質問をチェックしましたが、答えは見つかりませんでした。前もって感謝します。
ありがとうございます。私は間違いを見て、私はLCIAメソッド定義の "生物圏"の部分に混乱していましたが、代わりにそれがデータベースを指すフローのタイプだと思いました。 'myLCIAdata = [[( 'testdb'、 'Carbon dioxide')、1.0] ...' lca.lcia() 'を追加して、コードを修正しました。 (エレガンスポイントを得た、提案のおかげで)。 – Bax