pyCycle icon indicating copy to clipboard operation
pyCycle copied to clipboard

How to visualize a map

Open NJC1012 opened this issue 1 year ago • 5 comments

In the MAP file provided by PYCYCLE, there are five dimensional variables. How can we draw the image like this? If possible, it is best to provide a specific example. Looking forward to your help. thanks! map

NJC1012 avatar Jun 13 '24 02:06 NJC1012

The input of compressor map is Wc(mass flow corrected), PR(pressure ratio) and efficiency. We need two points to get any point on the map and they could be PR and Wc, but you will get two Wc at one PR. So the concept of Rline was introduced. So we can get any point on map using Rline and Ncline. The third variable is for inlet guide vane angle, so you can input multiple maps for multiple inlet angles.

So three training parametre are Rline, Ncline, alphaline and the trained data are Wc,PR,eff.

You can read the NPSS pdf: https://ntrs.nasa.gov/api/citations/20070018165/downloads/20070018165.pdf to get more info about input format.

arushkumarsingh avatar Jun 13 '24 05:06 arushkumarsingh

You can input any another map from your side, u can call the functions plot_compressor_maps, plot_turbine_maps from viewer.py to plot your maps.

arushkumarsingh avatar Jun 13 '24 05:06 arushkumarsingh

Thank you for your reminder. I already knew the corresponding relationships between the parameters in MAP before, but I didn't see any relevant examples in the viewer.py file, so I don't know how to implement them. If possible, could you provide a specific example of calculating MAP correction for off-design points. I already know the principles and basic concepts, but it is still quite difficult to implement. How can I get in touch with you? Communication is inconvenient here. Thank you!

NJC1012 avatar Jun 13 '24 06:06 NJC1012

You can input any another map from your side, u can call the functions plot_compressor_maps, plot_turbine_maps from viewer.py to plot your maps.

Thank you for your reminder. I already knew the corresponding relationships between the parameters in MAP before, but I didn't see any relevant examples in the viewer.py file, so I don't know how to implement them. If possible, could you provide a specific example of calculating MAP correction for off-design points. I already know the principles and basic concepts, but it is still quite difficult to implement. How can I get in touch with you? Communication is inconvenient here. Thanks!

NJC1012 avatar Jun 13 '24 06:06 NJC1012

Hello NJC1012, straight from file pycycle/viewers.py:

def plot_compressor_maps(prob, element_names, eff_vals=np.array([0,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0]),alphas=[0]):

    for e_name in element_names:
        comp = prob.model._get_subsystem(e_name)
        map_data = comp.options['map_data']

        s_Wc = prob[e_name+'.s_Wc']
        s_PR = prob[e_name+'.s_PR']
        s_eff = prob[e_name+'.s_eff']
        s_Nc = prob[e_name+'.s_Nc']

        RlineMap, NcMap = np.meshgrid(map_data.RlineMap, map_data.NcMap, sparse=False)

        for alpha in alphas:
          scaled_PR = (map_data.PRmap[alpha,:,:] - 1.) * s_PR + 1.

          plt.figure(figsize=(11,8))
          Nc = plt.contour(map_data.WcMap[alpha,:,:]*s_Wc,scaled_PR,NcMap*s_Nc,colors='k',levels=map_data.NcMap*s_Nc)
          R = plt.contour(map_data.WcMap[alpha,:,:]*s_Wc,scaled_PR,RlineMap,colors='k',levels=map_data.RlineMap)
          eff = plt.contourf(map_data.WcMap[alpha,:,:]*s_Wc,scaled_PR,map_data.effMap[alpha,:,:]*s_eff,levels=eff_vals)

          plt.colorbar(eff)

          plt.plot(prob[e_name+'.Wc'], prob[e_name+'.map.scalars.PR'][0], 'ko')

          plt.clabel(Nc, fontsize=9, inline=False)
          plt.clabel(R, fontsize=9, inline=False)
          # plt.clabel(eff, fontsize=9, inline=True)

          plt.xlabel('Wc, lbm/s')
          plt.ylabel('PR')
          plt.title(e_name)
          # plt.show()
          plt.savefig(e_name+'.pdf')

This will generate the figure you posted (for a problem you have defined, of course).

flight-test-engineering avatar Aug 14 '25 23:08 flight-test-engineering