Skip to content

Commit

Permalink
Patch fix (#118)
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

* fixed the double count of turns for reconstructing bcs

* vectorized the angle clamp
  • Loading branch information
jefalon authored Jul 23, 2024
1 parent b05183a commit eb6c3bb
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/9-Regression/3D_Skew_Steady.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ boundary_conditions:
vel_profile: log
HH_vel: 8.0
k: 0.4
inflow_angle: 205.256
inflow_angle: 205.25576915021696

problem:
type: stabilized
Expand Down
9 changes: 7 additions & 2 deletions windse/ProblemManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ def ComputeTurbineForceTerm(self,u,v,inflow_angle,**kwargs):
# Create a list of turbine force function and domain of integration for each turbine
if self.farm.turbine_type == "disabled" or self.farm.numturbs == 0:

# if there are no turbine return an zero force term
tf_term = Function(self.fs.V)*dx
# initialize turbine force
self.farm.compute_turbine_force(u,v,inflow_angle,self.fs,**kwargs)

# but set the turbine force term to zero
v, q = TestFunctions(self.fs.W)
tf_term = inner(Function(self.fs.V), v)*dx

else:

# compute tf and dx for each turbine
Expand Down
10 changes: 8 additions & 2 deletions windse/SolverManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2044,20 +2044,26 @@ def __init__(self,problem):
if self.params["domain"]["type"] in ["imported"]:
raise ValueError("Cannot use a Multi-Angle Solver with an "+self.params["domain"]["type"]+" domain.")
self.orignal_solve = super(MultiAngleSolver, self).Solve

if self.problem.dom.raw_inflow_angle is None:
self.wind_range = [0, 2.0*np.pi,self.num_wind_angles]
self.wind_range = [0, 360,self.num_wind_angles]
elif isinstance(self.problem.dom.raw_inflow_angle,list):
if len(self.problem.dom.raw_inflow_angle)==3:
self.wind_range = self.problem.dom.raw_inflow_angle
else:
self.wind_range = [self.problem.dom.raw_inflow_angle[0],self.problem.dom.raw_inflow_angle[1],self.num_wind_angles]
else:
self.wind_range = [self.problem.dom.raw_inflow_angle,self.problem.dom.raw_inflow_angle+2.0*np.pi,self.num_wind_angles]
self.wind_range = [self.problem.dom.raw_inflow_angle,self.problem.dom.raw_inflow_angle+360,self.num_wind_angles]


self.angles = np.linspace(*self.wind_range,endpoint=self.endpoint)
self.angles = meteor_to_math(self.angles)
# self.angles += self.angle_offset

# print(self.wind_range)
# print(self.angles)
# exit()

def Solve(self):
for i, theta in enumerate(self.angles):
self.fprint("Performing Solve {:d} of {:d}".format(i+1,len(self.angles)),special="header")
Expand Down
19 changes: 18 additions & 1 deletion windse/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ def meteor_to_math(angle):
Additionally the input is in degrees and the output is in radians.
'''
return np.radians(270.0-angle)
new_angle =np.radians(270.0-angle)

# Clamp between 0 and 2pi
new_angle = (new_angle < 0) * (new_angle + 2*np.pi) \
+ np.logical_and(new_angle >= 0, new_angle <= 2*np.pi) * (new_angle) \
+ (new_angle > 2*np.pi) * (new_angle - 2*np.pi)

return new_angle

def math_to_meteor(angle):
'''
Expand All @@ -31,6 +38,16 @@ def math_to_meteor(angle):
Additionally the input is in radians and the output is in degrees.
'''
new_angle =270.0-np.degrees(angle)

# Clamp between 0 and 360
new_angle = (new_angle < 0) * (new_angle + 360) \
+ np.logical_and(new_angle >= 0, new_angle <= 360) * (new_angle) \
+ (new_angle > 360) * (new_angle - 360)

return new_angle


return 270.0-np.degrees(angle)

def ufl_eval(form, print_statement=None):
Expand Down
2 changes: 1 addition & 1 deletion windse/input_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ properties:
- "null"
description: "Location for the turbsim inflow data."
inflow_angle:
default: 270.0
default: Null
type:
- "number"
- "array"
Expand Down
9 changes: 5 additions & 4 deletions windse/wind_farm_types/GenericWindFarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,11 @@ def save_functions(self,val=0):
self.params.Save(func, func_name,subfolder="functions/",val=val,file=self.func_files[i])

# save the farm level turbine subdomain function
if self.func_first_save:
self.subdomain_file = self.params.Save(self.turbine_subdomains,"turbine_subdomains",subfolder="mesh/",val=val,filetype="pvd")
else:
self.params.Save(self.turbine_subdomains,"turbine_subdomains",subfolder="mesh/",val=val,file=self.subdomain_file,filetype="pvd")
if self.numturbs > 0:
if self.func_first_save:
self.subdomain_file = self.params.Save(self.turbine_subdomains,"turbine_subdomains",subfolder="mesh/",val=val,filetype="pvd")
else:
self.params.Save(self.turbine_subdomains,"turbine_subdomains",subfolder="mesh/",val=val,file=self.subdomain_file,filetype="pvd")

# Flip the flag!
self.func_first_save = False
Expand Down

0 comments on commit eb6c3bb

Please sign in to comment.