Comment on wes-2022-7

The aims of this paper are twofold. First, the authors try to identify the most efficient and physically relevant way to estimate flow blockage in the front of a farm. To this end, three different metrics are adopted: a single point, resembling a met mast, a box and finally a cylinder. These regions extend both upstream and above the first row of turbines. The flow blockage is then measured while comparing the velocity fields with and without turbines. Experiments extend to a large variety of farm layouts. The authors conclude that in the majority of the cases and with all metrics adopted, the flow slows down in front of the farm and accelerates above it. Next, an optimization problem is formulated which aims to minimize the velocity slows down upstream of the farm and the velocity speed-up above the first row of turbines. Optimal wind-farm layouts including blockage effects only and blockage plus a minimal power constraint are then suggested. I believe this paper is of interest to the wind energy community. Moreover, it contains good quality figures. However, I also think that some important information is currently missing, such as the numerical domain description, gradient and model validation and a grid sensitivity study. These additions could increase the strength of the results presented. Here below, you can find some scientific questions and technical comments.

The aims of this paper are twofold. First, the authors try to identify the most efficient and physically relevant way to estimate flow blockage in the front of a farm. To this end, three different metrics are adopted: a single point, resembling a met mast, a box and finally a cylinder. These regions extend both upstream and above the first row of turbines. The flow blockage is then measured while comparing the velocity fields with and without turbines. Experiments extend to a large variety of farm layouts. The authors conclude that in the majority of the cases and with all metrics adopted, the flow slows down in front of the farm and accelerates above it. Next, an optimization problem is formulated which aims to minimize the velocity slows down upstream of the farm and the velocity speed-up above the first row of turbines. Optimal wind-farm layouts including blockage effects only and blockage plus a minimal power constraint are then suggested. I believe this paper is of interest to the wind energy community. Moreover, it contains good quality figures.
However, I also think that some important information is currently missing, such as the numerical domain description, gradient and model validation and a grid sensitivity study.
These additions could increase the strength of the results presented. Here below, you can find some scientific questions and technical comments.

Scientific comments/questions
Introduction: some more context would be appreciated. What do you mean when you refer to blockage? Is this related to a cumulative turbine induction effect (also called hydrodynamic effect), or is it also related to atmospheric conditions (such as flow blockage induced by atmospheric stability, for instance)? I would consider adding some more key points on how this work differs from previous ones. Is this the first of its kind? The work from Lanzilao and Meyers (https://doi.org/10.5194/wes-6-247-2021) also deals with optimization including blockage effects. How the current work differs from that one (for instance)? Section 2.1: How is the spatially-varying eddy viscosity computed? Which are the boundary conditions imposed at the sides and top of the domain? How is the presence of the wall treated (bottom boundary condition)? Overall, I would like to see some more information on the fluid solver. Section 2.2: Several studies that adopt the adjoint method to efficiently compute the gradient also show its accuracy using a comparison with a finite difference approximation (see Munters and Meyers (https://doi.org/10.3390/en11010177), Yilmaz and Meyers (https://doi.org/10.1063/1.5038600) or Lanzilao and Meyers (https://doi.org/10.5194/wes-6-247-2021), for instance). You mention in line 63 that the gradient you obtain is accurate. How accurate is it? Have you done such verification? This could build some additional thrust in the optimal layouts shown in section 4. Line 60: I would appreciate a more clear definition of the state and control variables adopted in your optimization framework. Line 61: Do you use dolphin-adjoint or SNOPT? It is not clear the relationship between these two packages to me, but it could be since I'm not familiar with these. Section 3: Table 1 reports detailed information about the turbine specifications and inflow conditions. However, I have not found information about the computational domain and grid resolution. On which basis were these chosen? I am asking this because the use of a small domain could eventually distort the farm induced blockage due to the close presence of boundaries, on which boundary conditions are imposed. Also, have you performed a grid sensitivity study? It would be interesting to see how J depends on the grid resolution (both horizontal and vertical). Line 151: Have you checked whether this behavior is also observed when placing the observation point differently? Line 155: It is not clear to me why the measurements within the cylinder would also include wake effects. Could you comment on this?  In all three sensitivity studies on the wind-farm layout carried out in this section, the upstream cylinder always predicts a blockage that is two or three orders of magnitude higher than the one measured with the upstream box or upstream point metrics. In some cases, this metric predicts a flow blockage close to 50%, which is rather far from the values usually seen in the literature (when referring to hydrodynamic blockage only). Could you further comment on this? In this study, you have fixed the 3 metrics and varied the wind-farm layout extensively. What about the vice versa? That is, fixing the farm layout and varying the position and shape of the three metrics. Could this provide additional insights on how to best estimate flow blockage? Out of curiosity, have you tried to do a similar sensitivity study when changing the rotor diameter? It would be nice to see how blockage scales with it. However, I understand that this might be out of the scope of the current study. It would be nice to see at least one 2D visualization of the velocity and/or pressure fields (top and/or side view). This would provide a better understanding of how turbulent structures and turbine wakes are resolved with the fluid solver adopted. Section 4.1: Wake effects induce much higher power losses than blockage effects. Therefore, what would be a real-case application of such a case study? I think it is very nice to know which farm layout minimizes blockage, but I feel that at the same time this farm layout must also account for turbine wakes. Line 220: I understand what you mean with this description of the optimization problem. However, I think the article would benefit from a more rigorous mathematical description of it. For instance, writing "minimize/maximize" could be ambiguous to a reader who didn't go through the full manuscript. Figure 5: The difference in blockage between the initial and optimized wind-farm layout is minimal in the upstream box case. On the other hand, higher speed recoveries are obtained when using the upstream point or upstream cylinder metrics. Could you comment on this? Line 305: are you also planning to include buoyancy forces in your governing equations? In such a case, the flow will be re-directed both above and at the side of the farm, depending on the strength and height of an eventual capping inversion. Moreover, atmospheric stability has an impact on the reduction in velocity upstream of the farm (see Allaerts and Meyers (https://doi.org/10.1007/s10546-017-0307-5) and Schneemann et al (https://doi.org/10.5194/wes-6-521-2021)). Would it be possible to take these effects into account with the proposed optimization technique?

Technical comments
Line 83: Typo in referencing the figure Table 1: Typo in second line "HH" -> H Line 163: typo "the the" -> the (end of the line) Line 173: typo "trend" -> tend