-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.py
135 lines (105 loc) · 3.44 KB
/
plotter.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
"""
#Theo_a_python
A simple tool for analysis of 2D airfoils using potential flow theory
Methodology: Linear vorticity distribution
Version: Python prepro, solver & postpro
@author: Rodrigo R. Velazquez
AUG 2023
#Module
Plotter
- Plotting funcs and general postpro tools. Needs math_tools.
"""
#Imports
import matplotlib.pyplot as plt
import math_tools as utis
import numpy as np
#General postpro funcs
def directors_plot(ax, prof, scale = 0.05):
for loc_beta, loc_x, loc_y in zip(prof.betas, prof.x_points[:-1], prof.y_points[:-1]):
p0, pt, pn = utis.gen_norm(loc_beta, [loc_x, loc_y], scale)
ax.plot([p0[0],pt[0]], [p0[1], pt[1]], 'r')
ax.plot([p0[0],pn[0]], [p0[1], pn[1]], 'b')
def plot_tester(prof):
fig, ax = plt.subplots()
ax.plot(prof.x_points, prof.y_points)
# ax.plot(prof.x_coords, prof.y_coords, 'ro')
# ax.plot(prof.x_mid, prof.y_mid, 'bo')
# directors_plot(ax, prof)
ax.grid()
ax.set_aspect('equal')
return fig,ax
def test_PL_point(ax, prof, Ploc, i):
dir_beta = prof.betas[i]
r0 = np.array([prof.x_points[i], prof.y_points[i]])
r_g = utis.RLOC_GLOB(Ploc, r0, dir_beta)
ax.plot(r_g[0], r_g[1], 'rs')
def plot_field(ax, X,Y,U,W, **kwargs):
if 'density' in kwargs:
density = kwargs.get('density')
else:
density = 1
# fig, ax = plt.subplots(dpi=100)
ax.streamplot(X, Y, U, W, density = density)
# return fig, ax
def plot_Vmap(ax, X, Y, U, W, **kwargs):
Z = np.sqrt(U**2+W**2)
ax.imshow(Z)
def plot_CPs(prof, CPs, **kwargs):
fig, ax = plt.subplots()
ax.plot(prof.x_mid, CPs)
return fig, ax
def plot_dLift(prof, dLift, **kwargs):
fig, ax = plt.subplots()
ax.plot(prof.x_mid, dLift)
return fig, ax
def plot_gammas(prof, gamma_vect, **kwargs):
fig, ax = plt.subplots()
ax.plot(prof.x_points, gamma_vect)
return fig, ax
#Testing dedicated funcs
def _testing_CLvs(validation,CL_lst, **kwargs):
'''
Testing func
Plot external CL data vs alpha against calculated CLs for a testing case
Parameters
----------
[validation] : list
internal: [alphas,CLs]
CL_lst: list
Calculated CLs
Returns
-------
fig, ax - Matplotlib fig and ax objs
'''
fig, ax = plt.subplots()
ax.plot(validation[0], validation[1], label = 'XFOIL')
ax.plot(validation[0], CL_lst, label = 'THEO_A')
ax.set_xlabel('alpha [deg]', fontsize = 12)
ax.set_ylabel('CL', fontsize = 12)
fig.suptitle('CL vs alpha')
ax.grid()
ax.legend(title='Testing - NACA 0012 - RE 500E3')
return fig, ax
def _testing_CPvs(prof, CPs, validation, **kwargs):
'''
Testing func
Plot external CP data vs calculated for a testing case
Parameters
----------
prof : theo_a Profile obj
CPs : nump.ndarray
validation : list
internal: [x,cp]
Returns
-------
fig, ax - Matplotlib fig and ax objs
'''
fig, ax = plt.subplots()
ax. plot(prof.x_mid, CPs, label = 'THEO_A')
ax.plot(validation[0], validation[1], label = 'XFOIL')
ax.set_xlabel('x coord [adim]', fontsize = 12)
ax.set_ylabel('-Cp [adim]', fontsize = 12)
fig.suptitle('Pressure coef. dist.')
ax.grid()
ax.legend(title='Testing - NACA 0012 - RE 500E3')
return fig, ax