def Compressor(): recip = Recip() recip.piston_stroke = 0.02 #Piston stroke, m recip.piston_diameter = 0.02 #Piston diameter, m recip.piston_length = 0.02 #Piston Length, m recip.omega = 377 #Frequency, rad/sec (60Hz) recip.crank_length = 0.01 #length of crank, m recip.connecting_rod_length = 0.04 #length of connecting rod, m recip.x_TDC = 0.003 #Distance to the TDC position of the piston from the valve plate recip.d_discharge = 0.0059 #discharge port diameter in meters recip.d_suction = recip.d_discharge #suction diameter in meters #These are parameters needed for the ambient heat transfer model recip.h_shell = 0.010 #[kW/m2/K] recip.A_shell = pi * 10 * 2 * (0.0254**2) #[m2] recip.Tamb = 298 #[K] recip.mu_oil = 0.0086 recip.delta_gap = 10e-6 recip.eta_motor = 0.95 recip.shell_volume = 100e-6 #Calculate Vdisp recip.pre_solve() recip.Vdisp = recip.Vdisp() Ref = 'R410A' inletState = State.State(Ref, dict(T=289.15, D=33.1)) p_outlet = inletState.p * 2.5 T2s = recip.guess_outlet_temp(inletState, p_outlet) outletState = State.State(Ref, {'T': T2s, 'P': p_outlet}) mdot_guess = inletState.rho * recip.Vdisp * recip.omega / (2 * pi) #First add the control volumes. recip.add_CV( ControlVolume(key='A', initialState=outletState.copy(), VdVFcn=recip.V_dV, becomes='A')) recip.add_CV( ControlVolume(key='shell', initialState=inletState.copy(), VdVFcn=recip.V_shell, becomes='shell')) recip.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.03, ID=0.02, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=recip.TubeCode)) recip.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.03, ID=0.02, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=recip.TubeCode)) recip.add_flow(FlowPath(key1='shell', key2='inlet.2', MdotFcn=recip.Inlet)) recip.add_flow(FlowPath(key1='inlet.2', key2='A', MdotFcn=recip.Suction)) recip.add_flow(FlowPath(key1='outlet.1', key2='A', MdotFcn=recip.Discharge)) recip.add_flow( FlowPath(key1='shell', key2='A', MdotFcn=recip.PistonLeakage)) E = 1.93e11 # Youngs Modulus, [Pa] h_valve = 0.0001532 # Valve thickness, [m] l_valve = 0.018 # Total length of valve, [m] a_valve = 0.0140 # Distance from anchor to force, [m] rho_valve = 8000 # Density of spring steel, [kg/m^3] C_D = 1.17 # Drag coefficient [-] d_valve = 0.007 # Valve Diameter [m] x_stopper = 0.0018 # Stopper location [m] I = (d_valve * h_valve**3) / 12 # Moment of Inertia for valve, [m^4] k_valve = (6 * E * I) / (a_valve**2 * (3 * l_valve - a_valve)) # Valve stiffness m_eff = ( 1 / 3 ) * rho_valve * l_valve * d_valve * h_valve # Effective mass of valve reeds, [kg] x_tr_suction = 0.25 * (recip.d_suction**2 / d_valve) x_tr_discharge = 0.25 * (recip.d_discharge**2 / d_valve) #The suction valve parameters recip.suction_valve = ValveModel(d_valve=d_valve, d_port=recip.d_suction, C_D=C_D, rho_valve=rho_valve, x_stopper=x_stopper, m_eff=m_eff, k_valve=k_valve, x_tr=x_tr_suction, key_up='inlet.2', key_down='A') recip.add_valve(recip.suction_valve) #The discharge valve parameters recip.discharge_valve = ValveModel(d_valve=d_valve, d_port=recip.d_discharge, C_D=C_D, rho_valve=rho_valve, x_stopper=x_stopper, m_eff=m_eff, k_valve=k_valve, x_tr=x_tr_discharge, key_up='A', key_down='outlet.1') recip.add_valve(recip.discharge_valve) recip.connect_callbacks( endcycle_callback=recip.endcycle_callback, heat_transfer_callback=recip.heat_transfer_callback, lumps_energy_balance_callback=recip.lump_energy_balance_callback) t1 = timeit.default_timer() recip.solve(key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=False, UseNR=True, eps_cycle=3e-2, eps_energy_balance=3e-2) print('time taken', timeit.default_timer() - t1) if plotting: debug_plots(recip, family='Recip Compressor') del recip.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() h5.write_to_file(recip, 'recipsample.h5')
def run(self): # Any stdout or stderr output will be redirected to a pipe for passing # back to the GUI. Pipes must be used because they are picklable and # otherwise the text output will not show up anywhere redir = RedirectText2Pipe(self.pipe_std) sys.stdout = redir sys.stderr = redir # Build happens through a dynamically generated build script while # thankfully removes the requirement for picklability #Get the module name (file name without the .py) script_name = self.script_name.split('.', 1)[0] print('About to run the script file', os.path.join(pdsim_home_folder, self.script_name)) #Import the script module script_module = __import__(script_name, globals(), locals(), [], -1) #Build the simulation self.sim = script_module.build() #Save the script in the simulation as a string self.sim.build_script = open( os.path.join(pdsim_home_folder, self.script_name), 'r').read() #Run the simulation script_module.run(self.sim, pipe_abort=self.pipe_abort) # Delete a few items that cannot pickle properly if hasattr(self.sim, 'pipe_abort'): del self.sim.pipe_abort del self.sim.FlowStorage del self.sim.Abort #Can't pickle because it is a pointer to a bound method if not self.sim._want_abort: temp_folder = pdsim_home_folder try: os.mkdir(temp_folder) except OSError: pass except WindowsError: pass identifier = 'PDSimGUI ' + time.strftime( '%Y-%m-%d-%H-%M-%S') + '_t' + script_name.split('_')[1] hdf5_path = os.path.join(temp_folder, identifier + '.h5') from PDSim.misc.hdf5 import HDF5Writer HDF5 = HDF5Writer() HDF5.write_to_file(self.sim, hdf5_path) # Prune off undesired keys as provided by get_prune_keys function HDF5.prune(hdf5_path, self.sim.get_prune_keys()) self.sim.attach_HDF5_annotations(hdf5_path) print('Wrote hdf5 file to', hdf5_path) # Send simulation result back to calling thread self.pipe_results.send(hdf5_path) print('Sent simulation back to calling thread', end='') # Wait for an acknowledgment of receipt while not self.pipe_results.poll(): time.sleep(0.1) #Check that you got the right acknowledgment key back ack_key = self.pipe_results.recv() if not ack_key == 'ACK': raise KeyError else: print('Acknowledgment of receipt accepted') break else: print('Acknowledging completion of abort') self.pipe_abort.send('ACK')
def Compressor(Te=0, DTsh=11.1, Tc=20, Tamb=25, Nmot=3600, f=None, OneCycle=False, Ref='R134a', HDF5file='scroll_compressor.h5'): ScrollComp = Scroll() #Set the scroll wrap geometry ScrollComp.set_scroll_geo(82.7e-6, 2.5, 0.004, 0.005, phi_i0=0.0, phi_os=0.3, phi_is=3.142) ScrollComp.set_disc_geo('2Arc', r2=0.0010) ScrollComp.geo.delta_suction_offset = 0.0e-3 ScrollComp.geo.phi_ie_offset = 0.0 ScrollComp.omega = Nmot / 60 * 2 * pi ScrollComp.slip_ratio = 0.01 ScrollComp.Tamb = Tamb + 273.15 #[K] #Temporarily set the bearing dimensions ScrollComp.mech = struct() ScrollComp.mech.detailed_analysis = True ScrollComp.mech.D_upper_bearing = 0.04 ScrollComp.mech.L_upper_bearing = 0.04 ScrollComp.mech.c_upper_bearing = 20e-6 ScrollComp.mech.D_crank_bearing = 0.04 ScrollComp.mech.L_crank_bearing = 0.04 ScrollComp.mech.c_crank_bearing = 20e-6 ScrollComp.mech.D_lower_bearing = 0.025 ScrollComp.mech.L_lower_bearing = 0.025 ScrollComp.mech.c_lower_bearing = 20e-6 ScrollComp.mech.thrust_ID = 0.05 ScrollComp.mech.thrust_friction_coefficient = 0.013 #0.028 #From Chen thesis ScrollComp.mech.orbiting_scroll_mass = 2.5 ScrollComp.mech.L_ratio_bearings = 3 ScrollComp.mech.mu_oil = 0.005 ScrollComp.mech.rho_oil = 930 ScrollComp.mech.oldham_ring_radius = 0.06 #m ScrollComp.mech.oldham_mass = 0.1 #kg ScrollComp.mech.oldham_thickness = 0.008 #m ScrollComp.mech.oldham_key_height = 0.006 #m ScrollComp.mech.oldham_key_width = 0.006 #m ScrollComp.mech.oldham_key_friction_coefficient = 0.01 #- ScrollComp.mech.oldham_rotation_beta = 0 #rad ScrollComp.h_shell = 0.02 ScrollComp.A_shell = 450.75e-3 * ((246.126e-3)**2 * pi / 4) ScrollComp.HTC = 0.0 ScrollComp.HT_corr = 'Pereira-Deschamps' #'Jang-Jeong' # Temperature Lumps ScrollComp.OEB_type = 'multi-lump' #'single-lump' ScrollComp.OEB_solver = 'MDNR' ScrollComp.Rshell_oil = 190 #K/kW from Chen (2000) - PhD thesis # Define motor efficiency ScrollComp.motor = Motor() ScrollComp.motor.set_eta(0.95) ScrollComp.motor.suction_fraction = 0.5 # Operating conditions Tevap = Te + 273.15 #K Tcond = Tc + 273.15 #K Tin = Tevap + DTsh temp = State.State(Ref, {'T': Tevap, 'Q': 1}) pe = temp.p temp.update(dict(T=Tcond, Q=1)) pc = temp.p inletState = State.State(Ref, {'T': Tin, 'P': pe}) ScrollComp.pressure_ratio = pc / pe print('Pressure Ratio:', pc / pe, pc, pe) T2s = ScrollComp.guess_outlet_temp(inletState, pc) outletState = State.State(Ref, {'T': T2s, 'P': pc}) print('Vdisp:', ScrollComp.Vdisp * 1e6, 'cm3/rev') mdot_guess = inletState.rho * ScrollComp.Vdisp * ScrollComp.omega / (2 * pi) #Leakage flow ScrollComp.geo.delta_flank = -9.615e-7 * (ScrollComp.pressure_ratio - 1.67) + 15e-6 #10e-6 ScrollComp.geo.delta_radial = 1.1e-6 * (ScrollComp.pressure_ratio - 1.67) + 1e-6 #10e-6 ScrollComp.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=ScrollComp.TubeCode)) ScrollComp.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=ScrollComp.TubeCode)) ScrollComp.auto_add_CVs(inletState, outletState) ScrollComp.auto_add_leakage(flankFunc=ScrollComp.FlankLeakage, radialFunc=ScrollComp.RadialLeakage) FP = FlowPath( key1='inlet.2', key2='sa', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * 0.01**2 / 4 ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='sa', key2='s1', MdotFcn=ScrollComp.SA_S1, MdotFcn_kwargs=dict(X_d=0.8))) ScrollComp.add_flow( FlowPath(key1='sa', key2='s2', MdotFcn=ScrollComp.SA_S2, MdotFcn_kwargs=dict(X_d=0.8))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='dd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.8))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='ddd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.8))) # ScrollComp.add_flow(FlowPath(key1 = 'outlet.1', # key2 = 'd1', # MdotFcn = ScrollComp.DISC_D1, # MdotFcn_kwargs = dict(X_d = 0.7) # ) # ) # # FP = FlowPath(key1='outlet.1', # key2='dd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # # FP = FlowPath(key1='outlet.1', # key2='ddd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='d1', key2='dd', MdotFcn=ScrollComp.D_to_DD)) ScrollComp.add_flow( FlowPath(key1='d2', key2='dd', MdotFcn=ScrollComp.D_to_DD)) #Connect the callbacks for the step, endcycle, heat transfer and lump energy balance ScrollComp.connect_callbacks( step_callback=ScrollComp.step_callback, endcycle_callback=ScrollComp.endcycle_callback, heat_transfer_callback=ScrollComp.heat_transfer_callback, lumps_energy_balance_callback=ScrollComp.lump_energy_balance_callback) from time import clock t1 = clock() ScrollComp.RK45_eps = 1e-6 ScrollComp.eps_cycle = 3e-3 ScrollComp.verbosity = 10 ScrollComp.solve( key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=OneCycle, plot_every_cycle=False, x0=[330, 330, 350], #Guesses [Td,Tlump[0],Tlump[1]] #hmin = 1e-3 eps_cycle=3e-3, eps_energy_balance=0.1 #relaxed multi-lump convergence ) print('time taken', clock() - t1) if '--plot' in sys.argv: debug_plots(ScrollComp) del ScrollComp.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() h5.write_to_file(ScrollComp, HDF5file) return ScrollComp
def Compressor(ScrollClass, Te=253, Tc=310, f=None, OneCycle=False, Ref='R410A', HDF5file='scroll_compressor.h5', discharge_valve=True): ScrollComp = ScrollClass() ScrollComp.set_scroll_geo(83e-6, 2.2, 0.005, 0.006) #Set the scroll wrap geometry ScrollComp.set_disc_geo('2Arc', r2=0) ScrollComp.geo.delta_flank = 10e-6 ScrollComp.geo.delta_radial = 10e-6 ScrollComp.geo.delta_suction_offset = 0.0e-3 ScrollComp.geo.phi_ie_offset = 0.0 # print(ScrollComp.geo); quit() ScrollComp.omega = 3000 / 60 * 2 * pi ScrollComp.Tamb = 298.0 #Temporarily set the bearing dimensions ScrollComp.mech = struct() ScrollComp.mech.D_upper_bearing = 0.04 ScrollComp.mech.L_upper_bearing = 0.04 ScrollComp.mech.c_upper_bearing = 20e-6 ScrollComp.mech.D_crank_bearing = 0.04 ScrollComp.mech.L_crank_bearing = 0.04 ScrollComp.mech.c_crank_bearing = 20e-6 ScrollComp.mech.D_lower_bearing = 0.025 ScrollComp.mech.L_lower_bearing = 0.025 ScrollComp.mech.c_lower_bearing = 20e-6 ScrollComp.mech.thrust_ID = 0.05 ScrollComp.mech.thrust_friction_coefficient = 0.028 #From Chen thesis ScrollComp.mech.orbiting_scroll_mass = 2.5 ScrollComp.mech.L_ratio_bearings = 3 ScrollComp.mech.mu_oil = 0.008 ScrollComp.h_shell = 0.02 ScrollComp.A_shell = 0.05 ScrollComp.HTC = 0.01 ScrollComp.motor = Motor() ScrollComp.motor.set_eta(0.9) ScrollComp.motor.suction_fraction = 1.0 Tin = Te + 11.1 temp = State.State(Ref, {'T': Te, 'Q': 1}) pe = temp.p temp.update(dict(T=Tc, Q=1)) pc = temp.p inletState = State.State(Ref, {'T': Tin, 'P': pe}) T2s = ScrollComp.guess_outlet_temp(inletState, pc) outletState = State.State(Ref, {'T': T2s, 'P': pc}) mdot_guess = inletState.rho * ScrollComp.Vdisp * ScrollComp.omega / (2 * pi) ScrollComp.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=ScrollComp.TubeCode)) ScrollComp.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=ScrollComp.TubeCode)) ScrollComp.auto_add_CVs(inletState, outletState) ScrollComp.auto_add_leakage(flankFunc=ScrollComp.FlankLeakage, radialFunc=ScrollComp.RadialLeakage) FP = FlowPath( key1='inlet.2', key2='sa', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * 0.01**2 / 4 ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='sa', key2='s1', MdotFcn=ScrollComp.SA_S1, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='sa', key2='s2', MdotFcn=ScrollComp.SA_S2, MdotFcn_kwargs=dict(X_d=0.7))) if not discharge_valve: ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='dd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='ddd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) else: E = 1.93e11 # Youngs Modulus, [Pa] h_valve = 0.0006 # Valve thickness, [m] d_discharge = ScrollComp.geo.ra_arc1 * 1.9 # Port diameter [m] l_valve = 5 * d_discharge # Total length of valve, [m] a_valve = l_valve / 1.5 # Distance from anchor to force, [m] assert (a_valve < l_valve) rho_valve = 8000 # Density of spring steel, [kg/m^3] C_D = 1.17 # Drag coefficient [-] d_valve = d_discharge * 1.5 # Valve Diameter [m] x_stopper = 0.006 # Stopper location [m] I = (d_valve * h_valve**3) / 12 # Moment of Inertia for valve,[m^4] k_valve = (6 * E * I) / (a_valve**2 * (3 * l_valve - a_valve)) # Valve stiffness m_eff = ( 1 / 3 ) * rho_valve * l_valve * d_valve * h_valve # Effective mass of valve reeds x_tr_discharge = 0.25 * (d_discharge**2 / d_valve) # Construct the valve ScrollComp.discharge_valve = ValveModel( d_valve=d_valve, d_port=d_discharge, C_D=C_D, m_eff=m_eff, k_valve=k_valve, rho_valve=rho_valve, # Not used directly x_stopper=x_stopper, x_tr=x_tr_discharge, key_up=['ddd', 'dd'], key_down='outlet.1') # Inform the model about the valve ScrollComp.add_valve(ScrollComp.discharge_valve) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='dd', MdotFcn=ScrollComp.DischargeValve, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='ddd', MdotFcn=ScrollComp.DischargeValve, MdotFcn_kwargs=dict(X_d=0.7))) # ScrollComp.add_flow(FlowPath(key1 = 'outlet.1', # key2 = 'd1', # MdotFcn = ScrollComp.DISC_D1, # MdotFcn_kwargs = dict(X_d = 0.7) # ) # ) # # FP = FlowPath(key1='outlet.1', # key2='dd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # # FP = FlowPath(key1='outlet.1', # key2='ddd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='d1', key2='dd', MdotFcn=ScrollComp.D_to_DD)) ScrollComp.add_flow( FlowPath(key1='d2', key2='dd', MdotFcn=ScrollComp.D_to_DD)) #Connect the callbacks for the step, endcycle, heat transfer and lump energy balance ScrollComp.connect_callbacks( step_callback=ScrollComp.step_callback, endcycle_callback=ScrollComp.endcycle_callback, heat_transfer_callback=ScrollComp.heat_transfer_callback, lumps_energy_balance_callback=ScrollComp.lump_energy_balance_callback) t1 = timeit.default_timer() ScrollComp.RK45_eps = 1e-6 ScrollComp.eps_cycle = 3e-3 try: ScrollComp.solve( key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=OneCycle, plot_every_cycle=False, #hmin = 1e-3 eps_cycle=3e-3) except BaseException as E: print(E) raise print('time taken', timeit.default_timer() - t1) del ScrollComp.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() h5.write_to_file(ScrollComp, HDF5file) debug_plots(ScrollComp, family='Scroll Compressor') return ScrollComp
def Compressor(ScrollClass, Te=273, Tc=300, f=None, OneCycle=False, Ref='R410A', HDF5file='scroll_compressor.h5'): ScrollComp = ScrollClass() #This runs if the module code is run directly ScrollComp.set_scroll_geo(83e-6, 3.3, 0.005, 0.006) #Set the scroll wrap geometry ScrollComp.set_disc_geo('2Arc', r2=0) ScrollComp.geo.delta_flank = 10e-6 ScrollComp.geo.delta_radial = 10e-6 ScrollComp.geo.delta_suction_offset = 0.0e-3 ScrollComp.geo.phi_ie_offset = 0.0 ScrollComp.omega = 3000 / 60 * 2 * pi ScrollComp.Tamb = 298.0 #Temporarily set the bearing dimensions ScrollComp.mech = struct() ScrollComp.mech.D_upper_bearing = 0.04 ScrollComp.mech.L_upper_bearing = 0.04 ScrollComp.mech.c_upper_bearing = 20e-6 ScrollComp.mech.D_crank_bearing = 0.04 ScrollComp.mech.L_crank_bearing = 0.04 ScrollComp.mech.c_crank_bearing = 20e-6 ScrollComp.mech.D_lower_bearing = 0.025 ScrollComp.mech.L_lower_bearing = 0.025 ScrollComp.mech.c_lower_bearing = 20e-6 ScrollComp.mech.thrust_ID = 0.05 ScrollComp.mech.thrust_friction_coefficient = 0.028 #From Chen thesis ScrollComp.mech.orbiting_scroll_mass = 2.5 ScrollComp.mech.L_ratio_bearings = 3 ScrollComp.mech.mu_oil = 0.008 ScrollComp.h_shell = 0.02 ScrollComp.A_shell = 0.05 ScrollComp.HTC = 0.0 ScrollComp.motor = Motor() ScrollComp.motor.set_eta(0.9) ScrollComp.motor.suction_fraction = 1.0 Te = -20 + 273.15 Tc = 20 + 273.15 Tin = Te + 11.1 DT_sc = 7 temp = State.State(Ref, {'T': Te, 'Q': 1}) pe = temp.p temp.update(dict(T=Tc, Q=1)) pc = temp.p inletState = State.State(Ref, {'T': Tin, 'P': pe}) T2s = ScrollComp.guess_outlet_temp(inletState, pc) outletState = State.State(Ref, {'T': T2s, 'P': pc}) mdot_guess = inletState.rho * ScrollComp.Vdisp * ScrollComp.omega / (2 * pi) ScrollComp.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=ScrollComp.TubeCode)) ScrollComp.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=ScrollComp.TubeCode)) ScrollComp.auto_add_CVs(inletState, outletState) ScrollComp.auto_add_leakage(flankFunc=ScrollComp.FlankLeakage, radialFunc=ScrollComp.RadialLeakage) FP = FlowPath( key1='inlet.2', key2='sa', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * 0.01**2 / 4 ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='sa', key2='s1', MdotFcn=ScrollComp.SA_S1, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='sa', key2='s2', MdotFcn=ScrollComp.SA_S2, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='dd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='ddd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) # ScrollComp.add_flow(FlowPath(key1 = 'outlet.1', # key2 = 'd1', # MdotFcn = ScrollComp.DISC_D1, # MdotFcn_kwargs = dict(X_d = 0.7) # ) # ) # # FP = FlowPath(key1='outlet.1', # key2='dd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # # FP = FlowPath(key1='outlet.1', # key2='ddd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='d1', key2='dd', MdotFcn=ScrollComp.D_to_DD)) ScrollComp.add_flow( FlowPath(key1='d2', key2='dd', MdotFcn=ScrollComp.D_to_DD)) #Connect the callbacks for the step, endcycle, heat transfer and lump energy balance ScrollComp.connect_callbacks( step_callback=ScrollComp.step_callback, endcycle_callback=ScrollComp.endcycle_callback, heat_transfer_callback=ScrollComp.heat_transfer_callback, lumps_energy_balance_callback=ScrollComp.lump_energy_balance_callback) t1 = timeit.default_timer() ScrollComp.RK45_eps = 1e-6 ScrollComp.eps_cycle = 3e-3 try: ScrollComp.precond_solve( key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=OneCycle, plot_every_cycle=False, #hmin = 1e-3 eps_cycle=3e-3) except BaseException as E: print(E) raise print('time taken', timeit.default_timer() - t1) del ScrollComp.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() h5.write_to_file(ScrollComp, HDF5file) # debug_plots(ScrollComp, family='Scroll Compressor') return ScrollComp
def Compressor(hs, Vdisp, Vratio, Thickness, OrbitingRadius, phi_i0=0.0, phi_os=0.3, phi_is=pi, phi_ie=21.76458, phi_o0=-1.06276, rb=0.004319, f=None, OneCycle=False, Ref='R410A', Qct=1, do=0.123, r_upper_bearing=0.02, r_lower_bearing=0.02, c_ub=1e-5): #def Compressor(Te = 273, Tc = 300,Tamb = 25, f = None, OneCycle = False, Ref = 'R410A'): Te = 280.37 Tc = 327.594 Tamb = 35 ScrollComp = Scroll() #This runs if the module code is run directly #ScrollComp.set_scroll_geo(1.53204e-5, 2.63, 0.00459, 0.004099,0.0,1.442,3.6) print(Vdisp, Vratio, Thickness, OrbitingRadius, phi_os, phi_is) ScrollComp.set_scroll_geo(Vdisp, Vratio, Thickness, OrbitingRadius, phi_i0=0.0, phi_os=phi_os, phi_is=phi_is, phi_ie=phi_ie, phi_o0=phi_o0, hs=hs, rb=rb) #ScrollComp.set_scroll_geo(2.1723e-4, 2.63, 0.00459582, 0.00565,0.0,1.442,3.639) #Set the scroll wrap geometry ScrollComp.set_disc_geo('2Arc', r2=0) ScrollComp.geo.delta_flank = 1.9e-5 ScrollComp.geo.delta_radial = 1.9e-5 #X_d=1 ScrollComp.geo.delta_suction_offset = 0.0e-3 #ScrollComp.geo.phi_ie_offset = 0.0 ScrollComp.Tamb = Tamb + 273.15 #[K] ScrollComp.omega = 3600 / 60 * 2 * pi f = 3600 / 60 # frequency for port size calculaton #ScrollComp.Tamb = 298.0 #ScrollComp.journal_tune_factor=1.3 # if Qct<2.6: # d_inlet=0.019 # elif Qct> 2.6 and Qct<7.6: # d_inlet=0.022 # elif Qct> 7.6 and Qct<15: # d_inlet=0.02857 # elif Qct> 15 and Qct<20: # d_inlet=0.0412 # elif Qct> 20 and Qct<29: # d_inlet=0.0539 # elif Qct> 29 and Qct<41: # d_inlet=0.0457 # elif Qct> 41 and Qct<88: # d_inlet=0.0666 # elif Qct> 88 and Qct<105: # d_inlet=0.092 # else: # d_inlet=0.092 # # if Qct < 4.5: d_outlet = 0.0127 elif Qct > 4.5 and Qct < 13.5: d_outlet = 0.020 elif Qct > 13.5 and Qct < 16.5: d_outlet = 0.02857 elif Qct > 16.5 and Qct < 29: d_outlet = 0.0349 elif Qct > 29 and Qct < 87: d_outlet = 0.041 elif Qct > 87 and Qct < 105: d_outlet = 0.0539 else: d_outlet = 0.0539 # d_inlet=0.01 # d_outlet=0.003 #Temporarily set the bearing dimensions ScrollComp.mech = struct() ScrollComp.mech.D_upper_bearing = 2 * r_upper_bearing ScrollComp.mech.L_upper_bearing = 2 * r_upper_bearing ScrollComp.mech.c_upper_bearing = c_ub ScrollComp.mech.D_crank_bearing = 2 * r_upper_bearing ScrollComp.mech.L_crank_bearing = 2 * r_upper_bearing ScrollComp.mech.c_crank_bearing = c_ub ScrollComp.mech.D_lower_bearing = 2 * r_lower_bearing ScrollComp.mech.L_lower_bearing = 2 * r_lower_bearing ScrollComp.mech.c_lower_bearing = 20e-6 ScrollComp.mech.thrust_ID = do ScrollComp.mech.thrust_friction_coefficient = 0.028 #From Chen thesis ScrollComp.mech.orbiting_scroll_mass = 2.5 ScrollComp.mech.L_ratio_bearings = 5 ScrollComp.mech.mu_oil = 0.02 ScrollComp.mech.oldham_ring_radius = 0.06 #m ScrollComp.mech.oldham_mass = 0.1 #kg ScrollComp.mech.oldham_thickness = 0.008 #m ScrollComp.mech.oldham_key_height = 0.006 #m ScrollComp.mech.oldham_key_width = 0.006 #m ScrollComp.mech.oldham_key_friction_coefficient = 0.01 #- ScrollComp.mech.oldham_rotation_beta = 0 #rad # ScrollComp.h_shell = 0.02 # ScrollComp.A_shell = 0.05 # ScrollComp.HTC = 3 ScrollComp.h_shell = 0.01 ScrollComp.A_shell = (2 * do + hs) * ((do)**2 * pi / 4) #ScrollComp.HTC = 0.0 ScrollComp.HT_corr = 'Dittus-Boelter' #'Jang-Jeong' # Temperature Lumps ScrollComp.OEB_type = 'single-lump' #'single-lump' ScrollComp.OEB_solver = 'MDNR' ScrollComp.Rshell_oil = 190 #K/kW from Chen (2000) - PhD thesis ScrollComp.motor = Motor() ScrollComp.motor.set_eta(0.9) ScrollComp.motor.suction_fraction = 1.0 # Te = Te+ 273.15 # Tc = Tc+ 273.15 Tin = Te + 11.1 DT_sc = 8.3 temp = State.State(Ref, {'T': Te, 'Q': 1}) pe = temp.p #pe=2950 temp.update(dict(T=Tc, Q=1)) pc = temp.p PR = pc / pe X_d = 0.7 #pc=4500 inletState = State.State(Ref, {'T': Tin, 'P': pe}) # defining the port area w.r.t displacement volume V = 10 A = Vdisp * f / V d_inlet = (4 * A / 3.14)**0.5 T2s = ScrollComp.guess_outlet_temp(inletState, pc) outletState = State.State(Ref, {'T': T2s, 'P': pc}) mdot_guess = inletState.rho * ScrollComp.Vdisp * ScrollComp.omega / (2 * pi) ScrollComp.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.3, ID=d_inlet, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=ScrollComp.TubeCode)) ScrollComp.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.3, ID=d_outlet, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=ScrollComp.TubeCode)) ScrollComp.auto_add_CVs(inletState, outletState) # ScrollComp.auto_add_leakage(flankFunc=ScrollComp.FlankLeakage, radialFunc=ScrollComp.RadialLeakage) FP = FlowPath( key1='inlet.2', key2='sa', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * d_inlet**2 / 4 ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='sa', key2='s1', MdotFcn=ScrollComp.SA_S1, MdotFcn_kwargs=dict(X_d=X_d))) ScrollComp.add_flow( FlowPath(key1='sa', key2='s2', MdotFcn=ScrollComp.SA_S2, MdotFcn_kwargs=dict(X_d=X_d))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='dd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=X_d))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='ddd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=X_d))) # ScrollComp.add_flow(FlowPath(key1 = 'outlet.1', # key2 = 'd1', # MdotFcn = ScrollComp.DISC_D1, # MdotFcn_kwargs = dict(X_d = 0.7) # ) # ) # # FP = FlowPath(key1='outlet.1', # key2='dd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # # FP = FlowPath(key1='outlet.1', # key2='ddd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='d1', key2='dd', MdotFcn=ScrollComp.D_to_DD, MdotFcn_kwargs=dict(X_d=1))) ScrollComp.add_flow( FlowPath(key1='d2', key2='dd', MdotFcn=ScrollComp.D_to_DD, MdotFcn_kwargs=dict(X_d=1))) #Connect the callbacks for the step, endcycle, heat transfer and lump energy balance ScrollComp.connect_callbacks( step_callback=ScrollComp.step_callback, endcycle_callback=ScrollComp.endcycle_callback, heat_transfer_callback=ScrollComp.heat_transfer_callback, lumps_energy_balance_callback=ScrollComp.lump_energy_balance_callback) from time import clock t1 = clock() ScrollComp.RK45_eps = 1e-4 ScrollComp.eps_cycle = 1e-3 try: ScrollComp.precond_solve( key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=OneCycle, plot_every_cycle=False, x0=[320, 320], #Guesses [Td,Tlump[0],Tlump[1]] hmin=1e-4, eps_cycle=1e-3, eps_energy_balance=0.1 #relaxed multi-lump convergence ) except BaseException as E: print(E) raise print('time taken', clock() - t1) #debug_plots(ScrollComp) del ScrollComp.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() import CoolProp Filepath1 = 'C:\Users\Mohsin\OneDrive - Oklahoma A and M System\Documents\Phd\Scroll comp scalling\cases_final\case 8/' Filepath2 = 'E:\OneDrive - Oklahoma A and M System\Documents\Phd\Scroll comp scalling\cases_final\case 8/' if os.path.isfile(Filepath1) == True: Filepath = Filepath1 else: Filepath = Filepath2 FileName = Filepath + 'Qc_t' + '_' + str(Qct) + '.h5' h5.write_to_file(ScrollComp, FileName) return ScrollComp
def Compressor(ScrollClass, Te=273, Tc=300, f=None, OneCycle=False, Ref='R410A', HDF5file='scroll_compressor.h5'): ScrollComp = ScrollClass() # This runs if the module code is run directly ScrollComp.set_scroll_geo(83e-6, 3.3, 0.005, 0.006) #Set the scroll wrap geometry ScrollComp.set_disc_geo('2Arc', r2=0) ScrollComp.geo.delta_flank = 10e-6 ScrollComp.geo.delta_radial = 10e-6 ScrollComp.geo.delta_suction_offset = 0.0e-3 ScrollComp.geo.phi_ie_offset = 0.0 ScrollComp.omega = 3000 / 60 * 2 * pi ScrollComp.Tamb = 298.0 #Temporarily set the bearing dimensions ScrollComp.mech = struct() ScrollComp.mech.D_upper_bearing = 0.04 ScrollComp.mech.L_upper_bearing = 0.04 ScrollComp.mech.c_upper_bearing = 20e-6 ScrollComp.mech.D_crank_bearing = 0.04 ScrollComp.mech.L_crank_bearing = 0.04 ScrollComp.mech.c_crank_bearing = 20e-6 ScrollComp.mech.D_lower_bearing = 0.025 ScrollComp.mech.L_lower_bearing = 0.025 ScrollComp.mech.c_lower_bearing = 20e-6 ScrollComp.mech.thrust_ID = 0.05 ScrollComp.mech.thrust_friction_coefficient = 0.028 #From Chen thesis ScrollComp.mech.orbiting_scroll_mass = 2.5 ScrollComp.mech.L_ratio_bearings = 3 ScrollComp.mech.mu_oil = 0.008 ScrollComp.h_shell = 0.02 ScrollComp.A_shell = 0.05 ScrollComp.HTC = 0.0 ScrollComp.motor = Motor() ScrollComp.motor.set_eta(0.9) ScrollComp.motor.suction_fraction = 1.0 Te = -20 + 273.15 Tc = 20 + 273.15 Tin = Te + 11.1 temp = State.State(Ref, {'T': Te, 'Q': 1}) pe = temp.p temp.update(dict(T=Tc, Q=1)) pc = temp.p inletState = State.State(Ref, {'T': Tin, 'P': pe}) T2s = ScrollComp.guess_outlet_temp(inletState, pc) outletState = State.State(Ref, {'T': T2s, 'P': pc}) mdot_guess = inletState.rho * ScrollComp.Vdisp * ScrollComp.omega / (2 * pi) ScrollComp.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=ScrollComp.TubeCode)) ScrollComp.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=ScrollComp.TubeCode)) ScrollComp.auto_add_CVs(inletState, outletState) ScrollComp.auto_add_leakage(flankFunc=ScrollComp.FlankLeakage, radialFunc=ScrollComp.RadialLeakage) FP = FlowPath( key1='inlet.2', key2='sa', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * 0.01**2 / 4 ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='sa', key2='s1', MdotFcn=ScrollComp.SA_S1, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='sa', key2='s2', MdotFcn=ScrollComp.SA_S2, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='dd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='outlet.1', key2='ddd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) # ScrollComp.add_flow(FlowPath(key1 = 'outlet.1', # key2 = 'd1', # MdotFcn = ScrollComp.DISC_D1, # MdotFcn_kwargs = dict(X_d = 0.7) # ) # ) # # FP = FlowPath(key1='outlet.1', # key2='dd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # # FP = FlowPath(key1='outlet.1', # key2='ddd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) sim = ScrollComp phi_list = [sim.geo.phi_fie - 2 * pi - 0.3] involute_list = ['i'] D_list = [sim.geo.t] * len(phi_list) offset_list = [d / 1.5 for d in D_list] X_d_list = [1.0] * len(phi_list) X_d_backflow_list = [0.0] * len(phi_list) port_tube_list = [0] Ltube_list = [0.001] IDtube_list = [0.003] # A superheated state Tsat_inj = (Te + Tc) / 2 # [K] temp = State.State(Ref, {'T': Tsat_inj, 'Q': 1}) temp = State.State(Ref, {'T': Tsat_inj + 10, 'P': temp.p}) Ttube_list = [temp.T] RHOtube_list = [temp.rho] sim.fixed_scroll_ports = [] for phi, involute, offset, D, parent, X_d, X_d_backflow in zip( phi_list, involute_list, offset_list, D_list, port_tube_list, X_d_list, X_d_backflow_list): p = Port() p.phi = phi p.involute = involute p.offset = offset p.D = D p.parent = parent p.X_d = X_d p.X_d_backflow = X_d_backflow sim.fixed_scroll_ports.append(p) more_keys = [] for i, (L, ID, T, D) in enumerate( zip(Ltube_list, IDtube_list, Ttube_list, RHOtube_list)): sim.add_tube( Tube(key1='VITube' + str(i + 1) + '.1', key2='VITube' + str(i + 1) + '.2', L=L, ID=ID, mdot=mdot_guess * 0.1, State1=State.State(inletState.Fluid, dict(T=T, D=D)), fixed=1, TubeFcn=sim.TubeCode)) more_keys.append('VITube' + str(i + 1) + '.1') sim.additional_inlet_keys = more_keys # # This block can be uncommented to plot the scroll wrap with the VI ports # plotScrollSet(0, geo = sim.geo) # for port in sim.fixed_scroll_ports: # x, y = scroll_geo.coords_inv(port.phi, sim.geo, 0, port.involute) # nx, ny = scroll_geo.coords_norm(port.phi, sim.geo, 0, port.involute) # x0 = x - nx*port.offset # y0 = y - ny*port.offset # t = np.linspace(0, 2*pi) # plt.plot(port.D/2.0*np.cos(t) + x0, port.D/2.0*np.sin(t) + y0,'b') # plt.savefig('wrap_with_VI_ports.png',transparent=True) # plt.close() # quit() # Calculate the areas between each VI port and every control volume sim.calculate_port_areas() for port in sim.fixed_scroll_ports: for partner in port.area_dict: # Create a spline interpolator object for the area between port and the partner chamber A_interpolator = interp.splrep(port.theta, port.area_dict[partner], k=2, s=0) # Add the flow between the EVI control volume and the chamber through the port sim.add_flow( FlowPath(key1='VITube' + str(port.parent + 1) + '.2', key2=partner, MdotFcn=sim.INTERPOLATING_NOZZLE_FLOW, MdotFcn_kwargs=dict(X_d=port.X_d, X_d_backflow=port.X_d_backflow, upstream_key='VITube' + str(port.parent + 1) + '.2', A_interpolator=A_interpolator))) ScrollComp.add_flow( FlowPath(key1='d1', key2='dd', MdotFcn=ScrollComp.D_to_DD)) ScrollComp.add_flow( FlowPath(key1='d2', key2='dd', MdotFcn=ScrollComp.D_to_DD)) #Connect the callbacks for the step, endcycle, heat transfer and lump energy balance ScrollComp.connect_callbacks( step_callback=ScrollComp.step_callback, endcycle_callback=ScrollComp.endcycle_callback, heat_transfer_callback=ScrollComp.heat_transfer_callback, lumps_energy_balance_callback=ScrollComp.lump_energy_balance_callback) t1 = timeit.default_timer() ScrollComp.RK45_eps = 1e-6 ScrollComp.eps_cycle = 3e-3 try: ScrollComp.solve( key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=OneCycle, plot_every_cycle=False, #hmin = 1e-3 eps_cycle=3e-3) except BaseException as E: print(E) raise print('time taken', timeit.default_timer() - t1) del ScrollComp.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() h5.write_to_file(ScrollComp, HDF5file) return ScrollComp
def Compressor(ScrollClass, *, Te=273, Tc=300, OneCycle=False, Ref='R410A', HDF5file='scroll_compressor_disc.h5', Nports=4): ScrollComp = ScrollClass() #This runs if the module code is run directly ScrollComp.set_scroll_geo(83e-6, 3.3, 0.005, 0.006) #Set the scroll wrap geometry ScrollComp.set_disc_geo('2Arc', r2=0) ScrollComp.geo.delta_flank = 10e-6 ScrollComp.geo.delta_radial = 10e-6 ScrollComp.geo.delta_suction_offset = 0.0e-3 ScrollComp.geo.phi_ie_offset = 0.0 ScrollComp.omega = 3000 / 60 * 2 * pi ScrollComp.Tamb = 298.0 # Temporarily set the bearing dimensions ScrollComp.mech = struct() ScrollComp.mech.D_upper_bearing = 0.04 ScrollComp.mech.L_upper_bearing = 0.04 ScrollComp.mech.c_upper_bearing = 20e-6 ScrollComp.mech.D_crank_bearing = 0.04 ScrollComp.mech.L_crank_bearing = 0.04 ScrollComp.mech.c_crank_bearing = 20e-6 ScrollComp.mech.D_lower_bearing = 0.025 ScrollComp.mech.L_lower_bearing = 0.025 ScrollComp.mech.c_lower_bearing = 20e-6 ScrollComp.mech.thrust_ID = 0.05 ScrollComp.mech.thrust_friction_coefficient = 0.028 # From Chen thesis ScrollComp.mech.orbiting_scroll_mass = 2.5 ScrollComp.mech.L_ratio_bearings = 3 ScrollComp.mech.mu_oil = 0.008 ScrollComp.h_shell = 0.02 # kW/m^2/K ScrollComp.A_shell = 0.05 # m^2 ScrollComp.HTC = 0.050 # Heat transfer coefficient between scroll and gas in chambers, in kW/m^2/K ScrollComp.motor = Motor() ScrollComp.motor.set_eta(0.9) ScrollComp.motor.suction_fraction = 1.0 Tin = Te + 11.1 temp = State.State(Ref, {'T': Te, 'Q': 1}) pe = temp.p temp.update(dict(T=Tc, Q=1)) pc = temp.p inletState = State.State(Ref, {'T': Tin, 'P': pe}) T2s = ScrollComp.guess_outlet_temp(inletState, pc) outletState = State.State(Ref, {'T': T2s, 'P': pc}) mdot_guess = inletState.rho * ScrollComp.Vdisp * ScrollComp.omega / (2 * pi) ScrollComp.add_tube( Tube(key1='inlet.1', key2='inlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State1=inletState.copy(), fixed=1, TubeFcn=ScrollComp.TubeCode)) ScrollComp.add_tube( Tube(key1='outlet.1', key2='outlet.2', L=0.3, ID=0.02, mdot=mdot_guess, State2=outletState.copy(), fixed=2, TubeFcn=ScrollComp.TubeCode)) ScrollComp.auto_add_CVs(inletState, outletState) ScrollComp.add_CV( ControlVolume( key='discplenum', initialState=outletState.copy(), VdVFcn=lambda theta: (1e-4, 0 ) # Constant volume, outputs of function are volume, dV/dtheta )) ScrollComp.auto_add_leakage(flankFunc=ScrollComp.FlankLeakage, radialFunc=ScrollComp.RadialLeakage) FP = FlowPath( key1='inlet.2', key2='sa', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * 0.01**2 / 4 ScrollComp.add_flow(FP) FP = FlowPath( key1='outlet.1', key2='discplenum', MdotFcn=IsentropicNozzleWrapper(), ) FP.A = pi * 0.01**2 / 4 ScrollComp.add_flow(FP) ScrollComp.add_flow( FlowPath(key1='sa', key2='s1', MdotFcn=ScrollComp.SA_S1, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='sa', key2='s2', MdotFcn=ScrollComp.SA_S2, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='discplenum', key2='dd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) ScrollComp.add_flow( FlowPath(key1='discplenum', key2='ddd', MdotFcn=ScrollComp.DISC_DD, MdotFcn_kwargs=dict(X_d=0.7))) # ScrollComp.add_flow(FlowPath(key1 = 'outlet.1', # key2 = 'd1', # MdotFcn = ScrollComp.DISC_D1, # MdotFcn_kwargs = dict(X_d = 0.7) # ) # ) # # FP = FlowPath(key1='outlet.1', # key2='dd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # # FP = FlowPath(key1='outlet.1', # key2='ddd', # MdotFcn=IsentropicNozzleWrapper(), # ) # FP.A = pi*0.006**2/4 # ScrollComp.add_flow(FP) # *************** # Discharge Ports # *************** sim = ScrollComp for involute in ['i', 'o']: # Define the parameters for the ports if involute == 'i': phi_list = np.linspace(sim.geo.phi_fie - 2 * np.pi - 0.1, sim.geo.phi_fis + np.pi / 2, Nports) elif involute == 'o': phi_list = np.linspace(sim.geo.phi_foe - 2 * np.pi - 0.1, sim.geo.phi_fos + np.pi / 2, Nports) else: raise ValueError(involute) involute_list = [involute] * len(phi_list) D_list = [sim.geo.t] * len( phi_list) # All ports are thickness of scroll in diameter offset_list = [ d * 0.5 for d in D_list ] # Distance of translation of center of port normal to wall X_d_list = [1.0] * len(phi_list) # Flow coefficient for forward flow X_d_backflow_list = [0.0] * len(phi_list) # Backflow coefficient # Add the ports to the model sim.fixed_scroll_ports = [] for i in range(Nports): p = Port() p.phi = phi_list[i] p.involute = involute_list[i] p.offset = offset_list[i] p.D = D_list[i] p.parent = 'discplenum' p.X_d = X_d_list[i] p.X_d_backflow = X_d_backflow_list[i] sim.fixed_scroll_ports.append(p) # Calculate the areas between each port and every control volume # # Can turn on plotting (plot=True) to see the flow areas. sim.calculate_port_areas(plot=False) # Iterate over the ports, connecting them to discharge plenum for port in sim.fixed_scroll_ports: # Iterate over the chambers each port is connected to at least # at some point for partner in port.area_dict: # Create a spline interpolator object for the area between port and the partner chamber A_interpolator = interp.splrep(port.theta, port.area_dict[partner], k=2, s=0) # Add the flow path connecting the working chamber and discharge plenum # # It is a simplified nozzle model, allowing for flow out the nozzle, # according to the flow area at the given crank angle, but no backflow. # This represents an idealized case. sim.add_flow( FlowPath(key1='discplenum', key2=partner, MdotFcn=sim.INTERPOLATING_NOZZLE_FLOW, MdotFcn_kwargs=dict( X_d=port.X_d, X_d_backflow=port.X_d_backflow, upstream_key=partner, A_interpolator=A_interpolator))) ScrollComp.add_flow( FlowPath(key1='d1', key2='dd', MdotFcn=ScrollComp.D_to_DD)) ScrollComp.add_flow( FlowPath(key1='d2', key2='dd', MdotFcn=ScrollComp.D_to_DD)) #Connect the callbacks for the step, endcycle, heat transfer and lump energy balance ScrollComp.connect_callbacks( step_callback=ScrollComp.step_callback, endcycle_callback=ScrollComp.endcycle_callback, heat_transfer_callback=ScrollComp.heat_transfer_callback, lumps_energy_balance_callback=ScrollComp.lump_energy_balance_callback) t1 = timeit.default_timer() ScrollComp.RK45_eps = 1e-6 ScrollComp.eps_cycle = 3e-3 try: ScrollComp.solve( key_inlet='inlet.1', key_outlet='outlet.2', solver_method='RK45', OneCycle=OneCycle, plot_every_cycle=False, #hmin = 1e-3 eps_cycle=3e-3) except BaseException as E: print(E) raise print('time taken', timeit.default_timer() - t1) del ScrollComp.FlowStorage from PDSim.misc.hdf5 import HDF5Writer h5 = HDF5Writer() h5.write_to_file(ScrollComp, HDF5file) if '--plot' in sys.argv: debug_plots(ScrollComp, family='Scroll Compressor') return ScrollComp