Beispiel #1
0
def CoordsOrbScroll(theta, geo, shaveOn=True, just_involutes=False, Ndict={}):

    from PDSim.scroll import scroll_geo

    shaveDelta = None
    if shaveOn == True:
        shaveDelta = pi / 2
    else:
        shaveDelta = 1e-16

    (xshave, yshave) = Shave(geo, theta, shaveDelta)

    Nphi = Ndict.get('phi', 500)
    Narc1 = Ndict.get('arc1', 100)
    Nline = Ndict.get('line', 100)
    Narc2 = Ndict.get('arc2', 100)

    phi = np.linspace(geo.phi_ois, geo.phi_oie, Nphi)
    (x_oi, y_oi) = scroll_geo.coords_inv(phi, geo, theta, flag="oi")
    phi = np.linspace(geo.phi_oos, geo.phi_ooe - shaveDelta, Nphi)
    (x_oo, y_oo) = scroll_geo.coords_inv(phi, geo, theta, flag="oo")

    xarc1 = geo.xa_arc1 + geo.ra_arc1 * cos(
        np.linspace(geo.t2_arc1, geo.t1_arc1, Narc1))
    yarc1 = geo.ya_arc1 + geo.ra_arc1 * sin(
        np.linspace(geo.t2_arc1, geo.t1_arc1, Narc1))
    xline = np.linspace(geo.t1_line, geo.t2_line, Nline)
    yline = geo.m_line * xline + geo.b_line
    xarc2 = geo.xa_arc2 + geo.ra_arc2 * cos(
        np.linspace(geo.t1_arc2, geo.t2_arc2, Narc2))
    yarc2 = geo.ya_arc2 + geo.ra_arc2 * sin(
        np.linspace(geo.t1_arc2, geo.t2_arc2, Narc2))

    ro = geo.rb * (pi - geo.phi_fi0 + geo.phi_fo0)
    om = geo.phi_fie - theta + 3.0 * pi / 2.0
    xarc1_o = -xarc1 + ro * cos(om)
    yarc1_o = -yarc1 + ro * sin(om)
    xline_o = -xline + ro * cos(om)
    yline_o = -yline + ro * sin(om)
    xarc2_o = -xarc2 + ro * cos(om)
    yarc2_o = -yarc2 + ro * sin(om)

    if just_involutes:
        x = np.r_[x_oo, x_oi[::-1]]
        y = np.r_[y_oo, y_oi[::-1]]
    else:
        if shaveOn:
            x = np.r_[x_oo, xshave, x_oi[::-1], xarc1_o, xline_o, xarc2_o]
            y = np.r_[y_oo, yshave, y_oi[::-1], yarc1_o, yline_o, yarc2_o]
        else:
            x = np.r_[x_oo, x_oi[::-1], xarc1_o, xline_o, xarc2_o]
            y = np.r_[y_oo, y_oi[::-1], yarc1_o, yline_o, yarc2_o]

    #Output as a column vector
    x = x.reshape(len(x), 1)
    y = y.reshape(len(y), 1)
    return x, y
Beispiel #2
0
def Shave(geo, theta, shaveDelta):
    from PDSim.scroll import scroll_geo

    phi = np.linspace(geo.phi_ooe - shaveDelta, geo.phi_ooe, 200)
    (xo, yo) = scroll_geo.coords_inv(phi, geo, theta, "oo")
    (xi, yi) = scroll_geo.coords_inv(phi, geo, theta, "oi")

    z = (1 - 0.8 * (phi - (geo.phi_ooe - shaveDelta)) / (shaveDelta))
    xnew = z * xo + (1 - z) * xi
    ynew = z * yo + (1 - z) * yi
    return (xnew, ynew)
