The –task argument defines what task to perform, the options are: run (just run the flow and adjoint once), opt (optimization), testsensshape (test the accuracy of sensitivity wrt to shape variables), testsensuin (test the accuracy of sensitivity wrt to the inlet boundary conditions), solvecl (solve for CL this is for wing cases only), plotsensmap (plot the sensitivity map).Īfter this, we define the boundary conditions and reference values: SLSQP (default), IPOPT, and PSQP are open souce while SNOPT is not. PyOptsparse supports multiple optimizers, here we pre-define some parameters for SNOPT, SLSQP, IPOPT, and PSQP. The –opt argument defines which optimizer to use. Note that the adjoint vectors are scaled based on the values defined by stateScaling in adjointDict. The adjoint vectors are stored in the same order as the state variables, either in state-by-state or cell-by-cell order. We do not store the adjoint vectors but they are available in the run folder with names psi_*. The intermediate results contain the OpenFOAM 3D flow fields, design variables, objective and derivatives values, flow and adjoint solution log files, check mesh quality logs for each optimization iteration. Here the –output argument defines where the intermediate results are stored, the default is. add_argument ( '-optVars', type = str, help = 'Vars for the optimizer', default = "" ) add_argument ( "-task", help = "type of run to do", type = str, default = 'opt' ) parser. add_argument ( "-opt", help = "optimizer to use", type = str, default = 'slsqp' ) parser. add_argument ( "-output", help = 'Output directory', type = str, default = './optOutput/' ) parser. Taking the runScript.py in tutorials/Aerodynamics/NACA0012_Airfoil_Incompressible as an example, we first define the input argument as follow: We need to modify the Input Parameters, DVGeo, and DVCon sections for different optimization cases. The second command mpirun -np $1 python runScript.py &> log.opt runs the Python layer and outputs the optimization log to log.opt.Īll the optimization configurations are defined in runScript.py.Īs mentioned in Tutorials, the runScript.py has seven sections. You need to change the names of the executives in foamRun.sh if you want to use different primal and adjoint solvers. I.e., run the coloring, check the mesh quality, simulate the flow, and compute the adjoint derivatives. This bash script will detect file output from the Python layer and run the corresponding executives, foamRun.sh $1 & runs a bash script for the OpenFOAM layer and put it to background. Mpirun -np $1 python runScript.py &> log.optĭAFoam has two major layers: OpenFOAM and Python, and they interact through file IO. Check the log.opt file for the progress." # these are the actually commands to run the caseĮcho "Running the optimization. In the third section, we run these commands to start the optimization: Or you can convert the plot3D mesh to OpenFOAM format by using the plot3dToFoam utility (see the example above). You can use Paraview to view the plot3D files (remember to uncheck Binary File and check Multi Grid), You can use the genFFD.py script to generate this FFD file by running python genFFD.py.Īlternatively, you can use advance software such as ICEM for more complex FFD point generation. The FFD file is in plot3D format and is located in FFD/wingFFD.xyz. NOTE: make sure the design surfaces are completely within the FFD volume, otherwise, you will see errors. Here the red squares are the FFD control points to morph the airfoil shape. Refer to Mesh Generation in OpenFOAM for detailed instructions. We convert it to OpenFOAM meshes using the plot3dToFoam, autoPatch, createPatch, and renumberMesh utilities in OpenFOAM. The pyHyp will output the volume mesh in plot3D format (.xyz). Here the genAirFoilMesh.py script reads the NACA 0012 profile, generates a surface mesh, and calls pyHyp to generate a volume mesh.ĭAFoam does not support pure 2D cases, so we use one cell in the spanwise (z) direction and impose the symmetry boundary condition. meshGeneration renumberMesh - overwrite > log. meshGeneration createPatch - overwrite > log. meshGeneration autoPatch 30 - overwrite > log. meshGeneration plot3dToFoam - noBlank volumeMesh. # generate mesh echo "Generating mesh." python genAirFoilMesh.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |