{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Demonstration 1: Capturing an OpenMDAO Assembly, editing it, and executing the modified assembly\n", "\n", "## Part 1: Capturing the OpenMDAO Assembly\n", "\n", "This is the first of three Jupyter Notebooks that show an example of the workflow pictured below:\n", "\n", "![Process showing separation of creation, editing, and use of MDAO models](workflow.drawio.svg)\n", "\n", "In this notebook engineer 1 is creating an OpenMDAO assembly that covers multiple use cases. In this example we are using the `PrepGeom` group from Aviary. \n", "\n", "
\n", "Note: Thanks to Ken Moore from NASA for providing the code to set this example up.\n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "metadata": {} }, "outputs": [], "source": [ "import openmdao.api as om\n", "\n", "from aviary.subsystems.geometry.flops_based.prep_geom import PrepGeom\n", "from aviary.utils.aviary_values import AviaryValues\n", "from aviary.validation_cases.validation_tests import get_flops_data\n", "\n", "from aviary.variable_info.functions import override_aviary_vars\n", "from aviary.variable_info.variables import Aircraft\n", "\n", "from aviary.validation_cases.validation_data.flops_data.FLOPS_Test_Data import \\\n", " FLOPS_Test_Data\n", "from aviary.variable_info.variables import Aircraft\n", "from standard_evaluator import save_assembly\n", "\n", "\n", "from aviary.subsystems.geometry.flops_based.prep_geom import PrepGeom" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "metadata": {} }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.canard' : input variable 'aircraft:canard:area', promoted using 'aircraft:canard:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.canard' : input variable 'aircraft:canard:thickness_to_chord', promoted using 'aircraft:canard:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.canard' : input variable 'aircraft:canard:wetted_area_scaler', promoted using 'aircraft:canard:wetted_area_scaler', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:canard:area', promoted using 'aircraft:canard:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:canard:aspect_ratio', promoted using 'aircraft:canard:aspect_ratio', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:canard:thickness_to_chord', promoted using 'aircraft:canard:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:fuselage:avg_diameter', promoted using 'aircraft:fuselage:avg_diameter', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:fuselage:length', promoted using 'aircraft:fuselage:length', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:horizontal_tail:area', promoted using 'aircraft:horizontal_tail:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:horizontal_tail:aspect_ratio', promoted using 'aircraft:horizontal_tail:aspect_ratio', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:horizontal_tail:thickness_to_chord', promoted using 'aircraft:horizontal_tail:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:nacelle:avg_diameter', promoted using 'aircraft:nacelle:avg_diameter', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:nacelle:avg_length', promoted using 'aircraft:nacelle:avg_length', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:vertical_tail:area', promoted using 'aircraft:vertical_tail:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:vertical_tail:aspect_ratio', promoted using 'aircraft:vertical_tail:aspect_ratio', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:vertical_tail:thickness_to_chord', promoted using 'aircraft:vertical_tail:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:wing:area', promoted using 'aircraft:wing:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:wing:aspect_ratio', promoted using 'aircraft:wing:aspect_ratio', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:wing:glove_and_bat', promoted using 'aircraft:wing:glove_and_bat', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:wing:taper_ratio', promoted using 'aircraft:wing:taper_ratio', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.characteristic_lengths' : input variable 'aircraft:wing:thickness_to_chord', promoted using 'aircraft:wing:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:fuselage:avg_diameter', promoted using 'aircraft:fuselage:avg_diameter', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:fuselage:length', promoted using 'aircraft:fuselage:length', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:fuselage:wetted_area_scaler', promoted using 'aircraft:fuselage:wetted_area_scaler', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:horizontal_tail:thickness_to_chord', promoted using 'aircraft:horizontal_tail:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:horizontal_tail:vertical_tail_fraction', promoted using 'aircraft:horizontal_tail:vertical_tail_fraction', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:vertical_tail:thickness_to_chord', promoted using 'aircraft:vertical_tail:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:wing:area', promoted using 'aircraft:wing:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:wing:aspect_ratio', promoted using 'aircraft:wing:aspect_ratio', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:wing:glove_and_bat', promoted using 'aircraft:wing:glove_and_bat', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.fuselage' : input variable 'aircraft:wing:thickness_to_chord', promoted using 'aircraft:wing:thickness_to_chord', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.nacelles' : input variable 'aircraft:nacelle:avg_diameter', promoted using 'aircraft:nacelle:avg_diameter', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.nacelles' : input variable 'aircraft:nacelle:avg_length', promoted using 'aircraft:nacelle:avg_length', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.nacelles' : input variable 'aircraft:nacelle:wetted_area_scaler', promoted using 'aircraft:nacelle:wetted_area_scaler', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.tail' : input variable 'aircraft:horizontal_tail:area', promoted using 'aircraft:horizontal_tail:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.tail' : input variable 'aircraft:horizontal_tail:vertical_tail_fraction', promoted using 'aircraft:horizontal_tail:vertical_tail_fraction', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.tail' : input variable 'aircraft:horizontal_tail:wetted_area_scaler', promoted using 'aircraft:horizontal_tail:wetted_area_scaler', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.tail' : input variable 'aircraft:vertical_tail:area', promoted using 'aircraft:vertical_tail:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.tail' : input variable 'aircraft:vertical_tail:wetted_area_scaler', promoted using 'aircraft:vertical_tail:wetted_area_scaler', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.wing' : input variable 'aircraft:wing:area', promoted using 'aircraft:wing:area', was already promoted using 'aircraft*'.\n", "C:\\Users\\tf715b\\Desktop\\standard-evaluator\\venv\\Lib\\site-packages\\openmdao\\core\\system.py:2697: PromotionWarning:'prep_geom.wing' : input variable 'aircraft:wing:wetted_area_scaler', promoted using 'aircraft:wing:wetted_area_scaler', was already promoted using 'aircraft*'.\n" ] } ], "source": [ "class PreMission(om.Group):\n", "\n", " def initialize(self):\n", " self.options.declare(\n", " 'aviary_options', types=AviaryValues,\n", " desc='collection of Aircraft/Mission specific options')\n", "\n", " def setup(self):\n", " self.add_subsystem('prep_geom', PrepGeom(),\n", " promotes=['*'])\n", "\n", " def configure(self):\n", " aviary_options = self.options['aviary_options']\n", "\n", " override_aviary_vars(self, aviary_options)\n", "\n", "\n", "case_name = 'LargeSingleAisle1FLOPS'\n", "keys = [\n", " Aircraft.Fuselage.NUM_FUSELAGES,\n", " Aircraft.Propulsion.TOTAL_NUM_FUSELAGE_ENGINES,\n", " Aircraft.VerticalTail.NUM_TAILS,\n", " Aircraft.Wing.SPAN_EFFICIENCY_REDUCTION,\n", " Aircraft.Engine.NUM_ENGINES,\n", " Aircraft.Propulsion.TOTAL_NUM_ENGINES,\n", "]\n", "\n", "options = get_flops_data(case_name, preprocess=True, keys=keys)\n", "model_options = {}\n", "for key in keys:\n", " model_options[key] = options.get_item(key)[0]\n", "\n", "prob = om.Problem(PreMission(aviary_options=options))\n", "\n", "# Joerg, this is the Model Options feature, that lets us set component options at the top, so that OpenMDAO will\n", "# propagate them to all the components.\n", "prob.model_options['*'] = model_options\n", "\n", "prob.setup(force_alloc_complex=True)\n", "\n", "flops_data = FLOPS_Test_Data[case_name]\n", "flops_inputs = flops_data['inputs']\n", "flops_outputs = flops_data['outputs']\n", "\n", "input_keys = [\n", " Aircraft.Fuselage.LENGTH,\n", " Aircraft.Fuselage.MAX_HEIGHT,\n", " Aircraft.Fuselage.MAX_WIDTH,\n", " Aircraft.Fuselage.WETTED_AREA_SCALER,\n", "\n", " Aircraft.HorizontalTail.AREA,\n", " Aircraft.HorizontalTail.ASPECT_RATIO,\n", " Aircraft.HorizontalTail.TAPER_RATIO,\n", " Aircraft.HorizontalTail.THICKNESS_TO_CHORD,\n", " Aircraft.HorizontalTail.VERTICAL_TAIL_FRACTION,\n", " Aircraft.HorizontalTail.WETTED_AREA_SCALER,\n", "\n", " Aircraft.Nacelle.AVG_DIAMETER,\n", " Aircraft.Nacelle.AVG_LENGTH,\n", "\n", " Aircraft.VerticalTail.AREA,\n", " Aircraft.VerticalTail.ASPECT_RATIO,\n", " Aircraft.VerticalTail.TAPER_RATIO,\n", " Aircraft.VerticalTail.THICKNESS_TO_CHORD,\n", " Aircraft.VerticalTail.WETTED_AREA_SCALER,\n", "\n", " Aircraft.Wing.AREA,\n", " Aircraft.Wing.ASPECT_RATIO,\n", " Aircraft.Wing.GLOVE_AND_BAT,\n", " Aircraft.Wing.SPAN,\n", " Aircraft.Wing.TAPER_RATIO,\n", " Aircraft.Wing.THICKNESS_TO_CHORD,\n", " Aircraft.Wing.WETTED_AREA_SCALER,\n", "]\n", "\n", "for key in input_keys:\n", " if key in flops_inputs:\n", " data = flops_inputs\n", " else:\n", " data = flops_outputs\n", " desired, units = data.get_item(key)\n", " prob.set_val(key, desired, units)\n", "\n", "prob.run_model()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have the OpenMDAO assembly we can show the values of it's inputs. This will be useful to compare with in the other parts of the demo." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "metadata": {} }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "78 Input(s) in 'model'\n", "\n", "varname val shape prom_name \n", "--------------------------------------------------- --------------- ----- -----------------------------------------------\n", "prep_geom\n", " fuselage_prelim\n", " aircraft:fuselage:length [128.] (1,) aircraft:fuselage:length \n", " aircraft:fuselage:max_height [13.17] (1,) aircraft:fuselage:max_height \n", " aircraft:fuselage:max_width [12.33] (1,) aircraft:fuselage:max_width \n", " wing_prelim\n", " aircraft:wing:area [1370.] (1,) aircraft:wing:area \n", " aircraft:wing:glove_and_bat [134.] (1,) aircraft:wing:glove_and_bat \n", " aircraft:wing:span [117.83] (1,) aircraft:wing:span \n", " prelim\n", " aircraft:fuselage:avg_diameter [12.75] (1,) aircraft:fuselage:avg_diameter \n", " aircraft:fuselage:max_width [12.33] (1,) aircraft:fuselage:max_width \n", " aircraft:horizontal_tail:area [355.] (1,) aircraft:horizontal_tail:area \n", " aircraft:horizontal_tail:aspect_ratio [6.] (1,) aircraft:horizontal_tail:aspect_ratio \n", " aircraft:horizontal_tail:taper_ratio [0.22] (1,) aircraft:horizontal_tail:taper_ratio \n", " aircraft:horizontal_tail:thickness_to_chord [0.125] (1,) aircraft:horizontal_tail:thickness_to_chord \n", " aircraft:vertical_tail:area [284.] (1,) aircraft:vertical_tail:area \n", " aircraft:vertical_tail:aspect_ratio [1.75] (1,) aircraft:vertical_tail:aspect_ratio \n", " aircraft:vertical_tail:taper_ratio [0.33] (1,) aircraft:vertical_tail:taper_ratio \n", " aircraft:vertical_tail:thickness_to_chord [0.1195] (1,) aircraft:vertical_tail:thickness_to_chord \n", " aircraft:wing:area [1370.] (1,) aircraft:wing:area \n", " aircraft:wing:glove_and_bat [134.] (1,) aircraft:wing:glove_and_bat \n", " aircraft:wing:span [117.83] (1,) aircraft:wing:span \n", " aircraft:wing:taper_ratio [0.278] (1,) aircraft:wing:taper_ratio \n", " aircraft:wing:thickness_to_chord [0.13] (1,) aircraft:wing:thickness_to_chord \n", " wing\n", " prep_geom:_Names:CROOT [16.415788] (1,) wing.prep_geom:_Names:CROOT \n", " prep_geom:_Names:CROOTB [15.13330021] (1,) wing.prep_geom:_Names:CROOTB \n", " prep_geom:_Names:XDX [12.75] (1,) wing.prep_geom:_Names:XDX \n", " prep_geom:_Names:XMULT [2.05031] (1,) wing.prep_geom:_Names:XMULT \n", " aircraft:wing:area [1370.] (1,) aircraft:wing:area \n", " aircraft:wing:wetted_area_scaler [1.] (1,) aircraft:wing:wetted_area_scaler \n", " tail\n", " prep_geom:_Names:XMULTH [2.048375] (1,) tail.prep_geom:_Names:XMULTH \n", " prep_geom:_Names:XMULTV [2.0462465] (1,) tail.prep_geom:_Names:XMULTV \n", " aircraft:horizontal_tail:area [355.] (1,) aircraft:horizontal_tail:area \n", " aircraft:horizontal_tail:vertical_tail_fraction [0.] (1,) aircraft:horizontal_tail:vertical_tail_fraction\n", " aircraft:horizontal_tail:wetted_area_scaler [1.] (1,) aircraft:horizontal_tail:wetted_area_scaler \n", " aircraft:vertical_tail:area [284.] (1,) aircraft:vertical_tail:area \n", " aircraft:vertical_tail:wetted_area_scaler [1.] (1,) aircraft:vertical_tail:wetted_area_scaler \n", " fuselage\n", " prep_geom:_Names:CROOTB [15.13330021] (1,) fuselage.prep_geom:_Names:CROOTB \n", " prep_geom:_Names:CROTVT [19.15660306] (1,) fuselage.prep_geom:_Names:CROTVT \n", " prep_geom:_Names:CRTHTB [13.50207305] (1,) fuselage.prep_geom:_Names:CRTHTB \n", " aircraft:fuselage:avg_diameter [12.75] (1,) aircraft:fuselage:avg_diameter \n", " aircraft:fuselage:length [128.] (1,) aircraft:fuselage:length \n", " aircraft:fuselage:wetted_area_scaler [1.] (1,) aircraft:fuselage:wetted_area_scaler \n", " aircraft:horizontal_tail:thickness_to_chord [0.125] (1,) aircraft:horizontal_tail:thickness_to_chord \n", " aircraft:horizontal_tail:vertical_tail_fraction [0.] (1,) aircraft:horizontal_tail:vertical_tail_fraction\n", " aircraft:vertical_tail:thickness_to_chord [0.1195] (1,) aircraft:vertical_tail:thickness_to_chord \n", " aircraft:wing:area [1370.] (1,) aircraft:wing:area \n", " aircraft:wing:aspect_ratio [11.232936] (1,) aircraft:wing:aspect_ratio \n", " aircraft:wing:glove_and_bat [134.] (1,) aircraft:wing:glove_and_bat \n", " aircraft:wing:thickness_to_chord [0.13] (1,) aircraft:wing:thickness_to_chord \n", " nacelles\n", " aircraft:nacelle:avg_diameter [7.94] (1,) aircraft:nacelle:avg_diameter \n", " aircraft:nacelle:avg_length [12.3] (1,) aircraft:nacelle:avg_length \n", " aircraft:nacelle:wetted_area_scaler [1.] (1,) aircraft:nacelle:wetted_area_scaler \n", " canard\n", " aircraft:canard:area [0.] (1,) aircraft:canard:area \n", " aircraft:canard:thickness_to_chord [0.] (1,) aircraft:canard:thickness_to_chord \n", " aircraft:canard:wetted_area_scaler [1.] (1,) aircraft:canard:wetted_area_scaler \n", " characteristic_lengths\n", " prep_geom:_Names:CROOT [16.415788] (1,) characteristic_lengths.prep_geom:_Names:CROOT \n", " aircraft:canard:area [0.] (1,) aircraft:canard:area \n", " aircraft:canard:aspect_ratio [0.] (1,) aircraft:canard:aspect_ratio \n", " aircraft:canard:thickness_to_chord [0.] (1,) aircraft:canard:thickness_to_chord \n", " aircraft:fuselage:avg_diameter [12.75] (1,) aircraft:fuselage:avg_diameter \n", " aircraft:fuselage:length [128.] (1,) aircraft:fuselage:length \n", " aircraft:horizontal_tail:area [355.] (1,) aircraft:horizontal_tail:area \n", " aircraft:horizontal_tail:aspect_ratio [6.] (1,) aircraft:horizontal_tail:aspect_ratio \n", " aircraft:horizontal_tail:thickness_to_chord [0.125] (1,) aircraft:horizontal_tail:thickness_to_chord \n", " aircraft:nacelle:avg_diameter [7.94] (1,) aircraft:nacelle:avg_diameter \n", " aircraft:nacelle:avg_length [12.3] (1,) aircraft:nacelle:avg_length \n", " aircraft:vertical_tail:area [284.] (1,) aircraft:vertical_tail:area \n", " aircraft:vertical_tail:aspect_ratio [1.75] (1,) aircraft:vertical_tail:aspect_ratio \n", " aircraft:vertical_tail:thickness_to_chord [0.1195] (1,) aircraft:vertical_tail:thickness_to_chord \n", " aircraft:wing:area [1370.] (1,) aircraft:wing:area \n", " aircraft:wing:aspect_ratio [11.232936] (1,) aircraft:wing:aspect_ratio \n", " aircraft:wing:glove_and_bat [134.] (1,) aircraft:wing:glove_and_bat \n", " aircraft:wing:taper_ratio [0.278] (1,) aircraft:wing:taper_ratio \n", " aircraft:wing:thickness_to_chord [0.13] (1,) aircraft:wing:thickness_to_chord \n", " total_wetted_area\n", " aircraft:canard:wetted_area [0.] (1,) aircraft:canard:wetted_area \n", " aircraft:fuselage:wetted_area [4158.62066062] (1,) aircraft:fuselage:wetted_area \n", " aircraft:horizontal_tail:wetted_area [592.64609688] (1,) aircraft:horizontal_tail:wetted_area \n", " aircraft:nacelle:total_wetted_area [546.9072] (1,) aircraft:nacelle:total_wetted_area \n", " aircraft:vertical_tail:wetted_area [581.134006] (1,) aircraft:vertical_tail:wetted_area \n", " aircraft:wing:wetted_area [2396.55520449] (1,) aircraft:wing:wetted_area \n", "\n", "\n" ] } ], "source": [ "_ = prob.model.list_inputs(shape=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also look at the N2 diagram for this model. If we carefully look at this diagram we can see that there are two main components that create outputs from this assembly:\n", "\n", "- `characteristic_lengths`\n", "- `total_wetted_area`\n", "\n", "We can also see that two components are only using inputs to the group, and are not depending on the preliminary calculations done in other components in this assembly. The two components only depending on inputs to the group are:\n", "\n", "- `nacelles`\n", "- `canard`" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "metadata": {} }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import os\n", "# Check if running in VS Code\n", "if 'VSCODE_PID' in os.environ:\n", " display_in_notebook = False\n", "else:\n", " display_in_notebook = True\n", "om.n2(prob, 'before_NASA.n2.html', display_in_notebook=display_in_notebook, )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The final step in this part of the workflow we are demonstrating is the engineer storing both the assembly information and the current state of the assembly in a JSON file (`demo_group_nasa.json`) and a HDF5 file (`state.h5`). \n", "\n", "
\n", "Note: We use the HDF5 format for storing the state since it is a binary file format which is compact and ensure no loss of accuracy. There are many different viewers and editors available to edit HDF5. A nice viewer is myHDF5.\n", "
" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "metadata": {} }, "outputs": [], "source": [ "save_assembly(prob, assembly_name='demo_group_nasa.json', state_name='state.h5')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 4 }