Beispiel #3
0
def CoordsOrbScroll(theta,geo,shaveOn=True, just_involutes = False, Ndict = {}):
    
    from PDSim.scroll import scroll_geo
    
    shaveDelta=None
    if shaveOn==True:
        shaveDelta = pi/2
    else:
        shaveDelta = 1e-16
    
    (xshave, yshave) = Shave(geo, theta, shaveDelta)
    
    Nphi = Ndict.get('phi',500)
    Narc1 = Ndict.get('arc1',100)
    Nline = Ndict.get('line',100)
    Narc2 = Ndict.get('arc2',100)
    
    phi = np.linspace(geo.phi_ois, geo.phi_oie, Nphi)
    (x_oi,y_oi) = scroll_geo.coords_inv(phi,geo,theta,flag="oi")
    phi = np.linspace(geo.phi_oos, geo.phi_ooe - shaveDelta, Nphi)
    (x_oo,y_oo) = scroll_geo.coords_inv(phi,geo,theta,flag="oo")
    
    xarc1=geo.xa_arc1+geo.ra_arc1*cos(np.linspace(geo.t2_arc1,geo.t1_arc1,Narc1))
    yarc1=geo.ya_arc1+geo.ra_arc1*sin(np.linspace(geo.t2_arc1,geo.t1_arc1,Narc1))
    xline=np.linspace(geo.t1_line,geo.t2_line,Nline)
    yline=geo.m_line*xline+geo.b_line
    xarc2=geo.xa_arc2+geo.ra_arc2*cos(np.linspace(geo.t1_arc2,geo.t2_arc2,Narc2))
    yarc2=geo.ya_arc2+geo.ra_arc2*sin(np.linspace(geo.t1_arc2,geo.t2_arc2,Narc2))
    
    ro = geo.rb*(pi-geo.phi_fi0+geo.phi_fo0)
    om = geo.phi_fie-theta+3.0*pi/2.0
    xarc1_o=-xarc1+ro*cos(om)
    yarc1_o=-yarc1+ro*sin(om)
    xline_o=-xline+ro*cos(om)
    yline_o=-yline+ro*sin(om)
    xarc2_o=-xarc2+ro*cos(om)
    yarc2_o=-yarc2+ro*sin(om)
    
    if just_involutes:
        x=np.r_[x_oo,x_oi[::-1]]
        y=np.r_[y_oo,y_oi[::-1]]
    else:
        if shaveOn:
            x=np.r_[x_oo,xshave,x_oi[::-1],xarc1_o,xline_o,xarc2_o]
            y=np.r_[y_oo,yshave,y_oi[::-1],yarc1_o,yline_o,yarc2_o]
        else:
            x=np.r_[x_oo,x_oi[::-1],xarc1_o,xline_o,xarc2_o]
            y=np.r_[y_oo,y_oi[::-1],yarc1_o,yline_o,yarc2_o]
            
    
    #Output as a column vector
    x=x.reshape(len(x),1)
    y=y.reshape(len(y),1)
    return x,y
Beispiel #4
0
def Shave(geo,theta,shaveDelta):
    from PDSim.scroll import scroll_geo
    
    phi=np.linspace(geo.phi_ooe-shaveDelta,geo.phi_ooe,200)
    (xo,yo)=scroll_geo.coords_inv(phi,geo,theta,"oo")
    (xi,yi)=scroll_geo.coords_inv(phi,geo,theta,"oi")
    
    z=(1-0.8*(phi-(geo.phi_ooe-shaveDelta))/(shaveDelta))
    xnew=z*xo+(1-z)*xi
    ynew=z*yo+(1-z)*yi
    return (xnew,ynew)
