diff --git a/openaerostruct/docs/advanced_features/aerostruct_ffd.rst b/openaerostruct/docs/advanced_features/aerostruct_ffd.rst index f805cc74c..f0acaf28f 100644 --- a/openaerostruct/docs/advanced_features/aerostruct_ffd.rst +++ b/openaerostruct/docs/advanced_features/aerostruct_ffd.rst @@ -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 `_. -.. 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 diff --git a/openaerostruct/docs/advanced_features/ground_effect.rst b/openaerostruct/docs/advanced_features/ground_effect.rst index 579a5290a..ac19e6a84 100644 --- a/openaerostruct/docs/advanced_features/ground_effect.rst +++ b/openaerostruct/docs/advanced_features/ground_effect.rst @@ -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. diff --git a/openaerostruct/docs/advanced_features/multiple_surfaces.rst b/openaerostruct/docs/advanced_features/multiple_surfaces.rst index 90a926b30..fd1842bfe 100644 --- a/openaerostruct/docs/advanced_features/multiple_surfaces.rst +++ b/openaerostruct/docs/advanced_features/multiple_surfaces.rst @@ -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 diff --git a/openaerostruct/docs/advanced_features/multipoint.rst b/openaerostruct/docs/advanced_features/multipoint.rst index 9ecac97be..b63384b13 100644 --- a/openaerostruct/docs/advanced_features/multipoint.rst +++ b/openaerostruct/docs/advanced_features/multipoint.rst @@ -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) diff --git a/openaerostruct/docs/advanced_features/multipoint_parallel.rst b/openaerostruct/docs/advanced_features/multipoint_parallel.rst index ac05f5e63..ab3f08545 100644 --- a/openaerostruct/docs/advanced_features/multipoint_parallel.rst +++ b/openaerostruct/docs/advanced_features/multipoint_parallel.rst @@ -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)] @@ -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)] @@ -64,7 +64,7 @@ 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)] @@ -72,7 +72,7 @@ In this case, the linear solves of AS_point_0 and AS_point_1 will be parallelize 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)] @@ -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: diff --git a/openaerostruct/docs/aerostructural_tube_walkthrough.rst b/openaerostruct/docs/aerostructural_tube_walkthrough.rst index 037d28259..48235a5f1 100644 --- a/openaerostruct/docs/aerostructural_tube_walkthrough.rst +++ b/openaerostruct/docs/aerostructural_tube_walkthrough.rst @@ -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 diff --git a/openaerostruct/docs/quick_example.rst b/openaerostruct/docs/quick_example.rst index db2524811..652f3d7a1 100644 --- a/openaerostruct/docs/quick_example.rst +++ b/openaerostruct/docs/quick_example.rst @@ -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 diff --git a/openaerostruct/docs/struct_example.rst b/openaerostruct/docs/struct_example.rst index c26a8579e..c0c5312be 100644 --- a/openaerostruct/docs/struct_example.rst +++ b/openaerostruct/docs/struct_example.rst @@ -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 \ No newline at end of file +.. literalinclude:: /../../tests/integration_tests/test_struct.py + :start-after: docs checkpoint 0 + :end-before: docs checkpoint 1 + :dedent: 8 diff --git a/openaerostruct/docs/user_reference/v1_v2_conversion.rst b/openaerostruct/docs/user_reference/v1_v2_conversion.rst index 1849c33ab..a90f23ac8 100644 --- a/openaerostruct/docs/user_reference/v1_v2_conversion.rst +++ b/openaerostruct/docs/user_reference/v1_v2_conversion.rst @@ -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 @@ -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 @@ -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 @@ -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 \ No newline at end of file diff --git a/tests/integration_tests/test_aero_ground_effect.py b/tests/integration_tests/test_aero_ground_effect.py index 2d5dd145a..f23d9765d 100644 --- a/tests/integration_tests/test_aero_ground_effect.py +++ b/tests/integration_tests/test_aero_ground_effect.py @@ -3,6 +3,7 @@ class Test(unittest.TestCase): def test(self): + # docs checkpoint 0 import numpy as np import openmdao.api as om @@ -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) diff --git a/tests/integration_tests/test_aerostruct.py b/tests/integration_tests/test_aerostruct.py index 27f67ac46..e62c4a946 100644 --- a/tests/integration_tests/test_aerostruct.py +++ b/tests/integration_tests/test_aerostruct.py @@ -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 @@ -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) diff --git a/tests/integration_tests/test_aerostruct_ffd.py b/tests/integration_tests/test_aerostruct_ffd.py index 0ee954db1..62cd8f1f5 100644 --- a/tests/integration_tests/test_aerostruct_ffd.py +++ b/tests/integration_tests/test_aerostruct_ffd.py @@ -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 @@ -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) diff --git a/tests/integration_tests/test_multiple_aero_analysis.py b/tests/integration_tests/test_multiple_aero_analysis.py index 7328f58aa..03d0218ef 100644 --- a/tests/integration_tests/test_multiple_aero_analysis.py +++ b/tests/integration_tests/test_multiple_aero_analysis.py @@ -4,6 +4,7 @@ class Test(unittest.TestCase): def test(self): + # docs checkpoint 0 import numpy as np import openmdao.api as om @@ -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) diff --git a/tests/integration_tests/test_multipoint_aero.py b/tests/integration_tests/test_multipoint_aero.py index 90f875dfa..0bc049990 100644 --- a/tests/integration_tests/test_multipoint_aero.py +++ b/tests/integration_tests/test_multipoint_aero.py @@ -4,6 +4,7 @@ class Test(unittest.TestCase): def test(self): + # docs checkpoint 0 import numpy as np import openmdao.api as om @@ -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) diff --git a/tests/integration_tests/test_multipoint_parallel.py b/tests/integration_tests/test_multipoint_parallel.py index 3fea70afe..7952f7430 100644 --- a/tests/integration_tests/test_multipoint_parallel.py +++ b/tests/integration_tests/test_multipoint_parallel.py @@ -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 @@ -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. diff --git a/tests/integration_tests/test_struct.py b/tests/integration_tests/test_struct.py index 0e9afc63b..044f8bda2 100644 --- a/tests/integration_tests/test_struct.py +++ b/tests/integration_tests/test_struct.py @@ -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 @@ -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)