예제 #1
0
 def test_aero_analysis_flat_side_by_side(self):
     OAS_prob = OASProblem({
         'type': 'aero',
         'optimize': False,
         'record_db': False
     })
     OAS_prob.add_surface({
         'name': 'wing',
         'span': 5.,
         'num_y': 3,
         'span_cos_spacing': 0.,
         'symmetry': False,
         'offset': np.array([0., -2.5, 0.])
     })
     OAS_prob.add_surface({
         'name': 'tail',
         'span': 5.,
         'num_y': 3,
         'span_cos_spacing': 0.,
         'symmetry': False,
         'offset': np.array([0., 2.5, 0.])
     })
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'],
                            0.46173591841167183,
                            places=5)
     self.assertAlmostEqual(prob['tail_perf.CL'],
                            0.46173591841167183,
                            places=5)
     self.assertAlmostEqual(prob['wing_perf.CD'], .005524603647, places=5)
     self.assertAlmostEqual(prob['tail_perf.CD'], .005524603647, places=5)
예제 #2
0
 def test_aero_analysis_flat_multiple(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False})
     OAS_prob.add_surface({'span_cos_spacing' : 0.})
     OAS_prob.add_surface({'name' : 'tail',
                           'span_cos_spacing' : 0.,
                           'offset' : np.array([0., 0., 1000000.])})
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], .46173591841167, places=5)
     self.assertAlmostEqual(prob['tail_perf.CL'], .46173591841167, places=5)
예제 #3
0
    def test_aerostruct_analysis_symmetry(self):
        OAS_prob = OASProblem({
            'type': 'aerostruct',
            'optimize': False,
            'record_db': False
        })
        surf_dict = {
            'symmetry': True,
            'num_y': 13,
            'num_x': 2,
            'wing_type': 'CRM',
            'CD0': 0.015
        }
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'],
                               0.49879098021094814,
                               places=5)
        self.assertAlmostEqual(prob['wing_perf.failure'],
                               -0.4358500552830447,
                               places=5)
        self.assertAlmostEqual(prob['fuelburn'], 70951.02191803591, places=1)
        self.assertAlmostEqual(prob['CM'][1], -0.13082531653444995, places=2)
예제 #4
0
    def test_aerostruct_analysis_symmetry(self):
        OAS_prob = OASProblem({
            'type': 'aerostruct',
            'optimize': False,
            'record_db': False
        })
        surf_dict = {
            'symmetry': True,
            'num_y': 13,
            'num_x': 2,
            'wing_type': 'CRM',
            'CD0': 0.015
        }
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'],
                               0.69060502679333224,
                               places=5)
        self.assertAlmostEqual(prob['wing_perf.failure'],
                               0.064759950520982532,
                               places=5)
        self.assertAlmostEqual(prob['fuelburn'], 57109.065516474155, places=1)
        self.assertAlmostEqual(prob['CM'][1], -0.19380236992046351, places=2)
예제 #5
0
    def test_aerostruct_analysis(self):
        OAS_prob = OASProblem({
            'type': 'aerostruct',
            'optimize': False,
            'record_db': False
        })
        surf_dict = {
            'num_y': 13,
            'num_x': 2,
            'wing_type': 'CRM',
            'CD0': 0.015,
            'symmetry': False
        }
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'],
                               0.6587983088529461,
                               places=5)
        self.assertAlmostEqual(prob['wing_perf.failure'],
                               0.13716279310143381,
                               places=5)
        self.assertAlmostEqual(prob['fuelburn'], 55565.087226705218, places=2)
        self.assertAlmostEqual(prob['CM'][1], -0.18836163204083048, places=2)
예제 #6
0
    def test_aerostruct_analysis(self):
        OAS_prob = OASProblem({
            'type': 'aerostruct',
            'optimize': False,
            'record_db': False
        })
        surf_dict = {
            'num_y': 13,
            'num_x': 2,
            'wing_type': 'CRM',
            'CD0': 0.015,
            'symmetry': False
        }
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'],
                               0.45756166834224915,
                               places=5)
        self.assertAlmostEqual(prob['wing_perf.failure'],
                               -0.41828919706776535,
                               places=5)
        self.assertAlmostEqual(prob['fuelburn'], 66894.86498288115, places=2)
        self.assertAlmostEqual(prob['CM'][1], -0.12243137977093457, places=2)
예제 #7
0
 def test_aero_analysis_flat_multiple(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False})
     OAS_prob.add_surface({'span_cos_spacing' : 0.})
     OAS_prob.add_surface({'name' : 'tail',
                           'span_cos_spacing' : 0.,
                           'offset' : np.array([0., 0., 1000000.])})
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], .46173591841167, places=5)
     self.assertAlmostEqual(prob['tail_perf.CL'], .46173591841167, places=5)
예제 #8
0
    def test_aero_analysis_flat(self):
        OAS_prob = OASProblem({'type' : 'aero',
                               'optimize' : False,
                               'record_db' : False})
        OAS_prob.add_surface({'span_cos_spacing' : 0})
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'], .46173591841167, places=5)
        self.assertAlmostEqual(prob['wing_perf.CD'], .005524603647, places=5)
예제 #9
0
 def test_aero_analysis_flat_full(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False})
     surf_dict = {'symmetry' : False}
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], .45655138, places=5)
     self.assertAlmostEqual(prob['wing_perf.CD'], 0.0055402121081108589, places=5)
