Пример #1
0
def main():
    
    #initialize the problem
    nexus                        = Nexus()
    vehicle = vehicle_setup()
    nexus.vehicle_configurations = configs_setup(vehicle)
    nexus.analyses               = Analyses.setup(nexus.vehicle_configurations)
    nexus.missions               = Missions.setup(nexus.analyses)
    
    #problem = Data()
    #nexus.optimization_problem       = problem
    nexus.procedure                  = setup()
    nexus.sizing_loop                = Sizing_Loop()
    nexus.total_number_of_iterations = 0
    
    evaluate_problem(nexus)
    results = nexus.results

    err      = nexus.sizing_loop.norm_error
    err_true = 0.00975078 #for 1E-2 tol
    error    = abs((err-err_true)/err)
    print 'error = ', error
    assert(error<1e-5), 'sizing loop regression failed'    
    
    #output=nexus._really_evaluate() #run; use optimization setup without inputs
    return
Пример #2
0
def main():

    #initialize the problem
    nexus = Nexus()
    vehicle = vehicle_setup()
    nexus.vehicle_configurations = configs_setup(vehicle)
    nexus.analyses = Analyses.setup(nexus.vehicle_configurations)
    nexus.missions = Missions.setup(nexus.analyses)

    problem = Data()
    problem_inputs = np.array([
        ['dummy', 1., (.1, 10.), 1., ' continuous', Units.less],
        ['dummy2', 2., (.1, 10.), 1., ' continuous', Units.less],
    ])  #create dummy inputs for optimization to test io
    problem.inputs = problem_inputs
    nexus.optimization_problem = problem
    nexus.procedure = setup()
    sizing_loop = Sizing_Loop()
    sizing_loop.output_filename = 'sizing_outputs.txt'
    nexus.sizing_loop = sizing_loop

    #create a fake array of data to test outputs
    write_sizing_outputs(sizing_loop, np.array([6.]), [5., 5.])
    write_sizing_outputs(sizing_loop, np.array([12.]), [4., 1.])
    write_sizing_outputs(sizing_loop, np.array([11.]), [1., 3.])

    nexus.total_number_of_iterations = 0
    evaluate_problem(nexus)
    results = nexus.results
    err = nexus.sizing_loop.norm_error

    err_true = 0.0008433474527249522  #for 1E-2 tol
    error = abs((err - err_true) / err_true)

    data_inputs, data_outputs, read_success = read_sizing_residuals(
        sizing_loop, problem.inputs)
    check_read_res = -0.06803060191281879

    error_res = (data_outputs[1][0] - check_read_res) / check_read_res

    #remove files for later
    os.remove('sizing_outputs.txt')
    os.remove('y_err_values.txt')
    print('error = ', error)
    print('error_res = ', error_res)
    assert (error < 1e-4), 'sizing loop regression failed'
    assert (error_res < 1e-4), 'sizing loop io failed'

    return
Пример #3
0
def main():

    #initialize the problem
    nexus = Nexus()
    vehicle = vehicle_setup()
    nexus.vehicle_configurations = configs_setup(vehicle)
    nexus.analyses = Analyses.setup(nexus.vehicle_configurations)
    nexus.missions = Missions.setup(nexus.analyses)

    nexus.procedure = setup()
    nexus.sizing_loop = Sizing_Loop()
    nexus.total_number_of_iterations = 0

    evaluate_problem(nexus)
    results = nexus.results

    err = nexus.sizing_loop.norm_error
    err_true = 0.0096907307307155348  #for 1E-2 tol
    error = abs((err_true - err) / err_true)
    print 'error = ', error
    assert (error < 1e-6), 'sizing loop regression failed'

    return
Пример #4
0
def main():
    
    #initialize the problem
    nexus                        = Nexus()
    vehicle = vehicle_setup()
    nexus.vehicle_configurations = configs_setup(vehicle)
    nexus.analyses               = Analyses.setup(nexus.vehicle_configurations)
    nexus.missions               = Missions.setup(nexus.analyses)
    
    nexus.procedure                  = setup()
    nexus.sizing_loop                = Sizing_Loop()
    nexus.total_number_of_iterations = 0
    
    evaluate_problem(nexus)
    results = nexus.results

    err      = nexus.sizing_loop.norm_error
    err_true = 0.0096907307307155348#for 1E-2 tol
    error    = abs((err_true-err)/err_true)
    print 'error = ', error
    assert(error<1e-6), 'sizing loop regression failed'    
    
    return
