Commit c895f446 authored by kdas's avatar kdas
Browse files

introducing wake - not working fully yet

parent 2335eb4c
Pipeline #20699 failed with stages
in 1 minute and 3 seconds
......@@ -23,6 +23,13 @@ import pickle
from docplex.mp.model import Model
import numpy_financial as npf
from py_wake.site._site import UniformWeibullSite
from py_wake.wind_turbines import OneTypeWindTurbines, WindTurbines
from py_wake.wake_models.noj import NOJ
from py_wake.wake_models.gaussian import BastankhahGaussian
from py_wake.aep_calculator import AEPCalculator
#from landbosse.excelio import landbosse_input_dir
......@@ -848,6 +855,140 @@ class HPP(object):
P_RES_available_ts[0], P_HPP_ts[0], P_curtailment_ts[0], \
P_charge_discharge_ts[0], E_SOC_ts[0], hpp_investment_cost, \
hpp_maintenance_cost, LCOE, NPV, IRR
def sizing_Wind_Solar_with_Wake(self, wind_ts, solar_ts, price_ts, wake_losses_ts):
"""
Method to calculate sizing of wind and solar
Returns
-------
Capacity of Wind Power
Capacity of Solar Power
HPP power output timeseries
HPP power curtailment timeseries
HPP total CAPEX
HPP total OPEX
Levelised cost of energy
"""
# extract parameters into the variable space
globals().update(self.__dict__)
mdl = Model(name='Sizing')
time = wake_losses_ts.index
wind_wake = wind_ts - wake_losses_ts
# wind_wake = wind_ts
# plt.plot(wind_ts)
# plt.plot(wind_wake)
# print(wind_ts.sum())
# print(wind_wake.sum())
# print(wake_losses_ts.sum())
# Variables definition
P_HPP_t = mdl.continuous_var_dict(
time, lb=0, ub=hpp_grid_connection,
name='HPP power output')
P_curtailment_t = mdl.continuous_var_dict(
time, lb=0, name='Curtailment')
Wind_MW = mdl.integer_var(lb=0, name='Wind capacity')
Solar_MW = mdl.integer_var(lb=0, name='Solar capacity')
for t in time:
# Constraints
#mdl.add_constraint(((turbine_spacing * rotor_diameter * 0.001 * (nWT_per_string-1)) * (turbine_row_spacing * rotor_diameter * 0.001 * ((X*(1/(rating_WT*nWT_per_string)))-1)) ) + (land_SOL*Y) <= land_area_available)
mdl.add_constraint(
P_curtailment_t[t] >= wind_wake[t] * Wind_MW +
solar_ts[t] * Solar_MW -
hpp_grid_connection)
mdl.add_constraint(
P_HPP_t[t] == wind_wake[t] * Wind_MW +
solar_ts[t] * Solar_MW -
P_curtailment_t[t])
# Objective function
mdl.maximize(
# E_u(NPV)
#mdl.sum(NPV[u]*weights[u] for u in unc)
# Q_u(NPV, q) approximate by a N
#mdl.sum(NPV[u]**N *weights[u] for u in unc)**(1/N)
#
#E_u(NPV) - 2*S_u(NPV)
# CAPEX
-(wind_turbine_cost * Wind_MW + \
solar_PV_cost * Solar_MW + \
hpp_BOS_soft_cost * (Wind_MW + Solar_MW) + \
hpp_grid_connection_cost * hpp_grid_connection + \
solar_hardware_installation_cost * Solar_MW + \
wind_civil_works_cost * Wind_MW) + \
# revenues and OPEX
mdl.sum(
(mdl.sum(
price_ts[t] * (wind_wake[t] * Wind_MW + \
solar_ts[t] * Solar_MW - \
P_curtailment_t[t])
for t in time) + \
- (wind_fixed_onm_cost * Wind_MW + \
solar_fixed_onm_cost * Solar_MW)
) / np.power(1 + hpp_discount_factor, i)
for i in range(1, hpp_lifetime + 1)
)
)
# Solving the problem
sol = mdl.solve(log_output=False)
# print(mdl.export_to_string())
# sol.display()
P_curtailment_ts = pd.DataFrame.from_dict(
sol.get_value_dict(P_curtailment_t), orient='index')
P_HPP_ts = pd.DataFrame.from_dict(
sol.get_value_dict(P_HPP_t), orient='index')
AEP = P_HPP_ts[0].sum()
AEP_per_year = np.ones(hpp_lifetime) * AEP
# Investment cost
hpp_investment_cost = \
wind_turbine_cost * sol.get_value(Wind_MW) + \
solar_PV_cost * sol.get_value(Solar_MW) + \
hpp_grid_connection_cost * hpp_grid_connection + \
hpp_BOS_soft_cost * (sol.get_value(Wind_MW) + sol.get_value(Solar_MW)) + \
wind_civil_works_cost * sol.get_value(Wind_MW) + \
solar_hardware_installation_cost * sol.get_value(Solar_MW)
# Maintenance cost
hpp_maintenance_cost = np.ones(hpp_lifetime) * (wind_fixed_onm_cost * sol.get_value(
Wind_MW) + solar_fixed_onm_cost * sol.get_value(Solar_MW))
LCOE = self.calculate_LCOE(
hpp_investment_cost,
hpp_maintenance_cost,
hpp_discount_factor,
hpp_lifetime,
AEP_per_year)
P_HPP_ts_2 = pd.DataFrame.from_dict(
sol.get_value_dict(P_HPP_t), orient='index')
IRR = self.calculate_IRR(
P_HPP_ts_2,
price_ts,
hpp_investment_cost,
hpp_maintenance_cost)
NPV = self.calculate_NPV(
P_HPP_ts_2,
price_ts,
hpp_investment_cost,
hpp_maintenance_cost,
hpp_discount_factor)
return sol.get_value(Wind_MW), sol.get_value(
Solar_MW), P_HPP_ts[0], P_curtailment_ts[0], hpp_investment_cost, hpp_maintenance_cost, LCOE, NPV, IRR
# =============================================================================
......@@ -872,7 +1013,7 @@ class HPP(object):
price_t,
investment_cost,
maintenance_cost_per_year):
time = price_t.index
time = P_HPP_t.index
Revenue_t = sum(price_t.loc[t] * P_HPP_t[0].loc[t] for t in time)
Profit_t = Revenue_t - maintenance_cost_per_year
# print(Profit_t)
......@@ -888,7 +1029,7 @@ class HPP(object):
investment_cost,
maintenance_cost_per_year,
discount_rate):
time = price_t.index
time = P_HPP_t.index
Revenue_t = sum(price_t.loc[t] * P_HPP_t[0].loc[t] for t in time)
Profit_t = Revenue_t - maintenance_cost_per_year
Cashflow = np.insert(Profit_t, 0, -investment_cost)
......@@ -922,3 +1063,21 @@ def read_csv_Data(
timeZone_analysis).tz_localize(None)
return ts
def get_ct_func(ct_curve):
def _ct(u):
return np.interp(u, ct_curve[:, 0], ct_curve[:, 1])
return _ct
def get_power_func(power_curve):
def _power(u):
return np.interp(u, power_curve[:, 0], power_curve[:, 1])
return _power
class single_WT_Site(UniformWeibullSite):
def __init__(self,wt_x,wt_y):
f = [1]*12
a = [10]*12
k = [2]*12
UniformWeibullSite.__init__(self, f, a, k, .1)
self.initial_position = np.array([wt_x, wt_y]).T
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment