From 9c3306b3a19f80a850e5161f5a82cadc6809c50e Mon Sep 17 00:00:00 2001 From: Neil Wu <602725+nwu63@users.noreply.github.com> Date: Sun, 10 Apr 2022 12:53:08 -0400 Subject: [PATCH 1/6] added autolink to one page to test it out --- conf.py | 17 +++++------------ machAeroTutorials/aero_pygeo.rst | 11 ++++++++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/conf.py b/conf.py index bb298ed..ad6df1a 100644 --- a/conf.py +++ b/conf.py @@ -4,18 +4,11 @@ project = "MACH-Aero Documentation" # -- General configuration ----------------------------------------------------- -# Specify the baseurls for the projects I want to link to -repos = [ - "pygeo", - "pyoptsparse", - "baseclasses", - "idwarp", - "adflow", - "pyhyp", - "multipoint", - "pyspline", -] -intersphinx_mapping = {r: (f"https://mdolab-{r}.readthedocs-hosted.com/en/latest", None) for r in repos} +# autolink +extensions.extend(["sphinx_codeautolink"]) +codeautolink_concat_default = True +codeautolink_warn_on_missing_inventory = True +codeautolink_warn_on_failed_resolve = True # bibtex bibtex_bibfiles = [ diff --git a/machAeroTutorials/aero_pygeo.rst b/machAeroTutorials/aero_pygeo.rst index 443e2c3..7c2ee47 100644 --- a/machAeroTutorials/aero_pygeo.rst +++ b/machAeroTutorials/aero_pygeo.rst @@ -38,12 +38,14 @@ We need to import the pyGeo library in order to use its functions. The pyGeo library, along with all other MACH libraries, should be importable because its code is located in a directory which is exposed to the system environment variable PYTHON_PATH. .. literalinclude:: ../tutorial/aero/geometry/generate_wing.py + :language: py :start-after: # rst Imports :end-before: # rst Airfoil file Wing Definition --------------- .. literalinclude:: ../tutorial/aero/geometry/generate_wing.py + :language: py :start-after: # rst Airfoil file :end-before: # rst Wing definition @@ -76,12 +78,14 @@ An offset in the x-y plane can be added to this position with the ``offset`` arr In this case, we don't want to apply any rotation (the rotation options shown below would be for rotation about the airfoil leading edge points and the units are degrees) or offset. .. literalinclude:: ../tutorial/aero/geometry/generate_wing.py + :language: py :start-after: # rst Wing definition :end-before: # rst Run pyGeo Call pyGeo ---------- .. literalinclude:: ../tutorial/aero/geometry/generate_wing.py + :language: py :start-after: # rst Run pyGeo :end-before: # rst Write output files @@ -92,11 +96,12 @@ Write output files ------------------ There are three options for writing the geometry surface definition to file. - 1. Write a dat file to view wing in Tecplot. - 2. Write an IGES file. This can be converted to a TIN file in ICEM. - 3. Write a TIN file directly from pyGeo. + #. Write a dat file to view wing in Tecplot. + #. Write an IGES file. This can be converted to a TIN file in ICEM. + #. Write a TIN file directly from pyGeo. .. literalinclude:: ../tutorial/aero/geometry/generate_wing.py + :language: py :start-after: # rst Write output files Run it yourself! From 12314b2fe92ebfe627c44ee13903854c04af0e24 Mon Sep 17 00:00:00 2001 From: Neil Wu <602725+nwu63@users.noreply.github.com> Date: Sun, 10 Apr 2022 12:56:02 -0400 Subject: [PATCH 2/6] add to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 71cc0b8..3dd0583 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ sphinx_mdolab_theme +sphinx_codeautolink From f461815c57d19338099e45fb801fb05ee8189a8c Mon Sep 17 00:00:00 2001 From: Neil Wu <602725+nwu63@users.noreply.github.com> Date: Sun, 10 Apr 2022 14:30:00 -0400 Subject: [PATCH 3/6] added autolink to the rest of the tutorials --- machAeroTutorials/aero_adflow.rst | 24 +++++++++----------- machAeroTutorials/aero_pyhyp.rst | 7 ++++++ machAeroTutorials/airfoilopt_ffd.rst | 6 +++++ machAeroTutorials/airfoilopt_mesh.rst | 5 ++++ machAeroTutorials/airfoilopt_multipoint.rst | 5 ++++ machAeroTutorials/airfoilopt_singlepoint.rst | 12 ++++++++++ machAeroTutorials/opt_aero.rst | 12 ++++++++++ machAeroTutorials/opt_ffd.rst | 14 ++++++++++++ machAeroTutorials/opt_pyopt.rst | 11 +++++++++ machAeroTutorials/overset_analysis.rst | 6 +++++ machAeroTutorials/overset_volume_mesh.rst | 10 ++++++++ 11 files changed, 99 insertions(+), 13 deletions(-) diff --git a/machAeroTutorials/aero_adflow.rst b/machAeroTutorials/aero_adflow.rst index 6aa237b..645ec98 100644 --- a/machAeroTutorials/aero_adflow.rst +++ b/machAeroTutorials/aero_adflow.rst @@ -33,6 +33,7 @@ Then copy the code from each of the following sections into this file. Import libraries ---------------- .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Imports :end-before: # rst ADflow options @@ -50,6 +51,7 @@ The ``analysis`` option here will simply run a single ADflow analysis, and the ` ADflow options -------------- .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst ADflow options :end-before: # rst Start ADflow @@ -64,6 +66,7 @@ We strongly recommend going over the descriptions and tips on solvers and solver Create solver ------------- .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Start ADflow :end-before: # rst Create AeroProblem @@ -75,6 +78,7 @@ Also, ADflow can write airfoil data for a given set of slices along the wing usi Set flow conditions ------------------- .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Create AeroProblem :end-before: # rst Run ADflow @@ -87,6 +91,7 @@ Some available functions include ``'cl'``, ``'cd'``, ``'cmz'``, ``'lift'``, and Single analysis --------------- .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Run ADflow :end-before: # rst Create polar arrays @@ -103,38 +108,30 @@ The only difference is that the analysis is now done within a loop. .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Create polar arrays :end-before: # rst Start loop We start by creating a list of the angle of attack values that we wish to analyze. In this case we use the ``numpy.linspace`` function to create a uniformly-spaced array with six whole number entries from 0 -- 5. -We also create the empty lists for storing the lift and drag coefficients. +We also create the empty lists for storing the lift and drag coefficients. The lift and drag data will be appended to these lists as the flow solutions are completed. .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Start loop - :end-before: # rst update AP + :end-before: # rst Print polar Having created the input array and data storage lists, we can now loop over the desired angles of attack to evaluate the polar. We accomplish this by using the builtin ``for`` loop structure in python. - -.. literalinclude:: ../tutorial/aero/analysis/aero_run.py - :start-after: # rst update AP - :end-before: # rst Run ADflow polar - Now for each angle of attack, we update two attributes of the aero problem. We update the name to include the current angle of attack. This allow the filenames of the lift distribution, slices, volume solution and surface solution to be updated with the current angle of attack, making it easier to keep track of the output files. We also update the alpha parameter, which is the attribute of the AeroProblem that represents the angle of attack. - -.. literalinclude:: ../tutorial/aero/analysis/aero_run.py - :start-after: # rst Run ADflow polar - :end-before: # rst Print polar - -Running the solver is identical to the simple single point example. +Running the solver is identical to the simple single point example. We simply call the ``CFDSolver`` instance with the current AeroProblem. This causes the CFD solver to be updated with the values of that AeroProblem prior to solving the flow. We then use the same ``EvalFunctions`` call to integrate the surface forces to get the lift and drag coefficients. @@ -142,6 +139,7 @@ The difference is that here, we append the coefficients from ``funcs`` into the .. literalinclude:: ../tutorial/aero/analysis/aero_run.py + :language: py :start-after: # rst Print polar Once we complete the loop and evaluate all of the desired flow conditions, we can print the completed data set to the screen. diff --git a/machAeroTutorials/aero_pyhyp.rst b/machAeroTutorials/aero_pyhyp.rst index 927a26c..3986510 100644 --- a/machAeroTutorials/aero_pyhyp.rst +++ b/machAeroTutorials/aero_pyhyp.rst @@ -32,6 +32,7 @@ Then copy the code from each of the following sections into this file. Import libraries ---------------- .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst Imports :end-before: # rst general @@ -45,6 +46,7 @@ Here we will point a few of the more basic options. For pyHyp, the options can be organized like so: .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst general :end-before: # rst grid @@ -68,6 +70,7 @@ General options: Name given to wall surfaces. If a dictionary is submitted, each wall patch can have a different name. This can help the user to apply certain operations to specific wall patches in ADflow. .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst grid :end-before: # rst pseudo @@ -88,14 +91,17 @@ More information can be found in the :doc:`pyHyp documentation `. For example, ``epsE`` may be of interest when dealing with concave corners. .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst pseudo :end-before: # rst smoothing .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst smoothing :end-before: # rst solution .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst solution :end-before: # rst run pyHyp @@ -103,6 +109,7 @@ Running pyHyp is quite simple, as shown below. After the mesh extrusion is done, we can write the volume mesh with the ``writeCGNS`` function. .. literalinclude:: ../tutorial/aero/meshing/volume/run_pyhyp.py + :language: py :start-after: # rst run pyHyp Run it yourself! diff --git a/machAeroTutorials/airfoilopt_ffd.rst b/machAeroTutorials/airfoilopt_ffd.rst index adf02e6..c3d0e44 100644 --- a/machAeroTutorials/airfoilopt_ffd.rst +++ b/machAeroTutorials/airfoilopt_ffd.rst @@ -25,18 +25,21 @@ Create the following empty runscript in the current directory. Import Packages =============== .. literalinclude:: ../tutorial/airfoilopt/ffd/genFFD.py + :language: py :start-after: # rst Import :end-before: # rst Load Load Airfoil ============ .. literalinclude:: ../tutorial/airfoilopt/ffd/genFFD.py + :language: py :start-after: # rst Load :end-before: # rst UpperLower The following two functions are used to get the upper and lower points of the airfoil. .. literalinclude:: ../tutorial/airfoilopt/ffd/genFFD.py + :language: py :start-after: # rst UpperLower :end-before: # rst FFDBox1 @@ -47,6 +50,7 @@ FFD Box Creation The FFD box can now be set up. .. literalinclude:: ../tutorial/airfoilopt/ffd/genFFD.py + :language: py :start-after: # rst FFDBox1 :end-before: # rst FFDBox2 @@ -58,6 +62,7 @@ The FFD box can now be set up. .. literalinclude:: ../tutorial/airfoilopt/ffd/genFFD.py + :language: py :start-after: # rst FFDBox2 :end-before: # rst WriteFile @@ -71,6 +76,7 @@ Writing to File =============== .. literalinclude:: ../tutorial/airfoilopt/ffd/genFFD.py + :language: py :start-after: # rst WriteFile Run it yourself! diff --git a/machAeroTutorials/airfoilopt_mesh.rst b/machAeroTutorials/airfoilopt_mesh.rst index 912c82a..4b87505 100644 --- a/machAeroTutorials/airfoilopt_mesh.rst +++ b/machAeroTutorials/airfoilopt_mesh.rst @@ -38,6 +38,7 @@ pyHyp runscript Import the pyHyp libraries and numpy. .. literalinclude:: ../tutorial/airfoilopt/mesh/genMesh.py + :language: py :start-after: # rst Import :end-before: # rst SurfMesh @@ -46,6 +47,7 @@ Surface Mesh Generation ======================= .. literalinclude:: ../tutorial/airfoilopt/mesh/genMesh.py + :language: py :start-after: # rst SurfMesh :end-before: # rst GenOptions @@ -65,6 +67,7 @@ Options ======= .. literalinclude:: ../tutorial/airfoilopt/mesh/genMesh.py + :language: py :start-after: # rst GenOptions :end-before: # rst GridOptions @@ -87,6 +90,7 @@ General Options .. literalinclude:: ../tutorial/airfoilopt/mesh/genMesh.py + :language: py :start-after: # rst GridOptions :end-before: # rst Run @@ -108,6 +112,7 @@ Running pyHyp and Writing to File The following three lines of code extrude the surface mesh and write the resulting volume mesh to a ``.cgns`` file. .. literalinclude:: ../tutorial/airfoilopt/mesh/genMesh.py + :language: py :start-after: # rst Run Run it yourself! diff --git a/machAeroTutorials/airfoilopt_multipoint.rst b/machAeroTutorials/airfoilopt_multipoint.rst index 69a023c..459c098 100644 --- a/machAeroTutorials/airfoilopt_multipoint.rst +++ b/machAeroTutorials/airfoilopt_multipoint.rst @@ -56,6 +56,7 @@ Specifying parameters for the optimization For multipoint optimization, the parameters have to be specified in lists of the same size. .. literalinclude:: ../tutorial/airfoilopt/multipoint/airfoil_multiopt.py + :language: py :start-after: # rst parameters (beg) :end-before: # rst parameters (end) @@ -65,6 +66,7 @@ This is largely unchanged from the single-point case, since we use a very simila The only difference is in defining the variable ``nGroup`` which is used later on to distinguish between the two AeroProblems. .. literalinclude:: ../tutorial/airfoilopt/multipoint/airfoil_multiopt.py + :language: py :start-after: # rst multipoint (beg) :end-before: # rst multipoint (end) @@ -75,6 +77,7 @@ For more than one AeroProblem, a list needs to be created. Each AeroProblem is created with the respective optimization point and appended to the list. .. literalinclude:: ../tutorial/airfoilopt/multipoint/airfoil_multiopt.py + :language: py :start-after: # rst aeroproblem (beg) :end-before: # rst aeroproblem (end) @@ -86,6 +89,7 @@ The lines that require a call to the an AeroProblem is now put into a for-loop t .. literalinclude:: ../tutorial/airfoilopt/multipoint/airfoil_multiopt.py + :language: py :start-after: # rst funcs (beg) :end-before: # rst funcs (end) @@ -99,6 +103,7 @@ In addition, we use the ``wrt`` keyword to specify the variables that affect eac In this case, the ``alpha`` from the other flight conditions do not impact the lift constraint, so they are set to zero. .. literalinclude:: ../tutorial/airfoilopt/multipoint/airfoil_multiopt.py + :language: py :start-after: # rst optprob (beg) :end-before: # rst optprob (end) diff --git a/machAeroTutorials/airfoilopt_singlepoint.rst b/machAeroTutorials/airfoilopt_singlepoint.rst index 8422666..3ac84c1 100644 --- a/machAeroTutorials/airfoilopt_singlepoint.rst +++ b/machAeroTutorials/airfoilopt_singlepoint.rst @@ -46,6 +46,7 @@ Then copy the code from each of the following sections into this file. Import libraries ---------------- .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst Imports (beg) :end-before: # rst Imports (end) @@ -60,6 +61,7 @@ Four options are provided: - Optimizer options .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst args (beg) :end-before: # rst args (end) @@ -69,6 +71,7 @@ Several conditions for the optimization are specified at the beginning of the sc These include the coefficient of lift constraint value, Mach number, and altitude to indicate flow conditions. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst parameters (beg) :end-before: # rst parameters (end) @@ -80,6 +83,7 @@ Creating processor sets Allocating sets of processors for different analyses can be helpful for multiple design points, but this is a single-point optimization, so only one point is added. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst multipoint (beg) :end-before: # rst multipoint (end) @@ -90,6 +94,7 @@ ADflow set-up The ADflow set-up looks similar to the aerodynamic analysis script. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst adflow (beg) :end-before: # rst adflow (end) @@ -117,6 +122,7 @@ Set the AeroProblem We add angle of attack as a design variable and set up the AeroProblem using given flow conditions. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst aeroproblem (beg) :end-before: # rst aeroproblem (end) @@ -131,6 +137,7 @@ Note that since we have to work with a 3D problem, this in fact has twice as man This is addressed by adding linear constraints in the following section. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst dvgeo (beg) :end-before: # rst dvgeo (end) @@ -144,6 +151,7 @@ This is accomplished with a call to ``addLinearConstraintsShape``. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst dvcon (beg) :end-before: # rst dvcon (end) @@ -152,6 +160,7 @@ Mesh warping set-up ------------------- .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst warp (beg) :end-before: # rst warp (end) @@ -160,6 +169,7 @@ Optimization callback functions This section is also the same as the corresponding section in aircraft optimization. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst funcs (beg) :end-before: # rst funcs (end) @@ -168,6 +178,7 @@ Optimization problem This section is also the same as the corresponding section in aircraft optimization. .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst optprob (beg) :end-before: # rst optprob (end) @@ -175,6 +186,7 @@ This section is also the same as the corresponding section in aircraft optimizat Run optimization ---------------- .. literalinclude:: ../tutorial/airfoilopt/singlepoint/airfoil_opt.py + :language: py :start-after: # rst optimizer Run it yourself! diff --git a/machAeroTutorials/opt_aero.rst b/machAeroTutorials/opt_aero.rst index 0dfcf6f..fb76988 100644 --- a/machAeroTutorials/opt_aero.rst +++ b/machAeroTutorials/opt_aero.rst @@ -44,6 +44,7 @@ Then copy the code from each of the following sections into this file. Import libraries ---------------- .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst Imports (beg) :end-before: # rst Imports (end) @@ -58,6 +59,7 @@ Two options are provided: - specifying the optimizer to be used .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst args (beg) :end-before: # rst args (end) @@ -68,6 +70,7 @@ This can be helpful if we want to consider multiple design points, each with a d In this case, we create a processor set for cruise cases, but we only add one point. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst multipoint (beg) :end-before: # rst multipoint (end) @@ -82,12 +85,14 @@ The set-up for adflow should look the same as for the aerodynamic analysis scrip We add a single lift distribution with 200 sampling points. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst adflow (beg) :end-before: # rst adflow (end) Set the AeroProblem ------------------- .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst aeroproblem (beg) :end-before: # rst aeroproblem (end) @@ -101,6 +106,7 @@ We include twist and local variables in the optimization. After setting up the DVGeometry instance we have to provide it to ADflow with the call ``setDVGeo``. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst dvgeo (beg) :end-before: # rst dvgeo (end) @@ -123,6 +129,7 @@ Therefore, ``lower=1.0`` in this example means that the lower limits for these c .. warning:: The ``leList`` and ``teList`` points must lie completely inside the wing. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst dvconVolThick (beg) :end-before: # rst dvconVolThick (end) @@ -141,6 +148,7 @@ This is done by constraining the upper and lower FFD control points on the leadi Note that the LeTe constraint is not related to the ``leList`` and ``teList`` points discussed above. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst dvconLeTe (beg) :end-before: # rst dvconLeTe (end) @@ -156,6 +164,7 @@ This command can also be added at the end of the script to visualize the final c Mesh warping set-up ------------------- .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst warp (beg) :end-before: # rst warp (end) @@ -166,6 +175,7 @@ In this case ``cruiseFuncs`` and ``cruiseFuncsSens`` belong to the ``cruise`` pr Then we need to set up an objCon function, which is used to create abstract functions of other functions. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst funcs (beg) :end-before: # rst funcs (end) @@ -213,6 +223,7 @@ We also need to provide it with the objCon and the optProb. The call ``optProb.printSparsity()`` prints out the constraint Jacobian at the beginning of the optimization. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst optprob (beg) :end-before: # rst optprob (end) @@ -221,6 +232,7 @@ Run optimization To finish up, we choose the optimizer and then run the optimization. .. literalinclude:: ../tutorial/opt/aero/aero_opt.py + :language: py :start-after: # rst optimizer .. note:: diff --git a/machAeroTutorials/opt_ffd.rst b/machAeroTutorials/opt_ffd.rst index d2e8909..93b0331 100644 --- a/machAeroTutorials/opt_ffd.rst +++ b/machAeroTutorials/opt_ffd.rst @@ -52,6 +52,7 @@ We need to define the dimensions of the grid at the root and the tip, and the sc We also need to specify the number of control points we want along each dimension of the FFD grid. .. literalinclude:: ../tutorial/opt/ffd/simple_ffd.py + :language: py :start-after: # rst Dimensions :end-before: # rst Compute @@ -62,6 +63,7 @@ The vector ``span_dist`` gives the spanwise distribution of the FFD sections, wh Here we use a distribution that varies from wider spacing at the root to narrower spacing at the tip. .. literalinclude:: ../tutorial/opt/ffd/simple_ffd.py + :language: py :start-after: # rst Compute :end-before: # rst Write @@ -70,6 +72,7 @@ Write to file Finally we write to file using the plot3d format. .. literalinclude:: ../tutorial/opt/ffd/simple_ffd.py + :language: py :start-after: # rst Write Generate the FFD @@ -97,6 +100,7 @@ Then copy the code from each of the following sections into this file. Import libraries ---------------- .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Import libraries :end-before: # rst Create DVGeometry object @@ -110,6 +114,7 @@ All that is needed to create an instance of the DVGeometry class is an FFD file Usually we call the DVGeometry instance ``DVGeo``. .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Create DVGeometry object :end-before: # rst Create reference axis @@ -140,6 +145,7 @@ The reference axis is a B-spline embedded in the FFD volume. For a wing, we can generate this reference axis simply by stating the fraction of the chord length at which it should be placed and the index of the FFD volume along which it should extend. .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Create reference axis :end-before: # rst Dihedral @@ -162,6 +168,7 @@ We will go through a few examples. Dihedral ~~~~~~~~ .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Dihedral :end-before: # rst Twist @@ -174,6 +181,7 @@ Finally, we restore the new control point coordinates to DVGeo with the call ``r Twist ~~~~~ .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Twist :end-before: # rst Taper @@ -186,6 +194,7 @@ Twisting about the x and y axes is provided through the ``rot_x`` and ``rot_y`` Taper ~~~~~ .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Taper :end-before: # rst Add global dvs @@ -213,6 +222,7 @@ We have now defined the callback functions for the global design variables, but This is done with the call ``addGlobalDV``. .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Add global dvs :end-before: # rst Add local dvs @@ -226,6 +236,7 @@ There are two options for defining local design variables. Only one of these should be used at one time. .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Add local dvs :end-before: # rst Embed points @@ -247,6 +258,7 @@ First we have to embed at least one point set in the FFD. Normally, ADflow automatically embeds the surface mesh nodes in the FFD, but here we will embed surface coordinates obtained using IDWarp's ``getSurfaceCoordinates`` function (just for this example without ADflow). .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Embed points :end-before: # rst Change dvs @@ -257,6 +269,7 @@ To adjust the variables, simply change the values in each variable array. Once this is done, you can return the new values with the call ``setDesignVars``. .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Change dvs :end-before: # rst Update @@ -267,6 +280,7 @@ We can view the current shape of the FFD by calling ``writePlot3d``. We can also view the updated surface coordinates by calling ``writePointSet``. .. literalinclude:: ../tutorial/opt/ffd/parametrize.py + :language: py :start-after: # rst Update Run it yourself! diff --git a/machAeroTutorials/opt_pyopt.rst b/machAeroTutorials/opt_pyopt.rst index 155a7f2..7f589e6 100644 --- a/machAeroTutorials/opt_pyopt.rst +++ b/machAeroTutorials/opt_pyopt.rst @@ -42,6 +42,7 @@ Then copy the code from each of the following sections into this file. Import libraries ---------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Imports :end-before: # rst Command line arguments @@ -51,6 +52,7 @@ Additionally we import ``argparse`` to enable the use of command line arguments. Command line arguments ---------------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Command line arguments :end-before: # rst Callback function @@ -60,6 +62,7 @@ In this case we set up a single command line argument to choose the optimizer th Define the callback function ----------------------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Callback function :end-before: # rst Sensitivity function @@ -71,6 +74,7 @@ The names of the design variables (``xvars``) and functions of interest (``obj`` Define the sensitivity function ------------------------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Sensitivity function :end-before: # rst Optimization problem @@ -83,6 +87,7 @@ For a vector variable (like ``xvars``), the sensitivity is provided as a Jacobia Instantiate the optimization problem ------------------------------------ .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Optimization problem :end-before: # rst Add objective @@ -92,6 +97,7 @@ We create an instance of this class by providing the name of the problem and the Indicate the objective function ------------------------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Add objective :end-before: # rst Add design variables @@ -102,6 +108,7 @@ This should correspond with one of the keys in the ``funcs`` dictionary that is Add design variables -------------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Add design variables :end-before: # rst Add constraints @@ -110,6 +117,7 @@ Now we need to add the design variables to the problem, which is done with a cal Add constraints --------------- .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Add constraints :end-before: # rst Instantiate optimizer @@ -122,6 +130,7 @@ The optimizer is set up with the following lines of code. The options dictionary can be modified to fine-tune the optimizer, but if it is left empty, default values will be used. .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Instantiate optimizer :end-before: # rst Solve @@ -132,6 +141,7 @@ We give the optimizer the optimization problem, the sensitivity function, and op The ``sens`` keyword also accepts ``'FD'`` to indicate that the user wants to use finite difference for derivative computations. .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Solve :end-before: # rst Plot @@ -195,6 +205,7 @@ You can run it with the command You can also load the history file in python to make your own plots, such as the one below, showing the path the optimiser took to the solution: .. literalinclude:: ../tutorial/opt/pyoptsparse/rosenbrock.py + :language: py :start-after: # rst Plot .. figure:: images/opt_optpath.png diff --git a/machAeroTutorials/overset_analysis.rst b/machAeroTutorials/overset_analysis.rst index d78685d..2a0bf39 100644 --- a/machAeroTutorials/overset_analysis.rst +++ b/machAeroTutorials/overset_analysis.rst @@ -58,12 +58,14 @@ Setup the Script First we have to import ``adflow_util``: .. literalinclude:: ../tutorial/overset/analysis/run_adflow_L3.py + :language: py :start-after: # rst Imports (beg) :end-before: # rst Imports (end) Then we define a variable for the level we want to use. This makes it easier to switch, if we want to: .. literalinclude:: ../tutorial/overset/analysis/run_adflow_L3.py + :language: py :start-after: # rst Level (beg) :end-before: # rst Level (end) @@ -72,6 +74,7 @@ one sets the boundary conditions, as ``AeroProblem`` would and the last one is t Lets set the ``adflow_util`` options first: .. literalinclude:: ../tutorial/overset/analysis/run_adflow_L3.py + :language: py :start-after: # rst Options (beg) :end-before: # rst Options (end) @@ -87,6 +90,7 @@ All adflow_util options can be found `here `_\: .. literalinclude:: ../tutorial/overset/mesh/run_pyhyp.py + :language: py :start-after: # rst common_options (beg) :end-before: # rst common_options (end) @@ -90,6 +94,7 @@ Individual pyHyp options Lets define some individual `options `_\: .. literalinclude:: ../tutorial/overset/mesh/run_pyhyp.py + :language: py :start-after: # rst individual_options (beg) :end-before: # rst individual_options (end) @@ -119,6 +124,7 @@ Extrude the nearfield Now we extrude the nearfield: .. literalinclude:: ../tutorial/overset/mesh/run_pyhyp.py + :language: py :start-after: # rst near_field (beg) :end-before: # rst near_field (end) @@ -132,6 +138,7 @@ The farfield consist of a cartesian part in the middle and a simple Ogrid around enclose all the nearfields. Because of that, we have to combine all the nearfields first: .. literalinclude:: ../tutorial/overset/mesh/run_pyhyp.py + :language: py :start-after: # rst combine_near_field (beg) :end-before: # rst combine_near_field (end) @@ -143,6 +150,7 @@ Generate the farfield Now we can generate the farfield: .. literalinclude:: ../tutorial/overset/mesh/run_pyhyp.py + :language: py :start-after: # rst far_field (beg) :end-before: # rst far_field (end) @@ -166,6 +174,7 @@ Combine everything Here we combine all the meshes into one. We do this only on the root processor if we run it in parallel. .. literalinclude:: ../tutorial/overset/mesh/run_pyhyp.py + :language: py :start-after: # rst combine (beg) :end-before: # rst combine (end) @@ -194,6 +203,7 @@ Check the Final Mesh Finally, we can use the ``ihc_check.py`` script to check the result of the implicit hole cutting process in ADflow: .. literalinclude:: ../tutorial/overset/mesh/ihc_check.py + :language: py :start-after: # rst start :end-before: # rst end From 53d1a72df490c39464c67f04e91aad9d4f69f0de Mon Sep 17 00:00:00 2001 From: Neil Wu <602725+nwu63@users.noreply.github.com> Date: Tue, 9 Aug 2022 19:04:22 -0400 Subject: [PATCH 4/6] try pinning sphinx version --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 3dd0583..afef7e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ sphinx_mdolab_theme sphinx_codeautolink +sphinx==4.5.0 From 1ded0127ea2fc9e24f8bc464902bd46b3c268137 Mon Sep 17 00:00:00 2001 From: Neil Wu <602725+nwu63@users.noreply.github.com> Date: Thu, 11 Aug 2022 18:04:12 -0400 Subject: [PATCH 5/6] set more versions to debug --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index afef7e4..6acda8c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ sphinx_mdolab_theme sphinx_codeautolink sphinx==4.5.0 +sphinx-tabs==3.3.1 +pyyaml==5.4.1 From 540ee24821d0ac585da6a340741531b6aa489b98 Mon Sep 17 00:00:00 2001 From: Eirikur Jonsson Date: Mon, 25 Mar 2024 20:16:11 +0000 Subject: [PATCH 6/6] remove fixed versions requirements to resolve build error --- requirements.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6acda8c..3dd0583 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,2 @@ sphinx_mdolab_theme sphinx_codeautolink -sphinx==4.5.0 -sphinx-tabs==3.3.1 -pyyaml==5.4.1