예제 #10
0
 def test_struct_analysis_symmetry(self):
     OAS_prob = OASProblem({'type' : 'struct',
                            'optimize' : False,
                            'record_db' : False})
     surf_dict = {'symmetry' : True,
                 't_over_c' : 0.15}
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing.structural_weight'], 988.13495481063956, places=3)
예제 #11
0
 def test_aero_analysis_flat_viscous_full(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False,
                            'with_viscous' : True})
     surf_dict = {'symmetry' : False}
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], .45655138, places=5)
     self.assertAlmostEqual(prob['wing_perf.CD'], 0.018942466133780547, places=5)
예제 #12
0
 def test_aero_analysis_flat_full(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False})
     surf_dict = {'symmetry' : False}
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], .45655138, places=5)
     self.assertAlmostEqual(prob['wing_perf.CD'], 0.0055402121081108589, places=5)
예제 #13
0
 def test_struct_analysis_symmetry(self):
     OAS_prob = OASProblem({'type' : 'struct',
                            'optimize' : False,
                            'record_db' : False})
     surf_dict = {'symmetry' : True,
                 't_over_c' : 0.15}
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing.structural_weight'], 988.13495481063956, places=3)
예제 #14
0
    def test_aero_analysis_flat(self):
        OAS_prob = OASProblem({'type' : 'aero',
                               'optimize' : False,
                               'record_db' : False})
        OAS_prob.add_surface({'span_cos_spacing' : 0})
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'], .46173591841167, places=5)
        self.assertAlmostEqual(prob['wing_perf.CD'], .005524603647, places=5)
예제 #15
0
 def test_aero_analysis_flat_viscous_full(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False,
                            'with_viscous' : True})
     surf_dict = {'symmetry' : False}
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], .45655138, places=5)
     self.assertAlmostEqual(prob['wing_perf.CD'], 0.018942466133780547, places=5)
예제 #16
0
    def test_aerostruct_analysis_symmetry_deriv(self):
        OAS_prob = OASProblem({
            'type': 'aerostruct',
            'optimize': False,
            'record_db': True
        })
        surf_dict = {
            'symmetry': True,
            'num_y': 7,
            'num_x': 2,
            'wing_type': 'CRM',
            'CD0': 0.015
        }
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        data = prob.check_partial_derivatives(out_stream=None)

        new_dict = {}
        for key1 in data.keys():
            for key2 in data[key1].keys():
                for key3 in data[key1][key2].keys():
                    if 'rel' in key3:
                        error = np.linalg.norm(data[key1][key2][key3])
                        new_key = key1 + '_' + key2[0] + '_' + key2[
                            1] + '_' + key3
                        new_dict.update({new_key: error})

        for key in new_dict.keys():
            error = new_dict[key]
            if not np.isnan(error):

                # The FD check is not valid for these cases
                if 'assembly_forces_Iy' in key or 'assembly_forces_J' in key or \
                'assembly_forces_A' in key or 'assembly_K_loads' in key or \
                'assembly_forces_loads' in key or 'assembly_forces_Iz' in key or \
                'assembly_forces_nodes' in key or 'CM_wing_S_ref' in key or \
                'CM_rho' in key:
                    pass
                elif 'K' in key or 'vonmises' in key:
                    self.assertAlmostEqual(0., error, places=0)
                else:
                    self.assertAlmostEqual(0., error, places=2)
예제 #17
0
 def test_aero_analysis_flat_side_by_side(self):
     OAS_prob = OASProblem({'type' : 'aero',
                            'optimize' : False,
                            'record_db' : False})
     OAS_prob.add_surface({'name' : 'wing',
                           'span' : 5.,
                           'num_y' : 3,
                           'span_cos_spacing' : 0.,
                           'symmetry' : False,
                           'offset' : np.array([0., -2.5, 0.])})
     OAS_prob.add_surface({'name' : 'tail',
                           'span' : 5.,
                           'num_y' : 3,
                           'span_cos_spacing' : 0.,
                           'symmetry' : False,
                           'offset' : np.array([0., 2.5, 0.])})
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], 0.46173591841167183, places=5)
     self.assertAlmostEqual(prob['tail_perf.CL'], 0.46173591841167183, places=5)
     self.assertAlmostEqual(prob['wing_perf.CD'], .005524603647, places=5)
     self.assertAlmostEqual(prob['tail_perf.CD'], .005524603647, places=5)
예제 #18
0
    def test_aerostruct_analysis(self):
        OAS_prob = OASProblem({'type' : 'aerostruct',
                               'optimize' : False,
                               'record_db' : False})
        surf_dict = {'num_y' : 13,
                  'num_x' : 2,
                  'wing_type' : 'CRM',
                  'CD0' : 0.015,
                  'symmetry' : False}
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'], 0.6587983088529461, places=5)
        self.assertAlmostEqual(prob['wing_perf.failure'], 0.13716279310143381, places=5)
        self.assertAlmostEqual(prob['fuelburn'], 55565.087226705218, places=2)
        self.assertAlmostEqual(prob['CM'][1], -0.18836163204083048, places=2)
예제 #19
0
    def test_aerostruct_analysis_symmetry(self):
        OAS_prob = OASProblem({'type' : 'aerostruct',
                               'optimize' : False,
                               'record_db' : False})
        surf_dict = {'symmetry' : True,
                  'num_y' : 13,
                  'num_x' : 2,
                  'wing_type' : 'CRM',
                  'CD0' : 0.015}
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        self.assertAlmostEqual(prob['wing_perf.CL'], 0.69060502679333224, places=5)
        self.assertAlmostEqual(prob['wing_perf.failure'], 0.064759950520982532, places=5)
        self.assertAlmostEqual(prob['fuelburn'], 57109.065516474155, places=1)
        self.assertAlmostEqual(prob['CM'][1], -0.19380236992046351, places=2)
