planformcreator2 5.0.0__tar.gz → 5.0.2__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.
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/.gitignore +1 -6
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/PKG-INFO +4 -4
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/README.md +37 -13
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/doc/README_PyPi.md +2 -2
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/app.py +2 -2
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/app_model.py +93 -30
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/app_modes.py +36 -11
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/VLM_wing.py +1087 -589
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/planform.py +436 -134
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/planform_mesh.py +117 -21
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/wing.py +43 -21
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/wing_exports.py +184 -139
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/wing_reference.py +33 -9
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/ui/pc2_artists.py +1014 -480
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/ui/pc2_diagrams.py +600 -282
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/ui/pc2_dialogs.py +161 -121
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/ui/pc2_panels.py +111 -21
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/pyproject.toml +11 -1
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/LICENSE +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/icons/AE.ico +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/icons/PC2.ico +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/icons/PC2_ico.pdn +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/__init__.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/__main__.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/VLM.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/__init__.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/model/image_definition.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/resources.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/planformcreator2/ui/__init__.py +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/ASW_17.png +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/Amokka.pc2 +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/Bow.pc2 +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/Elliptical.pc2 +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/F3B_F3F.pc2 +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/Scale_Glider.pc2 +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/Spitfire.png +0 -0
- {planformcreator2-5.0.0 → planformcreator2-5.0.2}/templates/Trapezoid.pc2 +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: planformcreator2
|
|
3
|
-
Version: 5.0.
|
|
3
|
+
Version: 5.0.2
|
|
4
4
|
Summary: Parametric wing planform design and aerodynamic analysis
|
|
5
5
|
Project-URL: Homepage, https://github.com/jxjo/PlanformCreator2
|
|
6
6
|
Project-URL: Issues, https://github.com/jxjo/PlanformCreator2/issues
|
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Requires-Python: >=3.12
|
|
15
|
-
Requires-Dist: airfoileditor<5.1,>=5.0.
|
|
15
|
+
Requires-Dist: airfoileditor<5.1,>=5.0.5
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
|
|
18
18
|

|
|
@@ -44,9 +44,9 @@ Description-Content-Type: text/markdown
|
|
|
44
44
|
* Generate trapezoidal meshes or Smooth meshes for Bezier-based planforms
|
|
45
45
|
* Calculate spanwise lift, drag and pitching moment using VLM combined with airfoil polar data
|
|
46
46
|
* Identify critical wing regions where stall is expected to begin
|
|
47
|
-
* Evaluate T1 wing
|
|
47
|
+
* Evaluate wing polars at constant airspeed (T1) or constant wing loading (T2), glide performance and key performance indicators
|
|
48
48
|
* Compare results with an elliptical reference planform or another PC2 design
|
|
49
|
-
* Export the wing's trapezoidal panel mesh and airfoils to Xflr5 and FLZ_vortex for further analysis
|
|
49
|
+
* Export the wing's trapezoidal panel mesh and airfoils to Xflr5, flow5 and FLZ_vortex for further analysis
|
|
50
50
|
|
|
51
51
|
The built-in analysis supports wing design exploration and comparison; it is not a complete aircraft-performance prediction or a post-stall flow model.
|
|
52
52
|
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|

