Coverage for rocketisp\geometry.py : 79%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
'''calculates a cylinder volume'''
'''calculates cone frustrum'''
"""If input inches > 12, return string with feet units.""" if val > 12.0: ft = int( val / 12 ) i = val - ft*12.0 s = ' (%g ft %.3f in)'%(ft, i ) else: s = '' return s
""" The Geometry object holds all the major thrust chamber geometry values.
:param Rthrt: in, throat radius :param CR: chamber contraction ratio (Ainj / Athroat) :param eps: nozzle area ratio (Aexit / Athroat) :param pcentBell: nozzle percent bell (Lnoz / L_15deg_cone) :param LnozInp: in, user input nozzle length (will override pcentBell) :param RupThroat: radius of curvature just upstream of throat (Rupstream / Rthrt) :param RdwnThroat: radius of curvature just downstream of throat (Rdownstream / Rthrt) :param RchmConv: radius of curvature at start of convergent section (Rconv / Rthrt) :param cham_conv_deg: deg, half angle of conical convergent section :param LchmOvrDt: ratio of chamber length to throat diameter (Lcham / Dthrt) :param LchmMin: in, minimum chamber length (will override LchmOvrDt) :param LchamberInp: in, user input value of chamber length (will override all other entries) :type Rthrt: float :type CR: float :type eps: float :type pcentBell: float :type LnozInp: float :type RupThroat: float :type RdwnThroat: float :type RchmConv: float :type cham_conv_deg: float :type LchmOvrDt: float :type LchmMin: float :type LchamberInp: float :return: Geometry object :rtype: Geometry
:ivar At: in**2, throat area :ivar Lnoz: in, nozzle length :ivar Ltotal: in, nozzle + chamber length :ivar Rinj: in, radius of injector :ivar Dinj: in, diameter of injector :ivar Ainj: in**2, area of injector :ivar Lcham_cyl: in, length of cylindrical section of chamber :ivar Lcham_conv: in, length of convergent section of chamber :ivar Vcham: in**3, approximate chamber volume """ CR=2.5, eps=20, pcentBell=80, LnozInp=None, RupThroat=1.5, RdwnThroat=1.0, RchmConv=1.0, cham_conv_deg=30, LchmOvrDt=3.0, LchmMin=1.0, LchamberInp=None): """ Initialize thrust chamber geometry """
# get input descriptions and units from doc string
"""Resets Geometry object attribute by name if that attribute already exists.""" else: raise Exception('Attempting to set un-authorized Geometry attribute named "%s"'%name )
""" Uses basic geometry input values to determine derived geometry values. (for example, throat area, nozzle length, injector area, etc.) """
# calc nozzle length else: # calc nozzle pcentBell
# calc injector area else: else:
# estimate chamber volume with simple cylinder and frustrum
"""return chamber length / chamber radius""" return self.Lcham / self.Rinj
"""Create and return a Nozzle object.""" return self.nozObj
Rt=self.Rthrt, Nsegs=30, Rup=self.RupThroat, Rd=self.RdwnThroat, cham_conv_ang=self.cham_conv_deg, Rc=self.RchmConv, theta=None, exitAng=None, forceCone=0, use_huzel_angles=False)
do_show=True, show_grid=True, make_vertical=False):
else: w,h = pixel_wh fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(w/100.0, h/100.0), dpi=100)
zL = [ -(z+self.Lcham) for z in zL ] min_z = min(zL) zL = [z-min_z for z in zL] ax.set_xlim( (-round(noz.abs_rContour[-1]+1), round(noz.abs_rContour[-1]+1)) ) plt.plot( rL, zL, '-k' ) plt.xlabel( 'Radius (in)' ) plt.ylabel( 'Axial Position (in)' ) else:
if not png_name.endswith('.png'): png_name = png_name + '.png' plt.savefig( png_name )
plt.show()
# radii are too big for CR... reduce radii or inc CR print('='*30, ' ERROR ','='*30) print(' Error in Convergent Section... ') print(' Rup, Rchm, CR, cham_conv_deg are INCONSISTENT !!!') print(' (i.e. conical convergent section has length < 0)') print(' decrease (Rup, Rchm) or increase (CR, cham_conv_deg)') print('='*30, ' ERROR ','='*30) raise Exception( 'Geometry Error... RI, RWTU and THETAI are INCONSISTENT' )
self.Lcham_cyl = 0.0 self.Lcham = self.Lcham_conv self.Lcham_desc = '(convergent section limited)'
"""Some attributes may have comments associated with them"""
if name=='Lnoz' and self.LnozInp is not None: return 'set by user with LnozInp'
if name=='pcentBell' and self.LnozInp is not None: return 'calculated from Lnoz=%g in'%self.LnozInp
# if no comment, return empty string return ''
""" print to standard output, the current state of Geometry instance. """
fillchar='.', max_banner=76, intro_str=''): """ return string of the current state of Geometry instance. """ add_trailer=add_trailer, fillchar=fillchar, max_banner=max_banner, intro_str=intro_str)
M = self.get_model_summ_obj() return M.html_table_str( alpha_ordered=alpha_ordered, numbered=numbered, intro_str=intro_str)
""" return ModelSummary object for current state of Geometry instance. """
# function to add parameters from __doc__ string to ModelSummary
else:
# parameters that are NOT attributes
CR=2.5, eps=20, pcentBell=80, LnozInp=18, RupThroat=1.5, RdwnThroat=1.0, RchmConv=1.0, cham_conv_deg=30, LchmOvrDt=3.10, LchmMin=2.0, LchamberInp=None)
#M = geom.get_model_summ_obj() #print( M.summ_str() )
geom.plot_geometry( png_name='geometry.png', do_show=do_show, show_grid=False, make_vertical=True, pixel_wh=(300,400) ) |