Beispiel #1
0
def read_history( History_filename, nZones = 1):
    """ reads a history file
        returns an ordered bunch with the history file headers for keys
        and a list of each header's floats for values.
        if header is an optimization objective, its name is mapped to 
        the optimization name.
        Iter and Time(min) headers are mapped to ITERATION and TIME
        respectively.
    """
    
    # read plot file
    plot_data = read_plot( History_filename )
    
    # initialize history data dictionary
    history_data = ordered_bunch()    

    # map header names
    for key in plot_data.keys():
        var = key
        for field in historyOutFields:
            
            if key == historyOutFields[field]['HEADER'] and nZones == 1:
                var = field

            if key.split('[')[0] == historyOutFields[field]['HEADER'] and nZones > 1:
                var = field + '[' + key.split('[')[1]
                
        history_data[var] = plot_data[key]

    return history_data
Beispiel #2
0
def read_history(History_filename):
    """ reads a history file
        returns an ordered bunch with the history file headers for keys
        and a list of each header's floats for values.
        if header is an optimization objective, its name is mapped to 
        the optimization name.
        Iter and Time(min) headers are mapped to ITERATION and TIME
        respectively.
    """

    # read plot file
    plot_data = read_plot(History_filename)

    # initialize history data dictionary
    history_data = ordered_bunch()

    # header name to config file name map
    map_dict = get_headerMap()

    # map header names
    for key in plot_data.keys():
        if map_dict.has_key(key):
            var = map_dict[key]
        else:
            var = key
        history_data[var] = plot_data[key]

    return history_data
Beispiel #3
0
def read_history( History_filename ):
    """ reads a history file
        returns an ordered bunch with the history file headers for keys
        and a list of each header's floats for values.
        if header is an optimization objective, its name is mapped to 
        the optimization name.
        Iter and Time(min) headers are mapped to ITERATION and TIME
        respectively.
    """
    
    # read plot file
    plot_data = read_plot( History_filename )
    
    # initialize history data dictionary
    history_data = ordered_bunch()    
    
    # header name to config file name map
    map_dict = get_headerMap()    
    
    # map header names
    for key in plot_data.keys():
        if map_dict.has_key(key):
            var = map_dict[key]
        else:
            var = key
        history_data[var] = plot_data[key]
    
    return history_data
Beispiel #4
0
def read_aerodynamics( History_filename , special_cases=[] ):
    """ values = read_aerodynamics(historyname, special_cases=[])
        read aerodynamic function values from history file
        
        Outputs:
            dictionary with function keys and thier values
            if special cases has 'UNSTEADY_SIMULATION', returns time averaged data
            otherwise returns final value from history file
    """
    
    # read the history data
    history_data = read_history(History_filename)
    
    # list of functions to pull
    func_names = optnames_aero

    # pull only these functions
    Func_Values = ordered_bunch()
    for this_objfun in func_names:
        if history_data.has_key(this_objfun):
            Func_Values[this_objfun] = history_data[this_objfun] 
    
    # for unsteady cases, average time-accurate objective function values
    if 'UNSTEADY_SIMULATION' in special_cases:
        for key,value in Func_Values.iteritems():
            Func_Values[key] = sum(value)/len(value)
    
    # otherwise, keep only last value
    else:
        for key,value in Func_Values.iteritems():
            Func_Values[key] = value[-1]
                    
    return Func_Values
Beispiel #5
0
def read_aerodynamics(History_filename,
                      nZones=1,
                      special_cases=[],
                      final_avg=0,
                      wnd_fct='SQUARE'):
    """ values = read_aerodynamics(historyname, special_cases=[])
        read aerodynamic function values from history file
        
        Outputs:
            dictionary with function keys and thier values
            if special cases has 'TIME_MARCHING', returns time averaged data
            otherwise returns final value from history file
    """

    # read the history data
    history_data = read_history(History_filename, nZones)

    # pull only these functions
    Func_Values = ordered_bunch()
    for this_objfun in historyOutFields:
        if nZones == 1:
            if this_objfun in history_data:
                if historyOutFields[this_objfun][
                        'TYPE'] == 'COEFFICIENT' or historyOutFields[
                            this_objfun]['TYPE'] == 'D_COEFFICIENT':
                    Func_Values[this_objfun] = history_data[this_objfun]
        else:
            for iZone in range(nZones):
                if this_objfun + '[' + str(iZone) + ']' in history_data:
                    if historyOutFields[this_objfun][
                            'TYPE'] == 'COEFFICIENT' or historyOutFields[
                                this_objfun]['TYPE'] == 'D_COEFFICIENT':
                        Func_Values[this_objfun + '[' + str(iZone) +
                                    ']'] = history_data[this_objfun + '[' +
                                                        str(iZone) + ']']

    if 'TIME_MARCHING' in special_cases:
        # for unsteady cases, average time-accurate objective function values
        for key, value in Func_Values.items():
            if historyOutFields[key]['TYPE'] == 'COEFFICIENT':
                if not history_data.get('TAVG_' + key):
                    raise KeyError('Key ' +
                                   historyOutFields['TAVG_' + key]['HEADER'] +
                                   ' was not found in history output.')
                Func_Values[key] = history_data['TAVG_' + key][-1]
            elif historyOutFields[key]['TYPE'] == 'D_COEFFICIENT':
                if not history_data.get('TAVG_' + key):
                    raise KeyError('Key ' +
                                   historyOutFields['TAVG_' + key]['HEADER'] +
                                   ' was not found in history output.')
                Func_Values[key] = history_data['TAVG_' + key][-1]
    else:
        # in steady cases take only last value.
        for key, value in Func_Values.iteritems():
            if not history_data.get(key):
                raise KeyError('Key ' + historyOutFields[key]['HEADER'] +
                               ' was not found in history output.')
            Func_Values[key] = value[-1]

    return Func_Values
