Commit 2335eb4c authored by kdas's avatar kdas
Browse files

introducing wake - not working fully yet

parent 6447eee5
......@@ -9,8 +9,24 @@ Created on Sun Nov 10 12:05:52 2019
import pandas as pd
import numpy as np
import xarray as xr
from HyDesign.sizing import HPP, read_csv_Data
from sizing import HPP, read_csv_Data, get_ct_func, get_power_func, single_WT_Site
#pywake
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
# layout sampler
from layout_sampler import sample_layout, get_spacing, sample_layout_in_circle, get_layout_based_on_spacing
import matplotlib.pyplot as plt
# %%
if __name__ == "__main__":
......@@ -20,9 +36,12 @@ if __name__ == "__main__":
input_wind_ts_filename = './Data/aveW.csv'
input_solar_ts_filename = './Data/aveS.csv'
input_price_ts_filename = './Data/PriceProfilePPA.csv'
input_wind_speed_ts_filename = './Data/WS.csv'
input_wind_direction_ts_filename = './Data/WD.csv'
start_date = pd.to_datetime('2018-09-01 00:00')
end_date = pd.to_datetime("2019-08-31 23:00")
start_date = pd.to_datetime('2018-09-01 05:00')
end_date = pd.to_datetime("2019-08-31 23:00")#pd.to_datetime("2018-12-31 23:00")
timeFormat_wind = "%d/%m/%Y %H:%M"
timeFormat_solar = "%d/%m/%Y %H:%M"
......@@ -32,6 +51,10 @@ if __name__ == "__main__":
timeZone_solar = 'Asia/Kolkata'
timeZone_price = 'Asia/Kolkata'
timeZone_analysis = 'Asia/Kolkata'
timeFormat_wind_speed = "%Y-%m-%d %H:%M:%S"
timeFormat_wind_direction = "%Y-%m-%d %H:%M:%S"
timeZone_wind_speed = 'UTC'
timeZone_wind_direction = 'UTC'
# inputs
# Alessandra's data
......@@ -55,6 +78,8 @@ if __name__ == "__main__":
'wind_turbine_cost': 851000, # [EUR/MW]
'wind_civil_works_cost': 116986, # [Eur/MW]
'wind_fixed_onm_cost': 12805, # Wind fixed O&M cost per year [Eur/MW]
'power_curve_fn' : './Data/S2_1.csv',
# hpp solar parameters
'solar_lifetime_PV': 30,
......@@ -106,10 +131,30 @@ if __name__ == "__main__":
timeZone_price,
timeZone_analysis,
)
wind_speed_t = read_csv_Data(
input_wind_speed_ts_filename,
timename,
timeFormat_wind_speed,
timeZone_wind_speed,
timeZone_analysis,
)
wind_direction_t = read_csv_Data(
input_wind_direction_ts_filename,
timename,
timeFormat_wind_direction,
timeZone_wind_direction,
timeZone_analysis,
)
wind_power_t = wind_power_t.loc[start_date:end_date, 'Pwind'] / 100
solar_power_t = solar_power_t.loc[start_date:end_date, 'Psolar'] / 100
spot_price_t = spot_price_t.loc[start_date:end_date, 'Price']
wind_speed_t = wind_speed_t.loc[start_date:end_date, 'WPP_Hybridize_India']
wind_speed_t = wind_speed_t.resample('1H').ffill()
wind_direction_t = wind_direction_t.loc[start_date:end_date, 'WPP_Hybridize_India']
wind_direction_t = wind_direction_t.resample('1H').ffill()
capacity_factor_wind = ExampleHPP.calculate_Capacity_Factor(
wind_power_t, 1)
......@@ -258,3 +303,118 @@ if __name__ == "__main__":
print('HPP LCOE = %.2f EUR/MWh' % LCOE)
print('HPP NPV= %.0f MEUR' % (NPV / 1000000))
print('HPP IRR = %.0f%%' % (IRR * 100))
# %% Wind solar optimization considering wake
# Power and ct curves
V117_df = pd.read_csv(ExampleHPP.power_curve_fn,sep=',')
V117_df.columns = ['ws','p','ct']
ct_curve = V117_df.loc[:,['ws','ct']].values
power_curve = V117_df.loc[:,['ws','p']].values
# specification of TI on the site
TI = 0.1
D = 3400#
D = int(np.sqrt(ExampleHPP.hpp_land_area_available*4/np.pi)*1000) #[m]
N = int(np.ceil(hpp_wind_capacity/ExampleHPP.wind_rating_WT))
D_WT = ExampleHPP.wind_rotor_diameter
HH = ExampleHPP.wind_hub_height
# Layout generation
wt_x, wt_y, site_borders = sample_layout_in_circle(D=D, N=N, seed=0, D_WT=D_WT, return_borders=True)
wt = WindTurbines(
names=['WT_'+str(i).zfill(3) for i in range(N)],
diameters=[D_WT]*N,
hub_heights=[HH]*N,
ct_funcs = [get_ct_func(ct_curve) for i in range(N)],
power_funcs = [get_power_func(power_curve) for i in range(N)],
power_unit='MW'
)
k = TI*0.3837 + 0.003678
site = single_WT_Site(wt_x, wt_y)
wm = BastankhahGaussian(site, wt, k=k)
aep_calculator = AEPCalculator(wm)
x_i = wt_x
y_i = wt_y
h_i = HH*np.ones_like(x_i)
wd_l = np.arange(0,360,1.)
ws_k = np.arange(0,25.1,0.5)
aep_calculator._run_wake_model(x_i, y_i, h_i, wd=wd_l, ws=ws_k)
P_WF = aep_calculator.power_ilk[:N,:,:].sum(axis=0)
P_WF = P_WF/np.max(P_WF)
plant_pc = pd.DataFrame(columns=ws_k, index=wd_l.astype(int), data=P_WF)
plant_pc = plant_pc
ws_lk, wd_lk = np.meshgrid(ws_k,wd_l)
P_no_wake = get_power_func(power_curve)(ws_lk)
P_no_wake = P_no_wake/np.max(P_no_wake)
wake_losses = pd.DataFrame(columns=ws_k, index=wd_l.astype(int), data=1-plant_pc.values/P_no_wake)
wake_losses = wake_losses.fillna(0.)
plant_pc = xr.Dataset(
data_vars={
'wake_losses': (
['wd','ws'],
wake_losses,
{'description': 'Plant wake losses'}),
'power': (
['wd','ws'],
plant_pc,
{'description': 'Plant power curve'}),
},
coords={'ws': ws_k,
'wd': wd_l}
)
# ---------------------------------------------------------------------------------
# interpolate the ws and wd time series
ts = xr.Dataset(
data_vars={
'ws': (
['t'],
wind_speed_t.values,
{'description': 'Plant wind speed time series'}),
'wd': (
['t'],
wind_direction_t.values,
{'description': 'Plant wind direction time series'}),
},
coords={'t': wind_direction_t.index.values,
}
)
WL_ts = plant_pc.wake_losses.interp(ts).to_dataframe().loc[:,['wake_losses']]
#%%
WP_no_wake_df = WL_ts.copy()
WP_no_wake_df['wake_losses'] = get_power_func(power_curve)(wind_speed_t)/2.1e6
WP_no_wake_df.rename(columns = {'wake_losses':'power'}, inplace = True)
# WP_no_wake = get_power_func(power_curve)(WS_ts)
fig, ax = plt.subplots(nrows=2, ncols=1, sharex=True, sharey=True)
ax[0].plot(WP_no_wake_df.power)
ax[1].plot(WL_ts.wake_losses)
aa= WL_ts.wake_losses/200
aa.fillna(0, inplace=True)
#%%
[hpp_wind_capacity, hpp_solar_capacity, P_HPP_t,
P_curtailment_t, hpp_investment_cost, hpp_maintenance_cost,
LCOE, NPV, IRR] = ExampleHPP.sizing_Wind_Solar_with_Wake(
wind_power_t, solar_power_t, spot_price_t, aa)
\ 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