예제 #20
0
 def test_aerostruct_analysis(self):
     OAS_prob = OASProblem({
         'type': 'aerostruct',
         'optimize': False,
         'record_db': False
     })
     surf_dict = {
         'num_y': 13,
         'num_x': 2,
         'wing_type': 'CRM',
         'CD0': 0.015,
         'symmetry': False
     }
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], 0.53470610411546438)
     self.assertAlmostEqual(prob['wing_perf.failure'],
                            -0.88555523062055341,
                            places=5)
     self.assertAlmostEqual(prob['fuelburn'], 99367.43763782426, places=2)
예제 #21
0
 def test_aerostruct_analysis_symmetry(self):
     OAS_prob = OASProblem({
         'type': 'aerostruct',
         'optimize': False,
         'record_db': False
     })
     surf_dict = {
         'symmetry': True,
         'num_y': 13,
         'num_x': 2,
         'wing_type': 'CRM',
         'CD0': 0.015
     }
     OAS_prob.add_surface(surf_dict)
     OAS_prob.setup()
     OAS_prob.run()
     prob = OAS_prob.prob
     self.assertAlmostEqual(prob['wing_perf.CL'], 0.57096081806728627)
     self.assertAlmostEqual(prob['wing_perf.failure'],
                            -0.8969902215221538,
                            places=5)
     self.assertAlmostEqual(prob['fuelburn'], 105120.8601409321, places=2)
예제 #22
0
    def test_aerostruct_analysis_symmetry_deriv(self):
        OAS_prob = OASProblem({'type' : 'aerostruct',
                               'optimize' : False,
                               'record_db' : True})
        surf_dict = {'symmetry' : True,
                  'num_y' : 7,
                  'num_x' : 2,
                  'wing_type' : 'CRM',
                  'CD0' : 0.015}
        OAS_prob.add_surface(surf_dict)
        OAS_prob.setup()
        OAS_prob.run()
        prob = OAS_prob.prob

        data = prob.check_partial_derivatives(out_stream=None)

        new_dict = {}
        for key1 in data.keys():
            for key2 in data[key1].keys():
                for key3 in data[key1][key2].keys():
                    if 'rel' in key3:
                        error = np.linalg.norm(data[key1][key2][key3])
                        new_key = key1+'_'+key2[0]+'_'+key2[1]+'_'+key3
                        new_dict.update({new_key : error})

        for key in new_dict.keys():
            error = new_dict[key]
            if not np.isnan(error):

                # The FD check is not valid for these cases
                if 'assembly_forces_Iy' in key or 'assembly_forces_J' in key or \
                'assembly_forces_A' in key or 'assembly_K_loads' in key or \
                'assembly_forces_loads' in key or 'assembly_forces_Iz' in key or \
                'assembly_forces_nodes' in key or 'CM_wing_S_ref' in key or \
                'CM_rho' in key:
                    pass
                elif 'K' in key or 'vonmises' in key:
                    self.assertAlmostEqual(0., error, places=0)
                else:
                    self.assertAlmostEqual(0., error, places=2)
예제 #23
0
        raise


    # Set problem type
    prob_dict = {'type' : 'aerostruct',
                 'with_viscous' : True,
                 'cg' : np.array([30., 0., 5.])
                 }

    if sys.argv[1].startswith('0'):  # run analysis once
        prob_dict.update({'optimize' : False})
    else:  # perform optimization
        prob_dict.update({'optimize' : True})

    # Instantiate problem and add default surface
    OAS_prob = OASProblem(prob_dict)

    # Create a dictionary to store options about the surface
    surf_dict = {'num_y' : 7,
                 'num_x' : 2,
                 'wing_type' : 'CRM',
                 'CD0' : 0.015,
                 'symmetry' : True,
                 'num_twist_cp' : 2,
                 'num_thickness_cp' : 2}

    # Add the specified wing surface to the problem
    OAS_prob.add_surface(surf_dict)

    # Add design variables, constraint, and objective on the problem
    OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
예제 #24
0
        def test_aero_optimization_fd(self):
            # Need to use SLSQP here because SNOPT finds a different optimum
            OAS_prob = OASProblem({
                'type': 'aero',
                'optimize': True,
                'record_db': False,
                'optimizer': 'SLSQP',
                'force_fd': True
            })
            OAS_prob.add_surface()

            OAS_prob.add_desvar('wing.twist_cp', lower=-10., upper=15.)
            OAS_prob.add_desvar('wing.sweep', lower=10., upper=30.)
            OAS_prob.add_desvar('wing.dihedral', lower=-10., upper=20.)
            OAS_prob.add_desvar('wing.taper', lower=.5, upper=2.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.5)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'],
                                   0.0038513637269919619,
                                   places=5)
예제 #25
0
        raise

    # Set problem type
    prob_dict = {
        'type': 'aerostruct',
        'with_viscous': True,
        'cg': np.array([30., 0., 5.])
    }

    if sys.argv[1].startswith('0'):  # run analysis once
        prob_dict.update({'optimize': False})
    else:  # perform optimization
        prob_dict.update({'optimize': True})

    # Instantiate problem and add default surface
    OAS_prob = OASProblem(prob_dict)

    # Create a dictionary to store options about the surface
    surf_dict = {
        'num_y': 5,
        'num_x': 2,
        'wing_type': 'CRM',
        'CD0': 0.015,
        'symmetry': True,
        'num_twist_cp': 3,
        'num_thickness_cp': 3
    }

    # Add the specified wing surface to the problem
    OAS_prob.add_surface(surf_dict)
