Skip to content

Commit

Permalink
Merge pull request OpenMDAO#581 from crecine/update_json
Browse files Browse the repository at this point in the history
adding unit test for json
  • Loading branch information
crecine authored Nov 4, 2024
2 parents 3e5116f + e8ceace commit e769e7d
Show file tree
Hide file tree
Showing 6 changed files with 1,387 additions and 7 deletions.
4 changes: 2 additions & 2 deletions aviary/docs/examples/off_design_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"Running a sizing mission followed by running fallout and alternate missions on the sized aircraft will be presented.\n",
"An overview of off-design missions is presented in [Off-Design Mission User Guide](../user_guide/off_design_missions).\n",
"\n",
"The example is available in `aviary/examples/off_design_example.py`\n",
"The examples start with `run_aviary_example.py` and add off-design missions.\n",
"The example is available in `aviary/examples/run_off_design_example.py`\n",
"The examples start with `run_aviary_example.py` and adds off-design missions.\n",
"\n",
"The results of the sizing problem are saved using `prob.save_sizing_to_json()`.\n",
"By default, this method saves the results to `sizing_problem.json` but the name of the file may be changed using the `json_filename` argument.\n",
Expand Down
4 changes: 2 additions & 2 deletions aviary/docs/user_guide/off_design_missions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"metadata": {},
"source": [
"You may also run multiple off-design missions in the same script used to solve the design mission.\n",
"An examples of this is shown in `off_design_example.py`."
"An examples of this is shown in `run_off_design_example.py`."
]
},
{
Expand All @@ -54,7 +54,7 @@
"\n",
"off_design_examples = av.get_path(os.path.join('examples'))\n",
"check_contains(\n",
" ('off_design_example.py'),\n",
" ('run_off_design_example.py'),\n",
" os.listdir(off_design_examples),\n",
" error_string=\"{var} not in \"+str(off_design_examples),\n",
" error_type=FileNotFoundError)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
We then call the correct methods in order to set up and run an Aviary optimization problem.
This performs a coupled design-mission optimization and outputs the results from Aviary into the `reports` folder.
"""
from openmdao.utils.general_utils import env_truthy
import aviary.api as av

from aviary.interface.default_phase_info.height_energy import phase_info_parameterization
Expand Down Expand Up @@ -117,7 +118,10 @@

# Link phases and variables
prob.link_phases()
prob.add_driver('SNOPT', max_iter=100)
if env_truthy("TESTFLO_RUNNING"):
prob.add_driver('SLSQP', max_iter=100)
else:
prob.add_driver('SNOPT', max_iter=100)
prob.add_design_variables()

# Load optimization problem formulation
Expand Down
4 changes: 2 additions & 2 deletions aviary/interface/methods_for_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2509,12 +2509,12 @@ def save_sizing_to_json(self, json_filename='sizing_problem.json'):

# Lists are fine except if they contain enums
if type_value == list:
if type(type(value[0])) == enum.EnumType:
if isinstance(value[0], enum.Enum):
for i in range(len(value)):
value[i] = str([value[i]])

# Enums need converting to a string
if type(type(value)) == enum.EnumType:
if isinstance(value, enum.Enum):
value = str([value])

# Append the data to the list
Expand Down
Loading

0 comments on commit e769e7d

Please sign in to comment.