• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NREL / WindSE / 5524401473

pending completion
5524401473

push

github

web-flow
Update main (#104)

* minor change to warning text

* shift gauss cyld by RD

* fixed cyld, converted point to expression

* fixed jit problem

* added sharpness param to point blockage

* fixed u_k update for constraints

* fixed taylor test convergence

* Added check_totals option

* fixed constraint derivatives, and taylor test inputs

* ALM DEL method

* default params

* updating yaml params

* moving example to demo folder

* renaming example folder

* starting on acuator disks

* fixed inflow angle bug

* made the multiangle solver more robust

* fixing what the fix broke

* yep

* Added fatpack to the install script

* added pandas

* got dolfin actuator disks working

* gotta fix a form_compiler issue, but it seems all good up to the gradient

* got numpy disks working

* added stop_annotation to the debug, and changed how boundary HH velocity calculated

* updated some demos/test, fixed objectives

* initial commit to compare to refactored ALM output to dev

* test push upstream

* minor cleaning after verifying results match

* adding power calc and more cleanup

* getting ready for optimization test

* adding test file for collaborating on optimization

* storing before opt testing original branch

* pushing latest mpi_u_fluid deriv testing

* adding latest test updates

* cleaning up ALM block tests

* syncing print statements for jeff

* refactored imported wind farms

* added empty farm, updated demos/test/docs

* fixed alm adjoint bug, got all test running

* moved test_alm_refactor.yaml to other folder so it doesn't get picked up by pytest

* fixing conflicts before factoring out trans/rots

* wrap values e.g. self.mz as float to avoid jit error

* factoring translation/rotation out of u-fluid and alm

* consistent var names prev vs behind

* fix alm gradients

* take two

* fixing merge conflicts

* fixing mz dijitso error

* added missi... (continued)

4003 of 4003 new or added lines in 47 files covered. (100.0%)

4546 of 7192 relevant lines covered (63.21%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.66
/windse/RefinementManager.py
1
import time
1✔
2
import numpy as np
1✔
3

4
def CreateRefinementList(dom, farm, refine_params):  
1✔
5
    farm_num          = refine_params["farm_num"]       
1✔
6
    farm_type         = refine_params["farm_type"]      
1✔
7
    farm_factor       = refine_params["farm_factor"]    
1✔
8
    turbine_num       = refine_params["turbine_num"]    
1✔
9
    turbine_type      = refine_params["turbine_type"]    
1✔
10
    turbine_factor    = refine_params["turbine_factor"] 
1✔
11
    refine_custom     = refine_params["refine_custom"]  ### Need to fix for if the domain is scaled
1✔
12
    refine_power_calc = refine_params["refine_power_calc"]
1✔
13

14
    refine_list = []
1✔
15

16
    RDs = farm.get_rotor_diameters()
1✔
17
    zs  = farm.get_hub_locations()[:,2]
1✔
18

19
    # if refine_custom is not None:
20
    #     refine_list = refine_list+refine_custom
21

22
    if refine_custom is not None:
1✔
23

24
        keys_are_integers = True
1✔
25

26
        for key in refine_custom.keys():
1✔
27
            if not isinstance(key, int):
1✔
28
                keys_are_integers = False
×
29
                break
×
30

31
        if keys_are_integers:
1✔
32
            sorted_refine_custom_keys = sorted(list(refine_custom.keys()))
1✔
33
        else:
34
            sorted_refine_custom_keys = list(refine_custom.keys())
×
35

36
        for key in sorted_refine_custom_keys:
1✔
37
            refine_list.append(refine_custom[key])
1✔
38
            if not keys_are_integers:
1✔
39
                refine_list[-1]["type"] = key
×
40

41
    if farm_num > 0:
1✔
42
        bbox = farm.calculate_farm_bounding_box()
×
43

44
        for i in range(farm_num,0,-1):
×
45
            # expand_factor = 1+(farm_factor-1)*(i)
46
            expand_factor = (farm_factor)**(i)
×
47

48
            if farm_type == 'box':
×
49
                RD = max(RDs)
×
50
                bbox[2] = [bbox[2][0]-RD,bbox[2][1]+RD]
×
51
                # refine_list.append(["box",[bbox,expand_factor]])
52
                refine_list.append({"type": "box",
×
53
                                    "x_range": bbox[0],
54
                                    "y_range": bbox[1],
55
                                    "z_range": bbox[2]})
56

57
            elif farm_type == 'cylinder':
×
58
                RD = max(RDs)
×
59
                x0 = (bbox[0][1]+bbox[0][0])/2.0
×
60
                y0 = (bbox[1][1]+bbox[1][0])/2.0
×
61
                if dom.dim == 3:
×
62
                    z0 = bbox[2][0]-RD
×
63
                    center = [x0,y0,z0]
×
64
                    height = bbox[2][1]-bbox[2][0]+2*RD
×
65
                else:
66
                    center = [x0,y0]
×
67
                    height = 0
×
68
                radius = np.sqrt((bbox[0][1]-bbox[0][0])**2+(bbox[1][1]-bbox[1][0])**2)/2.0
×
69
                # refine_list.append(["cylinder",[center,radius,height,expand_factor]])
70
                refine_list.append({"type": "cylinder",
×
71
                                    "center": center,
72
                                    "radius": radius,
73
                                    "height": height,
74
                                    "expand_factor": expand_factor})
75

76
            elif farm_type == 'stream':
×
77
                RD = max(RDs)
×
78
                x0 = bbox[0][0]-RD
×
79
                y0 = (bbox[1][1]+bbox[1][0])/2.0
×
80
                if dom.dim == 3:
×
81
                    z0 = (min(zs)+max(zs))/2.0
×
82
                    center = [x0,y0,z0]
×
83
                    radius = np.sqrt((bbox[1][1]-bbox[1][0])**2+(bbox[2][1]-bbox[2][0])**2)/2.0
×
84
                else:
85
                    center = [x0,y0]
×
86
                    radius = (bbox[1][1]-bbox[1][0])/2.0
×
87
                length = bbox[0][1]-bbox[0][0]+6*RD
×
88
                theta = dom.inflow_angle
×
89
                pivot_offset = 3*max(RDs)/2.0
×
90
                # refine_list.append(["stream",[center,radius,length,theta,pivot_offset,expand_factor]])
91
                refine_list.append({"type": "stream",
×
92
                                    "center": center,
93
                                    "radius": radius,
94
                                    "length": length,
95
                                    "theta": theta,
96
                                    "pivot_offset": pivot_offset,
97
                                    "expand_factor": expand_factor})
98

99
    if turbine_num > 0 and farm.numturbs > 0:
1✔
100
        for i in range(turbine_num,0,-1):
1✔
101
            expand_factor = (turbine_factor)**(i)
1✔
102

103
            if turbine_type == 'simple':
1✔
104
                radius = max(RDs)
1✔
105
                # refine_list.append(["simple",[radius,expand_factor]])
106
                refine_list.append({"type": "simple",
1✔
107
                                    "radius": radius,
108
                                    "expand_factor": expand_factor})
109

110
            elif turbine_type == 'sphere':
1✔
111
                radius = max(RDs)
1✔
112
                # refine_list.append(["sphere",[radius,expand_factor]])
113
                refine_list.append({"type": "sphere",
1✔
114
                                    "radius": radius,
115
                                    "expand_factor": expand_factor})
116

117
            elif turbine_type == 'wake':
1✔
118
                radius = max(RDs)
1✔
119
                length = 5*radius
1✔
120
                theta = dom.inflow_angle
1✔
121
                # refine_list.append(["wake",[radius,length,theta,expand_factor]])
122
                refine_list.append({"type": "wake",
1✔
123
                                    "radius": radius,
124
                                    "length": length,
125
                                    "theta": theta,
126
                                    "expand_factor": expand_factor})
127

128
            elif turbine_type == 'tear':
×
129
                radius = max(RDs)
×
130
                theta = dom.inflow_angle
×
131
                # refine_list.append(["tear",[radius,theta,expand_factor]])
132
                refine_list.append({"type": "tear",
×
133
                                    "radius": radius,
134
                                    "theta": theta,
135
                                    "expand_factor": expand_factor})
136

137
        if refine_power_calc:
1✔
138
            radius = max(RDs)
×
139
            length = radius/5.0
×
140
            theta = dom.inflow_angle
×
141
            centered = True
×
142
            # refine_list.append(["wake",[radius,length,theta,expand_factor,centered]])
143
            refine_list.append({"type": "wake",
×
144
                                "radius": radius,
145
                                "length": length,
146
                                "theta": theta,
147
                                "expand_factor": expand_factor,
148
                                "centered": centered})
149

150

151
    return refine_list
1✔
152

153
def RefineMesh(dom,farm):
1✔
154

155
    ### Define the possible operations ###
156
    refine_dict = {"full": dom.Refine,
1✔
157
                   "box": dom.BoxRefine,
158
                   "cylinder": dom.CylinderRefine,
159
                   "stream": dom.StreamRefine,
160
                   "simple": farm.SimpleRefine,
161
                   "sphere": farm.SphereRefine,
162
                   "tear": farm.TearRefine,
163
                   "wake": farm.WakeRefine
164
                   }
165

166
    ### Alias the print command ###
167
    fprint = dom.params.fprint
1✔
168

169
    ### Convert Parameters to a list of refine instructions ###
170
    refine_params = dom.params["refine"]
1✔
171
    refine_list = CreateRefinementList(dom,farm,refine_params)
1✔
172

173
    ### Step through refine instructions ###
174
    num = len(refine_list)
1✔
175
    for i, refinement_dict in enumerate(refine_list):
1✔
176
        fprint("Refining Mesh Step {:d} of {:d}".format(i+1,num), special="header")
1✔
177
        step_start = time.time()
1✔
178
        
179
        refine_type = refinement_dict["type"]
1✔
180
        refine_args = dict(refinement_dict)
1✔
181
        del refine_args["type"]
1✔
182

183
        refine_func = refine_dict[refine_type]
1✔
184
        refine_func(**refine_args)
1✔
185

186
        step_stop = time.time()
1✔
187
        fprint("Step {:d} of {:d} Finished: {:1.2f} s".format(i+1,num,step_stop-step_start), special="footer")
1✔
188

189
def WarpMesh(dom):
1✔
190

191
    warp_type      = dom.params["refine"]["warp_type"]      
1✔
192
    warp_strength  = dom.params["refine"]["warp_strength"]  
1✔
193
    warp_height    = dom.params["refine"]["warp_height"]    
1✔
194
    warp_percent   = dom.params["refine"]["warp_percent"]  
1✔
195

196
    if warp_type == "smooth":
1✔
197
        dom.WarpSmooth(warp_strength)
×
198
    elif warp_type == "split":
1✔
199
        dom.WarpSplit(warp_height*dom.xscale,warp_percent)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc