def make_new_chart( pvar='Pc', Pc=500, eps=10, pcentBell=80.0, TcCham=5500.0 ):

    fig, ax = plt.subplots( figsize=(7,5) )
    
    if pvar=='Pc':
            
        for i,Pc in enumerate(rangeD['Pc']):
            effblL = []
            for Rthrt in rthrtL:
                #effblL.append( eff_bl_NASA( Dt=2*Rthrt, Pc=Pc, eps=eps) )
                pcloss = calc_pcentLossBL_all(ceaObj, Pc=Pc, eps=eps, Rthrt=Rthrt, pcentBell=pcentBell, MR=MR)
                effblL.append( (100-pcloss)/100.0 )
                
            ax.semilogx(rthrtL, effblL,'--', label='MABL Pc=%g'%Pc, linewidth=3, color=colorL[i] )


        for i,Pc in enumerate(rangeD['Pc']):
            effblL = []
            _, _, TcCham, MolWt, gammaInit = ceaObj.get_IvacCstrTc_ChmMwGam( Pc=Pc, MR=MR, eps=eps)
            for Rthrt in rthrtL:
                effbl = (100-calc_pcentLossBL( Pc=Pc, eps=eps, Rthrt=Rthrt, pcentBell=pcentBell, TcCham=TcCham ))/100.0
                effblL.append( effbl )
            ax.semilogx(rthrtL, effblL,'-', label='MLP Pc=%g'%Pc, color=colorL[i] )

        plt.title('%s Impact on BL efficiency\n(area ratio=%g)'%(pvar, eps))
                
    
    elif pvar=='eps':
            
        for i,eps in enumerate(rangeD['eps']):
            effblL = []
            for Rthrt in rthrtL:
                pcloss = calc_pcentLossBL_all(ceaObj, Pc=Pc, eps=eps, Rthrt=Rthrt, pcentBell=pcentBell, MR=MR)
                effblL.append( (100-pcloss)/100.0 )
            ax.semilogx(rthrtL, effblL,'--', label='MABL eps=%g'%eps, linewidth=3, color=colorL[i] )


        for i,eps in enumerate(rangeD['eps']):
            effblL = []
            _, _, TcCham, MolWt, gammaInit = ceaObj.get_IvacCstrTc_ChmMwGam( Pc=Pc, MR=MR, eps=eps)
            for Rthrt in rthrtL:
                effbl = (100-calc_pcentLossBL( Pc=Pc, eps=eps, Rthrt=Rthrt, pcentBell=pcentBell, TcCham=TcCham ))/100.0
                effblL.append( effbl )
            ax.semilogx(rthrtL, effblL,'-', label='MLP eps=%g'%eps, color=colorL[i] )

        plt.title('%s Impact on BL efficiency\n(Pc=%g psia)'%(pvar, Pc))
    
    plt.gca().xaxis.set_major_formatter(StrMethodFormatter('{x:,g}')) # 2 decimal places
    plt.gca().xaxis.set_minor_formatter(StrMethodFormatter('{x:,g}')) # 2 decimal places
    ax.tick_params(axis='x', which='minor', labelsize=8)
    
    plt.ylabel('BL efficiency')
    plt.xlabel('Throat Radius, inch')
    #plt.ylim( (0.975, 1.0) )
    plt.grid( True )
    plt.legend()
    
    fig.tight_layout()
Exemple #2
0
def make_pc_chart( Rthrt=1, eps=20., pcentBell=80., TcCham=5500. ):
    
    png_path_name = '' #os.path.join(up_one, '_static', 'chk_PcDt_Pcparam_eps%g.png'%eps )
    title = 'Check Pc*Dt as Independent Variable'

    F = Figure( figsize=(6,6), dpi=300, nrows=1, ncols=1,
                sharex=False, sharey=False, hspace=None, wspace=None,
                title=title, show_grid=True, tight_layout=True,
                png_path_name=png_path_name )
                
    F.set_x_number_format(major_fmt='g', major_size=10, minor_fmt='', minor_size=8)
    F.set_y_number_format(major_fmt='g', major_size=10, minor_fmt='', minor_size=8)

    curveL = []

    for Pc in [100, 200, 500, 1000, 4000]:
        effblL = []
        for PcDt in PcDtL:
            Rthrt = PcDt/Pc/2.0
            effblL.append( (100-calc_pcentLossBL( Pc=Pc, eps=eps, Rthrt=Rthrt, 
                                             pcentBell=pcentBell, TcCham=TcCham ))/100.0 )
        
        curve = Curve(plot_type='semilogx', xL=PcDtL, yL=effblL, marker='',
                      label='Pc=%g psia'%Pc,
                      linestyle='-', linewidth=1, linecolor='',
                      place_labels_on_line=True, dy_placement=0)

        curveL.append( curve )

    chart = F.add_chart( row=0, col=0, curveL=curveL, 
                         xlabel='Pc(psia) * Dt(inch)', 
                         ylabel='Boundary Layer Efficiency',
                         show_legend=True, legend_loc='lower right')
    F.make( do_show=True )