예제 #26
0
        def test_aerostruct_optimization_symmetry_multiple(self):
            OAS_prob = OASProblem({
                'type': 'aerostruct',
                'optimize': True,
                'with_viscous': True,
                'record_db': False
            })
            surf_dict = {
                'name': 'wing',
                'symmetry': True,
                'num_y': 5,
                'num_x': 2,
                'wing_type': 'CRM',
                'CD0': 0.015,
                'num_twist_cp': 2,
                'num_thickness_cp': 2
            }
            OAS_prob.add_surface(surf_dict)
            surf_dict.update({
                'name': 'tail',
                'offset': np.array([10., 0., 10.])
            })
            OAS_prob.add_surface(surf_dict)

            # Add design variables and constraints for both the wing and tail
            OAS_prob.add_desvar('wing.twist_cp', lower=-15., upper=15.)
            OAS_prob.add_desvar('wing.thickness_cp',
                                lower=0.01,
                                upper=0.5,
                                scaler=1e2)
            OAS_prob.add_constraint('wing_perf.failure', upper=0.)
            OAS_prob.add_constraint('wing_perf.thickness_intersects', upper=0.)
            OAS_prob.add_desvar('tail.twist_cp', lower=-15., upper=15.)
            OAS_prob.add_desvar('tail.thickness_cp',
                                lower=0.01,
                                upper=0.5,
                                scaler=1e2)
            OAS_prob.add_constraint('tail_perf.failure', upper=0.)
            OAS_prob.add_constraint('tail_perf.thickness_intersects', upper=0.)

            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('L_equals_W', equals=0.)
            OAS_prob.add_objective('fuelburn', scaler=1e-5)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob

            self.assertAlmostEqual(prob['fuelburn'],
                                   171166.87568490615,
                                   places=1)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0, places=5)
예제 #27
0
        def test_struct_optimization_symmetry_exact(self):
            OAS_prob = OASProblem({
                'type': 'struct',
                'optimize': True,
                'record_db': False
            })
            OAS_prob.add_surface({
                'exact_failure_constraint': True,
                't_over_c': 0.15
            })

            OAS_prob.add_desvar('wing.thickness_cp',
                                lower=0.001,
                                upper=0.25,
                                scaler=1e2)
            OAS_prob.add_constraint('wing.failure', upper=0.)
            OAS_prob.add_constraint('wing.thickness_intersects', upper=0.)
            OAS_prob.add_objective('wing.structural_weight', scaler=1e-3)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing.structural_weight'],
                                   1132.0650209475402,
                                   places=2)
예제 #28
0
        def test_aero_optimization_fd(self):
            # Need to use SLSQP here because SNOPT finds a different optimum
            OAS_prob = OASProblem({'type' : 'aero',
                                   'optimize' : True,
                                   'record_db' : False,
                                   'optimizer' : 'SLSQP',
                                   'force_fd' : True})
            OAS_prob.add_surface()

            OAS_prob.add_desvar('wing.twist_cp', lower=-10., upper=15.)
            OAS_prob.add_desvar('wing.sweep', lower=10., upper=30.)
            OAS_prob.add_desvar('wing.dihedral', lower=-10., upper=20.)
            OAS_prob.add_desvar('wing.taper', lower=.5, upper=2.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.5)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'], 0.0038513637269919619, places=5)
예제 #29
0
        def test_aero_viscous_optimization(self):
            OAS_prob = OASProblem({'type' : 'aero',
                                   'optimize' : True,
                                   'record_db' : False,
                                   'with_viscous' : True})
            OAS_prob.add_surface()

            OAS_prob.add_desvar('wing.twist_cp', lower=-10., upper=15.)
            OAS_prob.add_desvar('wing.sweep', lower=10., upper=30.)
            OAS_prob.add_desvar('wing.dihedral', lower=-10., upper=20.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.5)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'], 0.019234984422361764, places=5)
예제 #30
0
        def test_aero_viscous_chord_optimization(self):
            # Need to use SLSQP here because SNOPT finds a different optimum
            OAS_prob = OASProblem({
                'type': 'aero',
                'optimize': True,
                'record_db': False,
                'optimizer': 'SLSQP',
                'with_viscous': True
            })
            OAS_prob.add_surface()

            OAS_prob.add_desvar('wing.chord_cp', lower=0.1, upper=3.)
            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.5)
            OAS_prob.add_constraint('wing.S_ref', equals=20)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'],
                                   0.023570021288019886,
                                   places=5)
예제 #31
0
        def test_aero_multiple_opt(self):
            OAS_prob = OASProblem({'type' : 'aero',
                                   'optimize' : True,
                                   'record_db' : False})
            surf_dict = { 'name' : 'wing',
                          'span' : 5.,
                          'num_y' : 3,
                          'span_cos_spacing' : 0.}
            OAS_prob.add_surface(surf_dict)
            surf_dict.update({'name' : 'tail',
                           'offset' : np.array([0., 0., 10.])})
            OAS_prob.add_surface(surf_dict)

            OAS_prob.add_desvar('tail.twist_cp', lower=-10., upper=15.)
            OAS_prob.add_desvar('tail.sweep', lower=10., upper=30.)
            OAS_prob.add_desvar('tail.dihedral', lower=-10., upper=20.)
            OAS_prob.add_desvar('tail.taper', lower=.5, upper=2.)
            OAS_prob.add_constraint('tail_perf.CL', equals=0.5)
            OAS_prob.add_objective('tail_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CL'], 0.41532382375677429, places=4)
            self.assertAlmostEqual(prob['tail_perf.CL'], .5, places=5)
            self.assertAlmostEqual(prob['wing_perf.CD'], .0075400306289957033, places=5)
            self.assertAlmostEqual(prob['tail_perf.CD'], 0.008087914662238814, places=5)
