ecopus commited on
Commit
b3e7be2
·
verified ·
1 Parent(s): 434438c

Upload wing_generation_explained.md

Browse files
Files changed (1) hide show
  1. wing_generation_explained.md +204 -0
wing_generation_explained.md ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # How the 500 Wing Samples Are Generated
3
+
4
+ This document explains how the Python pipeline creates the **500 aircraft‑style wings** in your dataset—what varies, what’s fixed, and the exact math behind the values stored.
5
+
6
+ ---
7
+
8
+ ## 1) Inputs & Reproducibility
9
+
10
+ - **Airfoil geometry**: Each airfoil file contains two columns \((x, y)\) forming a closed perimeter ordered **TE → upper → LE → lower → TE**.
11
+ - On load, \(x\) is normalized to \([0,1]\); the perimeter is rotated so the first point is closest to the **trailing edge** \((1,0)\) and the **upper surface** comes first.
12
+ - **Polars (optional)**: QBlade/XFOIL exports with \(\alpha, C_l, C_d, C_m\).
13
+ - Files are matched to airfoils by flexible filename heuristics.
14
+ - Polars are parsed (3–4 numeric columns), **deduplicated in \(\alpha\)**, and **sorted by \(\alpha\)**.
15
+ - **Random seed**: We use `np.random.default_rng(42)` so all 500 wings are reproducible bit‑for‑bit.
16
+
17
+ ---
18
+
19
+ ## 2) Per‑Wing Planform Sampling (What Varies)
20
+
21
+ We generate **500** wings. Airfoils are cycled round‑robin (≈50 wings per foil). For each wing we sample:
22
+
23
+ - **Half‑span** \(s\) (inches):
24
+ \(s \sim \mathcal{U}[60,\;120]\).
25
+ - **Root chord** \(c_{\text{root}}\) (inches):
26
+ \(c_{\text{root}} \sim \mathcal{U}[18,\;36]\).
27
+ - **Taper ratio** \(\lambda\):
28
+ \(\lambda \sim \mathcal{U}[0.25,\;0.50]\), so \(c_{\text{tip}}=\lambda\,c_{\text{root}}\).
29
+ - **Twist endpoints (washout)** (degrees):
30
+ \(i_{\text{root}} \sim \mathcal{U}[0,\;2]\), \(i_{\text{tip}} \sim \mathcal{U}[-6,\;-2]\).
31
+ - The final twist distribution is **linear** from root to tip; then we **pin** the very first station to **0°** so the wing “hinges” at the root plane (legacy convention).
32
+
33
+ We use **20 stations** along the half‑span:
34
+ \[
35
+ \text{Dis}[j] = y_j = \frac{j-1}{19}\; s,\quad j=1..20.
36
+ \]
37
+
38
+ ---
39
+
40
+ ## 3) Chord Distribution: Schrenk’s Approximation
41
+
42
+ We blend a trapezoid with an ellipse to approximate an elliptical lift distribution:
43
+
44
+ - Linear (trapezoid) chord:
45
+ \[
46
+ c_{\text{trap}}(y) = c_{\text{root}} + (c_{\text{tip}} - c_{\text{root}})\,\frac{y}{s}.
47
+ \]
48
+ - Elliptic surrogate:
49
+ \[
50
+ c_{\text{ell}}(y) = c_{\text{root}}\sqrt{1 - \left(\frac{y}{s}\right)^2}.
51
+ \]
52
+ - **Schrenk chord** at each station:
53
+ \[
54
+ c(y) = \tfrac{1}{2}\left[c_{\text{trap}}(y) + c_{\text{ell}}(y)\right].
55
+ \]
56
+
57
+ A small clamp prevents pathological tips for extreme tapers:
58
+ \[
59
+ c(y) \leftarrow \max\!\big(c(y),\;0.25\cdot\min\nolimits_y c_{\text{trap}}(y)\big).
60
+ \]
61
+
62
+ This yields the **Cho** vector (inches) over the 20 stations.
63
+
64
+ ---
65
+
66
+ ## 4) Twist (Washout) Distribution
67
+
68
+ With sampled endpoints \(i_{\text{root}}\) and \(i_{\text{tip}}\), define a **linear** twist:
69
+ \[
70
+ \text{Twi}[j] = i_{\text{root}} + \big(i_{\text{tip}} - i_{\text{root}}\big)\frac{y_j}{s},\quad j=1..20.
71
+ \]
72
+ Then set \(\text{Twi}[1]=0^\circ\) (root plane hinge).
73
+
74
+ ---
75
+
76
+ ## 5) Lofting the 3D Wing for Previews
77
+
78
+ Given the normalized perimeter \((\bar{x},\bar{y})\) (TE→upper→LE→lower→TE), we scale and twist each section about the **quarter‑chord** \(x_{\text{pivot}}=0.25\):
79
+
80
+ 1. Shift section to pivot origin: \(x_c = \bar{x} - 0.25\).
81
+ 2. Scale to local chord \(c_j\) (inches): \(X_s = x_c\,c_j,\; Y_s = \bar{y}\,c_j\).
82
+ 3. Rotate by \(\theta_j=\text{Twi}[j]\cdot\pi/180\):
83
+ \[
84
+ \begin{bmatrix} Y \\ Z \end{bmatrix}
85
+ = \begin{bmatrix} \cos\theta_j & -\sin\theta_j \\ \sin\theta_j & \cos\theta_j \end{bmatrix}
86
+ \begin{bmatrix} X_s \\ Y_s \end{bmatrix}.
87
+ \]
88
+ 4. Spanwise coordinate for the whole perimeter at station \(j\): \(S=y_j\) (inches).
89
+
90
+ The arrays \(S, Y, Z\) generate a fast **wireframe 3D PNG** used as the dataset’s `render_png` field.
91
+
92
+ ---
93
+
94
+ ## 6) Planform Integrals & Derived Metrics
95
+
96
+ Treat `Dis`/`Cho` as samples over the **half‑span** \([0,s]\) in **inches**. We integrate with the trapezoidal rule, then convert to SI for storage.
97
+
98
+ - **Wing area** (full wing):
99
+ \[
100
+ S_{\tfrac{1}{2}} = \int_0^s c(y)\,dy \;\approx\; \operatorname{trapz}(\text{Dis},\text{Cho})\quad [\text{in}^2],
101
+ \qquad
102
+ S_{\text{full}} = 2\,S_{\tfrac{1}{2}}.
103
+ \]
104
+ Convert: \(S_{\text{full (m}^2)} = S_{\text{full}}\cdot(0.0254)^2\).
105
+
106
+ - **Mean Aerodynamic Chord** (full wing):
107
+ \[
108
+ \text{MAC} = \frac{2}{S_{\text{full}}} \int_{-s}^{s} c(y)^2\,dy
109
+ = \frac{4}{S_{\text{full}}} \int_0^s c(y)^2\,dy.
110
+ \]
111
+ We integrate on the half‑span (inches), then convert MAC to meters.
112
+
113
+ - **Aspect Ratio** (full span \(b=2s\cdot 0.0254\) meters):
114
+ \[
115
+ \text{AR} = \frac{b^2}{S_{\text{full (m}^2)}}.
116
+ \]
117
+
118
+ - **Polar‑derived metrics** (if a polar is found):
119
+ - \(C_{l,\max}=\max C_l\) at \(\alpha_{C_{l,\max}}\).
120
+ - \(C_{d,\min}=\min C_d\) at \(\alpha_{C_{d,\min}}\).
121
+ - \((L/D)_{\max} = \max(C_l/C_d)\) at \(\alpha_{(L/D)_{\max}}\).
122
+ - Small‑angle lift slope and zero‑lift angle (linear fit on \(\alpha\in[-5^\circ,5^\circ]\)):
123
+ \[
124
+ C_l \approx m\,\alpha_{\deg} + b
125
+ \;\Rightarrow\;
126
+ C_{l_\alpha}\;[\text{per rad}] = m\cdot \frac{180}{\pi},
127
+ \quad
128
+ \alpha_{0L}\;[^\circ] = -\frac{b}{m}.
129
+ \]
130
+ - Also stored as objective‑style **scores**:
131
+ - `score_min_cd = min(C_d)`
132
+ - `score_max_cl = max(C_l)`
133
+ - `score_max_ld = max(C_l/C_d)`
134
+
135
+ If a polar is not found, these fields are **NaN**; geometry is still fully populated.
136
+
137
+ ---
138
+
139
+ ## 7) Station Count & Units
140
+
141
+ - **Stations**: always **20** over the half‑span (keeps compatibility with legacy builders).
142
+ - **Units**: dataset stores **SI** (`dis_m`, `chord_m`, `span_m`, `area_m2`, `mac_m`). Inches are used internally during generation for readability and then converted.
143
+
144
+ ---
145
+
146
+ ## 8) Image Preview Column
147
+
148
+ Each wing includes a 3D wireframe PNG (`render_png`) created from the lofted \(S,Y,Z\) arrays:
149
+ - Section loops at every station,
150
+ - ~14 spanwise polylines to suggest the surface,
151
+ - Isometric view (elev \(20^\circ\), azim \(35^\circ\)),
152
+ - Title string with span, root/tip chords, and taper.
153
+
154
+ This renders directly in the Hugging Face Dataset viewer.
155
+
156
+ ---
157
+
158
+ ## 9) Why These Look Like Transport Wings
159
+
160
+ - **Aspect ratio** typically in the 7–11 range (after area settles) due to sampled spans/cords.
161
+ - **Taper** \(0.25\to 0.50\) and **washout** \(-6^\circ\to -2^\circ\) are characteristic of transport wings aimed at cruise efficiency and benign stall.
162
+ - **Quarter‑chord pivot** is the standard torsion axis.
163
+ - **Schrenk chord** smooths the planform compared to pure linear taper, approximating more elliptical loading.
164
+
165
+ ---
166
+
167
+ ## 10) Worked Example (Representative Draw)
168
+
169
+ Let \(s=100\) in, \(c_{\text{root}}=30\) in, \(\lambda=0.35 \Rightarrow c_{\text{tip}}=10.5\) in, stations=20.
170
+ Twist endpoints: \(i_{\text{root}}=1.0^\circ\), \(i_{\text{tip}}=-4.0^\circ\), then \(\text{Twi}[1]=0^\circ\).
171
+
172
+ Mid‑span chord \(y=50\) in:
173
+ \[
174
+ c_{\text{trap}}(50) = 30 + (10.5-30)\cdot 0.5 = 20.25\text{ in},\quad
175
+ c_{\text{ell}}(50) = 30\sqrt{1-0.5^2} \approx 25.98\text{ in},
176
+ \]
177
+ \[
178
+ c(50) \approx \tfrac{1}{2}(20.25+25.98) \approx 23.11\text{ in}.
179
+ \]
180
+
181
+ If \(S_{\text{full}} \approx 5000\;\text{in}^2 \Rightarrow S_{\text{full}} \approx 3.226\;\text{m}^2\) and full span \(b=200\) in \(=5.08\) m, then:
182
+ \[
183
+ \text{AR} = \frac{b^2}{S} \approx \frac{(5.08)^2}{3.226} \approx 8.0.
184
+ \]
185
+
186
+ MAC comes from the \(c(y)^2\) integral and is often in the \(0.3\text{–}0.5\) m range here.
187
+
188
+ ---
189
+
190
+ ## 11) What Makes Each of the 500 Unique?
191
+
192
+ - **Airfoil choice** (≈50 samples per foil) → geometry & polar behavior differ.
193
+ - **Planform**: each wing draws a new \((s,\;c_{\text{root}},\;\lambda)\) → different area, AR, MAC.
194
+ - **Twist**: each wing draws \((i_{\text{root}}, i_{\text{tip}})\) → different load tendency.
195
+ - **Performance summaries**: objective‑style scores (\(\min C_d\), \(\max C_l\), \(\max C_l/C_d\)) and the \(\alpha\) at which they occur differ per wing.
196
+
197
+ ---
198
+
199
+ ### Notes for Objective‑Conditioned Training
200
+
201
+ To bias toward a given objective at training time:
202
+ - **Condition** on `objective ∈ {min Cd, max Cl, max Cl/Cd}` and **airfoil** (name or perimeter).
203
+ - Use the scalar **scores** as targets (e.g., regress `score_min_cd`) or form **ranking** pairs within the same airfoil.
204
+ - Optionally **post‑select** the top‑k wings per airfoil by the chosen objective as exemplar targets.