Beispiel #6
0
def read_aerodynamics( History_filename , special_cases=[] ):
    """ values = read_aerodynamics(historyname, special_cases=[])
        read aerodynamic function values from history file
        
        Outputs:
            dictionary with function keys and thier values
            if special cases has 'UNSTEADY_SIMULATION', returns time averaged data
            otherwise returns final value from history file
    """
    
    # read the history data
    history_data = read_history(History_filename)
    
    # list of functions to pull
    func_names = optnames_aero

    # pull only these functions
    Func_Values = ordered_bunch()
    for this_objfun in func_names:
        if history_data.has_key(this_objfun):
            Func_Values[this_objfun] = history_data[this_objfun] 
    
    # for unsteady cases, average time-accurate objective function values
    if 'UNSTEADY_SIMULATION' in special_cases:
        for key,value in Func_Values.iteritems():
            Func_Values[key] = sum(value)/len(value)
    
    # otherwise, keep only last value
    else:
        for key,value in Func_Values.iteritems():
            Func_Values[key] = value[-1]
                    
    return Func_Values
Beispiel #7
0
def read_aerodynamics(History_filename,
                      nZones=1,
                      special_cases=[],
                      final_avg=0):
    """ values = read_aerodynamics(historyname, special_cases=[])
        read aerodynamic function values from history file
        
        Outputs:
            dictionary with function keys and thier values
            if special cases has 'UNSTEADY_SIMULATION', returns time averaged data
            otherwise returns final value from history file
    """

    # read the history data
    history_data = read_history(History_filename, nZones)

    # list of functions to pull
    func_names = optnames_aero + grad_names_directdiff + optnames_turbo

    # pull only these functions
    Func_Values = ordered_bunch()
    for this_objfun in func_names:
        if this_objfun in history_data:
            Func_Values[this_objfun] = history_data[this_objfun]

    # for unsteady cases, average time-accurate objective function values
    if 'UNSTEADY_SIMULATION' in special_cases and not final_avg:
        for key, value in Func_Values.items():
            Func_Values[key] = sum(value) / len(value)

    # average the final iterations
    elif final_avg:
        for key, value in Func_Values.iteritems():
            # only the last few iterations
            i_fin = min([final_avg, len(value)])
            value = value[-i_fin:]
            Func_Values[key] = sum(value) / len(value)

    # otherwise, keep only last value
    else:
        for key, value in Func_Values.iteritems():
            Func_Values[key] = value[-1]

    return Func_Values
Beispiel #8
0
def find_cfl_number(config, state):

    # setup result data
    results = ordered_bunch()
    results.CONFIG = copy.deepcopy(config)
    results.ANALYSES = ordered_dict()

    # run a bracketing algorithm
    sp.optimize.brent(
        func=run_su2,
        args=(config, state, results),
        brack=tuple(SEARCH_BRACKET),
        tol=0.001,
        maxiter=MAX_ANALYSES -
        3,  #analyses are used in the first bracket pass and aren't counted by this algorithm
    )

    ## run a search method
    #sp.optimize.fminbound(
    #func    = run_su2,
    #x1      = SEARCH_BRACKET[0],
    #x2      = SEARCH_BRACKET[2],
    #args    = ( config, state, results ),
    #xtol    = 0.001,
    #maxfun  = MAX_ANALYSES,
    #disp    = 0,
    #)

    # get final result
    cfl = np.array([r.CFL_NUMBER for r in results.ANALYSES.values()])
    its = np.array([r.ITERATIONS for r in results.ANALYSES.values()])
    ind = np.lexsort((-cfl, its))

    # done!
    print 'Final Result'
    print '  CFL        = %.4f' % cfl[ind[0]]
    print '  Iterations = %i' % its[ind[0]]

    # save the data
    SU2.io.save_data('experiment_results.pkl', results)

    return