Пример #5
0
def setup():

    nexus = Nexus()
    problem = Data()
    nexus.optimization_problem = problem

    # -------------------------------------------------------------------
    # Inputs
    # -------------------------------------------------------------------

    # [ tag , initial, [lb,ub], scaling, units ]
    problem.inputs = np.array(
        [['aspect_ratio', 10.0, (5.0, 20.0), 10.0, Units.less]])

    # -------------------------------------------------------------------
    # Objective
    # -------------------------------------------------------------------

    # [ tag, scaling, units ]
    problem.objective = np.array([
        ['Nothing', 1., Units.kg],
    ])

    # -------------------------------------------------------------------
    # Constraints
    # -------------------------------------------------------------------

    # [ tag, sense, edge, scaling, units ]
    problem.constraints = np.array([
        ['CL', '>', 0.0, 1.0, Units.less],
        ['Throttle_min', '>', 0.0, 1.0, Units.less],
        ['Throttle_max', '>', 0.0, 1.0, Units.less],
    ])

    # -------------------------------------------------------------------
    #  Aliases
    # -------------------------------------------------------------------

    # [ 'alias' , ['data.path1.name','data.path2.name'] ]
    problem.aliases = [
        [
            'wing_area',
            [
                'vehicle_configurations.*.wings.main_wing.areas.reference',
                'vehicle_configurations.base.reference_area'
            ]
        ],
        [
            'aspect_ratio',
            'vehicle_configurations.*.wings.main_wing.aspect_ratio'
        ],
        [
            'kv',
            'vehicle_configurations.*.propulsors.network.motor.speed_constant'
        ],
        [
            'battery_mass',
            'vehicle_configurations.base.propulsors.network.battery.mass_properties.mass'
        ],
        [
            'dynamic_pressure',
            'missions.mission.segments.cruise.dynamic_pressure'
        ],
        ['Nothing', 'summary.nothing'],
        ['energy_constraint', 'summary.energy_constraint'],
        ['CL', 'summary.CL'],
        ['Throttle_min', 'summary.throttle_min'],
        ['Throttle_max', 'summary.throttle_max'],
    ]

    # -------------------------------------------------------------------
    #  Vehicles
    # -------------------------------------------------------------------
    nexus.vehicle_configurations = Vehicles.setup()

    # -------------------------------------------------------------------
    #  Analyses
    # -------------------------------------------------------------------
    nexus.analyses = Analyses.setup(nexus.vehicle_configurations)

    # -------------------------------------------------------------------
    #  Missions
    # -------------------------------------------------------------------
    nexus.missions = Missions.setup(nexus.analyses,
                                    nexus.vehicle_configurations)

    # -------------------------------------------------------------------
    #  Procedure
    # -------------------------------------------------------------------
    nexus.procedure = Procedure.setup()

    return nexus
