Python Script for complete lift polar
Hi SU2 users,
Is there already python script exists that automatically takes the converged solution of the current angle of attack as restart solution to compute the next angle of attack and so on ... to complete the lift polar. Instead of always doing this process manually to do the polars. Thanks and regards. |
Inelegant but effective...
1 Attachment(s)
Quote:
...I'm also not worried about space, so I just copy/paste a run directory to the next run (each AoA is a sub-directory of that) and run the script. Since I'm running on a KRAKEN Cray 5 system, I also need a submit script. As I say...not terribly sophisticated, and I am currently "tail"ing each output file one by one and transferring the CL and CD values. If you get anything more slick I'd be interested in taking a look! Good Luck! Dave |
Example Code
This is a good example to try with the new SU2 python package! Here's an example python script -
Code:
#!/usr/bin/env python |
How do I Use this code?
Hi rktchip
I try to draw drag polar range from -9 to 9. Sure, I could draw the polar manually trying to 19 times to complete. but I want to calculate automatically. Could u explain the code How could I do that using ur code? I dont know well python... and english.. thanks. |
In the script below, you can specify the angle of attack and mach number changing the value of
# angles to run angles = np.linspace(-15.0,15.0,11) # mach numbers to run mach = np.linspace(0.15,0.90,5) Best Regards, Francisco #!/usr/bin/env python ## \file shape_optimization.py # \brief Python script for performing the shape optimization. # \author Francisco Palacios, Trent Lukaczyk, Aerospace Design Laboratory (Stanford University) <http://su2.stanford.edu>. # \version 2.0.8 # # Stanford University Unstructured (SU2). # Copyright (C) 2012-2013 Aerospace Design Laboratory (ADL). # # SU2 is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # SU2 is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with SU2. If not, see <http://www.gnu.org/licenses/>. # imports import numpy as np from optparse import OptionParser import os, sys, shutil, copy sys.path.append(os.environ['SU2_RUN']) import SU2 # Command Line Options parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="read config from FILE", metavar="FILE") parser.add_option("-p", "--partitions", dest="partitions", default=2, help="number of PARTITIONS", metavar="PARTITIONS") parser.add_option("-i", "--iterations", dest="iterations", default=99999, help="number of ITERATIONS", metavar="ITERATIONS") (options, args)=parser.parse_args() options.partitions = int( options.partitions ) options.iterations = int( options.iterations ) # load config, start state config = SU2.io.Config(options.filename) state = SU2.io.State() # prepare config config.NUMBER_PART = options.partitions config.EXT_ITER = options.iterations # find solution files if they exist state.find_files(config) # angles to run angles = np.linspace(-15.0,15.0,11) # mach numbers to run mach = np.linspace(0.15,0.90,5) # start results data results = SU2.util.bunch() results.AoA = angles results.MACH = mach results.DRAG = [] results.LIFT = [] results.MOMENT_Z = [] # iterate mach for MachNumber in mach: f = open('Polar_M' + str(MachNumber) + '.dat', 'w') f.write('VARIABLES = "AoA", "C<sub>L</sub>", "C<sub>D</sub>", "C<sub>Mz</sub>" \n') # iterate angles for AngleAttack in angles: # local config and state konfig = copy.deepcopy(config) ztate = copy.deepcopy(state) # set angle of attack konfig.AoA = AngleAttack konfig.MACH_NUMBER = MachNumber print 'Mach = ' , konfig.MACH_NUMBER , 'AoA = ' , konfig.AoA # run su2 drag = SU2.eval.func('DRAG',konfig,ztate) lift = SU2.eval.func('LIFT',konfig,ztate) moment = SU2.eval.func('MOMENT_Z',konfig,ztate) # append results results.DRAG.append(drag) results.LIFT.append(lift) results.MOMENT_Z.append(moment) output = str(AngleAttack) + ", " + str(lift) + ", " + str(drag) + ", " + str(moment) + "\n" f.write(output) f.close() # Close open file #: for each angle # plotting # plt.figure() # plt.plot( results.MACH_NUMBER, results.AoA , results.LIFT , results.DRAG ) # plt.show() # save data SU2.io.save_data('results.pkl',results) |
All times are GMT -4. The time now is 00:09. |