Exemple #3
0
    def calc_all_eff(self):
        """
        Looks at the efficiency object (effObj) and calculates those efficiencies
        that have not been set as constants by the user.
        
        see: self.calc_CdThroat or effObj['XXX'].is_const for individual efficiencies
        """
        DOREVAL = False
        made_a_change = False
        effObj = self.coreObj.effObj

        if self.calc_CdThroat:
            #CdThroat = get_Cd( RWTU=self.geomObj.RupThroat, gamma=self.coreObj.gammaChm )
            CdThroat = calc_Cd(Pc=self.coreObj.Pc,
                               Rthrt=self.geomObj.Rthrt,
                               RWTU=self.geomObj.RupThroat)

            self.coreObj.reset_CdThroat(CdThroat,
                                        method_name='MLP fit',
                                        re_evaluate=DOREVAL)
            made_a_change = True

        #if self.calc_effPulse:
        if not effObj['Pulse'].is_const:
            effPulse = eff_pulse(pulse_sec=self.pulse_sec,
                                 pulse_quality=self.pulse_quality)
            msg = 'rough estimate (%g sec, Q=%g)' % (self.pulse_sec,
                                                     self.pulse_quality)
            self.coreObj.effObj.set_value('Pulse',
                                          effPulse,
                                          value_src=msg,
                                          re_evaluate=DOREVAL)
            made_a_change = True

        #if self.calc_effDiv:
        if not effObj['Div'].is_const:

            # AVAIL_EFF_MODEL_D['Div'] = ['simple fit', 'MLP fit']
            if selected_eff_modelD['Div'] == 'simple fit':
                effDiv = eff_div(eps=self.geomObj.eps,
                                 pcBell=self.geomObj.pcentBell)
                msg = selected_eff_modelD['Div'] + ' eps=%g, %%bell=%g' % (
                    self.geomObj.eps, self.geomObj.pcentBell)

            elif selected_eff_modelD['Div'] == 'MLP fit':
                raise Exception('MLP fit not yet implemented for eff Div')

            self.coreObj.effObj.set_value('Div',
                                          effDiv,
                                          value_src=msg,
                                          re_evaluate=DOREVAL)
            made_a_change = True

        #if self.calc_effBL:
        if not effObj['BL'].is_const:

            # AVAIL_EFF_MODEL_D['BL'] = ['MLP fit', 'NASA-SP8120']
            if selected_eff_modelD['BL'] == 'NASA-SP8120':
                effBL = eff_bl_NASA(Dt=self.geomObj.Rthrt * 2.0,
                                    Pc=self.coreObj.Pc,
                                    eps=self.geomObj.eps)
            elif selected_eff_modelD['BL'] == 'MLP fit':

                pclossBL = calc_pcentLossBL(Pc=self.coreObj.Pc,
                                            eps=self.geomObj.eps,
                                            Rthrt=self.geomObj.Rthrt,
                                            pcentBell=self.geomObj.pcentBell,
                                            TcCham=self.coreObj.TcODE)

                effBL = (100.0 - pclossBL) / 100.0

            msg = selected_eff_modelD['BL']

            if self.noz_regen_eps > 1.0:
                msg += 'regen-corrected'
                effBL = regen_corrected_bl(eff_bl=effBL,
                                           eps=self.geomObj.eps,
                                           noz_regen_eps=self.noz_regen_eps)

            self.coreObj.effObj.set_value('BL',
                                          effBL,
                                          value_src=msg,
                                          re_evaluate=DOREVAL)
            made_a_change = True

        #if self.calc_effKin:
        if not effObj['Kin'].is_const:
            IspODK = calc_IspODK(self.coreObj.ceaObj,
                                 Pc=self.coreObj.Pc,
                                 eps=self.geomObj.eps,
                                 Rthrt=self.geomObj.Rthrt,
                                 pcentBell=self.geomObj.pcentBell,
                                 MR=self.coreObj.MRcore)

            # coreObj has made IspODE calc already
            effKin = IspODK / self.coreObj.IspODE
            msg = selected_eff_modelD['Kin']

            self.coreObj.effObj.set_value('Kin',
                                          effKin,
                                          value_src=msg,
                                          re_evaluate=DOREVAL)
            made_a_change = True

        if self.injObj is not None:
            if not effObj.effD['ERE'].is_const:

                #if self.calc_effEm:
                if not effObj['Em'].is_const:
                    effEm = self.injObj.calculate_effEm()
                    msg = 'Rupe elemEm=%g' % self.injObj.elemEm
                    self.coreObj.effObj.set_value('Em',
                                                  effEm,
                                                  value_src=msg,
                                                  re_evaluate=DOREVAL)
                    made_a_change = True

                #if self.calc_effMix:
                if not effObj['Mix'].is_const:
                    effMix = self.injObj.calculate_effMix(
                    )  # calc inter-element mixing efficiency (2 deg estimate)
                    msg = 'mixAngle=%.2f deg' % self.injObj.mixAngle
                    self.coreObj.effObj.set_value('Mix',
                                                  effMix,
                                                  value_src=msg,
                                                  re_evaluate=DOREVAL)
                    made_a_change = True

                #if self.calc_effVap:
                if not effObj['Vap'].is_const:
                    effVap = self.injObj.calculate_effVap()
                    msg = 'gen vaporized length'
                    self.coreObj.effObj.set_value('Vap',
                                                  effVap,
                                                  value_src=msg,
                                                  re_evaluate=DOREVAL)
                    made_a_change = True

        # after all updates, re_evaluate
        if made_a_change:
            self.coreObj.evaluate()