Beispiel #5
0
def plotScrollSet(theta,
                  geo=None,
                  axis=None,
                  fig=None,
                  lw=None,
                  OSColor=None,
                  show=False,
                  offsetScroll=False,
                  **kwargs):
    """
    The function that plots the scroll sets

    Arguments:
        theta : float
            Crank angle in radians in the range 0 to :math:`2\pi`
            

    Returns:
        OS : matplotlib polygon object for the orbiting scroll

    Optional Parameters
    
    =============    =====================================================
    Variable         Description
    =============    =====================================================
    fig              figure to plot on : default, make new figure
    axis             axis to plot on : default pylab.gca()
    geo              geoVals class with geometric parameters
    discOn           plot the discharge port: True/[False]
    OSColor          color of orbiting scroll: default 'r'
    lw               line width : default 1.0
    discCurves       plot the discharge curves : True/[False]
    shaveOn          shave the end of orb. scroll : True/[False]
    saveCoords       save the coord. of the orb. scroll to file True/[False]
    wallOn           plot the outer wall : [True] /False
    offsetScroll     If true, scrolls are offset : True/[False]
    =============    =====================================================
        

    """
    from PDSim.scroll import scroll_geo

    if axis is None:
        if fig is None:
            fig = pylab.figure(figsize=(5, 5))
        axis = fig.add_axes((0, 0, 1, 1))

    if geo is None:
        geo = geoVals(rb=0.003522,
                      phi_i0=0.19829,
                      phi_is=4.7,
                      phi_ie=15.5,
                      phi_o0=-1.1248,
                      phi_os=1.8,
                      phi_oe=15.5,
                      h=0.03289)
        setDiscGeo(geo)

    if OSColor is not None:
        OSColor = kwargs['OSColor']
    else:
        OSColor = 'r'

    if lw is None:
        lw = 1.0

    if offsetScroll:
        #Turn off the conventional wall
        kwargs['wallOn'] = False
        #Turn off shaving of the orbiting scroll
        kwargs['shaveOn'] = False

        #        # This is the part of the fixed scroll forming the extension for
        #        # the offset scroll pocket
        #        phi  = np.linspace(geo.phi_fie, geo.phi_fie+geo.phi_ie_offset,1000)
        #        x,y = scroll_geo.coords_inv(phi, geo, 0.0, 'fi')
        #        axis.plot(x,y,'k')
        #        phi  = np.linspace(geo.phi_ie,geo.phi_ie+1.02*pi,1000)
        #        x,y = coords_inv(phi,geo,theta,'oo')
        #        axis.plot(x,y,'r--')

        #         pitch (involute-involute distance for a given involute)
        #         for 2*pi radians or one rotation is equal to 2*pi*rb, subtract
        #         thickness of scroll to get diameter
        #         and divide by two to get radius of closing arc for offset region
        r = (2 * pi * geo.rb - geo.t) / 2.0

        xee, yee = scroll_geo.coords_inv(geo.phi_fie, geo, 0.0, 'fi')
        xse, yse = scroll_geo.coords_inv(geo.phi_foe - 2 * pi, geo, 0.0, 'fo')
        x0, y0 = (xee + xse) / 2, (yee + yse) / 2

        beta = math.atan2(yee - y0, xee - x0)
        t = np.linspace(beta, beta + pi, 1000)
        x, y = x0 + r * np.cos(t), y0 + r * np.sin(t)
        axis.plot(x, y, 'k', lw=lw)
        axis.plot([x[0], x[-1]], [y[0], y[-1]], 'b-')

    xarc1 = geo.xa_arc1 + geo.ra_arc1 * cos(
        np.linspace(geo.t2_arc1, geo.t1_arc1, 100))
    yarc1 = geo.ya_arc1 + geo.ra_arc1 * sin(
        np.linspace(geo.t2_arc1, geo.t1_arc1, 100))
    xline = np.linspace(geo.t1_line, geo.t2_line, 100)
    yline = geo.m_line * xline + geo.b_line
    xarc2 = geo.xa_arc2 + geo.ra_arc2 * cos(
        np.linspace(geo.t1_arc2, geo.t2_arc2, 100))
    yarc2 = geo.ya_arc2 + geo.ra_arc2 * sin(
        np.linspace(geo.t1_arc2, geo.t2_arc2, 100))

    ##Fixed Scroll
    phi = np.linspace(geo.phi_fis, geo.phi_fie, 500)
    (x_fi, y_fi) = scroll_geo.coords_inv(phi, geo, theta, flag="fi")
    phi = np.linspace(geo.phi_fos, geo.phi_foe, 500)
    (x_fo, y_fo) = scroll_geo.coords_inv(phi, geo, theta, flag="fo")

    ## Discharge port
    if 'discOn' in kwargs and kwargs['discOn'] == True:
        t = np.linspace(0, 2 * pi, 100)
        x = geo.disc_x0 + geo.disc_R * cos(t)
        y = geo.disc_y0 + geo.disc_R * sin(t)
        axis.plot(x, y, 'k--', lw=lw, zorder=0)

    if 'discCurves' in kwargs and kwargs['discCurves'] == True:
        (x_fis, y_fis) = coords_inv(geo.phi_os + pi, geo, theta, flag="fi")
        (nx_fis, ny_fis) = coords_norm(geo.phi_os + pi, geo, theta, flag="fi")
        x0 = x_fis - nx_fis * geo.ro
        y0 = y_fis - ny_fis * geo.ro
        axis.plot(x0, y0, 'o')
        axis.plot(x_fis, y_fis, 's')
        t = np.linspace(0, 2 * pi, 200)
        axis.plot(x0 + geo.ro * cos(t), y0 + geo.ro * sin(t), '-')
        axis.plot(geo.xa_arc1, geo.ya_arc1, '^')
        axis.plot(geo.xa_arc1 + geo.ra_arc1 * cos(t),
                  geo.ya_arc1 + geo.ra_arc1 * sin(t), 'k--')

    if 'wallOn' not in kwargs or kwargs['wallOn']:
        ## Outer Wall
        (x_wall, y_wall) = circle(geo.x0_wall, geo.y0_wall, geo.r_wall, N=200)
        axis.plot(x_wall, y_wall, 'k', lw=lw)
        axis.set_xlim([min(x_wall) - 0.001, max(x_wall) + 0.001])
        axis.set_ylim([min(y_wall) - 0.001, max(y_wall) + 0.001])

    axis.plot(np.r_[xarc1, xline, xarc2],
              np.r_[yarc1, yline, yarc2],
              'k',
              lw=lw)
    axis.plot(x_fi, y_fi, 'k', lw=lw)
    axis.plot(x_fo, y_fo, 'k', lw=lw)
    axis.plot(np.r_[x_fo[-1], x_fi[-1]], np.r_[y_fo[-1], y_fi[-1]], 'k', lw=lw)

    shaveOn = None
    if 'shaveOn' in kwargs and kwargs['shaveOn'] == False:
        shaveOn = False
    else:
        shaveOn = True

    ##Orbiting Scroll
    (XOS, YOS) = CoordsOrbScroll(theta, geo, shaveOn)
    xy = np.hstack((XOS, YOS))
    OrbScroll = pyplot.Polygon(xy,
                               color=OSColor,
                               lw=lw,
                               fill=True,
                               closed=True,
                               ec='k')
    axis.add_patch(OrbScroll)

    axis.set_aspect(1.0)
    axis.axis('off')

    if 'saveCoords' in kwargs:
        np.savetxt('xos.csv', XOS, delimiter=',')
        np.savetxt('yos.csv', YOS, delimiter=',')

    if show:
        pylab.show()

    return OrbScroll
Beispiel #6
0
def plotScrollSet(theta,geo = None,axis = None, fig = None, lw = None, OSColor = None, show = False, offsetScroll = False, **kwargs):
    """
    The function that plots the scroll sets

    Arguments:
        theta : float
            Crank angle in radians in the range 0 to :math:`2\pi`
            

    Returns:
        OS : matplotlib polygon object for the orbiting scroll

    Optional Parameters
    
    =============    =====================================================
    Variable         Description
    =============    =====================================================
    fig              figure to plot on : default, make new figure
    axis             axis to plot on : default pylab.gca()
    geo              geoVals class with geometric parameters
    discOn           plot the discharge port: True/[False]
    OSColor          color of orbiting scroll: default 'r'
    lw               line width : default 1.0
    discCurves       plot the discharge curves : True/[False]
    shaveOn          shave the end of orb. scroll : True/[False]
    saveCoords       save the coord. of the orb. scroll to file True/[False]
    wallOn           plot the outer wall : [True] /False
    offsetScroll     If true, scrolls are offset : True/[False]
    =============    =====================================================
        

    """
    from PDSim.scroll import scroll_geo

    if axis is None:
        if fig is None:
            fig=pylab.figure(figsize=(5,5))
        axis=fig.add_axes((0,0,1,1))
        
    if geo is None:
        geo=geoVals(rb=0.003522,phi_i0=0.19829,phi_is=4.7,phi_ie=15.5,phi_o0=-1.1248,phi_os=1.8,phi_oe=15.5,h=0.03289)
        setDiscGeo(geo)
        
    if OSColor is not None:
        OSColor=kwargs['OSColor']
    else:
        OSColor='r'
        
    if lw is None:
        lw=1.0
        
    if offsetScroll:
        #Turn off the conventional wall
        kwargs['wallOn'] = False
        #Turn off shaving of the orbiting scroll
        kwargs['shaveOn'] = False
        
#        # This is the part of the fixed scroll forming the extension for
#        # the offset scroll pocket
#        phi  = np.linspace(geo.phi_fie, geo.phi_fie+geo.phi_ie_offset,1000)
#        x,y = scroll_geo.coords_inv(phi, geo, 0.0, 'fi')
#        axis.plot(x,y,'k')
#        phi  = np.linspace(geo.phi_ie,geo.phi_ie+1.02*pi,1000)
#        x,y = coords_inv(phi,geo,theta,'oo')
#        axis.plot(x,y,'r--')
        
#         pitch (involute-involute distance for a given involute) 
#         for 2*pi radians or one rotation is equal to 2*pi*rb, subtract 
#         thickness of scroll to get diameter
#         and divide by two to get radius of closing arc for offset region
        r = (2*pi*geo.rb-geo.t)/2.0
        
        xee,yee = scroll_geo.coords_inv(geo.phi_fie,geo,0.0,'fi')
        xse,yse = scroll_geo.coords_inv(geo.phi_foe-2*pi,geo,0.0,'fo')
        x0,y0 = (xee+xse)/2,(yee+yse)/2

        beta = math.atan2(yee-y0,xee-x0)
        t = np.linspace(beta,beta+pi,1000)
        x,y = x0+r*np.cos(t),y0+r*np.sin(t)
        axis.plot(x,y,'k',lw=lw)
        axis.plot([x[0],x[-1]],[y[0],y[-1]],'b-')
    
    xarc1=geo.xa_arc1+geo.ra_arc1*cos(np.linspace(geo.t2_arc1,geo.t1_arc1,100))
    yarc1=geo.ya_arc1+geo.ra_arc1*sin(np.linspace(geo.t2_arc1,geo.t1_arc1,100))
    xline=np.linspace(geo.t1_line,geo.t2_line,100)
    yline=geo.m_line*xline+geo.b_line
    xarc2=geo.xa_arc2+geo.ra_arc2*cos(np.linspace(geo.t1_arc2,geo.t2_arc2,100))
    yarc2=geo.ya_arc2+geo.ra_arc2*sin(np.linspace(geo.t1_arc2,geo.t2_arc2,100))
    
    ro=geo.rb*(pi-geo.phi_fi0+geo.phi_fo0)
    om=geo.phi_fie-theta+3.0*pi/2.0
    xarc1_o=-xarc1+ro*cos(om)
    yarc1_o=-yarc1+ro*sin(om)
    xline_o=-xline+ro*cos(om)
    yline_o=-yline+ro*sin(om)
    xarc2_o=-xarc2+ro*cos(om)
    yarc2_o=-yarc2+ro*sin(om)
    
    ##Fixed Scroll
    phi=np.linspace(geo.phi_fis,geo.phi_fie,500)
    (x_fi,y_fi)=scroll_geo.coords_inv(phi,geo,theta,flag="fi")
    phi=np.linspace(geo.phi_fos,geo.phi_foe,500)
    (x_fo,y_fo)=scroll_geo.coords_inv(phi,geo,theta,flag="fo")
    
    ## Discharge port
    if 'discOn' in kwargs and kwargs['discOn']==True:
        t=np.linspace(0,2*pi,100)
        x=geo.disc_x0+geo.disc_R*cos(t)
        y=geo.disc_y0+geo.disc_R*sin(t)
        axis.plot(x,y,'k--',lw=lw,zorder=0)
    
    if 'discCurves' in kwargs and kwargs['discCurves']==True:
        (x_fis,y_fis)=coords_inv(geo.phi_os+pi,geo,theta,flag="fi")
        (nx_fis,ny_fis)=coords_norm(geo.phi_os+pi,geo,theta,flag="fi")
        x0=x_fis-nx_fis*geo.ro
        y0=y_fis-ny_fis*geo.ro
        axis.plot(x0,y0,'o')
        axis.plot(x_fis,y_fis,'s')
        t=np.linspace(0,2*pi,200)
        axis.plot(x0+geo.ro*cos(t),y0+geo.ro*sin(t),'-')
        axis.plot(geo.xa_arc1,geo.ya_arc1,'^')
        axis.plot(geo.xa_arc1+geo.ra_arc1*cos(t),geo.ya_arc1+geo.ra_arc1*sin(t),'k--')
    
    if 'wallOn' not in kwargs or kwargs['wallOn']:
        ## Outer Wall
        (x_wall,y_wall)=circle(geo.x0_wall,geo.y0_wall,geo.r_wall,N=200)
        axis.plot(x_wall,y_wall,'k',lw=lw)
        axis.set_xlim([min(x_wall)-0.001,max(x_wall)+0.001])
        axis.set_ylim([min(y_wall)-0.001,max(y_wall)+0.001])
    
    axis.plot(np.r_[xarc1,xline,xarc2],np.r_[yarc1,yline,yarc2],'k',lw=lw)
    axis.plot(x_fi,y_fi,'k',lw=lw)
    axis.plot(x_fo,y_fo,'k',lw=lw)
    axis.plot(np.r_[x_fo[-1],x_fi[-1]],np.r_[y_fo[-1],y_fi[-1]],'k',lw=lw)
    
    shaveOn=None
    if 'shaveOn' in kwargs and kwargs['shaveOn']==False:
        shaveOn=False
    else:
        shaveOn=True
    
    ##Orbiting Scroll
    (XOS,YOS)=CoordsOrbScroll(theta,geo,shaveOn)
    xy=np.hstack((XOS,YOS))
    OrbScroll=pyplot.Polygon(xy,color=OSColor,lw=lw,fill=True,closed=True,ec='k')
    axis.add_patch(OrbScroll)
    
    axis.set_aspect(1.0)
    axis.axis('off')
    
    if 'saveCoords' in kwargs:
        np.savetxt('xos.csv',XOS,delimiter=',')
        np.savetxt('yos.csv',YOS,delimiter=',')
    
    if show:
        pylab.show()
        
    return OrbScroll