예제 #32
0
        def test_aero_viscous_chord_optimization(self):
            # Need to use SLSQP here because SNOPT finds a different optimum
            OAS_prob = OASProblem({'type' : 'aero',
                                   'optimize' : True,
                                   'record_db' : False,
                                   'optimizer' : 'SLSQP',
                                   'with_viscous' : True})
            OAS_prob.add_surface()

            OAS_prob.add_desvar('wing.chord_cp', lower=0.1, upper=3.)
            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.5)
            OAS_prob.add_constraint('wing.S_ref', equals=20)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'], 0.023570021288019886, places=5)
예제 #33
0
        def test_aerostruct_optimization_symmetry_multiple(self):
            OAS_prob = OASProblem({'type' : 'aerostruct',
                                   'optimize' : True,
                                   'with_viscous' : True,
                                   'record_db' : False})
            surf_dict = {'name' : 'wing',
                         'symmetry' : True,
                         'num_y' : 5,
                         'num_x' : 2,
                         'wing_type' : 'CRM',
                         'CD0' : 0.015,
                         'num_twist_cp' : 2,
                         'num_thickness_cp' : 2}
            OAS_prob.add_surface(surf_dict)
            surf_dict.update({'name' : 'tail',
                              'offset':np.array([10., 0., 10.])})
            OAS_prob.add_surface(surf_dict)

            # Add design variables and constraints for both the wing and tail
            OAS_prob.add_desvar('wing.twist_cp', lower=-15., upper=15.)
            OAS_prob.add_desvar('wing.thickness_cp', lower=0.01, upper=0.5, scaler=1e2)
            OAS_prob.add_constraint('wing_perf.failure', upper=0.)
            OAS_prob.add_constraint('wing_perf.thickness_intersects', upper=0.)
            OAS_prob.add_desvar('tail.twist_cp', lower=-15., upper=15.)
            OAS_prob.add_desvar('tail.thickness_cp', lower=0.01, upper=0.5, scaler=1e2)
            OAS_prob.add_constraint('tail_perf.failure', upper=0.)
            OAS_prob.add_constraint('tail_perf.thickness_intersects', upper=0.)

            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('L_equals_W', equals=0.)
            OAS_prob.add_objective('fuelburn', scaler=1e-5)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob

            self.assertAlmostEqual(prob['fuelburn'], 171166.87568490615, places=1)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0, places=5)
예제 #34
0
        def test_aerostruct_optimization_symmetry(self):
            OAS_prob = OASProblem({'type' : 'aerostruct',
                                   'optimize' : True,
                                   'with_viscous' : True,
                                   'record_db' : False})
            surf_dict = {'symmetry' : True,
                      'num_y' : 7,
                      'num_x' : 3,
                      'wing_type' : 'CRM',
                      'CD0' : 0.015,
                      'num_twist_cp' : 2,
                      'num_thickness_cp' : 2}
            OAS_prob.add_surface(surf_dict)

            OAS_prob.add_desvar('wing.twist_cp', lower=-15., upper=15.)
            OAS_prob.add_desvar('wing.thickness_cp', lower=0.01, upper=0.5, scaler=1e2)
            OAS_prob.add_constraint('wing_perf.failure', upper=0.)
            OAS_prob.add_constraint('wing_perf.thickness_intersects', upper=0.)
            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('L_equals_W', equals=0.)
            OAS_prob.add_objective('fuelburn', scaler=1e-4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob

            self.assertAlmostEqual(prob['fuelburn'], 96077.224922178371, places=0)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0, places=5)
예제 #35
0
def OAS_setup(user_prob_dict={}, user_surf_list=[]):

    # default prob_dict and surf_dict's from run_aerostruct.py
    default_prob_dict = _get_default_prob_dict()
    default_prob_dict.update(user_prob_dict)
    prob_dict = default_prob_dict

    # remove 'des_vars', 'contraints', and 'objectives' entries from prob_dict
    # so it doesn't potentially conflict with OASProblem object
    des_vars = prob_dict.pop('des_vars', [])
    constraints = prob_dict.pop('constraints', [])
    objectives = prob_dict.pop('objectives', [])

    if user_surf_list:
        # replace default_surf_list if user supplied one
        surf_list = user_surf_list
    else:
        surf_list = _get_default_surf_list()

    # when wrapping from Matlab, an array of a single value will always be
    # converted to a float in Python and not an iterable, which causes problems.
    iterable_vars = [
        'chord_cp', 'thickness_cp', 'radius_cp', 'twist_cp', 'xshear_cp',
        'yshear_cp', 'zshear_cp'
    ]
    for surf in surf_list:
        for key, val in iteritems(surf):
            if (key in iterable_vars) and (not hasattr(val, '__iter__')):
                surf[key] = np.array([val])  # make an ndarray from list

    # Create OASProblem object
    OASprob = OASProblem(prob_dict)

    # Add surfaces to OASProblem
    for surf in surf_list:
        OASprob.add_surface(surf)

    # Add design variables to OASProblem
    for var_tuple in des_vars:
        OASprob.add_desvar(var_tuple[0], **var_tuple[1])

    # Add constraints to OASProblem
    for var_tuple in constraints:
        OASprob.add_constraint(var_tuple[0], **var_tuple[1])

    # Add objectives to OASProblem
    for var_tuple in objectives:
        OASprob.add_objective(var_tuple[0], **var_tuple[1])

    # setup OpenMDAO components in OASProblem
    OASprob.setup()

    return OASprob
