Skip to content

SimulationResult.flow_map sometimes fail when groundModel=Mirror()

Small example that fail:

import numpy as np
import py_wake 
from py_wake.examples.data.iea37 import IEA37Site, IEA37_WindTurbines
from py_wake.ground_models import Mirror

site = IEA37Site(16)
x, y = site.initial_position.T
windTurbines = IEA37_WindTurbines()

wf_model = py_wake.NOJ(site, windTurbines, groundModel=Mirror())
sim_res = wf_model(x,y)

grid = py_wake.HorizontalGrid(
    x = np.arange(-1000,1000,100),
    y = np.arange(-500,500,100)
) 

flow = sim_res.flow_map(grid=grid)

The same code runs if groundModel=None

This is the error message:

ValueError: cannot reshape array of size 6400 into shape (2,16,200,360,1)

From the traceback I think this is where it fails:

File ~/projects/PyWake/py_wake/ground_models/ground_models.py:49, in Mirror.__call__(self, calc_deficit, **kwargs)
     47 new_kwargs = self._update_kwargs(**kwargs)
     48 above_ground = ((new_kwargs['h_il'][:, na, :, na] + new_kwargs['dh_ijlk']) > 0)
---> 49 deficit_mijlk = np.reshape(calc_deficit(**new_kwargs) * above_ground, (2,) + kwargs['IJLK'])
     50 return self.windFarmModel.superpositionModel(deficit_mijlk)
Edited by Bjarke Tobias Olsen