-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplot_blade.py
More file actions
37 lines (33 loc) · 1.1 KB
/
plot_blade.py
File metadata and controls
37 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import matplotlib.pyplot as plt
import re
sections = []
current = {'x': [], 'y': [], 'label': ''}
with open('blade.plt', 'r') as f:
for line in f:
line = line.strip()
if not line:
if current['x']:
sections.append(current)
current = {'x': [], 'y': [], 'label': ''}
elif line.startswith('# r/R'):
m = re.search(r'r/R\s*=\s*([\d.]+).*twist\s*=\s*([-\d.]+)', line)
if m:
current['label'] = f"r/R={m.group(1)} twist={m.group(2)}°"
elif not line.startswith('#'):
parts = line.split()
if len(parts) == 2:
current['x'].append(float(parts[0]))
current['y'].append(float(parts[1]))
if current['x']:
sections.append(current)
fig, ax = plt.subplots(figsize=(10, 6))
for s in sections:
ax.plot(s['x'], s['y'], label=s['label'])
ax.set_aspect('equal')
ax.set_xlabel('x [m]')
ax.set_ylabel('y [m]')
ax.set_title('Blade Sections (twisted, physical scale)')
ax.legend(fontsize=8, loc='upper right')
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()