def make_pc_chart(Pc=100, pcentBell=80., TcCham=5500.):

    png_path_name = os.path.join(up_one, '_static',
                                 'effbl_parametrics_Pc%g.png' % Pc)
    title = 'Pc = %g psia\nMLP vs NASA SP8120 Boundary Layer Efficiency' % Pc

    F = Figure(figsize=(6, 5),
               dpi=300,
               nrows=1,
               ncols=1,
               sharex=False,
               sharey=False,
               hspace=None,
               wspace=None,
               title=title,
               show_grid=True,
               tight_layout=True,
               png_path_name=png_path_name)

    F.set_x_number_format(major_fmt='g',
                          major_size=10,
                          minor_fmt='',
                          minor_size=8)
    F.set_y_number_format(major_fmt='.3f',
                          major_size=10,
                          minor_fmt='',
                          minor_size=8)

    curveL = []

    for i, eps in enumerate(epsL):

        # show MLP curves
        effblL = []
        for Rthrt in rtL:
            effblL.append((100 - calc_pcentLossBL(Pc=Pc,
                                                  eps=eps,
                                                  Rthrt=Rthrt,
                                                  pcentBell=pcentBell,
                                                  TcCham=TcCham)) / 100.0)
        curve = Curve(plot_type='semilogx',
                      xL=rtL,
                      yL=effblL,
                      marker='',
                      label='MLP %g:1' % eps,
                      xpos_label=.2,
                      linestyle='-',
                      linewidth=2,
                      linecolor=CWheel(i),
                      place_labels_on_line=True,
                      dy_placement='2%')
        curveL.append(curve)

    for i, eps in enumerate(epsL):
        # show NASA curves
        effblL = []
        short_rtL = []
        for Rthrt in rtL:
            DtPc = 2.0 * Rthrt * Pc
            if DtPc >= 8.0 and DtPc <= 2000:
                effblL.append(eff_bl_NASA(Dt=2.0 * Rthrt, Pc=Pc, eps=eps))
                short_rtL.append(Rthrt)

        curve = Curve(plot_type='semilogx',
                      xL=short_rtL,
                      yL=effblL,
                      marker='',
                      label='NASA %g:1' % eps,
                      xpos_label=1,
                      linestyle='--',
                      linewidth=1,
                      linecolor=CWheel(i),
                      place_labels_on_line=True,
                      dy_placement='2%')
        curveL.append(curve)

    msg =  'Area Ratio = 3:1 to 80:1\n'+\
           '%%Bell=%g, Tc=%g degR\n'%( pcentBell, TcCham) +\
           'NASA = NASA Report SP 8120\n'+\
           'MLP = Multi-layer Perceptron Regressor'

    curve.add_extra_text(label=msg,
                         xpos_label=3,
                         ypos_label=0.965,
                         show_label_frame=True,
                         dx_placement=0,
                         dy_placement=0,
                         dangle_placement=0,
                         abs_angle=0,
                         alpha=1,
                         alpha_label=1,
                         label_color='k')  #, label_font_size=12)

    chart = F.add_chart(row=0,
                        col=0,
                        curveL=curveL,
                        xlabel='Throat Radius (Rthrt, inch)',
                        ylabel='Boundary Layer Efficiency',
                        show_legend=True,
                        legend_loc='lower right',
                        ymin=0.96,
                        ymax=1.0)
    F.make(do_show=False)