Skip to content

Commit

Permalink
Inflow Angle Refactor (#117)
Browse files Browse the repository at this point in the history
* added ability to integrate turbines locally

* changed name of new parallel CI file

* added local dx test problem

* fixed typo in power calc

* refactor wind inflow angle to be consistent with meteorlogical convention
  • Loading branch information
jefalon authored May 8, 2024
1 parent b509619 commit b05183a
Show file tree
Hide file tree
Showing 44 changed files with 138 additions and 71 deletions.
2 changes: 1 addition & 1 deletion demo/documented/Driver_Example/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ the rotor diameter to ensure all turbines including the rotors are located
within the extents. The rest of the parameters determine the physical
properties of the turbines:

* ``yaw``: The yaw of the turbines where 0 is perpendicular to an East to West inflow.
* ``yaw``: The yaw of the turbines where 0 is perpendicular to inflow.
* ``axial``: The axial induction
* ``HH``: The hub height relative to the ground
* ``RD``: The rotor diameter
Expand Down
2 changes: 1 addition & 1 deletion demo/documented/Yaml_Examples/0-wind_farm_2D.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ turbines:

# These two are left off because they are supplied in the wind_farm.csv file
# HH: 90 # Hub Height | m
# yaw: 0.0 # Yaw | rads
# yaw: 0.0 # Yaw | degs
###################################################################

# Domain Parameters: Uncomment a set to change domain shape
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 12.0 # Effective Thickness | m
yaw: 0.0 # Yaw | rads
yaw: 0.0 # Yaw | degs
axial: 0.25 # Axial Induction | -

# Domain Parameters: Uncomment a set to change domain shape
Expand Down
4 changes: 2 additions & 2 deletions demo/documented/Yaml_Examples/2-wind_farm_3D.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ turbines:

# These two are left off because they are supplied in the wind_farm.csv file
# HH: 90 # Hub Height | m
# yaw: 0.0 # Yaw | rads
# yaw: 0.0 # Yaw | degs
###################################################################

# Domain Parameters: Uncomment a set to change domain shape
Expand Down Expand Up @@ -78,7 +78,7 @@ boundary_conditions:
vel_profile: log
HH_vel: 8.0
k: 0.4
inflow_angle: 1.13
inflow_angle: 285.0
######### Uncomment to test out custom BCs for BoxDomain ##########
# boundary_types:
# inflow: ["west"]
Expand Down
4 changes: 2 additions & 2 deletions demo/documented/Yaml_Examples/3-multiangle_solve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 20.0 # Effective Thickness | m
yaw: 0.0 # Yaw | rads
yaw: 0.0 # Yaw | degs
axial: 0.33 # Axial Induction | -

# Domain Parameters: Uncomment a set to change domain shape
Expand Down Expand Up @@ -64,7 +64,7 @@ boundary_conditions:
vel_profile: log
HH_vel: 8.0
k: 0.4
inflow_angle: [1.34,5.04,3]
inflow_angle: [45,115,3]
boundary_types:
inflow: ["west"]
no_stress: ["east"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ turbines:
HH: 80 # Hub Height | m
RD: 80.0 # Turbine Diameter | m
thickness: 20 # Effective Thickness | m
yaw: 0.0 # Yaw | rads
yaw: 0.0 # Yaw | degs
axial: 0.33 # Axial Induction | -

# Domain Constants for a Box Domain
Expand Down
2 changes: 1 addition & 1 deletion demo/documented/Yaml_Examples/5-yaw_optimization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ turbines:

# These two are left off because they are supplied in the wind_farm.csv file
# HH: 90 # Hub Height | m
# yaw: 0.0 # Yaw | rads
# yaw: 0.0 # Yaw | degs
###################################################################


Expand Down
2 changes: 1 addition & 1 deletion demo/documented/Yaml_Examples/7-wind_farm_2D_OM.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 12.0 # Effective Thickness | m
yaw: 0.0 # Yaw | rads
yaw: 0.0 # Yaw | degs
axial: 0.25 # Axial Induction | -

# Domain Parameters: Uncomment a set to change domain shape
Expand Down
2 changes: 1 addition & 1 deletion demo/documented/Yaml_Examples/8-spacing-and-shear.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 12.0 # Effective Thickness | m
yaw: 0.0 # Yaw | rads
yaw: 0.0 # Yaw | degs
axial: 0.25 # Axial Induction | -

# Domain Parameters: Uncomment a set to change domain shape
Expand Down
2 changes: 1 addition & 1 deletion demo/documented/Yaml_Examples/9-save_objective_output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ turbines:
HH: 90
RD: 126.0
thickness: 20.0
yaw: 0.349
yaw: 20.0
axial: 0.33

domain:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
x, y, HH, Yaw, Diameter, Thickness, Axial_Induction
0, 0, 110.0, -0.349, 130.0, 13.0, .33
0, 0, 110.0, -20.0, 130.0, 13.0, .33
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
x, y, HH, yaw, Diameter, Thickness, Axial_Induction
-882, 0, 90.0, 0.262, 126.0, 12.0, 0.25
0, 0, 90.0, 0.000, 126.0, 12.0, 0.25
882, 0, 90.0, -0.262, 126.0, 12.0, 0.25
-882, 0, 90.0, 15.0, 126.0, 12.0, 0.25
0, 0, 90.0, 0.0, 126.0, 12.0, 0.25
882, 0, 90.0, -15.0, 126.0, 12.0, 0.25
7 changes: 7 additions & 0 deletions doc/source/param_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ The syntax for each refinement type is::



.. _inflow_angle:

Defining Inflow Angle
---------------------

The inflow angle is defined in the meteorological sense with units of degrees. This means an inflow angle of 0 will result in wind blowing from the north to the south. Increasing the inflow angle will rotate the wind clockwise (i.e. 90 degrees corresponds to wind blowing from the east and moving west). The default value of 270 degrees, which corresponds to wind blowing from the west to the east.

.. _custom_boundaries:

Customizing Boundary Conditions
Expand Down
2 changes: 1 addition & 1 deletion doc/source/params_old.rst
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ This section will define all the parameters for the wind farm::
| ``RD`` | The rotor diameter | all | None | m |
| | | | | |
+------------------------+-----------------------------------------------+--------------------+----------+-------------+
| ``yaw`` | | Determines the yaw of all turbines. Yaw is | all | None | rad |
| ``yaw`` | | Determines the yaw of all turbines. Yaw is | all | None | degs |
| | | relative to the wind inflow direction | | | |
+------------------------+-----------------------------------------------+--------------------+----------+-------------+
| ``thickness`` | The effective thickness of the rotor disk | | "disk" or disk | None | m |
Expand Down
2 changes: 1 addition & 1 deletion tests/9-Regression/2D_Rectangle_Steady_gmsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 20.0 # Effective Thickness | m
yaw: 0.349 # Yaw | rads
yaw: 19.996 # Yaw | degs
axial: 0.33 # Axial Induction | -

domain:
Expand Down
2 changes: 1 addition & 1 deletion tests/9-Regression/3D_Box_Steady.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 20.0 # Effective Thickness | m
yaw: 0.349 # Yaw | rads
yaw: 19.996 # Yaw | degs
axial: 0.33 # Axial Induction | -

domain:
Expand Down
2 changes: 1 addition & 1 deletion tests/9-Regression/3D_Box_Steady_Local_dx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 20.0 # Effective Thickness | m
yaw: 0.349 # Yaw | rads
yaw: 19.996 # Yaw | degs
axial: 0.33 # Axial Induction | -

domain:
Expand Down
2 changes: 1 addition & 1 deletion tests/9-Regression/3D_Box_Steady_gmsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 20.0 # Effective Thickness | m
yaw: 0.349 # Yaw | rads
yaw: 19.996 # Yaw | degs
axial: 0.33 # Axial Induction | -

domain:
Expand Down
4 changes: 2 additions & 2 deletions tests/9-Regression/3D_Skew_Steady.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ turbines:
HH: 90 # Hub Height | m
RD: 126.0 # Turbine Diameter | m
thickness: 10.5 # Effective Thickness | m
yaw: 0.0 # Yaw | rads
yaw: 0.0 # Yaw | degs
axial: 0.33 # Axial Induction | -


Expand Down Expand Up @@ -64,7 +64,7 @@ boundary_conditions:
vel_profile: log
HH_vel: 8.0
k: 0.4
inflow_angle: 1.13
inflow_angle: 205.256

problem:
type: stabilized
Expand Down
2 changes: 1 addition & 1 deletion tests/9-Regression/Input_Data/ALM_Unsteady/iea_rwt.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
x, y, HH, Yaw, Diameter
0.0, 0.0, 110.0, -0.349, 130.0
0.0, 0.0, 110.0, -19.996, 130.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
x, y, HH, yaw, Diameter, Thickness, Axial_Induction
-882, 0, 90.0, 0.262, 126.0, 12.0, 0.25
-882, 0, 90.0, 15.011, 126.0, 12.0, 0.25
0, 0, 90.0, 0.000, 126.0, 12.0, 0.25
882, 0, 90.0, -0.262, 126.0, 12.0, 0.25
882, 0, 90.0, -15.011, 126.0, 12.0, 0.25
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, 0.000
630, 72, 0.0, 0.000
630, 72, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, 0.000
630, 0, 0.0, 0.000
0, 0, 0.0, 270.000
630, 0, 0.0, 270.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.08726646
0, 0, 0.0, -5.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.17453293
0, 0, 0.0, -10.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.26179939
0, 0, 0.0, -15.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.34906585
0, 0, 0.0, -20.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.43633231
0, 0, 0.0, -25.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.52359878
0, 0, 0.0, -30.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw
0, 0, 0.0, -0.61086524
0, 0, 0.0, -35.0
630, 0, 0.0, 0.000
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
x, y, HH, yaw, RD, thickness, axial
0.0, -325.0, 110.0, 0.5236, 130.0, 13.0, 0.33
0.0, 325.0, 110.0, -0.5236, 130.0, 13.0, 0.33
0.0, -325.0, 110.0, 30.0, 130.0, 13.0, 0.33
0.0, 325.0, 110.0, -30.0, 130.0, 13.0, 0.33
1 change: 1 addition & 0 deletions windse/BoundaryManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self,dom,fs,farm):
### Update attributes based on params file ###
for key, value in self.params["boundary_conditions"].items():
setattr(self,key,value)
del self.inflow_angle # remove inflow angle from bc because domain owns it.

self.extra_kwarg = {}
if self.params.dolfin_adjoint:
Expand Down
18 changes: 13 additions & 5 deletions windse/DomainManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
### Import the cumulative parameters ###
from windse import windse_parameters

### Import some helper functions
from windse.helper_functions import meteor_to_math

### Check if we need dolfin_adjoint ###
if windse_parameters.dolfin_adjoint:
from dolfin_adjoint import *
Expand Down Expand Up @@ -187,11 +190,16 @@ def __init__(self):
self.ground_reference = self.ground_reference*self.xscale

### Get the initial wind direction ###
self.inflow_angle = self.params["boundary_conditions"]["inflow_angle"]
if self.inflow_angle is None:
self.inflow_angle = 0.0
elif isinstance(self.inflow_angle,list):
self.inflow_angle = self.inflow_angle[0]
self.raw_inflow_angle = self.params["boundary_conditions"]["inflow_angle"]
if self.raw_inflow_angle is None:
inflow_angle = 270.0 # default inflow angle is from west to east
elif isinstance(self.raw_inflow_angle,list):
inflow_angle = self.raw_inflow_angle[0]
else:
inflow_angle = self.raw_inflow_angle
print(inflow_angle)
self.inflow_angle = meteor_to_math(inflow_angle)
print(self.inflow_angle)
self.initial_inflow_angle = self.inflow_angle

### Add a space to store periodic boundary conditions ###
Expand Down
15 changes: 14 additions & 1 deletion windse/OptimizationManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ def Gradient(self):
# d_format = np.float64(d)
# self.params.comm.Gather(d_format, d_global, root=0)
# d_sum = np.sum(d_global)

if "yaw" in self.names[i]:
ctl_val = np.degrees(ctl_val)
d = d*np.pi/180

d_out = '%12s: %12.5e, %22.15e' % (self.names[i], ctl_val, d)

# print('Rank %d, %s' % (self.params.rank, d_out))
Expand Down Expand Up @@ -630,6 +635,8 @@ def ListControls(self,m):

self.fprint("Next Control Values",special="header")
for i, val in enumerate(m):
if "yaw" in self.names[i]:
val = np.degrees(float(val))
self.fprint(self.names[i] +": " +repr(float(val)))
self.fprint("",special="footer")

Expand Down Expand Up @@ -666,7 +673,13 @@ def SaveControls(self,m):
else:
m_old.append(float(getattr(self.farm.turbines[index],control_name)))
# print(m_new)
# print(type(m_new))
# print(type(m_new))

for i in range(len(m_new)):
if "yaw" in self.names[i]:
m_new[i] = np.degrees(float(m_new[i]))
m_old[i] = np.degrees(float(m_old[i]))

if self.problem.params.rank == 0:
if self.iteration == 0:

Expand Down
2 changes: 1 addition & 1 deletion windse/PostprocessingManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def write_to_floris(data_to_write, solver):

yaws = solver.problem.farm.get_yaw_angles()

floris_dict["farm"]["yaw"] = yaws
floris_dict["farm"]["yaw"] = np.degrees(yaws)

# Generate the full path to the FLORIS file
path_to_floris_file = os.path.join(solver.params.folder,
Expand Down
Loading

0 comments on commit b05183a

Please sign in to comment.