Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion aviary/interface/methods_for_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,14 @@ def run_off_design_mission(
)

if name is None:
name = name = self._name + '_off_design'
# Numbering problem names.
suggestion = self._name + '_' + str(problem_type.value)
suggestion_update = suggestion
counter = 2
while os.path.exists(suggestion_update + '_out'):
suggestion_update = suggestion + '_' + str(counter)
counter += 1
name = suggestion_update
off_design_prob = AviaryProblem(name=name)

# Set up problem for mission, such as equations of motion, configurators, etc.
Expand Down
23 changes: 23 additions & 0 deletions aviary/interface/test/test_reports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import csv
import os
import unittest
from copy import deepcopy
from pathlib import Path
Expand Down Expand Up @@ -135,6 +136,28 @@ def build_pre_mission(self, aviary_inputs):
# no need to run this model, just generate the report.
prob.final_setup()

def test_report_directory_naming(self):
problem_name = 'test_problem'
phase_info['post_mission']['target_range'] = (2500.0, 'nmi')
prob = AviaryProblem(name=problem_name)
prob.load_inputs(
'models/aircraft/advanced_single_aisle/advanced_single_aisle_FLOPS.csv', phase_info
)
prob.check_and_preprocess_inputs()
prob.build_model()
prob.add_driver('SLSQP', max_iter=50)
prob.add_design_variables()
prob.add_objective()
prob.setup()
prob.run_aviary_problem()
self.assertTrue(os.path.exists(f'{problem_name}_out'))
_ = prob.run_off_design_mission(problem_type='fallout', mission_gross_mass=115000)
self.assertTrue(os.path.exists(f'{problem_name}_fallout_out'))
_ = prob.run_off_design_mission(problem_type='fallout', mission_gross_mass=115000)
self.assertTrue(os.path.exists(f'{problem_name}_fallout_2_out'))
_ = prob.run_off_design_mission(problem_type='fallout', mission_gross_mass=115000)
self.assertTrue(os.path.exists(f'{problem_name}_fallout_3_out'))


if __name__ == '__main__':
unittest.main()
Loading