def _iterate_visualization(axes, owflop, history): axes['convergence'].clear() vis.draw_convergence(axes['convergence'], history) axes['step_size'].clear() vis.draw_step_size(axes['step_size'], history) axes['layout'].clear() vis.site_setup(axes['layout']) vis.connect_layouts(axes['layout'], history.layout) vis.draw_turbines(axes['layout'], history.isel(iteration=0).layout, owflop.rotor_radius_adim) vis.draw_turbines(axes['layout'], history.isel(iteration=-1).layout, owflop.rotor_radius_adim, minimal_proximity=owflop.minimal_proximity, inside=owflop.inside) vis.draw_boundaries(axes['layout'], owflop.boundaries) _plt.pause(0.1)
def _setup_visualization(owflop, history): axes = {} fig = _plt.figure() grid = _gs.GridSpec(3, 5) axes['windrose'] = fig.add_subplot(grid[0, :2], polar=True) vis.draw_windrose(axes['windrose'], owflop._ds.direction_pmf) axes['convergence'] = fig.add_subplot(grid[1, :2]) axes['step_size'] = fig.add_subplot(grid[2, :2], sharex=axes['convergence']) axes['layout'] = fig.add_subplot(grid[:, 2:]) vis.site_setup(axes['layout']) vis.draw_turbines(axes['layout'], history.isel(iteration=0).layout, owflop.rotor_radius_adim, minimal_proximity=owflop.minimal_proximity, inside=owflop.inside) vis.draw_boundaries(axes['layout'], owflop.boundaries) grid.tight_layout(fig) _plt.pause(.10) return axes
plt.rc('font', family='serif', serif='Times') plt.rc('axes', titlesize=10) # %% set up problem o = wflopg.Owflop() o.load_problem("problem-IEA37_Optimization_Case_Study-small.yaml", wind_resource="wind_resource-from_West.yaml") o.calculate_wakeless_power() o.calculate_deficit() o.calculate_power() o.calculate_relative_wake_loss_vector() # %% save initial layout figure fig = plt.figure() ax = plt.subplot(111) vis.site_setup(ax, o.minimal_proximity) vis.draw_boundaries(ax, o.boundaries) vis.draw_turbines(ax, o._ds.layout, o.rotor_radius_adim, o.minimal_proximity) fig.savefig('IEA37C1W_16-layout_initial.pdf', bbox_inches="tight") # %% plot windrose and initial pseudogradients fig = plt.figure(figsize=(8, 1.7)) alignax = None gs = fig.add_gridspec(ncols=6, nrows=1, wspace=0., hspace=0., width_ratios=[.8, .2] + 4*[1]) axwr = fig.add_subplot(gs[0:2, 0], polar=True) vis.draw_windrose(axwr, o.wind_rose.dir_weights) axwr.set_xticks([0, np.pi/2, np.pi, 3*np.pi/2]) axwr.set_xticklabels(['N', 'O', 'S', 'W']) axwr.xaxis.set_tick_params(pad=-2) axwr.set_rticks([])
gs = fig.add_gridspec(ncols=2, nrows=3, wspace=0., hspace=0., width_ratios=[1] * 2, height_ratios=[1.1, .9, .9]) # axp = {} shareyp = None axc = {} shareyc = None axs = {} shareys = None for k, kind in enumerate(['soft', 'aggressive']): axp[kind] = fig.add_subplot(gs[0, k], sharey=shareyp) vis.site_setup(axp[kind], o.minimal_proximity) vis.draw_boundaries(axp[kind], o.boundaries) vis.draw_turbines(axp[kind], history[(kind, turbines)].layout.sel(iteration=0), o.rotor_radius_adim, turbine_color='#87f') vis.draw_turbines( axp[kind], history[(kind, turbines)].layout.isel( iteration=history[(kind, turbines)].objective.argmin()), o.rotor_radius_adim, o.minimal_proximity, turbine_color='#f56') vis.connect_layouts(axp[kind], history[(kind, turbines)].layout) axp[kind].set_xlim([-1.02, 1]) axp[kind].set_ylim([-1.02, .47])
plt.rc('text', usetex=True) plt.rc('font', family='serif', serif='Times') plt.rc('axes', titlesize=10) # %% set up problem o = wflopg.Owflop() o.load_problem("problem-Mosetti_et_al-WLP.yaml") o.calculate_wakeless_power() o.calculate_deficit() o.calculate_power() o.calculate_relative_wake_loss_vector() # %% save initial layout figure fig = plt.figure() ax = plt.subplot(111) vis.site_setup(ax, o.minimal_proximity) vis.draw_boundaries(ax, o.boundaries) vis.draw_turbines(ax, o._ds.layout, o.rotor_radius_adim, o.minimal_proximity) fig.savefig('Mosetti_et_al-layout_initial.pdf', bbox_inches="tight") # %% optimize using to various pseudo-gradient types history = {} # %% start from Mosetti's layout o = wflopg.Owflop() o.load_problem("problem-Mosetti_et_al-WLP.yaml") o.calculate_wakeless_power() history['M'] = opt.step_iterator(o, max_iterations=20, multiplier=3, scaling=[.9, 1.1]) # %% start from hex layout o = wflopg.Owflop() o.load_problem(
fig = plt.figure(figsize=(3.4, 5.)) gs = fig.add_gridspec(ncols=2, nrows=3, wspace=0., hspace=0., width_ratios=[1] * 2, height_ratios=[1.1, .9, .9]) axp = {} shareyp = None axc = {} shareyc = None axs = {} shareys = None for k, n in enumerate([36, 64]): axp[n] = fig.add_subplot(gs[0, k], sharey=shareyp) vis.site_setup(axp[n], os[n].minimal_proximity) vis.draw_boundaries(axp[n], os[n].boundaries) vis.draw_turbines(axp[n], histories[n].layout.sel(iteration=0), os[n].rotor_radius_adim, turbine_color='#87f') vis.draw_turbines( axp[n], histories[n].layout.isel(iteration=histories[n].objective.argmin()), os[n].rotor_radius_adim, os[n].minimal_proximity, turbine_color='#f56') vis.connect_layouts(axp[n], histories[n].layout) axp[n].set_title(f"{n} turbines") axs[n] = fig.add_subplot(gs[2, k], sharey=shareys) vis.draw_step_size(axs[n], histories[n])