Пример #6
0
def setup():

    nexus = Nexus()
    problem = Data()
    nexus.optimization_problem = problem

    # -------------------------------------------------------------------
    # Inputs
    # -------------------------------------------------------------------

    # [ tag , initial, [lb,ub], scaling, units ]
    problem.inputs = np.array([
        ['wing_area', 124.8, (70., 200.), 124.8, Units.meter**2],
        ['wing_aspect_ratio', 10.18, (5., 20.), 10.18, Units.less],
        ['wing_sweep', 25., (0., 35.), 25., Units.degrees],
        ['wing_thickness', 0.105, (0.07, 0.20), 0.105, Units.less],
        ['design_thrust', 52700., (10000., 70000.), 52700., Units.N],
        ['MTOW', 79090., (20000., 100000.), 79090., Units.kg],
        ['MZFW_ratio', 0.77, (0.6, 0.99), 0.77, Units.less],
        ['flap_takeoff_angle', 10., (0., 20.), 10., Units.degrees],
        ['flap_landing_angle', 40., (0., 50.), 40., Units.degrees],
        ['short_field_TOW', 64030., (20000., 100000.), 64030., Units.kg],
        ['design_TOW', 68520., (20000., 100000.), 68520., Units.kg],
        ['noise_takeoff_speed_increase', 10.0, (10., 20.), 10.0, Units.knots],
        ['noise_cutback_altitude', 304.8, (240., 400.), 304.8, Units.meter],
    ])

    # -------------------------------------------------------------------
    #  Objective
    # -------------------------------------------------------------------

    problem.objective = np.array([
        ['noise_cumulative_margin', 17, Units.less],
    ])

    # -------------------------------------------------------------------
    # Constraints
    # -------------------------------------------------------------------

    # [ tag, sense, edge, scaling, units ]
    problem.constraints = np.array([
        ['MZFW consistency', '>', 0., 10, Units.less],
        ['design_range_fuel_margin', '>', 0., 10, Units.less],
        ['short_field_fuel_margin', '>', 0., 10, Units.less],
        ['max_range_fuel_margin', '>', 0., 10, Units.less],
        ['wing_span', '<', 35.9664, 35.9664, Units.less],
        ['noise_flyover_margin', '>', 0., 10., Units.less],
        ['noise_sideline_margin', '>', 0., 10., Units.less],
        ['noise_approach_margin', '>', 0., 10., Units.less],
        ['takeoff_field_length', '<', 1985., 1985., Units.meters],
        ['landing_field_length', '<', 1385., 1385., Units.meters],
        ['2nd_segment_climb_max_range', '>', 0.024, 0.024, Units.less],
        ['2nd_segment_climb_short_field', '>', 0.024, 0.024, Units.less],
        ['max_throttle', '<', 1., 1., Units.less],
        ['short_takeoff_field_length', '<', 1330., 1330., Units.meters],
        ['noise_cumulative_margin', '>', 10., 10., Units.less],
    ])

    # -------------------------------------------------------------------
    #  Aliases
    # -------------------------------------------------------------------

    problem.aliases = [
        [
            'wing_area',
            [
                'vehicle_configurations.*.wings.main_wing.areas.reference',
                'vehicle_configurations.*.reference_area'
            ]
        ],
        [
            'wing_aspect_ratio',
            'vehicle_configurations.*.wings.main_wing.aspect_ratio'
        ],
        [
            'wing_incidence',
            'vehicle_configurations.*.wings.main_wing.twists.root'
        ],
        [
            'wing_tip_twist',
            'vehicle_configurations.*.wings.main_wing.twists.tip'
        ],
        [
            'wing_sweep',
            'vehicle_configurations.*.wings.main_wing.sweeps.quarter_chord'
        ],
        [
            'wing_thickness',
            'vehicle_configurations.*.wings.main_wing.thickness_to_chord'
        ],
        ['wing_taper', 'vehicle_configurations.*.wings.main_wing.taper'],
        [
            'wing_location',
            'vehicle_configurations.*.wings.main_wing.origin[0]'
        ],
        [
            'horizontal_tail_area',
            'vehicle_configurations.*.wings.horizontal_stabilizer.areas.reference'
        ],
        [
            'horizontal_tail_aspect_ratio',
            'vehicle_configurations.*.wings.horizontal_stabilizer.aspect_ratio'
        ],
        [
            'vertical_tail_area',
            'vehicle_configurations.*.wings.vertical_stabilizer.areas.reference'
        ],
        [
            'vertical_tail_aspect_ratio',
            'vehicle_configurations.*.wings.vertical_stabilizer.aspect_ratio'
        ],
        [
            'design_thrust',
            'vehicle_configurations.*.propulsors.turbofan.thrust.total_design'
        ],
        [
            'MTOW',
            [
                'vehicle_configurations.*.mass_properties.takeoff',
                'vehicle_configurations.*.mass_properties.max_takeoff'
            ]
        ],
        ['design_TOW', 'vehicle_configurations.base.mass_properties.takeoff'],
        [
            'short_field_TOW',
            'vehicle_configurations.short_field_takeoff.mass_properties.takeoff'
        ],
        [
            'flap_takeoff_angle',
            [
                'vehicle_configurations.takeoff.wings.main_wing.control_surfaces.flap.deflection',
                'vehicle_configurations.short_field_takeoff.wings.main_wing.control_surfaces.flap.deflection'
            ]
        ],
        [
            'flap_landing_angle',
            'vehicle_configurations.landing.wings.main_wing.control_surfaces.flap.deflection'
        ],
        [
            'slat_takeoff_angle',
            [
                'vehicle_configurations.takeoff.wings.main_wing.control_surfaces.slat.deflection',
                'vehicle_configurations.short_field_takeoff.wings.main_wing.control_surfaces.slat.deflection'
            ]
        ],
        [
            'slat_landing_angle',
            'vehicle_configurations.landing.wings.main_wing.control_surfaces.slat.deflection'
        ],
        [
            'wing_span',
            'vehicle_configurations.base.wings.main_wing.spans.projected'
        ],
        ['noise_approach_margin', 'summary.noise_approach_margin'],
        ['noise_sideline_margin', 'summary.noise_sideline_margin'],
        ['noise_flyover_margin', 'summary.noise_flyover_margin'],
        ['static_stability', 'summary.static_stability'],
        [
            'vertical_tail_volume_coefficient',
            'summary.vertical_tail_volume_coefficient'
        ],
        [
            'horizontal_tail_volume_coefficient',
            'summary.horizontal_tail_volume_coefficient'
        ],
        ['wing_max_cl_norm', 'summary.maximum_cl_norm'],
        ['design_range_fuel_margin', 'summary.design_range_fuel_margin'],
        ['takeoff_field_length', 'summary.takeoff_field_length'],
        ['landing_field_length', 'summary.landing_field_length'],
        ['short_takeoff_field_length', 'summary.short_takeoff_field_length'],
        [
            '2nd_segment_climb_max_range',
            'summary.second_segment_climb_gradient_takeoff'
        ],
        [
            '2nd_segment_climb_short_field',
            'summary.second_segment_climb_gradient_short_field'
        ],
        ['max_throttle', 'summary.max_throttle'],
        ['short_field_fuel_margin', 'summary.short_field_fuel_margin'],
        ['max_range_fuel_margin', 'summary.max_range_fuel_margin'],
        ['max_range', 'missions.max_range_distance'],
        ['MZFW consistency', 'summary.MZFW_consistency'],
        ['MZFW_ratio', 'MZFW_ratio'],
        ['noise_takeoff_speed_increase', 'noise_V2_increase'],
        [
            'noise_cutback_altitude',
            'missions.takeoff.segments.climb.altitude_end'
        ],
        ['noise_cumulative_margin', 'summary.noise_margin'],
        ['weighted_sum_objective', 'summary.weighted_sum_objective'],
    ]

    # -------------------------------------------------------------------
    #  Vehicles
    # -------------------------------------------------------------------
    vehicle = vehicle_setup()
    nexus.vehicle_configurations = configs_setup(vehicle)

    # -------------------------------------------------------------------
    #  Analyses
    # -------------------------------------------------------------------
    nexus.analyses = Analyses.setup(nexus.vehicle_configurations)

    # -------------------------------------------------------------------
    #  Missions
    # -------------------------------------------------------------------
    nexus.missions = Missions.setup(nexus.analyses)

    # -------------------------------------------------------------------
    #  Procedure
    # -------------------------------------------------------------------
    nexus.procedure = Procedure.setup()

    # -------------------------------------------------------------------
    #  Summary
    # -------------------------------------------------------------------
    nexus.summary = Data()

    return nexus
