Beispiel #1
0
        def test_aerostruct_optimization(self):
            OAS_prob = OASProblem({
                'type': 'aerostruct',
                'optimize': True,
                'with_viscous': True,
                'record_db': False
            })
            surf_dict = {
                'num_y': 7,
                'num_x': 2,
                'wing_type': 'CRM',
                'CD0': 0.015,
                'symmetry': False,
                '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-5)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob

            self.assertAlmostEqual(prob['fuelburn'],
                                   96889.255792361335,
                                   places=0)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0., places=4)
            self.assertAlmostEqual(prob['CM'][1],
                                   -0.14194155955058388,
                                   places=2)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
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'], 171158.11644279823, places=1)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0, places=5)
Beispiel #9
0
    def test_struct_optimization_symmetry(self):
        OAS_prob = OASProblem({
            'type': 'struct',
            'optimize': True,
            'record_db': False
        })
        OAS_prob.add_surface({'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'],
                               1144.8503583047038,
                               places=2)
Beispiel #10
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)
Beispiel #11
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('eq_con', equals=0.)
            OAS_prob.add_objective('fuelburn', scaler=1e-4)

            OAS_prob.setup()

            OAS_prob.run()
            prob = OAS_prob.prob
            self.assertAlmostEqual(prob['fuelburn'],
                                   91972.867902621932,
                                   places=0)
            self.assertAlmostEqual(prob['wing_perf.failure'], 0, places=5)
Beispiel #12
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)
Beispiel #13
0
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
Beispiel #14
0
    '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