예제 #36
0
        def test_aero_optimization_chord_monotonic_no_sym(self):
            OAS_prob = OASProblem({
                'type': 'aero',
                'optimize': True,
                'record_db': False,
                'symmetry': False,
                'with_viscous': False
            })
            OAS_prob.add_surface({
                'chord_cp': np.random.random(5),
                'num_y': 11,
                'monotonic_con': ['chord'],
                'span_cos_spacing': 0.,
            })

            OAS_prob.add_desvar('wing.chord_cp', lower=0.1, upper=5.)
            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.1)
            OAS_prob.add_constraint('wing.S_ref', equals=20)
            OAS_prob.add_constraint('wing.monotonic_chord', upper=0.)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'],
                                   0.00057432581266351113,
                                   places=5)
            self.assertAlmostEqual(prob['wing.monotonic_chord'][0],
                                   -1.710374671671999,
                                   places=2)
예제 #37
0
from os import sys, path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

from OpenAeroStruct import OASProblem
from time import time
import numpy as np

# Set problem type
prob_dict = {
    'type': 'aerostruct',
    'optimize': False,  # Don't optimize, only perform analysis
    'record_db': True,
}

# Instantiate problem and add default surface
OAS_prob = OASProblem(prob_dict)

# Create a dictionary to store options about the surface.
# Here we have 3 twist control points and 3 thickness control points.
# We also set the discretization, span, and panel spacing.
surf_dict = {
    'name': 'wing',
    'symmetry': True,
    'num_y': 7,
    'num_x': 2,
    'num_twist_cp': 3,
    'num_thickness_cp': 3,
    'num_chord_cp': 2,
    'wing_type': 'CRM',
    'CD0': 0.015,
    'span_cos_spacing': 0.,
예제 #38
0
        def test_aero_viscous_optimization(self):
            OAS_prob = OASProblem({
                'type': 'aero',
                'optimize': True,
                'record_db': False,
                'with_viscous': True
            })
            OAS_prob.add_surface()

            OAS_prob.add_desvar('wing.twist_cp', lower=-10., upper=15.)
            OAS_prob.add_desvar('wing.sweep', lower=10., upper=30.)
            OAS_prob.add_desvar('wing.dihedral', lower=-10., upper=20.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.5)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'],
                                   0.019234984422361764,
                                   places=5)
예제 #39
0
        raise

    # Set problem type
    prob_dict = {'type' : 'struct'}

    if sys.argv[1].startswith('0'):  # run analysis once
        prob_dict.update({'optimize' : False})
    else:  # perform optimization
        prob_dict.update({'optimize' : True})

    num_y = 11
    loads = np.zeros(((num_y+1)//2, 6))
    loads[:, 1] = 1e5

    # Instantiate problem and add default surface
    OAS_prob = OASProblem(prob_dict)
    OAS_prob.add_surface({'name' : 'wing',
                          'num_y' : 11,
                          'symmetry' : True,
                          'loads' : loads})

    # Single lifting surface
    if not sys.argv[1].endswith('m'):

        # Setup problem and add design variables, constraint, and objective
        OAS_prob.add_desvar('wing.thickness_cp', lower=0.001, upper=0.25, scaler=1e2)
        OAS_prob.add_constraint('wing.thickness_intersects', upper=0.)
        OAS_prob.add_constraint('wing.failure', upper=0.)
        OAS_prob.add_objective('wing.structural_weight', scaler=1e-3)
        OAS_prob.setup()
예제 #40
0
        def test_aero_multiple_opt(self):
            OAS_prob = OASProblem({
                'type': 'aero',
                'optimize': True,
                'record_db': False
            })
            surf_dict = {
                'name': 'wing',
                'span': 5.,
                'num_y': 3,
                'span_cos_spacing': 0.
            }
            OAS_prob.add_surface(surf_dict)
            surf_dict.update({
                'name': 'tail',
                'offset': np.array([0., 0., 10.])
            })
            OAS_prob.add_surface(surf_dict)

            OAS_prob.add_desvar('tail.twist_cp', lower=-10., upper=15.)
            OAS_prob.add_desvar('tail.sweep', lower=10., upper=30.)
            OAS_prob.add_desvar('tail.dihedral', lower=-10., upper=20.)
            OAS_prob.add_desvar('tail.taper', lower=.5, upper=2.)
            OAS_prob.add_constraint('tail_perf.CL', equals=0.5)
            OAS_prob.add_objective('tail_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CL'],
                                   0.41532382375677429,
                                   places=4)
            self.assertAlmostEqual(prob['tail_perf.CL'], .5, places=5)
            self.assertAlmostEqual(prob['wing_perf.CD'],
                                   .0075400306289957033,
                                   places=5)
            self.assertAlmostEqual(prob['tail_perf.CD'],
                                   0.008087914662238814,
                                   places=5)
        )
        print(
            ' +---------------------------------------------------------------+\n'
        )
        raise

    # Set problem type
    prob_dict = {'type': 'struct'}

    if sys.argv[1].startswith('0'):  # run analysis once
        prob_dict.update({'optimize': False})
    else:  # perform optimization
        prob_dict.update({'optimize': True})

    # Instantiate problem and add default surface
    OAS_prob = OASProblem(prob_dict)
    OAS_prob.add_surface({'name': 'wing', 'num_y': 11, 'symmetry': True})

    # Single lifting surface
    if not sys.argv[1].endswith('m'):

        # Setup problem and add design variables, constraint, and objective
        OAS_prob.add_desvar('wing.thickness_cp',
                            lower=0.001,
                            upper=0.25,
                            scaler=1e2)
        OAS_prob.add_constraint('wing.thickness_intersects', upper=0.)
        OAS_prob.add_constraint('wing.failure', upper=0.)
        OAS_prob.add_objective('wing.structural_weight', scaler=1e-3)
        OAS_prob.setup()
