Skip to content

refactor: single entry point with solver choice - #22

Open
PSamuele wants to merge 3 commits into
chore/merge-into-mainfrom
refactor/single-entry-point
Open

PSamuele wants to merge 3 commits into
chore/merge-into-mainfrom
refactor/single-entry-point

Conversation

@PSamuele

Copy link
Copy Markdown
Contributor

What

  • One program: python run.py in the repository root. The first question is the solver (1 = in-house panel method, 2 = XFOIL). The XFOIL check runs only if XFOIL is chosen.
  • The two optimizers move into naca_core/ (inhouse_optimizer.py, xfoil_optimizer.py). inhouse_potential_optimizer/ and xfoil_viscous_optimizer/ are removed; their READMEs are merged into the main one.
  • One Results/ folder in the root. Each run: Re<Re>_Alpha<alpha>_<objective>_<solver>_seed<N>/, e.g. Re3424658_Alpha4.0_Cl0.8_xfoil_seed42/. Validation: Results/validation/Re<Re>_Mach<M>/.
  • XFOIL executable in naca_core/bin/ (ignored by git). On Windows it is downloaded there automatically.
  • README updated (structure, usage, output).

Commits

  1. Moves only (100% renames, history preserved), including the in-house run.py to the root.
  2. Content: the single run.py, paths, deletions, README.

Verified: nothing lost

Reference outputs were recorded on Windows with the old code before the refactor (fixed seed 42), then the same inputs were run on the new code:

Case Terminal Output files
In-house identical (176 lines) identical (11 files)
XFOIL, objective 1 identical, see note identical (11 files)
XFOIL, objective 2 identical, see note identical (11 files)
Validation identical (80 lines) identical (3 files)

Accepted differences only: the solver question, the result-folder paths, the XFOIL path. SVG files are skipped (matplotlib writes the date inside), DXF files are compared by geometry.

Note on the two XFOIL cases: the only other lines that differ are not from our code. (1) In the reference run the old code downloaded xfoil.exe again, because the pull after #3 had removed the tracked one, as expected. (2) PowerShell wraps an ezdxf INFO message on stderr in a block that echoes the command line, and the command line changed from xfoil_viscous_optimizer\run.py to run.py.

Also checked: baseline 24/24 (also on a fresh clone of this branch); same results in a Linux sandbox; edge cases (bounding box 0.05 m, invalid solver choice, invalid input, XFOIL always failing, missing library) behave as before; XFOIL found in naca_core/bin/ and ignored by git.

After merging (on your PC)

Move xfoil.exe into naca_core/bin/, or just run with XFOIL once: on Windows it is downloaded there again. The old Results folders under the removed directories can be deleted.

Found on the way (not changed here)

naca_core/xfoil.py calls logging.basicConfig(level=INFO), so in XFOIL runs ezdxf INFO messages show up on stderr. Harmless; to fix in a separate PR.

Depends on

#20 (base branch: chore/merge-into-main).

@PSamuele

Copy link
Copy Markdown
Contributor Author

Before/after evidence

The attached zip contains everything needed to check the refactor independently:

Content What it is
before/ inputs, terminal outputs and result files of the old code (two run.py), recorded on Windows before the refactor
after/Results/ result files of the new single run.py, same inputs
compare_refactor.py the comparison script
comparison_result.txt its output

Four cases, all with seed 42: in-house, XFOIL objective 1, XFOIL objective 2, validation.

   === in-house
     terminal: identical (176 lines)
     files: identical (11 files; .svg skipped, .dxf compared by geometry)
   === XFOIL obj. 1
     ignored in old output (not from our code): 1 XFOIL download, 1 PowerShell stderr block
     ignored in new output (not from our code): 1 PowerShell stderr block
     terminal: identical (190 lines)
     files: identical (11 files; .svg skipped, .dxf compared by geometry)
   === XFOIL obj. 2
     ignored in old output (not from our code): 1 PowerShell stderr block
     ignored in new output (not from our code): 1 PowerShell stderr block
     terminal: identical (238 lines)
     files: identical (11 files; .svg skipped, .dxf compared by geometry)
   === validation
     terminal: identical (80 lines)
     files: identical (3 files; .svg skipped, .dxf compared by geometry)

   RESULT: ALL IDENTICAL

What the script accepts as different: the new solver question, the result-folder paths, the XFOIL path. What it removes and reports, because it does not come from our code: the one-off download of xfoil.exe in the old run, and the block PowerShell wraps around a stderr line (it echoes the command line, which changed). SVG files are skipped because matplotlib writes the date inside them; DXF files are compared by geometry. Everything else is compared byte by byte.

To rerun the check: unzip, then from inside the folder run
python compare_refactor.py before after
(needs ezdxf, already in requirements.txt). You can also open any pair of files from before/ and after/ side by side.

refactor_evidence.zip

PSamuele added a commit that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant