Skip to content

Commit

Permalink
Fixed paths to code in docs (#443)
Browse files Browse the repository at this point in the history
* Fixed paths to tests in docs

* Fixed paths to tests in docs that use embed-code

* Had to switch from embed-code to literalinclude since tests no longer in python package
  • Loading branch information
eytanadler authored Aug 4, 2024
1 parent 394f477 commit 87edebd
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 33 deletions.
6 changes: 4 additions & 2 deletions openaerostruct/docs/advanced_features/aerostruct_ffd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ This allows for more general design shape changes and helps sync up geometry cha
.. warning::
This example requires `pyGeo`, an external code developed by the MDO Lab. You can install it from `here <https://github.com/mdolab/pygeo>`_.

.. embed-code::
openaerostruct.tests.test_aerostruct_ffd.Test.test
.. literalinclude:: /../../tests/integration_tests/test_aerostruct_ffd.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8
6 changes: 4 additions & 2 deletions openaerostruct/docs/advanced_features/ground_effect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ This means that configurations deep in ground effect (small altitude compared to

To enable ground effect, add a :code:`groundplane: True` attribute to your aerosurfaces, like so:

.. embed-code::
openaerostruct.tests.test_aero_ground_effect.Test.test
.. literalinclude:: /../../tests/integration_tests/test_aero_ground_effect.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8

If groundplane is turned on for an AeroPoint or AeroStructPoint, a new input will be created (height_agl) which represents the distance from the origin (in airplane coordinates) to the ground plane.
The default value, 8000 meters, produces essentially zero ground effect.
Expand Down
7 changes: 4 additions & 3 deletions openaerostruct/docs/advanced_features/multiple_surfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Multiple Lifting Surfaces
It's easily possible to simulate multiple lifting surfaces simultaneously in OpenAeroStruct.
The most straightforward example is a wing and a tail for a conventional airplane, as shown below, though OpenAeroStruct can handle any arbitrary collection of lifting surfaces.

.. embed-code::
openaerostruct.tests.test_multiple_aero_analysis.Test.test
:layout: interleave
.. literalinclude:: /../../tests/integration_tests/test_multiple_aero_analysis.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8
7 changes: 4 additions & 3 deletions openaerostruct/docs/advanced_features/multipoint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ Aerodynamic Optimization Example
--------------------------------
We optimize the aircraft at two cruise flight conditions below.

.. embed-code::
openaerostruct.tests.test_multipoint_aero.Test.test
:layout: interleave
.. literalinclude:: /../../tests/integration_tests/test_multipoint_aero.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8


Aerostructural Optimization Example (Q400)
Expand Down
14 changes: 8 additions & 6 deletions openaerostruct/docs/advanced_features/multipoint_parallel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Then, let's set up the problem in the same way as the serial runscript.
Next, we need to add AS_points under a ``ParallelGroup`` instead of directly under the ``prob.model``.

.. literalinclude:: ../../tests/test_multipoint_parallel.py
.. literalinclude:: /../../tests/integration_tests/test_multipoint_parallel.py
:dedent: 8
:start-after: # [rst Setup ParallelGroup (beg)]
:end-before: # [rst Setup ParallelGroup (end)]
Expand All @@ -55,7 +55,7 @@ Among 6 functions, 4 depend only on AS_point_0, and 2 depend only on AS_point_1.
Therefore, we can form 2 pairs and perform linear solves in parallel.
We specify ``parallel_deriv_color`` to tell OpenMDAO which function's derivatives can be solved for in parallel.

.. literalinclude:: ../../tests/test_multipoint_parallel.py
.. literalinclude:: /../../tests/integration_tests/test_multipoint_parallel.py
:dedent: 8
:start-after: # [rst Parallel deriv color setup 1 (beg)]
:end-before: # [rst Parallel deriv color setup 1 (end)]
Expand All @@ -64,15 +64,15 @@ Furthermore, we will add another dummy (nonsense) constraint to explain how para
This dummy constraint (sum of the fuel burns from AS_point_0 and AS_point_1) depends on both AS points.
In this case, the linear solves of AS_point_0 and AS_point_1 will be parallelized.

.. literalinclude:: ../../tests/test_multipoint_parallel.py
.. literalinclude:: /../../tests/integration_tests/test_multipoint_parallel.py
:dedent: 8
:start-after: # [rst Parallel deriv color setup 2 (beg)]
:end-before: # [rst Parallel deriv color setup 2 (end)]

Finally, let's change the linear solver from default.
This step is not necessary and not directly relevant to parallelization, but the ``LinearBlockGS`` solver works better on a fine mesh than the default ``DirectSolver``.

.. literalinclude:: ../../tests/test_multipoint_parallel.py
.. literalinclude:: /../../tests/integration_tests/test_multipoint_parallel.py
:dedent: 8
:start-after: # [rst Change linear solver (beg)]
:end-before: # [rst Change linear solver (end)]
Expand All @@ -81,8 +81,10 @@ This step is not necessary and not directly relevant to parallelization, but the
Complete runscript
------------------

.. embed-code::
openaerostruct.tests.test_multipoint_parallel.Test.test_multipoint_MPI
.. literalinclude:: /../../tests/integration_tests/test_multipoint_parallel.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8

To run this example in parallel with two processors, use the following command:

Expand Down
7 changes: 4 additions & 3 deletions openaerostruct/docs/aerostructural_tube_walkthrough.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Additionally, we have more variable connections due to the more complex problem

For more details about ``mesh_dict`` and ``surface`` in the following script, see :ref:`Mesh and Surface Dict`.

.. embed-code::
openaerostruct.tests.test_aerostruct.Test.test
:layout: interleave
.. literalinclude:: /../../tests/integration_tests/test_aerostruct.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8
8 changes: 4 additions & 4 deletions openaerostruct/docs/quick_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Quick Example
Here is an example run script to perform aerodynamic optimization.
We'll go into more detail later about how to set up a model, define the optimization problem, and postprocess results.

.. embed-code::
openaerostruct.tests.test_aero.Test.test
:layout: interleave

.. literalinclude:: /../../tests/integration_tests/test_aero.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8
7 changes: 4 additions & 3 deletions openaerostruct/docs/struct_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Although doing structural-only optimizations is relatively rare, this is a build

For more details about ``mesh_dict`` and ``surf_dict`` in the following script, see :ref:`Mesh and Surface Dict`.

.. embed-code::
openaerostruct.tests.test_struct.Test.test
:layout: interleave
.. literalinclude:: /../../tests/integration_tests/test_struct.py
:start-after: docs checkpoint 0
:end-before: docs checkpoint 1
:dedent: 8
8 changes: 4 additions & 4 deletions openaerostruct/docs/user_reference/v1_v2_conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ v1 Script
v2 Script
^^^^^^^^^

.. literalinclude:: /../tests/test_v1_aero_opt.py
.. literalinclude:: /../../tests/integration_tests/test_v1_aero_opt.py
:start-after: checkpoint 0
:end-before: checkpoint 1
:dedent: 8
Expand All @@ -64,7 +64,7 @@ v1 Script
v2 Script
^^^^^^^^^

.. literalinclude:: /../tests/test_v1_aero_opt.py
.. literalinclude:: /../../tests/integration_tests/test_v1_aero_opt.py
:start-after: checkpoint 2
:end-before: checkpoint 3
:dedent: 8
Expand Down Expand Up @@ -92,7 +92,7 @@ v1 Script
v2 Script
^^^^^^^^^

.. literalinclude:: /../tests/test_v1_aero_opt.py
.. literalinclude:: /../../tests/integration_tests/test_v1_aero_opt.py
:start-after: checkpoint 4
:end-before: checkpoint 5
:dedent: 8
Expand Down Expand Up @@ -143,7 +143,7 @@ v1 Script
v2 Script
^^^^^^^^^

.. literalinclude:: /../tests/test_v1_aero_opt.py
.. literalinclude:: /../../tests/integration_tests/test_v1_aero_opt.py
:start-after: checkpoint 0
:end-before: checkpoint 5
:dedent: 8
2 changes: 2 additions & 0 deletions tests/integration_tests/test_aero_ground_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Test(unittest.TestCase):
def test(self):
# docs checkpoint 0
import numpy as np

import openmdao.api as om
Expand Down Expand Up @@ -107,6 +108,7 @@ def test(self):
prob.setup()

prob.run_driver()
# docs checkpoint 1

assert_near_equal(prob["aero_point_0.wing_perf.CD"][0], 0.03157578980832382, 1e-6)
assert_near_equal(prob["aero_point_0.wing_perf.CL"][0], 0.5, 1e-6)
Expand Down
6 changes: 4 additions & 2 deletions tests/integration_tests/test_aerostruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class Test(unittest.TestCase):
def test(self):
# docs checkpoint 0
import numpy as np

from openaerostruct.geometry.utils import generate_mesh
Expand Down Expand Up @@ -141,11 +142,12 @@ def test(self):
# Set up the problem
prob.setup(check=True)

optResult = prob.run_driver()
# docs checkpoint 1

# Inserting a small unit test here. Verify that beta is correctly promoted in an Aerostruct
# group.
assert_near_equal(prob["AS_point_0.beta"], 0.0)

optResult = prob.run_driver()
assert_opt_successful(self, optResult)

assert_near_equal(prob["AS_point_0.fuelburn"][0], 92523.945549167, 1e-8)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_aerostruct_ffd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@unittest.skipUnless(pygeo_flag, "pyGeo is required.")
class Test(unittest.TestCase):
def test(self):
# docs checkpoint 0
from openaerostruct.geometry.utils import generate_mesh, write_FFD_file

from openaerostruct.integration.aerostruct_groups import AerostructGeometry, AerostructPoint
Expand Down Expand Up @@ -167,6 +168,7 @@ def test(self):

# prob.run_model()
optResult = prob.run_driver()
# docs checkpoint 1
assert_opt_successful(self, optResult)

assert_near_equal(prob["AS_point_0.fuelburn"][0], 92474.52106288195, 1e-3)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_multiple_aero_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Test(unittest.TestCase):
def test(self):
# docs checkpoint 0
import numpy as np

import openmdao.api as om
Expand Down Expand Up @@ -134,6 +135,7 @@ def test(self):
prob.setup()

prob.run_model()
# docs checkpoint 1

assert_near_equal(prob["aero_point_0.wing_perf.CD"][0], 0.03539775778518085, 1e-6)
assert_near_equal(prob["aero_point_0.wing_perf.CL"][0], 0.5124736932248048, 1e-6)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_multipoint_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Test(unittest.TestCase):
def test(self):
# docs checkpoint 0
import numpy as np
import openmdao.api as om

Expand Down Expand Up @@ -127,6 +128,7 @@ def test(self):
# Set up the problem and run optimization.
prob.setup()
prob.run_driver()
# docs checkpoint 1

assert_near_equal(prob["aero_point_0.wing_perf.CL"][0], 0.45, 1e-6)
assert_near_equal(prob["aero_point_0.wing_perf.CD"][0], 0.030502881726099183, 1e-6)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration_tests/test_multipoint_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Test(unittest.TestCase):
N_PROCS = 2

def test_multipoint_MPI(self):
# docs checkpoint 0
import numpy as np
import time

Expand Down Expand Up @@ -386,6 +387,7 @@ def test_multipoint_MPI(self):
if MPI.COMM_WORLD.rank == 0:
print("Analysis runtime: ", run_model_time, "[s]")
print("Derivatives runtime: ", derivs_time, "[s]")
# docs checkpoint 1

# OpenMDAO versions before 3.31 use absolute names as dictionary keys, but versions after
# use user facing (promoted) names. Handle both cases here.
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Test(unittest.TestCase):
def test(self):
# docs checkpoint 0
import numpy as np

from openaerostruct.geometry.utils import generate_mesh
Expand Down Expand Up @@ -66,9 +67,10 @@ def test(self):
prob.model.add_objective("wing.structural_mass", scaler=1e-5)

# Set up the problem
prob.setup(force_alloc_complex=False)
prob.setup()

prob.run_driver()
# docs checkpoint 1

assert_near_equal(prob["wing.structural_mass"][0], 71088.4682399, 1e-8)

Expand Down

0 comments on commit 87edebd

Please sign in to comment.