def overlay_injection_port(theta, geo, phi, ax, inner_outer, rport=None, offset=None): """ Plot the injection ports on an axis - no scroll wrap plot is generated. Also see plot_injection_ports() Parameters ---------- theta : float crank angle in the range [0, :math:`2\pi`] geo : geoVals instance phi : float Involute angle in radians ax : matplotlib axis instance inner_outer : string If ``'i'``, phi is along the inner involute of the fixed scroll If ``'o'``, phi is along the outer involute of the fixed scroll Notes ----- If you want symmetric injection ports, the ones on the inner involute should have a value of phi that is pi radians greater than those on the outer involute """ #Common terms if rport is None: rport = geo.t / 2.0 if offset is None: offset = rport / 2.0 t = np.linspace(0, 2 * pi, 100) if inner_outer == 'o': #Involute angle along the outer involute of the scroll wrap x, y = common_scroll_geo.coords_inv(phi, geo, theta, 'fo') nx, ny = common_scroll_geo.coords_norm(phi, geo, theta, 'fo') xc, yc = x - nx * offset, y - ny * offset ax.plot(xc + rport * np.cos(t), yc + rport * np.sin(t), 'k') elif inner_outer == 'i': x, y = common_scroll_geo.coords_inv(phi, geo, theta, 'fi') nx, ny = common_scroll_geo.coords_norm(phi, geo, theta, 'fi') xc, yc = x - nx * offset, y - ny * offset ax.plot(xc + rport * np.cos(t), yc + rport * np.sin(t), 'k') else: raise KeyError
def fillS1(theta, **kwargs): if 'axis' in kwargs: axis = kwargs['axis'] else: axis = pylab.gca() if 'color' in kwargs: color = kwargs['color'] else: color = 'b' geo = LoadGeo() phi = np.linspace(geo.phi_oe, geo.phi_oe - theta, 500) (x_oi, y_oi) = coords_inv(phi, geo, theta, flag="oi") phi = np.linspace(geo.phi_oe - pi, geo.phi_oe - pi - theta, 500) (x_fo, y_fo) = coords_inv(phi, geo, theta, flag="fo") x = np.r_[x_oi, x_fo[::-1]] y = np.r_[y_oi, y_fo[::-1]] axis.fill(x, y, color=color) return polyarea(x, y) * geo.h
def setDiscGeo(geo, Type='Sanden', r2=0.001, **kwargs): """ Sets the discharge geometry for the compressor based on the arguments. Also sets the radius of the wall that contains the scroll set Arguments: geo : geoVals class class containing the scroll compressor geometry Type : string Type of discharge geometry, options are ['Sanden'],'2Arc','ArcLineArc' r2 : float or string Either the radius of the smaller arc as a float or 'PMP' for perfect meshing If Type is 'Sanden', this value is ignored Keyword Arguments: ======== ====================================================================== Value Description ======== ====================================================================== r1 the radius of the large arc for the arc-line-arc solution type ======== ====================================================================== """ #Recalculate the orbiting radius geo.ro = geo.rb * (pi - geo.phi_i0 + geo.phi_o0) if Type == 'Sanden': geo.x0_wall = 0.0 geo.y0_wall = 0.0 geo.r_wall = 0.065 setDiscGeo(geo, Type='ArcLineArc', r2=0.003178893902, r1=0.008796248080) elif Type == '2Arc': (x_is, y_is) = common_scroll_geo.coords_inv(geo.phi_is, geo, 0, 'fi') (x_os, y_os) = common_scroll_geo.coords_inv(geo.phi_os, geo, 0, 'fo') (nx_is, ny_is) = common_scroll_geo.coords_norm(geo.phi_is, geo, 0, 'fi') (nx_os, ny_os) = common_scroll_geo.coords_norm(geo.phi_os, geo, 0, 'fo') dx = x_is - x_os dy = y_is - y_os r2max = 0 a = cos(geo.phi_os - geo.phi_is) + 1.0 b = geo.ro * a - dx * (sin(geo.phi_os) - sin(geo.phi_is)) + dy * ( cos(geo.phi_os) - cos(geo.phi_is)) c = 1.0 / 2.0 * (2.0 * dx * sin(geo.phi_is) * geo.ro - 2.0 * dy * cos(geo.phi_is) * geo.ro - dy**2 - dx**2) if abs((geo.phi_os + pi) - geo.phi_is) < 1e-8: r2max = -c / b elif geo.phi_os - (geo.phi_is - pi) > 1e-12: r2max = (-b + sqrt(b**2 - 4.0 * a * c)) / (2.0 * a) else: print('error with starting angles phi_os %.16f phi_is-pi %.16f' % (geo.phi_os, geo.phi_is - pi)) if type(r2) is not float and r2 == 'PMP': r2 = r2max if r2 > r2max: print('r2 is too large, max value is : %0.5f' % (r2max)) xarc2 = x_os + nx_os * r2 yarc2 = y_os + ny_os * r2 r1 = ((1.0 / 2 * dy**2 + 1.0 / 2 * dx**2 + r2 * dx * sin(geo.phi_os) - r2 * dy * cos(geo.phi_os)) / (r2 * cos(geo.phi_os - geo.phi_is) + dx * sin(geo.phi_is) - dy * cos(geo.phi_is) + r2)) ## Negative sign since you want the outward pointing unit normal vector xarc1 = x_is - nx_is * r1 yarc1 = y_is - ny_is * r1 geo.xa_arc2 = xarc2 geo.ya_arc2 = yarc2 geo.ra_arc2 = r2 geo.t1_arc2 = math.atan2(yarc1 - yarc2, xarc1 - xarc2) geo.t2_arc2 = math.atan2(y_os - yarc2, x_os - xarc2) while geo.t2_arc2 < geo.t1_arc2: geo.t2_arc2 = geo.t2_arc2 + 2.0 * pi geo.xa_arc1 = xarc1 geo.ya_arc1 = yarc1 geo.ra_arc1 = r1 geo.t2_arc1 = math.atan2(y_is - yarc1, x_is - xarc1) geo.t1_arc1 = math.atan2(yarc2 - yarc1, xarc2 - xarc1) while geo.t2_arc1 < geo.t1_arc1: geo.t2_arc1 = geo.t2_arc1 + 2.0 * pi """ line given by y=m*t+b with one element at the intersection point with b=0, m=y/t """ geo.b_line = 0.0 geo.t1_line = xarc2 + r2 * cos(geo.t1_arc2) geo.t2_line = geo.t1_line geo.m_line = (yarc2 + r2 * sin(geo.t1_arc2)) / geo.t1_line """ Fit the wall to the chamber """ geo.x0_wall = geo.ro / 2.0 * cos(geo.phi_ie - pi / 2 - pi) geo.y0_wall = geo.ro / 2.0 * sin(geo.phi_ie - pi / 2 - pi) (x, y) = common_scroll_geo.coords_inv(geo.phi_ie, geo, pi, 'fo') geo.r_wall = 1.03 * sqrt((geo.x0_wall - x)**2 + (geo.y0_wall - y)**2) elif Type == 'ArcLineArc': (x_is, y_is) = common_scroll_geo.coords_inv(geo.phi_is, geo, 0, 'fi') (x_os, y_os) = common_scroll_geo.coords_inv(geo.phi_os, geo, 0, 'fo') (nx_is, ny_is) = common_scroll_geo.coords_norm(geo.phi_is, geo, 0, 'fi') (nx_os, ny_os) = common_scroll_geo.coords_norm(geo.phi_os, geo, 0, 'fo') dx = x_is - x_os dy = y_is - y_os r2max = 0 a = cos(geo.phi_os - geo.phi_is) + 1.0 b = geo.ro * a - dx * (sin(geo.phi_os) - sin(geo.phi_is)) + dy * ( cos(geo.phi_os) - cos(geo.phi_is)) c = 1.0 / 2.0 * (2.0 * dx * sin(geo.phi_is) * geo.ro - 2.0 * dy * cos(geo.phi_is) * geo.ro - dy**2 - dx**2) if geo.phi_os - (geo.phi_is - pi) > 1e-12: r2max = (-b + sqrt(b**2 - 4.0 * a * c)) / (2.0 * a) elif geo.phi_os - (geo.phi_is - pi) < 1e-12: r2max = -c / b else: print('error with starting angles phi_os %.16f phi_is-pi %.16f' % (geo.phi_os, geo.phi_is - pi)) if type(r2) is not float and r2 == 'PMP': r2 = r2max if r2 > r2max: print('r2 is too large, max value is : %0.5f' % (r2max)) xarc2 = x_os + nx_os * r2 yarc2 = y_os + ny_os * r2 if 'r1' not in kwargs: r1 = r2 + geo.ro else: r1 = kwargs['r1'] ## Negative sign since you want the outward pointing unit normal vector xarc1 = x_is - nx_is * r1 yarc1 = y_is - ny_is * r1 geo.xa_arc2 = xarc2 geo.ya_arc2 = yarc2 geo.ra_arc2 = r2 geo.t2_arc2 = math.atan2(y_os - yarc2, x_os - xarc2) geo.xa_arc1 = xarc1 geo.ya_arc1 = yarc1 geo.ra_arc1 = r1 geo.t2_arc1 = math.atan2(y_is - yarc1, x_is - xarc1) alpha = math.atan2(yarc2 - yarc1, xarc2 - xarc1) d = sqrt((yarc2 - yarc1)**2 + (xarc2 - xarc1)**2) beta = math.acos((r1 + r2) / d) L = sqrt(d**2 - (r1 + r2)**2) t1 = alpha + beta (xint, yint) = (xarc1 + r1 * cos(t1) + L * sin(t1), yarc1 + r1 * sin(t1) - L * cos(t1)) t2 = math.atan2(yint - yarc2, xint - xarc2) geo.t1_arc1 = t1 # (geo.t1_arc1,geo.t2_arc1)=sortAnglesCW(geo.t1_arc1,geo.t2_arc1) geo.t1_arc2 = t2 # (geo.t1_arc2,geo.t2_arc2)=sortAnglesCCW(geo.t1_arc2,geo.t2_arc2) while geo.t2_arc2 < geo.t1_arc2: geo.t2_arc2 = geo.t2_arc2 + 2.0 * pi while geo.t2_arc1 < geo.t1_arc1: geo.t2_arc1 = geo.t2_arc1 + 2.0 * pi """ line given by y=m*t+b with one element at the intersection point with b=0, m=y/t """ geo.m_line = -1 / tan(t1) geo.t1_line = xarc1 + r1 * cos(geo.t1_arc1) geo.t2_line = xarc2 + r2 * cos(geo.t1_arc2) geo.b_line = yarc1 + r1 * sin(t1) - geo.m_line * geo.t1_line """ Fit the wall to the chamber """ geo.x0_wall = geo.ro / 2.0 * cos(geo.phi_ie - pi / 2 - pi) geo.y0_wall = geo.ro / 2.0 * sin(geo.phi_ie - pi / 2 - pi) (x, y) = common_scroll_geo.coords_inv(geo.phi_ie, geo, pi, 'fo') geo.r_wall = 1.03 * sqrt((geo.x0_wall - x)**2 + (geo.y0_wall - y)**2) # f=pylab.Figure # pylab.plot(x_os,y_os,'o') # x=geo.xa_arc1+geo.ra_arc1*cos(np.linspace(geo.t1_arc1,geo.t2_arc1,100)) # y=geo.ya_arc1+geo.ra_arc1*sin(np.linspace(geo.t1_arc1,geo.t2_arc1,100)) # pylab.plot(x,y) # x=geo.xa_arc2+geo.ra_arc2*cos(np.linspace(geo.t1_arc2,geo.t2_arc2,100)) # y=geo.ya_arc2+geo.ra_arc2*sin(np.linspace(geo.t1_arc2,geo.t2_arc2,100)) # pylab.plot(x,y) # x=np.linspace(geo.t1_line,geo.t2_line,100) # y=geo.m_line*x+geo.b_line # pylab.plot(x,y) # pylab.plot(xint,yint,'^') # pylab.show() else: print('Type not understood:', Type)
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
def OverlayCVLabels(theta, **kwargs): fs = 0 if 'fs' in kwargs: fs = kwargs['fs'] else: fs = 12 if 'CVList' in kwargs: CVList = kwargs['CVList'] else: CVList = ['s1', 's2', 'c1', 'c2', 'd1', 'd2'] if 'CVNames' in kwargs: CVNames = kwargs['CVNames'] axis = kwargs['axis'] geo = LoadGeo() if 's1' in CVList: if not 'CVNames' in kwargs: label = '$s_1$' else: label = CVNames[CVList.index('s1')] phi = np.linspace(geo.phi_ie, geo.phi_ie - theta, 100) (x_fi, y_fi) = coords_inv(phi, geo, theta, flag="fi") phi = np.linspace(geo.phi_oe - pi, geo.phi_ie - pi - theta, 100) (x_oo, y_oo) = coords_inv(phi, geo, theta, flag="oo") x = np.r_[x_fi, x_oo[::-1], (x_fi[0] + x_oo[0]) / 2.0] y = np.r_[y_fi, y_oo[::-1], (y_fi[0] + y_oo[0]) / 2.0] (xc, yc) = MaxIncircle(x, y, 100) axis.text(xc, yc, label, ha='center', va='center', size=fs) if 's2' in CVList: if not 'CVNames' in kwargs: label = '$s_2$' else: label = CVNames[CVList.index('s2')] phi = np.linspace(geo.phi_ie, geo.phi_ie - theta, 100) (x_fi, y_fi) = coords_inv(phi, geo, theta, flag="oi") phi = np.linspace(geo.phi_oe - pi, geo.phi_ie - pi - theta, 100) (x_oo, y_oo) = coords_inv(phi, geo, theta, flag="fo") x = np.r_[x_fi, x_oo[::-1], (x_fi[0] + x_oo[0]) / 2.0] y = np.r_[y_fi, y_oo[::-1], (y_fi[0] + y_oo[0]) / 2.0] (xc, yc) = MaxIncircle(x, y, 100) axis.text(xc, yc, label, ha='center', va='center', size=fs) if theta < theta_d(): if 'c2' in CVList: if not 'CVNames' in kwargs: label = '$c_2$' else: label = CVNames[CVList.index('c2')] phi = np.linspace(geo.phi_oe - (theta), geo.phi_oe - theta - 2 * pi, 100) (x_oi, y_oi) = coords_inv(phi, geo, theta, flag="oi") phi = np.linspace(geo.phi_oe - (theta) - pi, geo.phi_oe - pi - theta - 2 * pi, 100) (x_fo, y_fo) = coords_inv(phi, geo, theta, flag="fo") x = np.r_[x_oi, x_fo[::-1]] y = np.r_[y_oi, y_fo[::-1]] (xc, yc) = MaxIncircle(x, y, 100) axis.text(xc, yc, label, ha='center', va='center', size=fs) if 'c1' in CVList: if not 'CVNames' in kwargs: label = '$c_1$' else: label = CVNames[CVList.index('c1')] phi = np.linspace(geo.phi_oe - (theta), geo.phi_oe - theta - 2 * pi, 100) (x_oi, y_oi) = coords_inv(phi, geo, theta, flag="fi") phi = np.linspace(geo.phi_oe - (theta) - pi, geo.phi_oe - pi - theta - 2 * pi, 100) (x_fo, y_fo) = coords_inv(phi, geo, theta, flag="oo") x = np.r_[x_oi, x_fo[::-1]] y = np.r_[y_oi, y_fo[::-1]] (xc, yc) = MaxIncircle(x, y, 100) axis.text(xc, yc, label, ha='center', va='center', size=fs) else: if 'd2' in CVList: if not 'CVNames' in kwargs: label = '$d_2$' else: label = CVNames[CVList.index('d2')] phi = np.linspace(geo.phi_oe - (theta), geo.phi_oe - theta - 2 * pi, 100) (x_oi, y_oi) = coords_inv(phi, geo, theta, flag="oi") phi = np.linspace(geo.phi_oe - (theta) - pi, geo.phi_oe - pi - theta - 2 * pi, 100) (x_fo, y_fo) = coords_inv(phi, geo, theta, flag="fo") x = np.r_[x_oi, x_fo[::-1]] y = np.r_[y_oi, y_fo[::-1]] (xc, yc) = MaxIncircle(x, y, 100) axis.text(xc, yc, label, ha='center', va='center', size=fs) if 'd1' in CVList: if not 'CVNames' in kwargs: label = '$d_1$' else: label = CVNames[CVList.index('d1')] phi = np.linspace(geo.phi_oe - (theta), geo.phi_oe - theta - 2 * pi, 100) (x_oi, y_oi) = coords_inv(phi, geo, theta, flag="fi") phi = np.linspace(geo.phi_oe - (theta) - pi, geo.phi_oe - pi - theta - 2 * pi, 100) (x_fo, y_fo) = coords_inv(phi, geo, theta, flag="oo") x = np.r_[x_oi, x_fo[::-1]] y = np.r_[y_oi, y_fo[::-1]] (xc, yc) = MaxIncircle(x, y, 100) axis.text(xc, yc, label, ha='center', va='center', size=fs) if 'dd' in CVList: if not 'CVNames' in kwargs: label = '$dd$' else: label = CVNames[CVList.index('dd')] (x1, y1) = (geo.t2_line, geo.m_line * geo.t2_line + geo.b_line) (x2, y2) = (-geo.t2_line + geo.ro * cos(geo.phi_ie - pi / 2 - theta), -(geo.m_line * geo.t2_line + geo.b_line) + geo.ro * sin(geo.phi_ie - pi / 2 - theta)) axis.text(0.5 * x1 + 0.5 * x2, 0.5 * y1 + 0.5 * y2, label, ha='center', va='center', size=fs) if 'ddd' in CVList: if not 'CVNames' in kwargs: label = '$ddd$' else: label = CVNames[CVList.index('ddd')] (x1, y1) = (geo.t2_line, geo.m_line * geo.t2_line + geo.b_line) (x2, y2) = (-geo.t2_line + geo.ro * cos(geo.phi_ie - pi / 2 - theta), -(geo.m_line * geo.t2_line + geo.b_line) + geo.ro * sin(geo.phi_ie - pi / 2 - theta)) axis.text(0.5 * x1 + 0.5 * x2, 0.5 * y1 + 0.5 * y2, label, ha='center', va='center', size=fs, color='k', bbox=dict(facecolor='white', alpha=0.5, boxstyle="round"))
def setDiscGeo(geo,Type='Sanden',r2=0.001,**kwargs): """ Sets the discharge geometry for the compressor based on the arguments. Also sets the radius of the wall that contains the scroll set Arguments: geo : geoVals class class containing the scroll compressor geometry Type : string Type of discharge geometry, options are ['Sanden'],'2Arc','ArcLineArc' r2 : float or string Either the radius of the smaller arc as a float or 'PMP' for perfect meshing If Type is 'Sanden', this value is ignored Keyword Arguments: ======== ====================================================================== Value Description ======== ====================================================================== r1 the radius of the large arc for the arc-line-arc solution type ======== ====================================================================== """ #Recalculate the orbiting radius geo.ro=geo.rb*(pi-geo.phi_i0+geo.phi_o0) if Type == 'Sanden': geo.x0_wall=0.0 geo.y0_wall=0.0 geo.r_wall=0.065 setDiscGeo(geo,Type='ArcLineArc',r2=0.003178893902,r1=0.008796248080) elif Type == '2Arc': (x_is,y_is) = common_scroll_geo.coords_inv(geo.phi_is,geo,0,'fi') (x_os,y_os) = common_scroll_geo.coords_inv(geo.phi_os,geo,0,'fo') (nx_is,ny_is) = common_scroll_geo.coords_norm(geo.phi_is,geo,0,'fi') (nx_os,ny_os) = common_scroll_geo.coords_norm(geo.phi_os,geo,0,'fo') dx=x_is-x_os dy=y_is-y_os r2max=0 a=cos(geo.phi_os-geo.phi_is)+1.0 b=geo.ro*a-dx*(sin(geo.phi_os)-sin(geo.phi_is))+dy*(cos(geo.phi_os)-cos(geo.phi_is)) c=1.0/2.0*(2.0*dx*sin(geo.phi_is)*geo.ro-2.0*dy*cos(geo.phi_is)*geo.ro-dy**2-dx**2) if abs((geo.phi_os+pi)-geo.phi_is) < 1e-8: r2max=-c/b elif geo.phi_os-(geo.phi_is-pi)>1e-12: r2max=(-b+sqrt(b**2-4.0*a*c))/(2.0*a) else: print('error with starting angles phi_os %.16f phi_is-pi %.16f' %(geo.phi_os,geo.phi_is-pi)) if type(r2) is not float and r2=='PMP': r2=r2max if r2>r2max: print('r2 is too large, max value is : %0.5f' %(r2max)) xarc2 = x_os+nx_os*r2 yarc2 = y_os+ny_os*r2 r1=((1.0/2*dy**2+1.0/2*dx**2+r2*dx*sin(geo.phi_os)-r2*dy*cos(geo.phi_os)) /(r2*cos(geo.phi_os-geo.phi_is)+dx*sin(geo.phi_is)-dy*cos(geo.phi_is)+r2)) ## Negative sign since you want the outward pointing unit normal vector xarc1 = x_is-nx_is*r1 yarc1 = y_is-ny_is*r1 geo.xa_arc2=xarc2 geo.ya_arc2=yarc2 geo.ra_arc2=r2 geo.t1_arc2=math.atan2(yarc1-yarc2,xarc1-xarc2) geo.t2_arc2=math.atan2(y_os-yarc2,x_os-xarc2) while geo.t2_arc2<geo.t1_arc2: geo.t2_arc2=geo.t2_arc2+2.0*pi; geo.xa_arc1=xarc1 geo.ya_arc1=yarc1 geo.ra_arc1=r1 geo.t2_arc1=math.atan2(y_is-yarc1,x_is-xarc1) geo.t1_arc1=math.atan2(yarc2-yarc1,xarc2-xarc1) while geo.t2_arc1<geo.t1_arc1: geo.t2_arc1=geo.t2_arc1+2.0*pi; """ line given by y=m*t+b with one element at the intersection point with b=0, m=y/t """ geo.b_line=0.0 geo.t1_line=xarc2+r2*cos(geo.t1_arc2) geo.t2_line=geo.t1_line geo.m_line=(yarc2+r2*sin(geo.t1_arc2))/geo.t1_line """ Fit the wall to the chamber """ geo.x0_wall=geo.ro/2.0*cos(geo.phi_ie-pi/2-pi) geo.y0_wall=geo.ro/2.0*sin(geo.phi_ie-pi/2-pi) (x,y)=common_scroll_geo.coords_inv(geo.phi_ie,geo,pi,'fo') geo.r_wall=1.03*sqrt((geo.x0_wall-x)**2+(geo.y0_wall-y)**2) elif Type=='ArcLineArc': (x_is,y_is) = common_scroll_geo.coords_inv(geo.phi_is,geo,0,'fi') (x_os,y_os) = common_scroll_geo.coords_inv(geo.phi_os,geo,0,'fo') (nx_is,ny_is) = common_scroll_geo.coords_norm(geo.phi_is,geo,0,'fi') (nx_os,ny_os) = common_scroll_geo.coords_norm(geo.phi_os,geo,0,'fo') dx=x_is-x_os dy=y_is-y_os r2max=0 a=cos(geo.phi_os-geo.phi_is)+1.0 b=geo.ro*a-dx*(sin(geo.phi_os)-sin(geo.phi_is))+dy*(cos(geo.phi_os)-cos(geo.phi_is)) c=1.0/2.0*(2.0*dx*sin(geo.phi_is)*geo.ro-2.0*dy*cos(geo.phi_is)*geo.ro-dy**2-dx**2) if geo.phi_os-(geo.phi_is-pi)>1e-12: r2max=(-b+sqrt(b**2-4.0*a*c))/(2.0*a) elif geo.phi_os-(geo.phi_is-pi)<1e-12: r2max=-c/b else: print('error with starting angles phi_os %.16f phi_is-pi %.16f' %(geo.phi_os,geo.phi_is-pi)) if type(r2) is not float and r2=='PMP': r2=r2max if r2>r2max: print('r2 is too large, max value is : %0.5f' %(r2max)) xarc2 = x_os+nx_os*r2 yarc2 = y_os+ny_os*r2 if 'r1' not in kwargs: r1=r2+geo.ro else: r1=kwargs['r1'] ## Negative sign since you want the outward pointing unit normal vector xarc1 = x_is-nx_is*r1 yarc1 = y_is-ny_is*r1 geo.xa_arc2=xarc2 geo.ya_arc2=yarc2 geo.ra_arc2=r2 geo.t2_arc2=math.atan2(y_os-yarc2,x_os-xarc2) geo.xa_arc1=xarc1 geo.ya_arc1=yarc1 geo.ra_arc1=r1 geo.t2_arc1=math.atan2(y_is-yarc1,x_is-xarc1) alpha=math.atan2(yarc2-yarc1,xarc2-xarc1) d=sqrt((yarc2-yarc1)**2+(xarc2-xarc1)**2) beta=math.acos((r1+r2)/d) L=sqrt(d**2-(r1+r2)**2) t1=alpha+beta (xint,yint)=(xarc1+r1*cos(t1)+L*sin(t1),yarc1+r1*sin(t1)-L*cos(t1)) t2=math.atan2(yint-yarc2,xint-xarc2) geo.t1_arc1=t1 # (geo.t1_arc1,geo.t2_arc1)=sortAnglesCW(geo.t1_arc1,geo.t2_arc1) geo.t1_arc2=t2 # (geo.t1_arc2,geo.t2_arc2)=sortAnglesCCW(geo.t1_arc2,geo.t2_arc2) while geo.t2_arc2<geo.t1_arc2: geo.t2_arc2=geo.t2_arc2+2.0*pi; while geo.t2_arc1<geo.t1_arc1: geo.t2_arc1=geo.t2_arc1+2.0*pi; """ line given by y=m*t+b with one element at the intersection point with b=0, m=y/t """ geo.m_line=-1/tan(t1) geo.t1_line=xarc1+r1*cos(geo.t1_arc1) geo.t2_line=xarc2+r2*cos(geo.t1_arc2) geo.b_line=yarc1+r1*sin(t1)-geo.m_line*geo.t1_line """ Fit the wall to the chamber """ geo.x0_wall=geo.ro/2.0*cos(geo.phi_ie-pi/2-pi) geo.y0_wall=geo.ro/2.0*sin(geo.phi_ie-pi/2-pi) (x,y)=common_scroll_geo.coords_inv(geo.phi_ie,geo,pi,'fo') geo.r_wall=1.03*sqrt((geo.x0_wall-x)**2+(geo.y0_wall-y)**2) # f=pylab.Figure # pylab.plot(x_os,y_os,'o') # x=geo.xa_arc1+geo.ra_arc1*cos(np.linspace(geo.t1_arc1,geo.t2_arc1,100)) # y=geo.ya_arc1+geo.ra_arc1*sin(np.linspace(geo.t1_arc1,geo.t2_arc1,100)) # pylab.plot(x,y) # x=geo.xa_arc2+geo.ra_arc2*cos(np.linspace(geo.t1_arc2,geo.t2_arc2,100)) # y=geo.ya_arc2+geo.ra_arc2*sin(np.linspace(geo.t1_arc2,geo.t2_arc2,100)) # pylab.plot(x,y) # x=np.linspace(geo.t1_line,geo.t2_line,100) # y=geo.m_line*x+geo.b_line # pylab.plot(x,y) # pylab.plot(xint,yint,'^') # pylab.show() else: print('Type not understood:',Type)