hoburg / pyxfoil

Python tools for running xfoil many times
MIT License
10 stars 4 forks source link

File name: genpolar.py Author: Steven Chiu

genpolar provides an entrance to the pyxfoil module which provides an interface between python and XFOIL. The genpolar interface behaves like the standard python interpreter.

STARTING GENPOLAR

From the terminal, enter python genpolar.py [ run-name ] If no run name is provided, genpolar will prompt for a run. If the run does not exist, genpolar will create a new run with the given name and the following directory structure:

README pyxfoil/ ... pyxfoil module genpolar.py run-name/logs/ contains session logs, XFOIL output logs, etc. /savedpolars/ contains polar files generated by sweep() and fill() /mergedump/ contains remaining files after merge()

Otherwise genpolar will open the existing file with the given name.

IMPORTANT: Always exit from a run by calling 'quit'. This ensures that the logs are properly written

COMMANDS

Genpolar behaves like the python interpreter with built in functions for use with pyxfoil. The three main functions are:

sweep(airfoils, res, write_file, plots_on, panels):
    Runs a large sweep over the set airfoils x res

    @param airfoils   iterable containing string NACA numbers to sweep over
    @param res        iterable containing float reynolds numbers to sweep over
    @param write_file boolean indicating whether or not to create polars
    @param plots_on   boolean indicating whether or not to simulate with plots on
    @param panels     included as per original genpolar file

fill(threshold, stepsize, write_file, plots_on, panels):
    Sifts through existing polars and reruns simulations with smaller step size
    This should be run after sweep()

    @param threshold  float minimum alfa value to be included in fill()
    @param stepsize   float alfa step size to simulate with
    @param write_file boolean indicating whether polar is created
    @param plots_on   boolean indicating whether plots are shown
    @param panels     included as per original genpolar file

merge():
    Merges .pol files with _aug.pol files
    Dumps the original files in cwd/mergedump/

SAMPLE INPUT/OUTPUT

~/aero_models/profile_drag/chiu$ vim genpolar.py smallrun
New run created: smallrun
Genpolar >> nacaset = ['2413', '2414', '2415']
Genpolar >> import numpy     
Genpolar >> reynolds_set = numpy.logspace(4, 8, 41)
Genpolar >> sweep(nacaset, reynolds_set)

Airfoil = NACA2413 Re = 10000.0
CL successfully zeroed: a = 1.321

Airfoil = NACA2415 Re = 100000000.0
CL successfully zeroed: a = -2.086
skipping a = 0.914: skips so far: 1
skipping a = 11.414: skips so far: 1
skipping a = 12.914: skips so far: 1
aborting at cl = 2.2163, a = 24.414: past peak 2.2341, 22.914
Exiting simulation at a = 24.414
100.0% complete, 10.22 seconds
Number of xfoil timeouts: 1
Time to complete: 0.0 hours 20.0 minutes 12.311 seconds.
Number of simulations: 123
Average simulation length: 9.856 seconds.

Genpolar >> fill()
Airfoil = NACA2415 Re = 12000.0
Beginning simulation at a = -2.317

Airfoil = NACA2414 Re = 15000.0
Beginning simulation at a = -2.348
aborting at cl = -0.1184, a = -1.598: past peak -0.0673, -2.348
Exiting simulation at a = -1.598
100.0% complete, 2.1 seconds
Number of xfoil timeouts: 0
Time to complete: 0.0 hours 0.0 minutes 8.781 seconds.
Number of simulations: 4
Average simulation length: 2.195 seconds.
Genpolar >> merge()
4 files merged with their filler files.
Genpolar >> quit