Exemplo n.º 1
0
class TestRankineBasic(unittest.TestCase):
    wf = mc.FlowState("R123")
    pEvap = 10.e5
    superheat = 30.
    TCond = 300.
    subcool = 0
    comp = mc.CompBasic(nan, 0.7, sizeAttr="pRatio")
    sourceIn = mc.FlowState("Air", 0.09, mc.PT_INPUTS, 1.116e5, 1170.)
    evap = mc.library.alfaLaval_AC30EQ()
    evap.update({'sizeAttr': "NPlate", 'plate.T': 573.15})
    exp = mc.ExpBasic(nan, 0.7, sizeAttr="pRatio")
    sinkIn = mc.FlowState("Air", 0.20, mc.PT_INPUTS, 0.88260e5, 281.65)
    sinkAmbient = sinkIn.copy()
    sourceAmbient = sinkIn.copy()
    cond = mc.ClrBasic(mc.CONSTANT_P, nan, 1, sizeAttr="QCool")
    config = mc.Config()
    config.update({
        'dpEvap': False,
        'dpCond': False,
        'dpAcc': False,
        'dpPort': False,
        'dpHead': False
    })
    config.set_method("savostinTikhonov_sp", "GeomHxPlateChevron",
                      mc.TRANSFER_ALL, mc.UNITPHASE_ALL, mc.SECONDARY_FLUID)
    cycle = mc.RankineBasic(wf, evap, exp, cond, comp, pEvap, superheat, nan,
                            subcool, config)
    cycle.setAll_config(config)
    cycle.update({
        'TCond': TCond,
        'sourceIn': sourceIn,
        #'sinkIn': sinkIn,
        'sourceAmbient': sourceAmbient,
        #'sinkAmbient': sinkAmbient
    })
    cycle.pptdEvap = 10.

    def test_0_setup_cycle(self):
        self.assertAlmostEqual(self.cycle.pCond, 97797.60828695059, 5)
        self.assertIs(self.cycle.exp.config, self.config)
        self.assertAlmostEqual(self.cycle.mWf, 0.34307814292524513, 10)

    def test_1_size(self):
        self.cycle.update({"config.dpEvap": False, "evap.L": 0.269})
        self.cycle.size()
        self.assertEqual(self.cycle.evap.NPlate, 23)
        self.assertAlmostEqual(
            abs(self.cycle.evap.L - 0.268278920236407), 0, 2)
        self.assertAlmostEqual(self.cycle.comp.pRatio, 10.22519893, 4)
        self.assertAlmostEqual(self.cycle.exp.pRatio, 10.22519893, 4)
        self.assertAlmostEqual(self.cycle.evap.Q(), 83891.17350428084, 4)

    def test_1_size_dpEvap_True(self):
        self.cycle.update({"config.dpEvap": True, "evap.L": 0.269})
        self.cycle.size()
        self.assertAlmostEqual(
            abs(self.cycle.evap.L - 0.268278920236407), 0, 2)
        self.assertAlmostEqual(
            (self.cycle.comp.pRatio - 10.22519893) / 10.22519893, 0, 4)
        self.assertAlmostEqual(
            self.cycle.exp.pRatio,
            (self.cycle.pEvap - 39607.4552153897) / self.cycle.pCond, 4)
        self.assertAlmostEqual(self.cycle.evap.Q(), 83891.17350428084, 4)

    def test_1_run_from_comp(self):
        self.cycle.update({
            "config.dpEvap": False,
            "evap.NPlate": 23,
            "evap.L": 0.269,
            "pRatioExp": 10.22519893,
            "pRatioComp": 10.22519893,
            "cond.QCool": 73582.4417680011
        })
        self.cycle.clearWf_flows()
        rb0 = self.wf.copyUpdateState(mc.PT_INPUTS, self.pEvap,
                                      self.cycle.TEvap + 20.).h()
        rb1 = self.wf.copyUpdateState(mc.PT_INPUTS, self.pEvap,
                                      self.cycle.TEvap + 32.).h()
        self.evap.update({"runBounds": [rb0, rb1]})
        self.cycle.set_state6(
            self.wf.copyUpdateState(mc.QT_INPUTS, 0, self.TCond))
        self.cycle.run()
        self.assertAlmostEqual(
            abs(self.cycle.state4.T() / 3.6047e+02) - 1, 0, 3)
        self.assertAlmostEqual(
            abs(self.cycle.state4.p() / self.cycle.pCond) - 1, 0, 5)
        self.assertAlmostEqual(
            abs(self.cycle.state3.T() / (self.cycle.TEvap + 30)) - 1, 0, 3)

    '''
    def test_1_run_from_comp_dpEvap_True(self):
        self.cycle.update({
            "config.dpEvap": True,
            "evap.NPlate": 23,
            "evap.L": 0.269,
            "exp.pRatio": 9.820204742676,
            "comp.pRatio": 10.22519893,
            "cond.QCool": 73582.4417680011
        })
        self.cycle.clearWf_flows()
        rb0 = self.wf.copyUpdateState(mc.PT_INPUTS, self.pEvap,
                                self.cycle.TEvap + 20.).h()
        rb1 = self.wf.copyUpdateState(mc.PT_INPUTS, self.pEvap,
                                self.cycle.TEvap + 32.).h()
        self.evap.update({"runBounds": [rb0, rb1]})
        self.cycle.set_state6(self.wf.copyUpdateState(mc.QT_INPUTS, 0, self.TCond))
        self.cycle.run()
        self.assertAlmostEqual(
            abs(self.cycle.state4.T() / 3.6047e+02) - 1, 0, 3)
        self.assertAlmostEqual(
            abs(self.cycle.state4.p() / self.cycle.pCond) - 1, 0, 5)
        self.assertAlmostEqual(abs(self.cycle.state3.T() / (413.67)) - 1, 0, 2)
        self.assertAlmostEqual(
            abs(self.cycle.state3.p() / (9.6039e5)) - 1, 0, 1)
    '''

    def test_1_run_from_exp(self):
        self.cycle.update({
            "config.dpEvap": False,
            "evap.NPlate": 23,
            "evap.L": 0.269,
            "pRatioExp": 10.22519893,
            "pRatioComp": 10.22519893,
            "cond.QCool": 73582.4417680011
        })
        self.cycle.clearWf_flows()
        rb0 = self.wf.copyUpdateState(mc.PT_INPUTS, self.pEvap,
                                      self.cycle.TEvap + 20.).h()
        rb1 = self.wf.copyUpdateState(mc.PT_INPUTS, self.pEvap,
                                      self.cycle.TEvap + 32.).h()
        self.evap.update({"runBounds": [rb0, rb1]})
        self.cycle.set_state3(
            self.wf.copyUpdateState(mc.PT_INPUTS, self.cycle.pEvap,
                                    self.cycle.TEvap + 30))
        self.cycle.run()
        self.assertAlmostEqual(
            abs(self.cycle.state4.T() / 3.6047e+02) - 1, 0, 3)
        self.assertAlmostEqual(
            abs(self.cycle.state4.p() / self.cycle.pCond) - 1, 0, 5)
        self.assertAlmostEqual(
            abs(self.cycle.state3.T() / (self.cycle.TEvap + 30)) - 1, 0, 3)

    def test_cycle_plot(self):
        import os
        self.cycle.sizeSetup(True, True)
        self.cycle.plot(
            title="test_cycle_plot",
            show=False,
            savefig=True,
            savefig_name="test_cycle_plot",
            savefig_format="png",
            savefig_folder=".")
        cwd = os.getcwd()
        os.remove("./test_cycle_plot.png")