Beispiel #9
0
def find_cfl_number(config,state):

    # setup result data
    results = ordered_bunch()
    results.CONFIG = copy.deepcopy(config)
    results.ANALYSES = ordered_dict()
        
    # run a bracketing algorithm
    sp.optimize.brent(
        func    = run_su2,
        args    = ( config, state, results ),
        brack   = tuple(SEARCH_BRACKET),
        tol     = 0.001,
        maxiter = MAX_ANALYSES-3, #analyses are used in the first bracket pass and aren't counted by this algorithm
    )
    
    ## run a search method
    #sp.optimize.fminbound(
        #func    = run_su2,
        #x1      = SEARCH_BRACKET[0],
        #x2      = SEARCH_BRACKET[2],
        #args    = ( config, state, results ),
        #xtol    = 0.001,
        #maxfun  = MAX_ANALYSES,
        #disp    = 0,
    #)
    
    
    # get final result
    cfl = np.array([ r.CFL_NUMBER for r in results.ANALYSES.values() ])
    its = np.array([ r.ITERATIONS for r in results.ANALYSES.values() ])
    ind = np.lexsort((-cfl,its))
    
    # done!
    print 'Final Result'
    print '  CFL        = %.4f' % cfl[ind[0]]
    print '  Iterations = %i'   % its[ind[0]]
    
    # save the data
    SU2.io.save_data('experiment_results.pkl',results)    
    
    return
Beispiel #10
0
def read_aerodynamics( History_filename , nZones = 1, special_cases=[], final_avg=0 ):
    """ values = read_aerodynamics(historyname, special_cases=[])
        read aerodynamic function values from history file
        
        Outputs:
            dictionary with function keys and thier values
            if special cases has 'UNSTEADY_SIMULATION', returns time averaged data
            otherwise returns final value from history file
    """
    
    # read the history data
    history_data = read_history(History_filename, nZones)
    
    # list of functions to pull
    func_names = optnames_aero + grad_names_directdiff + optnames_turbo

    # pull only these functions
    Func_Values = ordered_bunch()
    for this_objfun in func_names:
        if this_objfun in history_data:
            Func_Values[this_objfun] = history_data[this_objfun] 
    
    # for unsteady cases, average time-accurate objective function values
    if 'UNSTEADY_SIMULATION' in special_cases and not final_avg:
        for key,value in Func_Values.items():
            Func_Values[key] = sum(value)/len(value)
         
    # average the final iterations   
    elif final_avg:
        for key,value in Func_Values.iteritems():
            # only the last few iterations
            i_fin = min([final_avg,len(value)])
            value = value[-i_fin:]
            Func_Values[key] = sum(value)/len(value)
    
    # otherwise, keep only last value
    else:
        for key,value in Func_Values.iteritems():
            Func_Values[key] = value[-1]
                    
    return Func_Values
Beispiel #11
0
def read_aerodynamics( History_filename , nZones = 1, special_cases=[], final_avg=0 ):
    """ values = read_aerodynamics(historyname, special_cases=[])
        read aerodynamic function values from history file
        
        Outputs:
            dictionary with function keys and thier values
            if special cases has 'TIME_MARCHING', returns time averaged data
            otherwise returns final value from history file
    """
    
    # read the history data
    history_data = read_history(History_filename, nZones)
    
    # pull only these functions
    Func_Values = ordered_bunch()
    for this_objfun in historyOutFields:
        if this_objfun in history_data:
            if historyOutFields[this_objfun]['TYPE'] == 'COEFFICIENT' or historyOutFields[this_objfun]['TYPE'] == 'D_COEFFICIENT':
                Func_Values[this_objfun] = history_data[this_objfun] 
    
    # for unsteady cases, average time-accurate objective function values
    if 'TIME_MARCHING' in special_cases and not final_avg:
        for key,value in Func_Values.items():
            Func_Values[key] = sum(value)/len(value)
         
    # average the final iterations   
    elif final_avg:
        for key,value in Func_Values.iteritems():
            # only the last few iterations
            i_fin = min([final_avg,len(value)])
            value = value[-i_fin:]
            Func_Values[key] = sum(value)/len(value)
    
    # otherwise, keep only last value
    else:
        for key,value in Func_Values.iteritems():
            Func_Values[key] = value[-1]
                    
    return Func_Values
