Fix the consumption function
#601
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Broken this off from #556 as it's relatively simple and self contained
The
consumptionfunction takes production data and then back-calculates commodity consumption based on the technologyCommIn. But the calculation was all wrongLet's say you've got a technology with the following reaction: 1A -> 2B + 3C
If you present production data of 4B & 6C to
consumption, you should get 2A (this is the amount of A you'd need to produce 4B and 6C). To calculate this, you first need to calculate the degree of technology activity (i.e. how many units of flow do you need to produce 4B and 6C), and then multiply this by theCommInquantity (in this case 1).But previously it was summing together the output quantities (assuming they are both end-use commodities) and multiplying this by
CommIn, so it would have given 10A ((4 + 6) * 1)The logic for correctly calculating the degree of technology activity is included in a new function
production_amplitude. This same calculation is done a few times in thecostsmodule, although I haven't used the function here to avoid conflicts with #556Hopefully
consumptionis now correct and more readable. This will have implications for commodity prices as fuel costs ans material costs depend on the amount of commodity consumption. It doesn't change any of the results in the example models as all the technologies have a single end-use output commodity.