@@ -21,7 +21,11 @@ class VLMGeometry(om.ExplicitComponent):
2121 b_pts[nx-1, ny, 3] : numpy array
2222 Bound points for the horseshoe vortices, found along the 1/4 chord.
2323 widths[ny-1] : numpy array
24- The spanwise widths of each individual panel.
24+ The widths of each individual panel along y-axis (spanwise direction with zero sweep).
25+ lengths_spanwise[ny-1] : numpy array
26+ The the length of the quarter-chord line of each panels.
27+ This is identical to `widths` if sweep angle is 0.
28+ When wing is swept, `lengths_spanwise` is longer than `widths`.
2529 lengths[ny] : numpy array
2630 The chordwise length of the entire airfoil following the camber line.
2731 chords[ny] : numpy array
@@ -49,7 +53,7 @@ def setup(self):
4953 rng = np .random .default_rng (314 )
5054 self .add_output ("b_pts" , val = rng .random ((nx - 1 , ny , 3 )), units = "m" )
5155 self .add_output ("widths" , val = np .ones ((ny - 1 )), units = "m" )
52- self .add_output ("cos_sweep " , val = np .zeros ((ny - 1 )), units = "m" )
56+ self .add_output ("lengths_spanwise " , val = np .ones ((ny - 1 )), units = "m" )
5357 self .add_output ("lengths" , val = np .zeros ((ny )), units = "m" )
5458 self .add_output ("chords" , val = np .zeros ((ny )), units = "m" )
5559 self .add_output ("normals" , val = np .zeros ((nx - 1 , ny - 1 , 3 )))
@@ -68,19 +72,19 @@ def setup(self):
6872 val [size :] = 0.25
6973 self .declare_partials ("b_pts" , "def_mesh" , rows = rows , cols = cols , val = val )
7074
71- # widths
75+ # width
7276 size = ny - 1
7377 base = np .arange (size )
74- rows = np .tile (base , 12 )
75- col = np .tile (3 * base , 6 ) + np .repeat (np . arange ( 6 ) , len (base ))
78+ rows = np .tile (base , 8 )
79+ col = np .tile (3 * base , 4 ) + np .repeat ([ 1 , 2 , 4 , 5 ] , len (base ))
7680 cols = np .tile (col , 2 ) + np .repeat ([0 , (nx - 1 ) * ny * 3 ], len (col ))
7781 self .declare_partials ("widths" , "def_mesh" , rows = rows , cols = cols )
7882
79- # cos_sweep
80- rows = np .tile (base , 8 )
81- col = np .tile (3 * base , 4 ) + np .repeat ([ 1 , 2 , 4 , 5 ] , len (base ))
83+ # length of panel in spanwise direction with sweep
84+ rows = np .tile (base , 12 )
85+ col = np .tile (3 * base , 6 ) + np .repeat (np . arange ( 6 ) , len (base ))
8286 cols = np .tile (col , 2 ) + np .repeat ([0 , (nx - 1 ) * ny * 3 ], len (col ))
83- self .declare_partials ("cos_sweep " , "def_mesh" , rows = rows , cols = cols )
87+ self .declare_partials ("lengths_spanwise " , "def_mesh" , rows = rows , cols = cols )
8488
8589 # lengths
8690 size = ny
@@ -116,16 +120,13 @@ def compute(self, inputs, outputs):
116120 # Compute the bound points at quarter-chord
117121 b_pts = mesh [:- 1 , :, :] * 0.75 + mesh [1 :, :, :] * 0.25
118122
119- # Compute the widths of each panel at the quarter-chord line
123+ # Compute the length of the quarter-chord line of each panels
120124 quarter_chord = 0.25 * mesh [- 1 ] + 0.75 * mesh [0 ]
121- widths = np .linalg .norm (quarter_chord [1 :, :] - quarter_chord [:- 1 , :], axis = 1 )
125+ lengths_spanwise = np .linalg .norm (quarter_chord [1 :, :] - quarter_chord [:- 1 , :], axis = 1 )
122126
123- # Compute the numerator of the cosine of the sweep angle of each panel
124- # (we need this for the viscous drag dependence on sweep, and we only compute
125- # the numerator because the denominator of the cosine fraction is the width,
126- # which we have already computed. They are combined in the viscous drag
127- # calculation.)
128- cos_sweep = np .linalg .norm (quarter_chord [1 :, [1 , 2 ]] - quarter_chord [:- 1 , [1 , 2 ]], axis = 1 )
127+ # Compute the widths of each panel.
128+ # This is a projection of `lengths_spanwise` to the spanwise axis (y-axis)
129+ widths = np .linalg .norm (quarter_chord [1 :, [1 , 2 ]] - quarter_chord [:- 1 , [1 , 2 ]], axis = 1 )
129130
130131 # Compute the length of each chordwise set of mesh points through the camber line.
131132 dx = mesh [1 :, :, 0 ] - mesh [:- 1 , :, 0 ]
@@ -171,7 +172,7 @@ def compute(self, inputs, outputs):
171172 # Store each array in the outputs dict
172173 outputs ["b_pts" ] = b_pts
173174 outputs ["widths" ] = widths
174- outputs ["cos_sweep " ] = cos_sweep
175+ outputs ["lengths_spanwise " ] = lengths_spanwise
175176 outputs ["lengths" ] = lengths
176177 outputs ["normals" ] = normals
177178 outputs ["S_ref" ] = S_ref
@@ -184,18 +185,18 @@ def compute_partials(self, inputs, partials):
184185 ny = self .ny
185186 mesh = inputs ["def_mesh" ]
186187
187- # Compute the widths of each panel at the quarter-chord line
188+ # Compute the length of the quarter-chord line of each panels
188189 quarter_chord = 0.25 * mesh [- 1 ] + 0.75 * mesh [0 ]
189- widths = np .linalg .norm (quarter_chord [1 :, :] - quarter_chord [:- 1 , :], axis = 1 )
190+ lengths_spanwise = np .linalg .norm (quarter_chord [1 :, :] - quarter_chord [:- 1 , :], axis = 1 )
190191
191- # Compute the cosine of the sweep angle of each panel
192- cos_sweep_array = np .linalg .norm (quarter_chord [1 :, [1 , 2 ]] - quarter_chord [:- 1 , [1 , 2 ]], axis = 1 )
192+ # Compute the widths of each panel.
193+ widths = np .linalg .norm (quarter_chord [1 :, [1 , 2 ]] - quarter_chord [:- 1 , [1 , 2 ]], axis = 1 )
193194
194195 delta = np .diff (quarter_chord , axis = 0 ).T
195- d1 = delta / widths
196+ d1 = delta / lengths_spanwise
197+ partials ["lengths_spanwise" , "def_mesh" ] = np .outer ([- 0.75 , 0.75 , - 0.25 , 0.25 ], d1 .flatten ()).flatten ()
198+ d1 = delta [1 :, :] / widths
196199 partials ["widths" , "def_mesh" ] = np .outer ([- 0.75 , 0.75 , - 0.25 , 0.25 ], d1 .flatten ()).flatten ()
197- d1 = delta [1 :, :] / cos_sweep_array
198- partials ["cos_sweep" , "def_mesh" ] = np .outer ([- 0.75 , 0.75 , - 0.25 , 0.25 ], d1 .flatten ()).flatten ()
199200
200201 partials ["lengths" , "def_mesh" ][:] = 0.0
201202 dmesh = np .diff (mesh , axis = 0 )
0 commit comments