Exemplo n.º 2
0
    m=1.0,
    inputPair=mc.PT_INPUTS,
    input1=mc.atm2Pa(1),
    input2=298)
print("  - created working fluid")
exp = mc.ExpBasic(pRatio=1, efficiencyIsentropic=0.9, sizeAttr="pRatio")
print("  - created expander")
cond = mc.ClrBasic(constraint=mc.CONSTANT_P, QCool=1, efficiencyThermal=1.0, sizeAttr="Q")
print("  - created condenser")
comp = mc.CompBasic(pRatio=1, efficiencyIsentropic=0.85, sizeAttr="pRatio")
print("  - created compressor")
evap = mc.HtrBasic(constraint=mc.CONSTANT_P, QHeat=1, efficiencyThermal=1.0, sizeAttr="Q")
print("  - created evaporator")
config = mc.Config()
print("  - created configuration object")
cycle = mc.RankineBasic(
    wf=wf, evap=evap, exp=exp, cond=cond, comp=comp, config=config)
cycle.update({
    "pEvap": mc.bar2Pa(10),
    "superheat": 10.,
    "TCond": mc.degC2K(25),
    "subcool": 5.
})
print("  - created cycle")
print("setup done.")


@mc.timer
def plot_cycle():
    cycle.sizeSetup(unitiseEvap=False, unitiseCond=False)
    cycle.plot(
        graph='Ts',  # either 'Ts' or 'ph'
Exemplo n.º 3
0
    'dpEvap': False,
    'dpCond': False,
    'dpF': True,
    'dpAcc': False,
    'dpPort': False,
    'dpHead': False
})
config.set_method("chisholmWannairachchi_sp", ["GeomHxPlateCorrugatedChevron"],
                  ["all"], ["all-sp"], ["wf"])