예제 #42
0
        def test_aero_optimization_chord_monotonic_no_sym(self):
            OAS_prob = OASProblem({'type' : 'aero',
                                   'optimize' : True,
                                   'record_db' : False,
                                   'symmetry' : False,
                                   'with_viscous' : False})
            OAS_prob.add_surface({
            'chord_cp' : np.random.random(5),
            'num_y' : 11,
            'monotonic_con' : ['chord'],
            'span_cos_spacing' : 0.,
            })

            OAS_prob.add_desvar('wing.chord_cp', lower=0.1, upper=5.)
            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('wing_perf.CL', equals=0.1)
            OAS_prob.add_constraint('wing.S_ref', equals=20)
            OAS_prob.add_constraint('wing.monotonic_chord', upper=0.)
            OAS_prob.add_objective('wing_perf.CD', scaler=1e4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing_perf.CD'], 0.00057432581266351113, places=5)
            self.assertAlmostEqual(prob['wing.monotonic_chord'][0], -1.710374671671999, places=2)
예제 #43
0
파일: UAV.py 프로젝트: samtx/OpenAeroStruct
    'type': prob_type,
    'compute_static_margin': True,
    'optimizer': 'SNOPT',
    'with_viscous': True,
    'W0': 14.,  # kg, empty weight from manufacturer
    'a': 322.2,  # m/s, at 15,000 ft
    'rho': 0.770816,  # kg/m^3, at 15,000 ft
    'R': 2500e3,  # estimated range based on cruise speed and flight endurance
    'CT': 9.80665 * 8.6e-6,  # piston-prop estimation from Raymer
    'Re': 4e5,
    'M': .093,  # calc'd from 30 m/s cruise speed
    'cg': np.array([.4, 0., 0.]),  # estimated based on aircraft pictures
}

# Instantiate problem and add default surface
OAS_prob = OASProblem(prob_dict)

zshear_cp = np.zeros(10)
zshear_cp[0] = .3

xshear_cp = np.zeros(10)
xshear_cp[0] = .15

chord_cp = np.ones(10)
chord_cp[0] = .5

radius_cp = 0.02 * np.ones(10)
radius_cp[0] = 0.015

if mesh_level == 'L1':
    num_y = 101
예제 #44
0
        )
        print(
            ' +---------------------------------------------------------------+\n'
        )
        raise

    # Set problem type
    prob_dict = {'type': 'aero'}

    if sys.argv[1].startswith('0'):  # run analysis once
        prob_dict.update({'optimize': False})
    else:  # perform optimization
        prob_dict.update({'optimize': True})

    # Instantiate problem and add default surface
    OAS_prob = OASProblem(prob_dict)

    # Create a dictionary to store options about the surface
    surf_dict = {
        'num_y': 7,
        'num_x': 2,
        'wing_type': 'rect',
        'CD0': 0.015,
        'symmetry': True,
        'num_twist_cp': 2,
        'num_thickness_cp': 2
    }

    # Add the specified wing surface to the problem
    OAS_prob.add_surface(surf_dict)
예제 #45
0
        print(' | ERROR: Please supply a correct input argument to this script. |')
        print(' | Possible options are ' + print_str[:-2] + '                             |')
        print(' | See the docstring at the top of this file for more info.      |')
        print(' +---------------------------------------------------------------+\n')
        raise

    # Set problem type
    prob_dict = {'type' : 'aero'}

    if sys.argv[1].startswith('0'):  # run analysis once
        prob_dict.update({'optimize' : False})
    else:  # perform optimization
        prob_dict.update({'optimize' : True})

    # Instantiate problem and add default surface
    OAS_prob = OASProblem(prob_dict)

    # Create a dictionary to store options about the surface
    surf_dict = {'num_y' : 7,
                 'num_x' : 2,
                 'wing_type' : 'rect',
                 'CD0' : 0.015,
                 'symmetry' : True,
                 'num_twist_cp' : 2,
                 'num_thickness_cp' : 2}

    # Add the specified wing surface to the problem
    OAS_prob.add_surface(surf_dict)

    # Single lifting surface
    if not sys.argv[1].endswith('m'):
예제 #46
0
        def test_aerostruct_optimization_symmetry(self):
            OAS_prob = OASProblem({
                'type': 'aerostruct',
                'optimize': True,
                'with_viscous': True,
                'record_db': False
            })
            surf_dict = {
                'symmetry': True,
                'num_y': 7,
                'num_x': 3,
                'wing_type': 'CRM',
                'CD0': 0.015,
                'num_twist_cp': 2,
                'num_thickness_cp': 2
            }
            OAS_prob.add_surface(surf_dict)

            OAS_prob.add_desvar('wing.twist_cp', lower=-15., upper=15.)
            OAS_prob.add_desvar('wing.thickness_cp',
                                lower=0.01,
                                upper=0.5,
                                scaler=1e2)
            OAS_prob.add_constraint('wing_perf.failure', upper=0.)
            OAS_prob.add_constraint('wing_perf.thickness_intersects', upper=0.)
            OAS_prob.add_desvar('alpha', lower=-10., upper=10.)
            OAS_prob.add_constraint('L_equals_W', equals=0.)
            OAS_prob.add_objective('fuelburn', scaler=1e-4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob

            self.assertAlmostEqual(prob['fuelburn'],
                                   96077.224922178371,
                                   places=0)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0, places=5)
