def test_Run(self): wt_layout = generate_random_wt_layout() x_g, y_g, z_g = get_T2T_gl_coord(wt_layout) dt = wt_layout.wt_array(attr='rotor_diameter') # Interpolate power curves to have the same number of elements nu = 22 p_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='power_curve')[j][:,0], wt_layout.wt_array(attr='power_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) ct_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='c_t_curve')[j][:,0], wt_layout.wt_array(attr='c_t_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) for iwt, wt in enumerate(wt_layout.wt_list): wt.power_curve = p_c[iwt, :, :] wt.c_t_curve = ct_c[iwt, :, :] rho = np.min(wt_layout.wt_array(attr='air_density')) ws_ci = wt_layout.wt_array(attr='cut_in_wind_speed') ws_co = wt_layout.wt_array(attr='cut_out_wind_speed') a1, a2, a3, a4, b1, b2 = [0.5, 0.9, -0.124, 0.13, 15.63, 1.0] pars = [a1, a2, a3, a4, b1, b2] ws = 8.0 wd = 270.0 ti = 0.07 ng = 5 inputs = dict(ws=ws, wd=wd, ti=ti, ng=ng) P_WT, U_WT, Ct = FortranGCL.gcl(x_g, y_g, z_g, dt, p_c, ct_c, ws, wd, ti, a1, a2, a3, a4, b1, b2, ng, rho, ws_ci, ws_co) fgcl = FusedFGCL() # Setting the inputs fgcl.wt_layout = wt_layout for k, v in rosettaGCL.iteritems(): setattr(fgcl, v, inputs[k]) fgcl.pars = pars fgcl.run() if np.allclose(P_WT, fgcl.wt_power, rtol=1.e-5, atol=1e-7): save(wt_layout, 'failures/FGCLarsenTestCase_'+ \ time.strftime('%d_%m_%Y__%H_%M')+'.p', \ fmt=4, proto=-1, logger=None) np.testing.assert_allclose(P_WT, fgcl.wt_power, rtol=1.e-5, atol=1e-7) np.testing.assert_allclose(U_WT, fgcl.wt_wind_speed, rtol=1.e-5, atol=1e-7)
def test_execute(self): cG = AEPMultipleWindRoses() cG.add('wf', MyTestWindFarm()) cG.configure() cG.connect('wt_layout', 'wf.wt_layout') cG.wind_speeds = np.linspace(4., 25., 10).tolist() cG.wind_directions = np.linspace(0., 360., 36)[:-1].tolist() nwt = 5 cG.wt_layout = generate_random_wt_layout(nwt=nwt) cG.run() print cG.net_aep print cG.wt_aep
def test_execute(self): cG = AEPMultipleWindRoses() cG.add("wf", MyTestWindFarm()) cG.configure() cG.connect("wt_layout", "wf.wt_layout") cG.wind_speeds = np.linspace(4.0, 25.0, 10).tolist() cG.wind_directions = np.linspace(0.0, 360.0, 36)[:-1].tolist() nwt = 5 cG.wt_layout = generate_random_wt_layout(nwt=nwt) cG.run() print cG.net_aep print cG.wt_aep
def my_aep_calculation(wind_farm_model): aep = AEPMultipleWindRoses() aep.add('wf', wind_farm_model()) aep.configure() aep.connect('wt_layout', 'wf.wt_layout') # The wind speed/directions bins to consider in the AEP calculation aep.wind_speeds = np.linspace(4., 25., 10).tolist() aep.wind_directions = np.linspace(0., 360., 36)[:-1].tolist() # Number of wind turbines nwt = 5 aep.wt_layout = generate_random_wt_layout(nwt=nwt) aep.run() return aep
def my_aep_calculation(wind_farm_model): aep = AEPMultipleWindRoses() aep.add("wf", wind_farm_model()) aep.configure() aep.connect("wt_layout", "wf.wt_layout") # The wind speed/directions bins to consider in the AEP calculation aep.wind_speeds = np.linspace(4.0, 25.0, 10).tolist() aep.wind_directions = np.linspace(0.0, 360.0, 36)[:-1].tolist() # Number of wind turbines nwt = 5 aep.wt_layout = generate_random_wt_layout(nwt=nwt) aep.run() return aep
def test_execute(self): # Preparing inputs cG = MultipleWindRosesCaseGenerator() cG.wind_speeds = np.linspace(4., 25., 22).tolist() cG.wind_directions = np.linspace(0., 360., 36)[:-1].tolist() nwt = 5 cG.wt_layout = generate_random_wt_layout(nwt=nwt) cG.run() nwd, nws = len(cG.wind_directions), len(cG.wind_speeds) self.assertEqual(len(cG.all_wind_speeds), nws * nwd) self.assertEqual(len(cG.all_wind_directions), nws * nwd) self.assertEqual(len(cG.all_frequencies), nws * nwd) self.assertEqual(len(cG.all_frequencies[0]), nwt)
def test_run(self): aep = AEPSingleWindRose() aep.add('wf', TestWindFarm()) #aep.run() #generate_inputs_AEPWindRose(aep) wr = generate_random_GenericWindRoseVT() aep.wind_rose = wr.frequency_array aep.wind_speeds = wr.wind_speeds aep.wind_directions = wr.wind_directions #aep.create_passthrough('wf.wt_layout') aep.wf.wt_layout = generate_random_wt_layout(nwt=50) aep.run() #print aep.net_aep, aep.gross_aep, aep.capacity_factor, aep.array_aep assert aep.net_aep > 0.0, 'net_aep hasn\'t been set properlyy: %f'%(aep.net_aep)
def test_run(self): aep = AEPSingleWindRose() aep.add("wf", TestWindFarm()) # aep.run() # generate_inputs_AEPWindRose(aep) wr = generate_random_GenericWindRoseVT() aep.wind_rose = wr.frequency_array aep.wind_speeds = wr.wind_speeds aep.wind_directions = wr.wind_directions # aep.create_passthrough('wf.wt_layout') aep.wf.wt_layout = generate_random_wt_layout(nwt=50) aep.run() # print aep.net_aep, aep.gross_aep, aep.capacity_factor, aep.array_aep assert aep.net_aep > 0.0, "net_aep hasn't been set properlyy: %f" % (aep.net_aep)
def test_Run(self): wt_layout = generate_random_wt_layout() x_g,y_g,z_g=get_T2T_gl_coord(wt_layout) dt = wt_layout.wt_array(attr='rotor_diameter') # Interpolate power curves to have the same number of elements nu = 22 p_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='power_curve')[j][:,0], wt_layout.wt_array(attr='power_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) ct_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='c_t_curve')[j][:,0], wt_layout.wt_array(attr='c_t_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) for iwt, wt in enumerate(wt_layout.wt_list): wt.power_curve = p_c[iwt,:,:] wt.c_t_curve = ct_c[iwt,:,:] rho = np.min(wt_layout.wt_array(attr='air_density')) ws_ci = wt_layout.wt_array(attr='cut_in_wind_speed') ws_co = wt_layout.wt_array(attr='cut_out_wind_speed') ws=8.0 wd=270.0 kj=0.05 inputs=dict( ws=ws, wd=wd, kj=kj ) P_WT,U_WT, Ct = FortranNOJ.noj( x_g,y_g,z_g,dt,p_c,ct_c,ws,wd,kj,rho,ws_ci,ws_co) fnoj = FusedFNOJ() # Setting the inputs fnoj.wt_layout = wt_layout for k,v in rosettaNOJ.iteritems(): setattr(fnoj, v, inputs[k]) fnoj.run() np.testing.assert_almost_equal(P_WT, fnoj.wt_power) np.testing.assert_almost_equal(U_WT, fnoj.wt_wind_speed)
def test_execute(self): cG = MultipleWindRosesCaseGenerator() cG.wind_speeds = np.linspace(4., 25., 22).tolist() cG.wind_directions = np.linspace(0., 360., 36)[:-1].tolist() nwt = 5 cG.wt_layout = generate_random_wt_layout(nwt=nwt) cG.run() cP = PostProcessMultipleWindRoses() cP.wind_directions = cG.wind_directions cP.wind_speeds = cG.wind_speeds cP.frequencies = cG.all_frequencies cP.powers = [[random()*2.E6 for iwt in range(nwt)] for i in cG.all_wind_speeds] cP.run() assert_equal(cP.array_aep.shape, [len(cP.wind_directions), len(cP.wind_speeds)])
def test_Run(self): wt_layout = generate_random_wt_layout() x_g, y_g, z_g = get_T2T_gl_coord(wt_layout) dt = wt_layout.wt_array(attr='rotor_diameter') # Interpolate power curves to have the same number of elements nu = 22 p_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='power_curve')[j][:,0], wt_layout.wt_array(attr='power_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) ct_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='c_t_curve')[j][:,0], wt_layout.wt_array(attr='c_t_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) for iwt, wt in enumerate(wt_layout.wt_list): wt.power_curve = p_c[iwt, :, :] wt.c_t_curve = ct_c[iwt, :, :] rho = np.min(wt_layout.wt_array(attr='air_density')) ws_ci = wt_layout.wt_array(attr='cut_in_wind_speed') ws_co = wt_layout.wt_array(attr='cut_out_wind_speed') ws = 8.0 wd = 270.0 kj = 0.05 inputs = dict(ws=ws, wd=wd, kj=kj) P_WT, U_WT, Ct = FortranNOJ.noj(x_g, y_g, z_g, dt, p_c, ct_c, ws, wd, kj, rho, ws_ci, ws_co) fnoj = FusedFNOJ() # Setting the inputs fnoj.wt_layout = wt_layout for k, v in rosettaNOJ.iteritems(): setattr(fnoj, v, inputs[k]) fnoj.run() np.testing.assert_almost_equal(P_WT, fnoj.wt_power) np.testing.assert_almost_equal(U_WT, fnoj.wt_wind_speed)
def test_execute(self): cG = MultipleWindRosesCaseGenerator() cG.wind_speeds = np.linspace(4., 25., 22).tolist() cG.wind_directions = np.linspace(0., 360., 36)[:-1].tolist() nwt = 5 cG.wt_layout = generate_random_wt_layout(nwt=nwt) cG.run() cP = PostProcessMultipleWindRoses() cP.wind_directions = cG.wind_directions cP.wind_speeds = cG.wind_speeds cP.frequencies = cG.all_frequencies cP.powers = [[random() * 2.E6 for iwt in range(nwt)] for i in cG.all_wind_speeds] cP.run() assert_equal(cP.array_aep.shape, [len(cP.wind_directions), len(cP.wind_speeds)])
def test_Run(self): wt_layout = generate_random_wt_layout() x_g,y_g,z_g=get_T2T_gl_coord(wt_layout) dt = wt_layout.wt_array(attr='rotor_diameter') # Interpolate power curves to have the same number of elements nu = 22 p_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='power_curve')[j][:,0], wt_layout.wt_array(attr='power_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) ct_c = np.array([[[np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i], interp(wt_layout.wt_array(attr='c_t_curve')[j][:,0], wt_layout.wt_array(attr='c_t_curve')[j][:,1], np.linspace(wt_layout.wt_array(attr='cut_in_wind_speed')[j], wt_layout.wt_array(attr='cut_out_wind_speed')[j],nu)[i])] \ for i in range(nu)] for j in range(wt_layout.n_wt)]) for iwt, wt in enumerate(wt_layout.wt_list): wt.power_curve = p_c[iwt,:,:] wt.c_t_curve = ct_c[iwt,:,:] rho = np.min(wt_layout.wt_array(attr='air_density')) ws_ci = wt_layout.wt_array(attr='cut_in_wind_speed') ws_co = wt_layout.wt_array(attr='cut_out_wind_speed') a1,a2,a3,a4,b1,b2=[0.5,0.9,-0.124,0.13,15.63,1.0] pars=[a1,a2,a3,a4,b1,b2] ws=8.0 wd=270.0 ti=0.07 ng=5 inputs=dict( ws=ws, wd=wd, ti=ti, ng=ng ) P_WT,U_WT, Ct = FortranGCL.gcl( x_g,y_g,z_g,dt,p_c,ct_c,ws,wd,ti, a1,a2,a3,a4,b1,b2,ng,rho,ws_ci,ws_co) fgcl = FusedFGCL() # Setting the inputs fgcl.wt_layout = wt_layout for k,v in rosettaGCL.iteritems(): setattr(fgcl, v, inputs[k]) fgcl.pars=pars fgcl.run() if np.allclose(P_WT, fgcl.wt_power, rtol=1.e-5, atol=1e-7): save(wt_layout, 'failures/FGCLarsenTestCase_'+ \ time.strftime('%d_%m_%Y__%H_%M')+'.p', \ fmt=4, proto=-1, logger=None) np.testing.assert_allclose(P_WT, fgcl.wt_power, rtol=1.e-5, atol=1e-7) np.testing.assert_allclose(U_WT, fgcl.wt_wind_speed, rtol=1.e-5, atol=1e-7)
def fill_up(self, gwf): """Fill up a generic windfarm with random inputs""" gwf.wind_speed = random() * 25.0 gwf.wind_direction = random() * 360.0 gwf.wt_layout = generate_random_wt_layout()
def test_generate_random_WTLayout(self): wtl = generate_random_wt_layout(nwt=5)