pyfoiltools 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Xero64
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyfoiltools
3
+ Version: 0.0.1
4
+ Summary: Python Package containing tools for pyfoil
5
+ Author-email: Xero64 <xero64@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Xero64/pyfoiltools
8
+ Project-URL: Issues, https://github.com/Xero64/pyfoiltools/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: matplotlib>=3.10.5
15
+ Requires-Dist: pygeom>=0.0.13
16
+ Requires-Dist: numpy>=2.2.6
17
+ Requires-Dist: py2md>=0.1.3
18
+ Dynamic: license-file
19
+
20
+ # pyfoiltools
21
+
22
+ Python Package containing tools for pyfoil
@@ -0,0 +1,3 @@
1
+ # pyfoiltools
2
+
3
+ Python Package containing tools for pyfoil
@@ -0,0 +1,25 @@
1
+ [project]
2
+ name = "pyfoiltools"
3
+ version = "0.0.1"
4
+ authors = [
5
+ { name="Xero64", email="xero64@gmail.com" },
6
+ ]
7
+ description = "Python Package containing tools for pyfoil"
8
+ readme = "README.md"
9
+ requires-python = ">=3.10"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ license = "MIT"
15
+ license-files = ["LICEN[CS]E*"]
16
+ dependencies = [
17
+ "matplotlib>=3.10.5",
18
+ "pygeom>=0.0.13",
19
+ "numpy>=2.2.6",
20
+ "py2md>=0.1.3",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/Xero64/pyfoiltools"
25
+ Issues = "https://github.com/Xero64/pyfoiltools/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,207 @@
1
+ from collections.abc import Iterable
2
+ from typing import TYPE_CHECKING
3
+
4
+ from matplotlib.pyplot import figure
5
+ from numpy import arctan2, argmax, asarray, cos, flip, sin, sqrt
6
+
7
+ if TYPE_CHECKING:
8
+ from matplotlib.axes import Axes
9
+ from numpy.typing import NDArray
10
+
11
+
12
+ class Airfoil():
13
+ name: str = None
14
+ x: 'NDArray' = None
15
+ y: 'NDArray' = None
16
+ _xte: float = None
17
+ _yte: float = None
18
+ _ile: int = None
19
+ _xle: float = None
20
+ _yle: float = None
21
+ _chord: float = None
22
+ _alrad: float = None
23
+ _tte: float = None
24
+ _area: float = None
25
+ _xu: 'NDArray' = None
26
+ _yu: 'NDArray' = None
27
+ _xl: 'NDArray' = None
28
+ _yl: 'NDArray' = None
29
+
30
+ def __init__(self, name: str, x: Iterable, y: Iterable) -> None:
31
+ self.name = name
32
+ self.x = asarray(x)
33
+ self.y = asarray(y)
34
+ self.validate_area()
35
+
36
+ def reset(self) -> None:
37
+ for attr in self.__dict__:
38
+ if attr.startswith('_'):
39
+ setattr(self, attr, None)
40
+
41
+ @property
42
+ def xte(self) -> float:
43
+ if self._xte is None:
44
+ self._xte = (self.x[-1] + self.x[0])/2
45
+ return self._xte
46
+
47
+ @property
48
+ def yte(self) -> float:
49
+ if self._yte is None:
50
+ self._yte = (self.y[-1] + self.y[0])/2
51
+ return self._yte
52
+
53
+ @property
54
+ def ile(self) -> int:
55
+ if self._ile is None:
56
+ dx = self.x - self.xte
57
+ dy = self.y - self.yte
58
+ d2 = dx**2 + dy**2
59
+ self._ile = argmax(d2)
60
+ return self._ile
61
+
62
+ @property
63
+ def xle(self) -> float:
64
+ if self._xle is None:
65
+ self._xle = self.x[self.ile]
66
+ return self._xle
67
+
68
+ @property
69
+ def yle(self) -> float:
70
+ if self._yle is None:
71
+ self._yle = self.y[self.ile]
72
+ return self._yle
73
+
74
+ def calc_alrad_chord(self) -> None:
75
+ dx = self.xte - self.xle
76
+ dy = self.yte - self.yle
77
+ self._chord = sqrt(dx**2 + dy**2)
78
+ self._alrad = arctan2(dy, dx)
79
+
80
+ @property
81
+ def alrad(self) -> float:
82
+ if self._alrad is None:
83
+ self.calc_alrad_chord()
84
+ return self._alrad
85
+
86
+ @property
87
+ def chord(self) -> float:
88
+ if self._chord is None:
89
+ self.calc_alrad_chord()
90
+ return self._chord
91
+
92
+ @property
93
+ def tte(self) -> float:
94
+ if self._tte is None:
95
+ dx = self.x[-1] - self.x[0]
96
+ dy = self.y[-1] - self.y[0]
97
+ self._tte = sqrt(dx**2 + dy**2)
98
+ return self._tte
99
+
100
+ def validate_area(self) -> None:
101
+ xa = self.x[:-1]
102
+ xb = self.x[1:]
103
+ ya = self.y[:-1]
104
+ yb = self.y[1:]
105
+ doubarea = xb*ya - xa*yb
106
+ xa = self.x[-1]
107
+ xb = self.x[0]
108
+ ya = self.y[-1]
109
+ yb = self.y[0]
110
+ doubarea = doubarea.sum() + xb*ya - xa*yb
111
+ if doubarea < 0.0:
112
+ self.reverse()
113
+ self._area = -doubarea/2
114
+ else:
115
+ self._area = doubarea/2
116
+
117
+ @property
118
+ def area(self) -> float:
119
+ if self._area is None:
120
+ self.validate_area()
121
+ return self._area
122
+
123
+ @property
124
+ def xu(self) -> 'NDArray':
125
+ if self._xu is None:
126
+ self._xu = self.x[self.ile:]
127
+ return self._xu
128
+
129
+ @property
130
+ def yu(self) -> 'NDArray':
131
+ if self._yu is None:
132
+ self._yu = self.y[self.ile:]
133
+ return self._yu
134
+
135
+ @property
136
+ def xl(self) -> 'NDArray':
137
+ if self._xl is None:
138
+ self._xl = flip(self.x[:self.ile+1])
139
+ return self._xl
140
+
141
+ @property
142
+ def yl(self) -> 'NDArray':
143
+ if self._yl is None:
144
+ self._yl = flip(self.y[:self.ile+1])
145
+ return self._yl
146
+
147
+ def scale(self, scale: float) -> None:
148
+ self.x = self.x*scale
149
+ self.y = self.y*scale
150
+ self.reset()
151
+
152
+ def translate(self, x: float, y: float) -> None:
153
+ self.x = self.x + x
154
+ self.y = self.y + y
155
+ self.reset()
156
+
157
+ def rotate(self, angle: float) -> None:
158
+ cosal = cos(angle)
159
+ sinal = sin(angle)
160
+ self.x = self.x*cosal - self.y*sinal
161
+ self.y = self.x*sinal + self.y*cosal
162
+ self.reset()
163
+
164
+ def normalise(self) -> None:
165
+ self.translate(-self.xle, -self.yle)
166
+ self.scale(1/self.chord)
167
+ self.rotate(-self.alrad)
168
+
169
+ def reverse(self) -> None:
170
+ self.x = self.x[::-1]
171
+ self.y = self.y[::-1]
172
+ self.reset()
173
+
174
+ def plot(self, ax: 'Axes' = None) -> 'Axes':
175
+ if ax is None:
176
+ fig = figure()
177
+ ax = fig.gca()
178
+ ax.grid(True)
179
+ ax.set_aspect('equal')
180
+ ax.plot(self.x, self.y, label=self.name)
181
+ return ax
182
+
183
+ def __repr__(self) -> str:
184
+ return f'<Airfoil: {self.name:s}>'
185
+
186
+ def __str__(self) -> str:
187
+ return f'Airfoil: {self.name:s}'
188
+
189
+ @classmethod
190
+ def from_dat(cls, datfilepath: str) -> 'Airfoil':
191
+
192
+ name = ''
193
+ x = []
194
+ y = []
195
+
196
+ with open(datfilepath, 'rt') as file:
197
+ for i, line in enumerate(file):
198
+ line = line.rstrip('\n')
199
+ if i == 0:
200
+ name = line.strip()
201
+ else:
202
+ split = line.split()
203
+ if len(split) == 2:
204
+ x.append(float(split[0]))
205
+ y.append(float(split[1]))
206
+
207
+ return cls(name, x, y)
@@ -0,0 +1,7 @@
1
+ from .airfoilbspline import AirfoilBSpline as AirfoilBSpline
2
+ from .airfoilbspline import AirfoilBSplineFit as AirfoilBSplineFit
3
+ from .airfoilpoly import AirfoilPoly as AirfoilPoly
4
+ from .airfoilpoly import AirfoilPolyFit as AirfoilPolyFit
5
+ from .airfoilshape import AirfoilShape as AirfoilShape
6
+ from .airfoilshape import AirfoilShapeFit as AirfoilShapeFit
7
+ from .chordspacing import ChordSpacing as ChordSpacing