예제 #47
0
        def test_struct_optimization_symmetry_exact(self):
            OAS_prob = OASProblem({'type' : 'struct',
                                   'optimize' : True,
                                   'record_db' : False})
            OAS_prob.add_surface({'exact_failure_constraint' : True,
                                't_over_c': 0.15})

            OAS_prob.add_desvar('wing.thickness_cp', lower=0.001, upper=0.25, scaler=1e2)
            OAS_prob.add_constraint('wing.failure', upper=0.)
            OAS_prob.add_constraint('wing.thickness_intersects', upper=0.)
            OAS_prob.add_objective('wing.structural_weight', scaler=1e-3)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['wing.structural_weight'], 1132.0650209475402, places=2)
예제 #48
0
파일: oas_driver.py 프로젝트: zgrey/PSDR
def driver(X):

    assert len(
        X[0]) == (2 * N_CP +
                  6), "Found dimension %d, expected %d" % (len(X[0]),
                                                           (2 * N_CP + 6))

    # Set problem type
    prob_dict = {
        'type': 'aerostruct',
        'optimize': False,  # Don't optimize, only perform analysis
        'record_db': False,
        'W0':
        1000.,  # OEW of the aircraft without fuel and the structural weight, in kg
    }

    # Instantiate problem and add default surface
    with silence_stdout():
        oas_prob = OASProblem(prob_dict)

    # Create a dictionary to store options about the surface.
    # Here we have 3 twist control points and 3 thickness control points.
    # We also set the discretization, span, and panel spacing.
    surf_dict = {
        'name': 'wing',
        'symmetry': True,
        'num_y': 7,
        'num_x': 2,
        'span': 10.,
        'num_twist_cp': N_CP,
        'num_thickness_cp': N_CP,
        'num_chord_cp': 2,
        'wing_type': 'rect',
        'span_cos_spacing': 0.,
    }

    # Add the specified wing surface to the problem
    with silence_stdout():
        oas_prob.add_surface(surf_dict)

    # Set up the problem. Once we have this done, we can modify the internal
    # unknowns and run the multidisciplinary analysis at that design point.
    oas_prob.add_desvar('wing.twist_cp')
    oas_prob.add_desvar('wing.thickness_cp')
    oas_prob.add_desvar('wing.chord_cp')
    oas_prob.setup(out_stream=null_stream)

    Y = np.zeros((X.shape[0], 5))
    for i, x in enumerate(tqdm(X)):
        twist_cp = x[:N_CP]
        thickness_cp = x[N_CP:2 * N_CP]
        root_chord = x[2 * N_CP]
        taper_ratio = x[2 * N_CP + 1]
        alpha = x[2 * N_CP + 2]
        E = x[2 * N_CP + 3]
        G = x[2 * N_CP + 4]
        mrho = x[2 * N_CP + 5]

        oas_prob.surfaces[0]['E'] = E
        oas_prob.surfaces[0]['G'] = G
        oas_prob.surfaces[0]['mrho'] = mrho
        with silence_stdout():
            oas_prob.setup(out_stream=null_stream)

        # set design variables
        oas_prob.prob['alpha'] = alpha
        oas_prob.prob['wing.twist_cp'] = twist_cp
        oas_prob.prob['wing.thickness_cp'] = thickness_cp
        oas_prob.prob['wing.chord_cp'] = np.array([taper_ratio, 1.
                                                   ]) * root_chord

        with silence_stdout():
            oas_prob.run()

        Y[i, 0] = oas_prob.prob['fuelburn']
        Y[i, 1] = oas_prob.prob['wing_perf.structural_weight']
        Y[i, 2] = oas_prob.prob['wing_perf.L']
        Y[i, 3] = oas_prob.prob['total_weight']
        Y[i, 4] = oas_prob.prob['wing_perf.failure']

    return Y
예제 #49
0
def OAS_setup(user_prob_dict={}, user_surf_list=[]):

    # default prob_dict and surf_dict's from run_aerostruct.py
    default_prob_dict = _get_default_prob_dict()
    default_prob_dict.update(user_prob_dict)
    prob_dict = default_prob_dict

    # remove 'des_vars', 'contraints', and 'objectives' entries from prob_dict
    # so it doesn't potentially conflict with OASProblem object
    des_vars = prob_dict.pop('des_vars', [])
    constraints = prob_dict.pop('constraints', [])
    objectives = prob_dict.pop('objectives', [])

    if user_surf_list:
        # replace default_surf_list if user supplied one
        surf_list = user_surf_list
    else:
        surf_list = _get_default_surf_list()


    # when wrapping from Matlab, an array of a single value will always be
    # converted to a float in Python and not an iterable, which causes problems.
    iterable_vars = ['chord_cp','thickness_cp','radius_cp','twist_cp',
                    'xshear_cp','yshear_cp','zshear_cp']
    for surf in surf_list:
    	for key, val in iteritems(surf):
            if (key in iterable_vars) and (not hasattr(val,'__iter__')):
		        surf[key] = np.array([val])  # make an ndarray from list

    # Create OASProblem object
    OASprob = OASProblem(prob_dict)

    # Add surfaces to OASProblem
    for surf in surf_list:
        OASprob.add_surface(surf)

    # Add design variables to OASProblem
    for var_tuple in des_vars:
        OASprob.add_desvar(var_tuple[0], **var_tuple[1])

    # Add constraints to OASProblem
    for var_tuple in constraints:
        OASprob.add_constraint(var_tuple[0], **var_tuple[1])

    # Add objectives to OASProblem
    for var_tuple in objectives:
        OASprob.add_objective(var_tuple[0], **var_tuple[1])

    # setup OpenMDAO components in OASProblem
    OASprob.setup()

    return OASprob