Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPV/solve_IRR/solve_price methods consistent with cashflow table #180 #183

Merged
merged 5 commits into from
Jan 10, 2024

Conversation

yoelcortes
Copy link
Member

@yoelcortes yoelcortes commented Jan 10, 2024

It should work as it should, but we still need to add tests.

from biorefineries import cornstover as cs
cs.ethanol.price = 0.7198608114634679
table = cs.tea.get_cashflow_table()
print(table['Cumulative NPV [MM$]'].iloc[-1]*1e6)
print(cs.tea.NPV)
31341873.413599316
31341873.413599316
from biorefineries import cornstover as cs
cs.ethanol.price = 0.7198608114634679
table = cs.tea.get_cashflow_table()
index = ['Taxed earnings [MM$]', 'Forwarded losses [MM$]', 'Tax [MM$]', 'Net earnings [MM$]']
table[index]
      Taxed earnings [MM$]  Forwarded losses [MM$]  Tax [MM$]  Net earnings [MM$]
2004                     0                       0          0                   0
2005                     0                       0          0                   0
2006                     0                       0          0                   0
2007                     0                       0          0               -29.4
2008                     0                   -29.4          0               -51.3
2009                     0                   -80.8          0                 -28
2010                     0                    -109          0               -11.3
2011                     0                    -120          0               0.618
2012                     0                    -119          0               0.651
2013                     0                    -119          0               0.618
2014                     0                    -118          0                15.5
2015                     0                    -103          0                30.4
2016                     0                   -72.1          0                30.4
2017                  9.96                   -41.7       3.49                48.2
2018                  51.7                       0       18.1                33.6
2019                  51.7                       0       18.1                33.6
2020                  51.7                       0       18.1                33.6
2021                  51.7                       0       18.1                33.6
2022                  51.7                       0       18.1                33.6
2023                  51.7                       0       18.1                33.6
2024                  51.7                       0       18.1                33.6
2025                  51.7                       0       18.1                33.6
2026                  51.7                       0       18.1                33.6
2027                  51.7                       0       18.1                33.6
2028                  51.7                       0       18.1                33.6
2029                  51.7                       0       18.1                33.6
2030                  51.7                       0       18.1                33.6
2031                  51.7                       0       18.1                33.6
2032                  51.7                       0       18.1                33.6
2033                  51.7                       0       18.1                33.6
2034                  51.7                       0       18.1                33.6
2035                  51.7                       0       18.1                33.6
2036                  51.7                       0       18.1                33.6

Copy link
Member

@yalinli2 yalinli2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test added!

@yalinli2
Copy link
Member

@yoelcortes thanks for patching up things, I added the test and it passed. I'm attaching the updated Excel sheet in case for the test case and people can check the formula, feel free to close this!

TEA comparison_V03.xlsx

@yoelcortes
Copy link
Member Author

@yalinli2, I greatly appreciate the rigorous tests you added!

By the way, I also added some tests of my own for consistency between solve_price, solve_IRR, and NPV methods. It turns out there was a minor bug that always resulted in solve_price never reaching an NPV of exactly 0. The issue was in the sales fraction during startup (this is fixed now!; see commits).

@yoelcortes yoelcortes merged commit 6f94939 into master Jan 10, 2024
1 check failed
@yalinli2
Copy link
Member

GREAT! I'll delete the npv branch now, glad we got them all fixed!

@yalinli2 yalinli2 deleted the npv branch January 10, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants