forked from dqsis/parsec-airfoils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseccoef.py
executable file
·57 lines (42 loc) · 1.51 KB
/
parseccoef.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
# Import libraries
from math import sqrt, tan, pi
import numpy as np
# User function pcoef
def pcoef(
xte,yte,rle,
x_cre,y_cre,d2ydx2_cre,th_cre,
surface):
# Docstrings
"""evaluate the PARSEC coefficients"""
# Initialize coefficients
coef = np.zeros(6)
# 1st coefficient depends on surface (pressure or suction)
if surface.startswith('p'):
coef[0] = -sqrt(2*rle)
else:
coef[0] = sqrt(2*rle)
# Form system of equations
A = np.array([
[xte**1.5, xte**2.5, xte**3.5, xte**4.5, xte**5.5],
[x_cre**1.5, x_cre**2.5, x_cre**3.5, x_cre**4.5,
x_cre**5.5],
[1.5*sqrt(xte), 2.5*xte**1.5, 3.5*xte**2.5,
4.5*xte**3.5, 5.5*xte**4.5],
[1.5*sqrt(x_cre), 2.5*x_cre**1.5, 3.5*x_cre**2.5,
4.5*x_cre**3.5, 5.5*x_cre**4.5],
[0.75*(1/sqrt(x_cre)), 3.75*sqrt(x_cre), 8.75*x_cre**1.5,
15.75*x_cre**2.5, 24.75*x_cre**3.5]
])
B = np.array([
[yte - coef[0]*sqrt(xte)],
[y_cre - coef[0]*sqrt(x_cre)],
[tan(th_cre*pi/180) - 0.5*coef[0]*(1/sqrt(xte))],
[-0.5*coef[0]*(1/sqrt(x_cre))],
[d2ydx2_cre + 0.25*coef[0]*x_cre**(-1.5)]
])
# Solve system of linear equations
X = np.linalg.solve(A,B)
# Gather all coefficients
coef[1:6] = X[0:5,0]
# Return coefficients
return coef