config.set_method("yanLin_tpEvap", ["GeomHxPlateCorrugatedChevron"], ["all"],
                  ["tpEvap"], ["wf"])
config.set_method("savostinTikhonov_sp", ["GeomHxPlateCorrugatedChevron"],
                  ["all"], ["all-sp"], ["sf"])
print("  - created configuration object")
#evap.update({'config': config})
cycle = mc.RankineBasic(wf, evap, exp, cond, comp, pEvap, superheat, nan,
                        subcool, config)
cycle.update({
    'TCond': TCond,
    'sourceIn': sourceIn,
    'sourceAmbient': sourceAmbient,
    #'sinkIn': sinkIn,
    #'sinkDead': sinkDead
})
cycle.setAll_config(config)
print("  - created cycle")
print("setup done.")


@mc.timeThis
def run_plot():
    """Example of RankineBasic.plot()."""
Exemplo n.º 4
0
def run_example():
    """run example: zarati2017.py"""
    # ************************************************
    # Set up formatting
    # ************************************************
    # cycle.plot parameters
    plots_folder = "plots"
    plots_format = "png"  # change to "jpg" if preferred
    plots_dpi = 600
    if not os.path.exists(plots_folder):
        os.makedirs(plots_folder)
    # custom format for matplotlib
    mpl.rc("lines", lw=2.0)
    mpl.rc("lines", markersize=2)
    colours = ["blue", "red", "green", "black"]
    linestyles = ["-", "--", "-.", ":"]
    markerstyles = ["o", "v", "s", "^"]

    # ************************************************
    # Set up default cycle parameters
    # ************************************************
    #
    comp = mc.CompBasic(None, 0.9, sizeAttr="pRatio")
    #
    exp = mc.ExpBasic(None, 0.85, sizeAttr="pRatio")
    #
    sourceFluid = "Air"
    sourceIn_m = 5.5
    sourceIn_T = 744.  # from Table 9
    sourceIn_p = 0.37e5  # from cp=1085.4
    sourceIn = mc.FlowState(sourceFluid, "HEOS", None, sourceIn_m,
                            CP.PT_INPUTS, sourceIn_p, sourceIn_T)
    evapGeomPlateWf = mc.GeomHxPlateSmooth(b=0.024375)
    evapGeomPlateSf = mc.GeomHxPlateFinOffset(s=0.008,
                                              h=0.03,
                                              t=0.0002,
                                              l=0.02)
    stainlessSteel = mc.SolidMaterial(rho=8010., k=17.)
    evap = mc.HxPlate(flowSense="counterflow",
                      NPlate=17,
                      RfWf=0,
                      RfSf=0,
                      plate=stainlessSteel,
                      tPlate=0.2e-3,
                      geomPlateWf=evapGeomPlateWf,
                      geomPlateSf=evapGeomPlateSf,
                      L=0.2,
                      W=0.44,
                      effThermal=1.0)
    #
    ambient = mc.isa(mc.ft2m(20000))
    sinkFluid = "Air"
    sinkIn_m = None
    sinkIn_T = ambient.T / mc.TTotalRatio(gamma=1.4,
                                          M=0.49)  # from alt=20000ft
    sinkIn_p = ambient.p / mc.pTotalRatio(gamma=1.4,
                                          M=0.49)  # TODO from alt=20000ft
    sinkIn = mc.FlowState(sinkFluid, "HEOS", None, sinkIn_m, CP.PT_INPUTS,
                          sinkIn_p, sinkIn_T)
    sinkDead = sinkIn.copy()
    sourceDead = mc.FlowState(sourceFluid, "HEOS", None, None, CP.PT_INPUTS,
                              sinkIn_p, sinkIn_T)
    cond = mc.ClrBasicConstP(None, 1, sizeAttr="Q")
    #
    config = mc.Config(dpEvap=False,
                       dpCond=False,
                       dpF=True,
                       dpAcc=False,
                       dpPort=False,
                       dpHead=False)
    config.methods.set("shah_1phase_h", ["GeomHxPlateSmooth"], ["heat"],
                       ["wf"], "all-sp")
    cycle = mc.RankineBasic(wf=mc.FlowState("R245fa", "HEOS", None),
                            evap=evap,
                            exp=exp,
                            cond=cond,
                            comp=comp,
                            TEvap=416.18,
                            superheat=1.,
                            pCond=180.e3,
                            subcool=3.,
                            config=config,
                            sourceIn=sourceIn,
                            sinkIn=sinkIn,
                            sourceDead=sourceDead,
                            sinkDead=sinkDead)

    # ************************************************
    # Computations
    # ************************************************
    mWf_vals = np.linspace(1.0, 10.0, 20)
    plot_x = []
    plot_y0 = []
    plot_y1 = []
    plot_y2 = []
    for m in mWf_vals:
        cycle.update(mWf=m)
        cycle.sizeSetup(True, False)
        try:
            cycle.evap.run()
            print("---------")
            print(cycle.evap.L)
            plot_x.append(m)
            plot_y0.append(cycle.evap.flowOutSf.cp)
            plot_y1.append(cycle.evap.flowOutWf.T)
            plot_y2.append(cycle.evap.dpSf / cycle.evap.flowInSf.p)
        except:
            print("No convergence for m={}".format(m))

    plt.figure()
    plt.plot(plot_x, plot_y0)
    plt.savefig("{}/cp_vs_mWf.{}".format(plots_folder, plots_format))
    plt.figure()
    plt.plot(plot_x, plot_y1)
    plt.savefig("{}/T3Wf_vs_mWf.{}".format(plots_folder, plots_format))
    plt.figure()
    plt.plot(plot_x, plot_y2)
    plt.savefig("{}/dpSf/pSf_vs_mWf.{}".format(plots_folder, plots_format))
    """
Exemplo n.º 5
0
class TestRankineBasic(unittest.TestCase):
    wf = mc.FlowState("R123", "HEOS", None)
    pEvap = 10.e5
    superheat = 30.
    TCond = 300.
    subcool = None
    comp = mc.CompBasic(None, 0.7, sizeAttr="pRatio")
    sourceIn = mc.FlowState("Air", "HEOS", None, 0.09, CP.PT_INPUTS, 1.116e5,
                            1170.)
    evap = mc.library.alfaLaval_AC30EQ()
    evap.update(sizeAttr="NPlate")
    exp = mc.ExpBasic(None, 0.7, sizeAttr="pRatio")
    sinkIn = mc.FlowState("Air", "HEOS", None, 0.20, CP.PT_INPUTS, 0.88260e5,
                          281.65)
    sinkDead = sinkIn.copy()
    sourceDead = sinkIn.copy()
    #cond = mc.library.alfaLaval_CBXP27, sizeAttr="NPlate")
    cond = mc.ClrBasicConstP(None, 1, sizeAttr="Q")
    config = mc.Config(dpEvap=False,
                       dpCond=False,
                       dpAcc=False,
                       dpPort=False,
                       dpHead=False)
    cycle = mc.RankineBasic(wf,
                            evap,
                            exp,
                            cond,
                            comp,
                            pEvap,
                            superheat,
                            None,
                            subcool,
                            config,
                            TCond=TCond,
                            sourceIn=sourceIn,
                            sinkIn=sinkIn,
                            sourceDead=sourceDead,
                            sinkDead=sinkDead)
    cycle.pptdEvap = 10.

    def test_0_setup_cycle(self):
        self.assertAlmostEqual(self.cycle.pCond, 97797.60828695059, 5)
        self.assertIs(self.cycle.exp.config, self.config)
        self.assertAlmostEqual(self.cycle.mWf, 0.34307814292524513, 10)

    def test_1_size(self):
        self.cycle.config.dpEvap = False
        self.cycle.size()
        self.assertAlmostEqual(abs(self.cycle.evap.L - 0.268278920236407), 0,
                               2)
        self.assertAlmostEqual(self.cycle.comp.pRatio, 10.22519893, 4)
        self.assertAlmostEqual(self.cycle.exp.pRatio, 10.22519893, 4)
        self.assertAlmostEqual(self.cycle.evap.Q, 83891.17350428084, 6)

    def test_1_size_dpEvap_True(self):
        self.cycle.config.dpEvap = True
        self.cycle.size()
        self.assertAlmostEqual(abs(self.cycle.evap.L - 0.268278920236407), 0,
                               2)
        self.assertAlmostEqual(
            (self.cycle.comp.pRatio - 10.22519893) / 10.22519893, 0, 4)
        self.assertAlmostEqual(self.cycle.exp.pRatio,
                               (self.cycle.pEvap - 39607.4552153897) /
                               self.cycle.pCond, 4)
        self.assertAlmostEqual(self.cycle.evap.Q, 83891.17350428084, 4)

    def test_cycle_plot(self):
        import os
        self.cycle.sizeSetup()
        self.cycle.plot(title="test_cycle_plot",
                        show=False,
                        savefig=True,
                        savefig_name="test_cycle_plot",
                        savefig_format="png",
                        savefig_folder="")
        cwd = os.getcwd()
        os.remove(cwd + "/test_cycle_plot.png")