OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
23 stars 17 forks source link

[Bug]: Incorrect `DiscountRateIdv` and `DiscountRate` assignments in `CapitalIvestment` calcualtion #228

Open trevorb1 opened 2 months ago

trevorb1 commented 2 months ago

The Issue

In the results processing we correctly assign DiscountRateIdv the value of DiscountRate if no DiscountRateIdv is given; see below.

https://github.com/OSeMOSYS/otoole/blob/efe0e170258994f6514ec9a49a0a5a0dcabaa102/src/otoole/results/result_package.py#L295-L342

However, as flagged by @robertodawid in this comment, if a DiscountRateIdv is given, the DiscountRate value passed into both the capital recovery factor and PV Annuity calculation will be the DiscountRateIdv value. This is incorrect. CRF should use the DiscountRateIdv but the PV Annuity should still use the DiscountRate value.

Expected Behavior

No response

Steps To Reproduce

No response

Log output

No response

Operating System

Linux

What version of otoole are you running?

1.1.2

Possible Solution

Add in a variable called discount_rate_idv, which is what the conditional assigns. Pass this in the CRF calculation, and just the discount_rate into the PVA calculation.

Not sure if this will cause issues with the change in index levels, but we have a comment here that seems to address this already.

Anything else?

No response