Beispiel #12
0
#: optnames_geo

grad_names_directdiff = [
    "D_LIFT", "D_DRAG", "D_SIDEFORCE", "D_MOMENT_X", "D_MOMENT_Y",
    "D_MOMENT_Z", "D_FORCE_X", "D_FORCE_Y", "D_FORCE_Z", "D_EFFICIENCY",
    "D_CUSTOM_OBJFUNC", "D_HEAT", "D_MAX_HEAT", "D_TOTAL_PRESSURE_LOSS",
    "D_TOTAL_EFFICIENCY", "D_TOTAL_PRESSURE_LOSS", "D_KINETIC_ENERGY_LOSS",
    "D_TOTAL_STATIC_EFFICIENCY", "D_FLOW_ANGLE_OUT", "D_FLOW_ANGLE_IN",
    "D_MASS_FLOW_IN", "D_MASS_FLOW_OUT", "D_PRESSURE_RATIO", "D_ENTHALPY_OUT",
    "D_TOTAL_ENTHALPY_OUT", "D_SURFACE_UNIFORMITY", "D_SURFACE_SECONDARY",
    "D_SURFACE_MOM_DISTORTION", "D_SURFACE_SECOND_OVER_UNIFORM",
    "D_SURFACE_PRESSURE_DROP"
]

grad_names_map = ordered_bunch()
grad_names_map.MASS_FLOW_IN = "D_MASS_FLOW_IN"
grad_names_map.MOMENT_Z = "D_MOMENT_Z"
grad_names_map.FLOW_ANGLE_OUT = "D_FLOW_ANGLE_OUT"
grad_names_map.MASS_FLOW_OUT = "D_MASS_FLOW_OUT"
grad_names_map.FLOW_ANGLE_IN = "D_FLOW_ANGLE_IN"
grad_names_map.FORCE_Z = "D_FORCE_Z"
grad_names_map.FORCE_Y = "D_FORCE_Y"
grad_names_map.FORCE_X = "D_FORCE_X"
grad_names_map.TOTAL_EFFICIENCY = "D_TOTAL_EFFICIENCY"
grad_names_map.TOTAL_STATIC_EFFICIENCY = "D_TOTAL_STATIC_EFFICIENCY"
grad_names_map.PRESSURE_RATIO = "D_PRESSURE_RATIO"
grad_names_map.EFFICIENCY = "D_EFFICIENCY"
grad_names_map.DRAG = "D_DRAG"
grad_names_map.LIFT = "D_LIFT"
grad_names_map.TOTAL_ENTHALPY_OUT = "D_TOTAL_ENTHALPY_OUT"
Beispiel #13
0
                         "D_FORCE_Z",
                         "D_EFFICIENCY",
                         "D_TOTAL_PRESSURE_LOSS",
                         "D_TOTAL_EFFICIENCY",
                         "D_TOTAL_PRESSURE_LOSS",
                         "D_KINETIC_ENERGY_LOSS",
                         "D_TOTAL_STATIC_EFFICIENCY",
                         "D_FLOW_ANGLE_OUT",
                         "D_FLOW_ANGLE_IN",
                         "D_MASS_FLOW_IN",
                         "D_MASS_FLOW_OUT",
                         "D_PRESSURE_RATIO",
                         "D_ENTHALPY_OUT",
                         "D_TOTAL_ENTHALPY_OUT"]

grad_names_map = ordered_bunch()
grad_names_map.MASS_FLOW_IN = "D_MASS_FLOW_IN"
grad_names_map.MOMENT_Z = "D_MOMENT_Z"
grad_names_map.FLOW_ANGLE_OUT = "D_FLOW_ANGLE_OUT"
grad_names_map.MASS_FLOW_OUT = "D_MASS_FLOW_OUT"
grad_names_map.FLOW_ANGLE_IN = "D_FLOW_ANGLE_IN"
grad_names_map.FORCE_Z = "D_FORCE_Z"
grad_names_map.FORCE_Y = "D_FORCE_Y"
grad_names_map.FORCE_X = "D_FORCE_X"
grad_names_map.TOTAL_EFFICIENCY = "D_TOTAL_EFFICIENCY"
grad_names_map.TOTAL_STATIC_EFFICIENCY = "D_TOTAL_STATIC_EFFICIENCY"
grad_names_map.PRESSURE_RATIO = "D_PRESSURE_RATIO"
grad_names_map.EFFICIENCY = "D_EFFICIENCY"
grad_names_map.DRAG = "D_DRAG"
grad_names_map.LIFT = "D_LIFT"
grad_names_map.TOTAL_ENTHALPY_OUT = "D_TOTAL_ENTHALPY_OUT"