import pandas as pd
%matplotlib inline
lifetime = 20 #years
discount_rate = 0.04 #0.0775 #per unit
size = 100 #kW
specific_cost = 800 #EUR/kW
fom = 20 #EUR/kW/a
fit = 0.1 #EUR/kWh
flh = 1000 #h/a
flows = pd.DataFrame(index=range(lifetime+1))
flows["investment"] = [-size*specific_cost] + [0]*lifetime
flows["FOM"] = [0] + [-size*fom]*lifetime
flows["income"] = [0] + [size*flh*fit]*lifetime
flows["total_flow"] = flows.sum(axis=1)
flows["discount_factor"] = [(1+discount_rate)**(-t) for t in range(lifetime+1)]
flows["discounted_total_flow"] = flows["total_flow"]*flows["discount_factor"]
flows.head()
flows.sum()
(size*specific_cost/(sum(flows["discount_factor"])-1)+2500)/1e5
flows["discount_factor"].plot()
lifetime = 40 #years
discount_rate = 0.10 #per unit
size = 3e6 #kW
specific_cost = 5000 #EUR/kW
decommissioning_cost = 0 #EUR/kW
fom = 20 #EUR/kW/a
fuel = 10 #EUR/MWh
market_value = 50 #EUR/MWh
flh = 8000 #h/a
flows = pd.DataFrame(index=range(lifetime+1))
flows["investment"] = [-size*specific_cost] + [0]*(lifetime-1) + [-size*decommissioning_cost]
flows["FOM"] = [0] + [-size*fom]*lifetime
flows["income"] = [0] + [size*flh*market_value/1000]*lifetime
flows["total_flow"] = flows.sum(axis=1)
flows["discount_factor"] = [(1+discount_rate)**(-t) for t in range(lifetime+1)]
flows["discounted_total_flow"] = flows["total_flow"]*flows["discount_factor"]
flows.head()
flows.sum()