|
|
3
3
|
|
|
4
4
|
[](https://github.com/jxjo/PlanformCreator2/releases/latest)
|
|
5
|
+
[](https://pypi.org/project/planformcreator2/)
|
|
5
6
|
[](LICENSE)
|
|
6
7
|
|
|
7
8
|
# Version 5.0
|
|
8
9
|
|
|
9
10
|
Version 5.0 integrates [NeuralFoil](https://github.com/peterdsharpe/NeuralFoil) as a fast alternative to Xfoil for airfoil polar generation. Wing analysis now includes drag calculation and glide performance estimates, as well as comparison with a reference wing.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
> [!TIP]
|
|
13
|
+
> **New to wing analysis?** Start with [About Version 5.0](doc/About_5.0_en.md). It explains in plain terms how paneling, drag and T1/T2 polars work, what the results can and cannot tell you, and shows interactive demos.
|
|
12
14
|
|
|
13
15
|
**PlanformCreator2** (PC2) is an app for parametric wing planform design and wing performance analysis, with a focus on model aircraft. Its interactive workflow combines geometry design with aerodynamic feedback to help compare and refine wing designs.
|
|
14
16
|
|
|
@@ -31,8 +33,9 @@ For an introduction to the new features, their background and interactive demos,
|
|
|
31
33
|
* Identify critical wing regions where airfoils reach their maximum lift coefficient and stall is expected to begin
|
|
32
34
|
* Calculate wing drag and estimate glide performance
|
|
33
35
|
* Evaluate wing pitching moment
|
|
36
|
+
* Analyze wing polars at constant airspeed (T1) or constant wing loading (T2)
|
|
34
37
|
* Compare performance with a reference wing to assess design changes
|
|
35
|
-
* Export the wing's panel mesh and airfoils to Xflr5 and FLZ_vortex for further analysis
|
|
38
|
+
* Export the wing's panel mesh and airfoils to Xflr5, flow5 and FLZ_vortex for further analysis
|
|
36
39
|
|
|
37
40
|
The built-in analysis supports wing design exploration and comparison; it is not a complete aircraft-performance prediction.
|
|
38
41
|
|
|
@@ -103,7 +106,13 @@ The "banana function" bends the planform's reference line without changing the c
|
|
|
103
106
|
|
|
104
107
|
It can also be used to fine-tune flap depth along the span: with a straight hinge line, bending the planform changes the distance between the hinge line and the trailing edge.
|
|
105
108
|
|
|
106
|
-
<img src="./images/planform_banana.png" width="
|
|
109
|
+
<img src="./images/planform_banana.png" width="600" />
|
|
110
|
+
|
|
111
|
+
For trapezoidal planforms, smooth bending would create curved lines. Instead, you can add kinks to the reference line while keeping the planform straight between sections.
|
|
112
|
+
|
|
113
|
+
<img src="./images/planform_trapezoidal_kink.png" width="600" />
|
|
114
|
+
|
|
115
|
+
|
|
107
116
|
|
|
108
117
|
### Background Image
|
|
109
118
|
|
|
@@ -152,6 +161,8 @@ For independent control of flap depth, define a separate hinge line using hinge
|
|
|
152
161
|
### Export as DXF File
|
|
153
162
|
Export the planform as a DXF file for use in CAD. Airfoils can optionally be included in the drawing, exported separately as `.dat` files, or both.
|
|
154
163
|
|
|
164
|
+
The hinge line can also be included in the DXF export.
|
|
165
|
+
|
|
155
166
|
An optional common trailing-edge thickness (TE gap), specified in millimeters, reduces the need to adjust individual airfoils in CAD.
|
|
156
167
|
|
|
157
168
|
<img src="images/dxf_view.png" width="800" />
|
|
@@ -160,7 +171,7 @@ An optional common trailing-edge thickness (TE gap), specified in millimeters, r
|
|
|
160
171
|
|
|
161
172
|
### Export as CSV File
|
|
162
173
|
|
|
163
|
-
Export wing
|
|
174
|
+
Export wing-section geometry as CSV.
|
|
164
175
|
|
|
165
176
|
|
|
166
177
|
## Airfoils and Polars
|
|
@@ -192,7 +203,7 @@ PC2 supports two methods for generating airfoil polars:
|
|
|
192
203
|
* **NeuralFoil** provides fast predictions, making it useful for interactive exploration of airfoil and wing designs.
|
|
193
204
|
* **Xfoil**, run through Worker from the [Xoptfoil2 project](https://jxjo.github.io/Xoptfoil2), generates polars in background tasks and supports multi-threaded calculation of polar sets.
|
|
194
205
|
|
|
195
|
-
Choose the calculation method and flow conditions in the polar definition. Polars are generated on demand
|
|
206
|
+
Choose the calculation method and flow conditions in the polar definition. Polars are generated on demand, and Xfoil-format polar files can also be imported into Xflr5.
|
|
196
207
|
|
|
197
208
|
Define the Reynolds number at the root section. PC2 scales it by the local chord length at each other section, so the resulting polar set represents consistent flow conditions along the wing.
|
|
198
209
|
|
|
@@ -209,11 +220,11 @@ Paneling prepares the designed wing for aerodynamic calculation by dividing its
|
|
|
209
220
|
|
|
210
221
|
The mesh is a discretized representation of the wing, separate from the parametric planform. Its type and resolution determine how closely it follows the designed geometry and how finely the aerodynamic calculation resolves the wing. Paneling settings can therefore be adjusted without changing the design itself.
|
|
211
222
|
|
|
212
|
-
PC2 provides two mesh types: **Trapezoidal** and **Smooth**. Both are available for built-in wing analysis;
|
|
223
|
+
PC2 provides two mesh types: **Trapezoidal** and **Smooth**. Both are available for built-in wing analysis; Xflr5, flow5 and FLZ_vortex exports use the trapezoidal mesh.
|
|
213
224
|
|
|
214
225
|
### Trapezoidal Mesh
|
|
215
226
|
|
|
216
|
-
A trapezoidal mesh connects wing sections with straight leading and trailing edges. It directly represents trapezoidal planforms and provides the mesh structure required by Xflr5 and FLZ_vortex.
|
|
227
|
+
A trapezoidal mesh connects wing sections with straight leading and trailing edges. It directly represents trapezoidal planforms and provides the mesh structure required by Xflr5, flow5 and FLZ_vortex.
|
|
217
228
|
|
|
218
229
|
For Bezier-based planforms, this approximation can deviate significantly from the curved outline if too few sections are used. Set the chordwise (x) and spanwise (y) panel counts and distributions, then refine the mesh to reduce these geometric deviations.
|
|
219
230
|
|
|
@@ -235,7 +246,7 @@ Set the number and distribution of panels along the chord (x) and across the spa
|
|
|
235
246
|
|
|
236
247
|
<img src="./images/panelling_smooth.png" width="800" />
|
|
237
248
|
|
|
238
|
-
|
|
249
|
+
Exports always use the trapezoidal mesh, even when the Smooth mesh is selected. Switch to Trapezoidal to inspect and adjust the mesh that will be exported.
|
|
239
250
|
|
|
240
251
|
### Mesh Optimization
|
|
241
252
|
|
|
@@ -254,6 +265,13 @@ PC2 exports the trapezoidal mesh definition and automatically generates the inte
|
|
|
254
265
|
See [the short description](doc/PC2_export_to_Xflr5.md) for details.
|
|
255
266
|
|
|
256
267
|
|
|
268
|
+
### Export to flow5
|
|
269
|
+
|
|
270
|
+
PC2 exports a flow5 plane containing the trapezoidal wing and the required airfoils. The plane has the same name as the wing; no fuselage, elevator or fin is added. Import the exported airfoil `.dat` files into flow5 first, then import the plane XML file. Configure the aircraft and analysis in flow5.
|
|
271
|
+
|
|
272
|
+
See [the short description](doc/PC2_export_to_flow5.md) for details.
|
|
273
|
+
|
|
274
|
+
|
|
257
275
|
### Export to FLZ_vortex
|
|
258
276
|
|
|
259
277
|
|
|
@@ -265,7 +283,9 @@ Do not forget to adjust the plane mass in FLZ before running a calculation.
|
|
|
265
283
|
|
|
266
284
|
Aero analysis connects local aerodynamic behavior with the performance of the complete wing. Spanwise results help assess lift distribution and stall onset at a selected angle of attack, while wing polars show performance over a range of operating points.
|
|
267
285
|
|
|
268
|
-
The analysis uses the panel mesh and
|
|
286
|
+
The analysis uses the panel mesh and supports T1 and T2 polar definitions for the root airfoil. T1 defines constant-airspeed conditions, with Reynolds numbers scaled to the local chord along the span. T2 defines constant wing loading; airspeed varies between operating points as wing lift changes.
|
|
287
|
+
|
|
288
|
+
T2 polars are limited to `CL` of 0.02 and above. At high `CL` the airspeed and the Reynolds numbers drop, especially at the wing tip, so set a minimum chord for tip in Paneling. [About Version 5.0](doc/About_5.0_en.md#t2-constant-lift-constant-wing-loading) explains how to read T1 and T2 results and where the analysis reaches its limits.
|
|
269
289
|
|
|
270
290
|
### VLM Analysis
|
|
271
291
|
|
|
@@ -273,6 +293,8 @@ The vortex lattice method (VLM) calculates the three-dimensional flow effects of
|
|
|
273
293
|
|
|
274
294
|
A purely inviscid VLM assumes a linear lift response and cannot determine stall onset on its own. PC2 combines the VLM solution with two-dimensional airfoil polars from NeuralFoil or Xfoil in a **viscous loop**. The local effective angles of attack are used to evaluate the airfoil lift response, and the VLM solution is iteratively adjusted to account for its nonlinearity.
|
|
275
295
|
|
|
296
|
+
Inspect panel pressure coefficients (`Cp`) for the selected operating point.
|
|
297
|
+
|
|
276
298
|
<img src="./images/vlm_viscous_loop.png" width="400" />
|
|
277
299
|
|
|
278
300
|
Wing drag combines two contributions:
|
|
@@ -298,16 +320,18 @@ Setting the angle of attack to its automatically determined maximum highlights t
|
|
|
298
320
|
|
|
299
321
|
Show the chord distribution alongside the aerodynamic results to adjust it interactively and assess how the loading and critical regions move. This makes it possible to refine the planform for the intended stall progression, for example by reducing the tendency toward tip stall.
|
|
300
322
|
|
|
301
|
-
|
|
323
|
+
Export spanwise operating-point results and wing totals as CSV.
|
|
302
324
|
|
|
303
325
|
### Wing Polar
|
|
304
326
|
|
|
305
|
-
|
|
327
|
+
Wing polars show performance over a range of angles of attack, up to the estimated onset of stall.
|
|
306
328
|
|
|
307
|
-
Different variable combinations reveal different aspects of performance: `CL` versus `CD` shows the drag polar, while `CL/CD` versus `CL` shows where the wing achieves its best glide ratio. Pitching-moment
|
|
329
|
+
Different variable combinations reveal different aspects of performance: `CL` versus `CD` shows the drag polar, while `CL/CD` versus `CL` shows where the wing achieves its best glide ratio. Pitching-moment polars show total wing moment and its lift and airfoil contributions. Airfoil and induced drag contributions are shown separately to understand what limits performance.
|
|
308
330
|
|
|
309
331
|
Optional **key performance indicators** mark characteristic values such as maximum `CL`, minimum `CD` and maximum `CL/CD`, depending on the selected diagram. A level-flight point can also be shown for a specified mass or wing loading, identifying the operating point where wing lift balances weight at the selected speed.
|
|
310
332
|
|
|
333
|
+
Export wing-polar results as CSV.
|
|
334
|
+
|
|
311
335
|
<img src="images/vlm_wing_polar.png" width="600" />
|
|
312
336
|
|
|
313
337
|
|
|
@@ -317,7 +341,7 @@ Use a reference wing to assess a design against an existing baseline rather than
|
|
|
317
341
|
|
|
318
342
|
Reference geometry can be used without scaling or matched to selected dimensions of the current wing: span and area, root chord and area, or root chord and span. Choose the matching conditions to suit the comparison.
|
|
319
343
|
|
|
320
|
-
The reference results are overlaid on the spanwise diagrams and wing polars. Additional **delta diagrams** show the differences over the shared operating range. For example, comparing `CD` and `CL/CD` at the same `CL` reveals where a design reduces drag or improves glide ratio, and where it introduces a trade-off.
|
|
344
|
+
The reference results are overlaid on the spanwise diagrams and wing polars. Additional **delta diagrams** show the differences over the shared operating range and mark ranges where no comparison is available. For example, comparing `CD` and `CL/CD` at the same `CL` reveals where a design reduces drag or improves glide ratio, and where it introduces a trade-off.
|
|
321
345
|
|
|
322
346
|
Drag and glide-ratio deltas are expressed as percentages relative to the reference: negative drag differences and positive glide-ratio differences indicate an improvement.
|
|
323
347
|
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
* Generate trapezoidal meshes or Smooth meshes for Bezier-based planforms
|
|
28
28
|
* Calculate spanwise lift, drag and pitching moment using VLM combined with airfoil polar data
|
|
29
29
|
* Identify critical wing regions where stall is expected to begin
|
|
30
|
-
* Evaluate T1 wing
|
|
30
|
+
* Evaluate wing polars at constant airspeed (T1) or constant wing loading (T2), glide performance and key performance indicators
|
|
31
31
|
* Compare results with an elliptical reference planform or another PC2 design
|
|
32
|
-
* Export the wing's trapezoidal panel mesh and airfoils to Xflr5 and FLZ_vortex for further analysis
|
|
32
|
+
* Export the wing's trapezoidal panel mesh and airfoils to Xflr5, flow5 and FLZ_vortex for further analysis
|
|
33
33
|
|
|
34
34
|
The built-in analysis supports wing design exploration and comparison; it is not a complete aircraft-performance prediction or a post-stall flow model.
|
|
35
35
|
|
|
@@ -66,7 +66,7 @@ logger = logging.getLogger(__name__)
|
|
|
66
66
|
#-------------------------------------------------------------------------------
|
|
67
67
|
|
|
68
68
|
APP_NAME = "PlanformCreator2"
|
|
69
|
-
__version__ = "5.0.
|
|
69
|
+
__version__ = "5.0.2" # hatch "version dynamic" reads this version for build
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
# DEV: Ensure compatibility with airfoileditor 5.0
|
|
@@ -109,7 +109,7 @@ class Main (QMainWindow):
|
|
|
109
109
|
# --- init App Model ---------------
|
|
110
110
|
|
|
111
111
|
self._app_model = App_Model (workingDir_default=Settings.user_data_dir (APP_NAME))
|
|
112
|
-
self._app_model.set_app_info (__version__, "No CHANGE_TEXT", is_first_run)
|
|
112
|
+
self._app_model.set_app_info (__version__, "No CHANGE_TEXT", is_first_run, app_name=APP_NAME)
|
|
113
113
|
|
|
114
114
|
# either airfoil file or Xoptfoil2 input file
|
|
115
115
|
|
|
@@ -22,7 +22,7 @@ from PyQt6.QtCore import pyqtSignal, QObject, QThread, QTimer
|
|
|
22
22
|
|
|
23
23
|
from airfoileditor.resources import get_assets_dir as ae_assets_dir
|
|
24
24
|
from airfoileditor.base.common_utils import clip
|
|
25
|
-
from airfoileditor.base.app_utils import Settings
|
|
25
|
+
from airfoileditor.base.app_utils import Settings, Recent_Files
|
|
26
26
|
from airfoileditor.model.airfoil_examples import Example
|
|
27
27
|
from airfoileditor.model.xo2_driver import Worker
|
|
28
28
|
from airfoileditor.model.polar_set import Polar_Task, Polar_Definition, polarType
|
|
@@ -38,7 +38,7 @@ from .model.VLM_wing import VLM_OpPoint, VLM_Polar
|
|
|
38
38
|
|
|
39
39
|
import logging
|
|
40
40
|
logger = logging.getLogger(__name__)
|
|
41
|
-
logger.setLevel(logging.DEBUG)
|
|
41
|
+
# logger.setLevel(logging.DEBUG)
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
# -----------------------------------------------------------------------------
|
|
@@ -68,6 +68,7 @@ class App_Model (QObject):
|
|
|
68
68
|
sig_new_wing = pyqtSignal() # new wing loaded
|
|
69
69
|
|
|
70
70
|
sig_planform_changed = pyqtSignal() # planform geometry changed
|
|
71
|
+
sig_wing_meta_changed = pyqtSignal() # wing name or description changed
|
|
71
72
|
sig_wingSection_selected = pyqtSignal() # current wing section selected
|
|
72
73
|
sig_wingSection_changed = pyqtSignal() # current wing section changed
|
|
73
74
|
sig_airfoil_changed = pyqtSignal() # airfoil in wing section changed
|
|
@@ -88,10 +89,12 @@ class App_Model (QObject):
|
|
|
88
89
|
|
|
89
90
|
|
|
90
91
|
self._version = "" # application version
|
|
92
|
+
self._app_name = "" # application name
|
|
91
93
|
self._change_text = "" # change text for this version
|
|
92
94
|
self._is_first_run = False # is first run of this version
|
|
93
95
|
|
|
94
96
|
self._wing : Wing = None # actual wing model
|
|
97
|
+
self._recent_files = Recent_Files() # history of recently used main wings
|
|
95
98
|
self._cur_wingSection : WingSection = None # current selected wing section
|
|
96
99
|
|
|
97
100
|
self._ref_wing : Wing = None # reference wing of the current planform
|
|
@@ -125,15 +128,15 @@ class App_Model (QObject):
|
|
|
125
128
|
after changing wing or polar data to ensure the current polar def is consistent."""
|
|
126
129
|
|
|
127
130
|
# all fine
|
|
128
|
-
if self._cur_polar_def in self.
|
|
131
|
+
if self._cur_polar_def in self.polar_definitions:
|
|
129
132
|
return
|
|
130
133
|
|
|
131
|
-
# current doesn't exist, take first available
|
|
132
|
-
if self.
|
|
133
|
-
self._cur_polar_def = self.
|
|
134
|
+
# current doesn't exist, take first available polar definition
|
|
135
|
+
if self.polar_definitions:
|
|
136
|
+
self._cur_polar_def = self.polar_definitions[0]
|
|
134
137
|
else:
|
|
135
138
|
self._cur_polar_def = None
|
|
136
|
-
logger.warning (f"{self}: no
|
|
139
|
+
logger.warning (f"{self}: no polar definitions available")
|
|
137
140
|
|
|
138
141
|
if self.vlm_alpha_fixed_to_max:
|
|
139
142
|
self._cur_vlm_alpha = None
|
|
@@ -175,9 +178,22 @@ class App_Model (QObject):
|
|
|
175
178
|
|
|
176
179
|
# --- properties
|
|
177
180
|
|
|
178
|
-
|
|
181
|
+
@property
|
|
182
|
+
def version (self) -> str:
|
|
183
|
+
""" application version """
|
|
184
|
+
return self._version
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def app_name (self) -> str:
|
|
189
|
+
""" application name """
|
|
190
|
+
return self._app_name
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def set_app_info (self, version: str, change_text: str, is_first_run: bool, app_name: str = ""):
|
|
179
194
|
""" set application info """
|
|
180
195
|
self._version = version
|
|
196
|
+
self._app_name = app_name
|
|
181
197
|
self._change_text = change_text
|
|
182
198
|
self._is_first_run = is_first_run
|
|
183
199
|
|
|
@@ -294,16 +310,16 @@ class App_Model (QObject):
|
|
|
294
310
|
|
|
295
311
|
|
|
296
312
|
@property
|
|
297
|
-
def
|
|
313
|
+
def ref_wings_filename (self) -> list[str]:
|
|
298
314
|
""" list of available reference wing names """
|
|
299
|
-
return self.wing.
|
|
315
|
+
return self.wing.ref_wing_filenames
|
|
300
316
|
|
|
301
317
|
|
|
302
318
|
@property
|
|
303
|
-
def
|
|
319
|
+
def ref_wing_filename (self) -> str:
|
|
304
320
|
""" name of the reference wing """
|
|
305
321
|
if self._ref_wing:
|
|
306
|
-
return self.ref_wing.
|
|
322
|
+
return self.ref_wing.filename
|
|
307
323
|
else:
|
|
308
324
|
return None
|
|
309
325
|
|
|
@@ -327,24 +343,24 @@ class App_Model (QObject):
|
|
|
327
343
|
def remove_ref_pc2_file (self):
|
|
328
344
|
""" remove the current ref file and make the next ref wing the current one """
|
|
329
345
|
|
|
330
|
-
if not self._ref_wing or self.
|
|
346
|
+
if not self._ref_wing or self.ref_wing_filename == Reference_Wing_Elliptical.name:
|
|
331
347
|
return
|
|
332
348
|
|
|
333
349
|
# index of current reference wing
|
|
334
|
-
cur_index = self.
|
|
350
|
+
cur_index = self.ref_wings_filename.index(self.ref_wing_filename)
|
|
335
351
|
|
|
336
352
|
self.wing.update_ref_pc2_files(self.ref_wing.reference_pc2_file, remove=True)
|
|
337
353
|
|
|
338
354
|
# set the next reference wing as the current one
|
|
339
|
-
next_index = cur_index if cur_index < len(self.
|
|
355
|
+
next_index = cur_index if cur_index < len(self.ref_wings_filename) else len(self.ref_wings_filename) - 1
|
|
340
356
|
if next_index >= 0:
|
|
341
|
-
self.
|
|
357
|
+
self.set_ref_wing_filename(self.ref_wings_filename[next_index])
|
|
342
358
|
self.notify_ref_wing_changed()
|
|
343
359
|
|
|
344
360
|
|
|
345
|
-
def
|
|
361
|
+
def set_ref_wing_filename (self, name: str):
|
|
346
362
|
""" set new reference wing by (file)name"""
|
|
347
|
-
if name not in self.
|
|
363
|
+
if name not in self.ref_wings_filename:
|
|
348
364
|
self._ref_wing = None
|
|
349
365
|
elif name == Reference_Wing_Elliptical.name:
|
|
350
366
|
self._ref_wing = Reference_Wing_Elliptical (self.wing)
|
|
@@ -391,7 +407,7 @@ class App_Model (QObject):
|
|
|
391
407
|
|
|
392
408
|
@property
|
|
393
409
|
def cur_polar_def (self) -> Polar_Definition:
|
|
394
|
-
""" selected
|
|
410
|
+
""" selected polar definition of wingSection at root"""
|
|
395
411
|
|
|
396
412
|
# ensure that the current polar definition is valid
|
|
397
413
|
self._ensure_cur_polar_def()
|
|
@@ -402,7 +418,7 @@ class App_Model (QObject):
|
|
|
402
418
|
def set_cur_polar_def (self, polar_def : Polar_Definition):
|
|
403
419
|
""" set selected polar definition of wingSection at root"""
|
|
404
420
|
|
|
405
|
-
if polar_def in self.
|
|
421
|
+
if polar_def in self.polar_definitions:
|
|
406
422
|
if polar_def != self._cur_polar_def:
|
|
407
423
|
self._cur_polar_def = polar_def
|
|
408
424
|
logger.debug (f"{self} set cur_polar_def to {polar_def}")
|
|
@@ -416,10 +432,10 @@ class App_Model (QObject):
|
|
|
416
432
|
|
|
417
433
|
|
|
418
434
|
@property
|
|
419
|
-
def
|
|
420
|
-
""" available
|
|
435
|
+
def polar_definitions (self) -> list[Polar_Definition]:
|
|
436
|
+
""" available polar definitions of wingSection at root"""
|
|
421
437
|
|
|
422
|
-
return
|
|
438
|
+
return self.wing.polar_definitions
|
|
423
439
|
|
|
424
440
|
@property
|
|
425
441
|
def cur_vlm_polar (self) -> VLM_Polar:
|
|
@@ -430,6 +446,15 @@ class App_Model (QObject):
|
|
|
430
446
|
else:
|
|
431
447
|
return None
|
|
432
448
|
|
|
449
|
+
|
|
450
|
+
@property
|
|
451
|
+
def cur_vlm_polar_available (self) -> VLM_Polar | None:
|
|
452
|
+
"""Current VLM polar if available, without creating or loading it."""
|
|
453
|
+
if not self.wing.vlm_data_available or not self.cur_polar_def:
|
|
454
|
+
return None
|
|
455
|
+
return self.wing.vlm_wing.existing_polar_at (self.cur_polar_def)
|
|
456
|
+
|
|
457
|
+
|
|
433
458
|
@property
|
|
434
459
|
def cur_vlm_alpha (self) -> float:
|
|
435
460
|
""" alpha for current vlm opPoint"""
|
|
@@ -460,15 +485,16 @@ class App_Model (QObject):
|
|
|
460
485
|
self.sig_vlm_changed.emit()
|
|
461
486
|
|
|
462
487
|
@property
|
|
463
|
-
def cur_vlm_opPoint (self) -> VLM_OpPoint:
|
|
488
|
+
def cur_vlm_opPoint (self) -> VLM_OpPoint | None:
|
|
464
489
|
""" current VLM operating point based on alpha """
|
|
465
490
|
|
|
466
|
-
#
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
else:
|
|
491
|
+
# Do not create a VLM polar/wing while consumers only inspect availability.
|
|
492
|
+
polar = self.cur_vlm_polar_available
|
|
493
|
+
if polar is None or not self.wing.planform.wingSections.strak_done:
|
|
470
494
|
return None
|
|
471
495
|
|
|
496
|
+
return polar.opPoint_at (self.cur_vlm_alpha)
|
|
497
|
+
|
|
472
498
|
|
|
473
499
|
@property
|
|
474
500
|
def ref_vlm_polar (self) -> VLM_Polar:
|
|
@@ -491,6 +517,32 @@ class App_Model (QObject):
|
|
|
491
517
|
# --- model methods -----
|
|
492
518
|
|
|
493
519
|
|
|
520
|
+
@property
|
|
521
|
+
def recent_files (self) -> Recent_Files:
|
|
522
|
+
"""History of main wings; record user actions via remember_wing."""
|
|
523
|
+
return self._recent_files
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
def remember_wing (self, wing: Wing | None):
|
|
527
|
+
"""Remember a saved main wing, excluding new and reference wings."""
|
|
528
|
+
|
|
529
|
+
if wing is not None and not wing.is_new_wing and not wing.is_reference_wing:
|
|
530
|
+
self._recent_files.add (wing.parm_path_abs)
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def forget_wing_file (self, pathFilename: str | Path):
|
|
534
|
+
"""Remove a deleted or renamed wing file from the history."""
|
|
535
|
+
|
|
536
|
+
self._recent_files.remove (pathFilename)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
def open_wing (self, pathFilename: str | Path | None):
|
|
540
|
+
"""Load and remember a main wing opened by the user, including startup."""
|
|
541
|
+
|
|
542
|
+
self.load_wing (pathFilename)
|
|
543
|
+
self.remember_wing (self.wing)
|
|
544
|
+
|
|
545
|
+
|
|
494
546
|
def load_wing (self, pathFilename, as_new = False):
|
|
495
547
|
""" creates / loads new wing as current"""
|
|
496
548
|
|
|
@@ -522,6 +574,8 @@ class App_Model (QObject):
|
|
|
522
574
|
# remove airfoil strak dir etc...
|
|
523
575
|
if all:
|
|
524
576
|
self.wing.remove_tmp ()
|
|
577
|
+
else:
|
|
578
|
+
self.wing.remove_tmp (only_if_empty=True)
|
|
525
579
|
|
|
526
580
|
# remove airfoils dir if new file or empty
|
|
527
581
|
self.wing.remove_airfoils_dir_not_needed ()
|
|
@@ -544,8 +598,9 @@ class App_Model (QObject):
|
|
|
544
598
|
if len(polar_defs) == 1 and not polar_defs[0].active:
|
|
545
599
|
polar_defs[0].set_active(True)
|
|
546
600
|
|
|
547
|
-
#
|
|
548
|
-
|
|
601
|
+
# polar definitions could have changed - sync each airfoil's Polar_Set in place
|
|
602
|
+
# (keeps unrelated helper polars, e.g. a T2 Re-grid, intact - see refresh_polar_sets)
|
|
603
|
+
self.wing.planform.wingSections.refresh_polar_sets (reset=False)
|
|
549
604
|
|
|
550
605
|
self._ensure_cur_polar_def()
|
|
551
606
|
|
|
@@ -557,6 +612,8 @@ class App_Model (QObject):
|
|
|
557
612
|
def notify_planform_changed (self):
|
|
558
613
|
""" notify self that planform changed """
|
|
559
614
|
|
|
615
|
+
self.wing.planform.wingSections.reset_strak ()
|
|
616
|
+
|
|
560
617
|
# if there is a reference wing, we have to reset its vlm_wing to be recalculated
|
|
561
618
|
self.notify_ref_wing_changed(silent=True)
|
|
562
619
|
|
|
@@ -566,6 +623,11 @@ class App_Model (QObject):
|
|
|
566
623
|
self.notify_paneling_changed ()
|
|
567
624
|
|
|
568
625
|
|
|
626
|
+
def notify_wing_meta_changed (self):
|
|
627
|
+
"""Notify consumers that non-geometric wing metadata changed."""
|
|
628
|
+
self.sig_wing_meta_changed.emit ()
|
|
629
|
+
|
|
630
|
+
|
|
569
631
|
def notify_wingSection_changed (self):
|
|
570
632
|
""" notify self that wing section changed """
|
|
571
633
|
|
|
@@ -574,6 +636,7 @@ class App_Model (QObject):
|
|
|
574
636
|
self.notify_planform_changed ()
|
|
575
637
|
|
|
576
638
|
else:
|
|
639
|
+
self.wing.planform.wingSections.reset_strak ()
|
|
577
640
|
# inform diagram
|
|
578
641
|
self.sig_wingSection_changed.emit()
|
|
579
642
|
# just handle new paneling
|
|
@@ -10,6 +10,8 @@ The modes are controlled by the Modes_Manager
|
|
|
10
10
|
"""
|
|
11
11
|
import os
|
|
12
12
|
import shutil
|
|
13
|
+
from html import escape
|
|
14
|
+
from pathlib import Path
|
|
13
15
|
|
|
14
16
|
from typing import override
|
|
15
17
|
|
|
@@ -249,7 +251,7 @@ class Mode_Modify (Mode_Abstract):
|
|
|
249
251
|
""" Actions to perform when entering the mode. """
|
|
250
252
|
|
|
251
253
|
self.app_model.set_mode (self.mode_id)
|
|
252
|
-
self.app_model.
|
|
254
|
+
self.app_model.open_wing (pc2_file)
|
|
253
255
|
super().on_enter()
|
|
254
256
|
|
|
255
257
|
|
|
@@ -278,7 +280,7 @@ class Mode_Modify (Mode_Abstract):
|
|
|
278
280
|
if self.wing.is_new_wing:
|
|
279
281
|
leave = self.save_as () # save as new file - or cancel
|
|
280
282
|
else:
|
|
281
|
-
self.save()
|
|
283
|
+
leave = self.save() # save parameter file
|
|
282
284
|
|
|
283
285
|
elif button == QMessageBox.StandardButton.Discard:
|
|
284
286
|
# on Discard remove temp dir of airfoil strak etc
|
|
@@ -305,21 +307,37 @@ class Mode_Modify (Mode_Abstract):
|
|
|
305
307
|
newPathFilename, _ = QFileDialog.getOpenFileName(self.stacked_panel, filter=filters, directory=workingDir)
|
|
306
308
|
|
|
307
309
|
if newPathFilename:
|
|
308
|
-
self.app_model.
|
|
310
|
+
self.app_model.open_wing (newPathFilename)
|
|
309
311
|
|
|
310
312
|
|
|
311
|
-
def
|
|
313
|
+
def open_recent (self, pathFilename: str):
|
|
314
|
+
"""Open a recent wing with the usual unsaved-changes confirmation."""
|
|
315
|
+
|
|
316
|
+
path = Path(pathFilename)
|
|
317
|
+
if not path.is_file():
|
|
318
|
+
logger.warning("Recent planform no longer exists: %s", path)
|
|
319
|
+
self.app_model.forget_wing_file(path)
|
|
320
|
+
MessageBox.error(self.stacked_panel, "Open Recent Planform",
|
|
321
|
+
f"File not found:<br>{escape(str(path))}<br><br>"
|
|
322
|
+
"The entry has been removed from recent files.")
|
|
323
|
+
return
|
|
324
|
+
if self.confirm_close():
|
|
325
|
+
self.app_model.open_wing(str(path))
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def save (self) -> bool:
|
|
312
329
|
""" save wing data to the action parameter file - if new wing to saveAs"""
|
|
313
330
|
|
|
314
331
|
if self.wing.is_new_wing:
|
|
315
|
-
self.save_as ()
|
|
316
|
-
return
|
|
332
|
+
return self.save_as ()
|
|
317
333
|
|
|
318
334
|
ok = self.wing.save ()
|
|
319
335
|
if ok:
|
|
336
|
+
self.app_model.remember_wing (self.wing)
|
|
320
337
|
self._toast_message (f"Planform {self.wing.parm_path.name} saved", toast_style=style.GOOD)
|
|
321
338
|
else:
|
|
322
339
|
MessageBox.error (self.stacked_panel,"Save Planform", f"<b>{self.wing.parm_path.name}</b> couldn't be saved", min_height= 60)
|
|
340
|
+
return ok
|
|
323
341
|
|
|
324
342
|
|
|
325
343
|
def save_as (self) ->bool:
|
|
@@ -332,17 +350,17 @@ class Mode_Modify (Mode_Abstract):
|
|
|
332
350
|
newPathFilename, _ = QFileDialog.getSaveFileName(self.stacked_panel, filter=filters, directory=directory)
|
|
333
351
|
|
|
334
352
|
if not newPathFilename:
|
|
335
|
-
return
|
|
353
|
+
return False
|
|
336
354
|
|
|
337
355
|
ok = self.wing.save (newPathFilename = newPathFilename)
|
|
338
356
|
if ok:
|
|
357
|
+
self.app_model.remember_wing (self.wing)
|
|
339
358
|
self._toast_message (f"Planform saved as {newPathFilename}", toast_style=style.GOOD)
|
|
340
359
|
self.app_model.notify_fileName_changed() # refresh title ...
|
|
341
360
|
else:
|
|
342
361
|
MessageBox.error (self.stacked_panel,"Save Planform", f"<b>{newPathFilename}</b> couldn't be saved", min_height= 60)
|
|
343
362
|
|
|
344
|
-
|
|
345
|
-
return
|
|
363
|
+
return ok
|
|
346
364
|
|
|
347
365
|
|
|
348
366
|
|
|
@@ -374,11 +392,17 @@ class Mode_Modify (Mode_Abstract):
|
|
|
374
392
|
def rename (self):
|
|
375
393
|
""" rename current airfoil as ..."""
|
|
376
394
|
|
|
395
|
+
old_path = self.wing.parm_path_abs.resolve()
|
|
377
396
|
dialog = Dialog_Rename (self.stacked_panel, lambda: self.wing,
|
|
378
397
|
parentPos=(0.3,-0.6), dialogPos=(0,1))
|
|
379
398
|
dialog.exec()
|
|
380
399
|
|
|
381
|
-
|
|
400
|
+
new_path = self.wing.parm_path_abs.resolve()
|
|
401
|
+
if old_path != new_path:
|
|
402
|
+
self.app_model.forget_wing_file (old_path)
|
|
403
|
+
self.app_model.open_wing (str(new_path))
|
|
404
|
+
else:
|
|
405
|
+
self.app_model.load_wing (str(new_path)) # internal reload
|
|
382
406
|
|
|
383
407
|
|
|
384
408
|
|
|
@@ -421,6 +445,7 @@ class Mode_Modify (Mode_Abstract):
|
|
|
421
445
|
p = Panel_File (self, self.app_model, width=250, lazy=True)
|
|
422
446
|
p.sig_toggle_panel_size.connect (self.toggle_minimized)
|
|
423
447
|
p.sig_open.connect (self.open)
|
|
448
|
+
p.sig_open_recent.connect (self.open_recent)
|
|
424
449
|
p.sig_new.connect (self.new)
|
|
425
450
|
p.sig_save.connect (self.save)
|
|
426
451
|
p.sig_save_as.connect (self.save_as)
|
|
@@ -450,6 +475,7 @@ class Mode_Modify (Mode_Abstract):
|
|
|
450
475
|
p = Panel_File_Small (self, self.app_model, width=250, lazy=True, has_head=False)
|
|
451
476
|
p.sig_toggle_panel_size.connect (self.toggle_minimized)
|
|
452
477
|
p.sig_open.connect (self.open)
|
|
478
|
+
p.sig_open_recent.connect (self.open_recent)
|
|
453
479
|
p.sig_new.connect (self.new)
|
|
454
480
|
p.sig_save.connect (self.save)
|
|
455
481
|
p.sig_save_as.connect (self.save_as)
|
|
@@ -673,4 +699,3 @@ class Modes_Manager (QObject):
|
|
|
673
699
|
# adjust new min with of data panel
|
|
674
700
|
self._set_min_width()
|
|
675
701
|
|
|
676
|
-
|