Пример #7
0
def setup():

    nexus = Nexus()
    problem = Data()
    nexus.optimization_problem = problem

    # -------------------------------------------------------------------
    # Inputs
    # -------------------------------------------------------------------

    # [ tag , initial, [lb,ub], scaling, units ]
    problem.inputs = np.array([
        [ 'wing_area'                    ,    124.8 , (    70.    ,   200.   ) ,   124.8 , Units.meter**2],
        [ 'wing_aspect_ratio'            ,     10.18, (     5.    ,    20.   ) ,    10.18,     Units.less],
        [ 'wing_sweep'                   ,    25.   , (     0.    ,    35.   ) ,    25.  ,  Units.degrees],
        [ 'wing_thickness'               ,     0.105 , (     0.07  ,     0.20 ) ,     0.105,     Units.less],
        [ 'design_thrust'                , 52700.   , ( 10000.    , 70000.   ) , 52700.  ,        Units.N],
        [ 'MTOW'                         , 79090.   , ( 20000.    ,100000.   ) , 79090.  ,       Units.kg],
        [ 'MZFW_ratio'                   ,     0.77 , (     0.6   ,     0.99 ) ,    0.77 ,     Units.less],
        [ 'flap_takeoff_angle'           ,    10.   , (     0.    ,    20.   ) ,    10.  ,  Units.degrees],
        [ 'flap_landing_angle'           ,    40.   , (     0.    ,    50.   ) ,    40.  ,  Units.degrees],
        [ 'short_field_TOW'              , 64030.   , ( 20000.    ,100000.   ) , 64030.  ,       Units.kg],
        [ 'design_TOW'                   , 68520.   , ( 20000.    ,100000.   ) , 68520.  ,       Units.kg],
        [ 'noise_takeoff_speed_increase' ,    10.0  , (    10.    ,    20.   ) ,    10.0 ,     Units.knots],
        [ 'noise_cutback_altitude'       ,   304.8  , (   240.    ,   400.   ) ,   304.8 ,    Units.meter],
    ])

    # -------------------------------------------------------------------
    #  Objective
    # -------------------------------------------------------------------

    problem.objective = np.array([

        [ 'noise_cumulative_margin', 17, Units.less ],

    ])


    # -------------------------------------------------------------------
    # Constraints
    # -------------------------------------------------------------------

    # [ tag, sense, edge, scaling, units ]
    problem.constraints = np.array([
        [ 'MZFW consistency' , '>' , 0. , 10 , Units.less],
        [ 'design_range_fuel_margin' , '>', 0., 10, Units.less],
        [ 'short_field_fuel_margin' , '>' , 0. , 10, Units.less],
        [ 'max_range_fuel_margin' , '>' , 0. , 10, Units.less], 
        [ 'wing_span' , '<', 35.9664, 35.9664, Units.less],
        [ 'noise_flyover_margin' , '>', 0. , 10., Units.less],
        [ 'noise_sideline_margin' , '>', 0. , 10. , Units.less],
        [ 'noise_approach_margin' , '>', 0., 10., Units.less],
        [ 'takeoff_field_length' , '<', 1985., 1985., Units.meters],
        [ 'landing_field_length' , '<', 1385., 1385., Units.meters],
        [ '2nd_segment_climb_max_range' , '>', 0.024, 0.024, Units.less],
        [ '2nd_segment_climb_short_field' , '>', 0.024, 0.024, Units.less],
        [ 'max_throttle' , '<', 1., 1., Units.less],
        [ 'short_takeoff_field_length' , '<', 1330., 1330., Units.meters],
        [ 'noise_cumulative_margin' , '>', 10., 10., Units.less],
    ])

    # -------------------------------------------------------------------
    #  Aliases
    # -------------------------------------------------------------------


    problem.aliases = [
        [ 'wing_area'                        ,   ['vehicle_configurations.*.wings.main_wing.areas.reference',
                                                  'vehicle_configurations.*.reference_area'                            ]],
        [ 'wing_aspect_ratio'                ,    'vehicle_configurations.*.wings.main_wing.aspect_ratio'               ],
        [ 'wing_incidence'                   ,    'vehicle_configurations.*.wings.main_wing.twists.root'                ],
        [ 'wing_tip_twist'                   ,    'vehicle_configurations.*.wings.main_wing.twists.tip'                 ],
        [ 'wing_sweep'                       ,    'vehicle_configurations.*.wings.main_wing.sweeps.quarter_chord'        ],
        [ 'wing_thickness'                   ,    'vehicle_configurations.*.wings.main_wing.thickness_to_chord'         ],
        [ 'wing_taper'                       ,    'vehicle_configurations.*.wings.main_wing.taper'                      ],
        [ 'wing_location'                    ,    'vehicle_configurations.*.wings.main_wing.origin[0]'                  ],
        [ 'horizontal_tail_area'             ,    'vehicle_configurations.*.wings.horizontal_stabilizer.areas.reference'],
        [ 'horizontal_tail_aspect_ratio'     ,    'vehicle_configurations.*.wings.horizontal_stabilizer.aspect_ratio'   ],
        [ 'vertical_tail_area'               ,    'vehicle_configurations.*.wings.vertical_stabilizer.areas.reference'  ],
        [ 'vertical_tail_aspect_ratio'       ,    'vehicle_configurations.*.wings.vertical_stabilizer.aspect_ratio'     ],
        [ 'design_thrust'                    ,    'vehicle_configurations.*.propulsors.turbofan.thrust.total_design'   ],
        [ 'MTOW'                             ,   ['vehicle_configurations.*.mass_properties.takeoff'   ,
                                                  'vehicle_configurations.*.mass_properties.max_takeoff'               ]],
        [ 'design_TOW'                       ,    'vehicle_configurations.base.mass_properties.takeoff'                 ],
        [ 'short_field_TOW'                  ,    'vehicle_configurations.short_field_takeoff.mass_properties.takeoff'  ],
        [ 'flap_takeoff_angle'               ,    ['vehicle_configurations.takeoff.wings.main_wing.flaps.angle',
                                                   'vehicle_configurations.short_field_takeoff.wings.main_wing.flaps.angle']],
        [ 'flap_landing_angle'               ,    'vehicle_configurations.landing.wings.main_wing.flaps.angle'          ],
        [ 'slat_takeoff_angle'               ,    ['vehicle_configurations.takeoff.wings.main_wing.slats.angle',
                                               'vehicle_configurations.short_field_takeoff.wings.main_wing.slats.angle']],
        [ 'slat_landing_angle'               ,    'vehicle_configurations.landing.wings.main_wing.slats.angle'          ],
        [ 'wing_span'                        ,    'vehicle_configurations.base.wings.main_wing.spans.projected'         ],
        [ 'noise_approach_margin'            ,    'summary.noise_approach_margin'                                       ],
        [ 'noise_sideline_margin'            ,    'summary.noise_sideline_margin'                                       ],
        [ 'noise_flyover_margin'             ,    'summary.noise_flyover_margin'                                        ],
        [ 'static_stability'                 ,    'summary.static_stability'                                            ],
        [ 'vertical_tail_volume_coefficient' ,    'summary.vertical_tail_volume_coefficient'                            ],
        [ 'horizontal_tail_volume_coefficient',   'summary.horizontal_tail_volume_coefficient'                          ],
        [ 'wing_max_cl_norm'                 ,    'summary.maximum_cl_norm'                                             ],
        [ 'design_range_fuel_margin'         ,    'summary.design_range_fuel_margin'                                    ],
        [ 'takeoff_field_length'             ,    'summary.takeoff_field_length'                                        ],
        [ 'landing_field_length'             ,    'summary.landing_field_length'                                        ],
        [ 'short_takeoff_field_length'       ,    'summary.short_takeoff_field_length'                                  ],
        [ '2nd_segment_climb_max_range'      ,    'summary.second_segment_climb_gradient_takeoff'                       ],
        [ '2nd_segment_climb_short_field'    ,    'summary.second_segment_climb_gradient_short_field'                   ],
        [ 'max_throttle'                     ,    'summary.max_throttle'                                                ],
        [ 'short_field_fuel_margin'          ,    'summary.short_field_fuel_margin'                                     ],
        [ 'max_range_fuel_margin'            ,    'summary.max_range_fuel_margin'                                       ],
        [ 'max_range'                        ,    'missions.max_range_distance'                                         ],
        [ 'MZFW consistency'                 ,    'summary.MZFW_consistency'                                            ],
        [ 'MZFW_ratio'                       ,    'MZFW_ratio'                                                          ],
        [ 'noise_takeoff_speed_increase'     ,    'noise_V2_increase'                                                   ],
        [ 'noise_cutback_altitude'           ,    'missions.takeoff.segments.climb.altitude_end'                        ],
        [ 'noise_cumulative_margin'          ,    'summary.noise_margin'                                                ],
        [ 'weighted_sum_objective'           ,    'summary.weighted_sum_objective'                                      ],
    ]

    # -------------------------------------------------------------------
    #  Vehicles
    # -------------------------------------------------------------------
    vehicle = vehicle_setup()
    nexus.vehicle_configurations = configs_setup(vehicle)
    

    # -------------------------------------------------------------------
    #  Analyses
    # -------------------------------------------------------------------
    nexus.analyses = Analyses.setup(nexus.vehicle_configurations)


    # -------------------------------------------------------------------
    #  Missions
    # -------------------------------------------------------------------
    nexus.missions = Missions.setup(nexus.analyses)


    # -------------------------------------------------------------------
    #  Procedure
    # -------------------------------------------------------------------
    nexus.procedure = Procedure.setup()

    # -------------------------------------------------------------------
    #  Summary
    # -------------------------------------------------------------------
    nexus.summary = Data()

    return nexus
Пример #8
0
def setup():

    nexus = Nexus()
    problem = Data()
    nexus.optimization_problem = problem

    # -------------------------------------------------------------------
    # Inputs
    # -------------------------------------------------------------------

    # [ tag , initial, [lb,ub], scaling, units ]
    problem.inputs = np.array([
        [ 'wing_area'       ,   0.5, (  0.1,    1.5 ),    0.5, Units.meter      ],
        [ 'aspect_ratio'    ,  10.0, (  5.0,   20.0 ),   10.0, Units.less       ], 
        [ 'dynamic_pressure', 125.0, (  1.0, 2000.0 ),  125.0, Units.pascals    ], 
        [ 'solar_ratio'     ,   0.0, (  0.0,    0.97),    1.0, Units.less       ], 
        [ 'kv'              , 800.0, ( 10.0, 1500.0 ),  800.0, Units['rpm/volt']], 
    ])

    # -------------------------------------------------------------------
    # Objective
    # -------------------------------------------------------------------

    # [ tag, scaling, units ]
    problem.objective = np.array([
         [ 'Nothing', 1. , Units.kg],
    ])
    
    # -------------------------------------------------------------------
    # Constraints
    # -------------------------------------------------------------------

    # [ tag, sense, edge, scaling, units ]
    problem.constraints = np.array([
        [ 'energy_constraint', '=', 0.0, 1.0, Units.less],
        [ 'battery_mass'     , '>', 0.0, 1.0, Units.kg  ],       
        [ 'CL'               , '>', 0.0, 1.0, Units.less],
        [ 'Throttle_min'     , '>', 0.0, 1.0, Units.less],
        [ 'Throttle_max'     , '>', 0.0, 1.0, Units.less],
    ])
    
    # -------------------------------------------------------------------
    #  Aliases
    # -------------------------------------------------------------------
    
    # [ 'alias' , ['data.path1.name','data.path2.name'] ]
    problem.aliases = [
        [ 'wing_area'        ,['vehicle_configurations.*.wings.main_wing.areas.reference',
                               'vehicle_configurations.base.reference_area']                                ], 
        [ 'aspect_ratio'     , 'vehicle_configurations.*.wings.main_wing.aspect_ratio'                      ],
        [ 'kv'               , 'vehicle_configurations.*.propulsors.network.motor.speed_constant'           ], 
        [ 'battery_mass'     , 'vehicle_configurations.base.propulsors.network.battery.mass_properties.mass'],
        [ 'solar_ratio'      , 'vehicle_configurations.*.propulsors.network.solar_panel.ratio'              ],
        [ 'dynamic_pressure' , 'missions.mission.segments.cruise.dynamic_pressure'                          ],  
        [ 'Nothing'          , 'summary.nothing'                                                            ],
        [ 'energy_constraint', 'summary.energy_constraint'                                                  ],
        [ 'CL'               , 'summary.CL'                                                                 ],    
        [ 'Throttle_min'     , 'summary.throttle_min'                                                       ],
        [ 'Throttle_max'     , 'summary.throttle_max'                                                       ],
    ]      
    
    # -------------------------------------------------------------------
    #  Vehicles
    # -------------------------------------------------------------------
    nexus.vehicle_configurations = Vehicles.setup()
    
    # -------------------------------------------------------------------
    #  Analyses
    # -------------------------------------------------------------------
    nexus.analyses = Analyses.setup(nexus.vehicle_configurations)
       
    # -------------------------------------------------------------------
    #  Missions
    # -------------------------------------------------------------------
    nexus.missions = Missions.setup(nexus.analyses,nexus.vehicle_configurations)
    
    # -------------------------------------------------------------------
    #  Procedure
    # -------------------------------------------------------------------    
    nexus.procedure = Procedure.setup()
    
    return nexus