Beispiel #1
0
    def test_suphVap_10(self):
        # MECH2201 A8 Q1 State 1

        statePropt = {'P': 8000, 'T': 500}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)

        expected_h = 3398.3
        expected_s = 6.7240

        self.assertTrue(isWithin(testState.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState.h))

        self.assertTrue(isWithin(testState.s, 3, '%', expected_s))
        print('Expected: {0}'.format(expected_s))
        print('Received: {0}'.format(testState.s))

        # state 2s

        statePropt = {'P': 30, 's': testState.s}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)

        expected_h = 2276.8
        expected_x = 0.847

        self.assertTrue(isWithin(testState.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState.h))

        self.assertTrue(isWithin(testState.x, 3, '%', expected_x))
        print('Expected: {0}'.format(expected_x))
        print('Received: {0}'.format(testState.x))
Beispiel #2
0
    def test_flows_water_15(self):

        # CENGEL P10-22

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.massFR = 20
        flow_a.items = [
            state_01 := StatePure(P=6000), boiler := Boiler(), state_02 :=
            StatePure(T=450), turbine := Turbine(eta_isentropic=0.94), state_03
            := StatePure(), condenser := Condenser(), state_04 :=
            StatePure(P=50, T=water.define(StatePure(P=50, x=0)).T - 6.3), pump
            := Pump(), state_01
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.solve()

        self.CompareResults(state_04, {'h': 314.03, 'mu': 0.001026}, 2)
        self.CompareResults(state_01, {'h': 320.13}, 2)
        self.CompareResults(state_03, {'h': 2394.4}, 2)

        self.assertTrue(isWithin(cycle.Q_in, 1, '%', 59660))
        self.assertTrue(isWithin(cycle.netPower, 1, '%', 18050))
        self.assertTrue(isWithin(cycle.efficiency, 1, '%', 0.303))

        pass
Beispiel #3
0
 def defineState_ifDefinable(self, state: StatePure):
     if not state.isFullyDefined() and state.isFullyDefinable():
         try:
             state.copy_fromState(self.define(state))
         except NeedsExtrapolationError:
             print(
                 'Fluid.defineState_ifDefinable: Leaving state @ {0} not fully defined'
                 .format(state))
     return state
Beispiel #4
0
    def test_flows_water_14(self):

        # CENGEL P10-47

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.massFR = 16
        flow_a.items = [
            ofwh2 := MixingChamber(), state_05 := StatePure(x=0), pump3 :=
            Pump(), state_06 := StatePure(), boiler := Boiler(), state_07 :=
            StatePure(P=8000, T=550), turbine := Turbine()
        ]

        flow_b = Flow(water)
        flow_b.items = [turbine, state_08 := StatePure(P=600), ofwh2]

        flow_c = Flow(water)
        flow_c.items = [
            turbine, state_09 := StatePure(P=200), ofwh1 := MixingChamber()
        ]

        flow_d = Flow(water)
        flow_d.items = [
            turbine, state_10 := StatePure(P=10), condenser := Condenser(),
            state_01 := StatePure(x=0), pump1 := Pump(), state_02 :=
            StatePure(), ofwh1
        ]

        flow_e = Flow(water)
        flow_e.items = [
            ofwh1, state_03 := StatePure(x=0), pump2 := Pump(), state_04 :=
            StatePure(), ofwh2
        ]

        cycle = Cycle()
        cycle.flows = [flow_a, flow_b, flow_c, flow_d, flow_e]
        cycle.solve()

        for e in cycle._equations:
            e.update()
        cycle.solve()

        for e in cycle._equations:
            e.update()
        cycle.solve()

        self.CompareResults(state_02, {'h': 192}, 2)
        self.CompareResults(state_04, {'h': 505.13}, 2)
        self.CompareResults(state_06, {'h': 678.52}, 2)
        self.CompareResults(flow_b, {'massFF': 0.07171}, 2)
        self.CompareResults(flow_c, {'massFF': 0.1201}, 2)

        self.assertTrue(isWithin(cycle.netPower, 1, '%', 19800))
        self.assertTrue(isWithin(cycle.efficiency, 1, '%', 0.435))

        pass
Beispiel #5
0
def apply_isentropicEfficiency(state_in: StatePure, state_out_ideal: StatePure, eta_isentropic: float, fluid: 'Fluid'):
    """Returns a new state_out based on the provided one, with all fields filled out based on the isentropic efficiency of the process between the state_in and state_out."""

    assert state_out_ideal.hasDefined('P')
    state_out_ideal.set_or_verify({'s': state_in.s})
    try:
        state_out_ideal.copy_fromState(fluid.define(state_out_ideal))
    except NeedsExtrapolationError:
        # For pumps dealing with subcooled liquids no data may be available. w = mu*dP relation can be used to get at least the h.
        if all(state.x <= 0 for state in [state_in, state_out_ideal]):
            apply_incompressibleWorkRelation(state_in=state_in, state_out=state_out_ideal)

    assert all(state.hasDefined('h') for state in [state_in, state_out_ideal])  # state_in & state_out should have *h* defined
    work_ideal = state_out_ideal.h - state_in.h

    state_out_actual = StatePure(P=state_out_ideal.P)

    if work_ideal >= 0:
        # work provided to flow from device -> eta_s = w_ideal / w_actual
        work_actual = work_ideal / eta_isentropic
        state_out_actual.h = work_actual + state_in.h
    elif work_ideal < 0:
        # work extracted from flow by device -> eta_s = w_actual / w_ideal
        work_ideal = abs(work_ideal)
        work_actual = eta_isentropic * work_ideal
        state_out_actual.h = state_in.h - work_actual

    return fluid.defineState_ifDefinable(state_out_actual)
Beispiel #6
0
    def test_flows_water_06(self):
        # CENGEL P10-48
        # diagram in book is not helpful - see solutions

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            mixc := MixingChamber(), state_t := StatePure(), condenser :=
            Condenser(), state_1 := StatePure(x=0), pump := Pump(), state_2 :=
            StatePure(), cfwh := HeatExchanger(), state_3 :=
            StatePure(T=water.define(StatePure(P=1000, x=0)).T), boiler :=
            Boiler(), state_4 := StatePure(P=3000,
                                           T=350), turbine := Turbine()
        ]

        flow_b = Flow(water)
        flow_b.items = [
            turbine, state_5 := StatePure(P=1000), cfwh, state_7 :=
            StatePure(x=0), trap := Trap(), state_8 := StatePure(P=20), mixc
        ]

        flow_c = Flow(water)
        flow_c.items = [turbine, state_6 := StatePure(), mixc]

        cycle = Cycle()
        cycle.flows = [flow_a, flow_b, flow_c]
        cycle.solve()

        for e in cycle._equations:
            e.update()
        cycle.solve()
        for e in cycle._equations:
            e.update()
        cycle.solve()

        for f in cycle.flows:  # TODO - Has to solve the flows manually again
            f.solve()

        for e in cycle._equations:
            e.update()
        cycle.solve()

        self.CompareResults(state_2, {'h': 254.45}, 2)
        self.CompareResults(state_4, {'h': 3116.1, 's': 6.7450}, 2)
        self.CompareResults(state_5, {'h': 2851.9}, 2)
        self.CompareResults(state_6, {'h': 2221.7, 'x': 0.8357}, 2)
        self.CompareResults(state_7, {'h': 762.51, 'T': 179.9}, 2)
        self.CompareResults(flow_b, {'massFF': 0.2437}, 2)

        self.assertTrue(isWithin(cycle.sHeat, 2, '%', 2353))
        self.assertTrue(isWithin(cycle.net_sPower, 2, '%', 737.8))
        self.assertTrue(isWithin(cycle.efficiency, 1, '%', 0.3136))

        pass
Beispiel #7
0
    def test_satMix_02(self):
        # From MECH2201 - A9 Q2 - state 4

        statePropt = {'P': 5, 's': 7.7622, 'x': 0.92}
        testState = StatePure(**statePropt)
        self.assertTrue(testState.isFullyDefinable())
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected = 2367.8
        self.assertTrue(isWithin(testState.h, 3, '%', expected))
        print('Expected: {0}'.format(expected))
        print('Received: {0}'.format(testState.h))
Beispiel #8
0
    def test_satMix_01(self):
        # From MECH2201 - A9 Q3

        statePropt = {'P': 6, 's': 6.4855, 'x': 0.7638}
        testState = StatePure(**statePropt)
        self.assertTrue(testState.isFullyDefinable())
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected = 1996.7
        self.assertTrue(isWithin(testState.h, 3, '%', expected))
        print('Expected: {0}'.format(expected))
        print('Received: {0}'.format(testState.h))
Beispiel #9
0
    def test_subcLiq_02(self):
        # From MECH2201 - A9 Q2 - state 6

        state5 = StatePure(P=5, x=0)
        state5 = fullyDefine_StatePure(state5, water_mpDF)

        state6s = StatePure(P=200, s=state5.s)
        state6s = fullyDefine_StatePure(state6s, water_mpDF)

        h6_manual = state5.h + state5.mu * (state6s.P - state5.P)

        self.assertTrue(isWithin(h6_manual, 3, '%', 138))
Beispiel #10
0
    def test_subcLiq_03(self):
        # From MECH2201 - A9 Q3 - state 4

        s3 = fullyDefine_StatePure(StatePure(P=6, x=0), water_mpDF)
        s4 = fullyDefine_StatePure(StatePure(P=150, s=s3.s), water_mpDF)

        s4_h_alt = 151.67  # manua calculation with vdp
        self.assertTrue(isWithin(s4.h, 3, '%', s4_h_alt))

        s5 = fullyDefine_StatePure(StatePure(P=150, x=0), water_mpDF)
        s6 = fullyDefine_StatePure(StatePure(P=12000, s=s5.s), water_mpDF)

        s6_h_alt = 479.59
        self.assertTrue(isWithin(s6.h, 3, '%', s6_h_alt))
Beispiel #11
0
    def test_suphVap_09(self):
        # MECH2201 A7 Q2 State 3 & 1 & 2

        statePropt = {
            'P': 50,
            'T': 100
        }  # P & T above critical values - no saturated mixture exists
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)

        expected_h = 2682.5
        expected_s = 7.6947

        self.assertTrue(isWithin(testState.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState.h))

        self.assertTrue(isWithin(testState.s, 3, '%', expected_s))
        print('Expected: {0}'.format(expected_s))
        print('Received: {0}'.format(testState.s))

        # below is state 1

        statePropt2 = {'P': 3000, 's': testState.s}
        testState2 = StatePure(**statePropt2)
        testState2 = fullyDefine_StatePure(testState2, water_mpDF)

        expected_h = 3854.1

        self.assertTrue(isWithin(testState2.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState2.h))

        self.assertTrue(testState2.x > 1)

        # below is state 2

        statePropt3 = {'P': 500, 's': testState.s}
        testState3 = StatePure(**statePropt3)
        testState3 = fullyDefine_StatePure(testState3, water_mpDF)

        expected_h = 3207.7

        self.assertTrue(isWithin(testState3.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState3.h))

        self.assertTrue(testState2.x > 1)
Beispiel #12
0
    def test_subcLiq_01(self):
        # From MECH2201 - A9 Q1 - state 6

        state5 = StatePure(P=10, x=0)
        state5 = fullyDefine_StatePure(state5, water_mpDF)

        state6s = StatePure(P=10000, s=state5.s)
        state6s = fullyDefine_StatePure(state6s, water_mpDF)

        eta_p = 0.95

        W_is = state5.mu * (state6s.P - state5.P)
        W_ia = W_is / eta_p

        h6a = state5.h + W_ia
        self.assertTrue(isWithin(h6a, 3, '%', 202.45))
Beispiel #13
0
    def test_satVap_01(self):
        # From MECH2201 - A7 Q3 - state 1

        statePropt = {'P': 600, 'x': 1}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected_mu = 0.3157
        expected_s = 6.76
        expected_T = 158.85
        expected_u = 2567.4

        self.assertTrue(isWithin(testState.u, 3, '%', expected_u))
        print('Expected: {0}'.format(expected_u))
        print('Received: {0}'.format(testState.u))

        self.assertTrue(isWithin(testState.mu, 3, '%', expected_mu))
        print('Expected: {0}'.format(expected_mu))
        print('Received: {0}'.format(testState.mu))

        self.assertTrue(isWithin(testState.s, 3, '%', expected_s))
        print('Expected: {0}'.format(expected_s))
        print('Received: {0}'.format(testState.s))

        self.assertTrue(isWithin(testState.T, 3, '%', expected_T))
        print('Expected: {0}'.format(expected_T))
        print('Received: {0}'.format(testState.T))
Beispiel #14
0
    def test_satLiq_03(self):
        # From MECH2201 - A9 Q1 - state 5

        statePropt = {'P': 10, 'x': 0}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected_h = 191.83
        expected_mu = 0.001010
        expected_s = 0.6493
        expected_T = 45.81

        self.assertTrue(isWithin(testState.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState.h))

        self.assertTrue(isWithin(testState.mu, 3, '%', expected_mu))
        print('Expected: {0}'.format(expected_mu))
        print('Received: {0}'.format(testState.mu))

        self.assertTrue(isWithin(testState.s, 3, '%', expected_s))
        print('Expected: {0}'.format(expected_s))
        print('Received: {0}'.format(testState.s))

        self.assertTrue(isWithin(testState.T, 3, '%', expected_T))
        print('Expected: {0}'.format(expected_T))
        print('Received: {0}'.format(testState.T))
Beispiel #15
0
def apply_isentropicEfficiency(constant_c: bool, state_in: StatePure, state_out_ideal: StatePure, eta_isentropic: float, fluid: 'Fluid'):
    """Returns a new state_out based on the provided one, with all fields filled out based on the isentropic efficiency of the process between the state_in and state_out."""

    if not constant_c:  # Variable c analysis - will use tabulated data for fluids other than ideal gases
        if state_out_ideal.hasDefined('P'):

            if fluid.stateClass is StatePure:  # if not an IGas flow - ideally should check if fluid is IGas but cannot as ThprOps do not know fluids.
                state_out_ideal.set_or_verify({'s': state_in.s})
                try:
                    state_out_ideal.copy_fromState(fluid.define(state_out_ideal))
                except NeedsExtrapolationError:
                    # For pumps dealing with subcooled liquids no data may be available. w = mu*dP relation can be used to get at least the h.
                    if all(state.x <= 0 for state in [state_in, state_out_ideal]):
                        apply_incompressibleWorkRelation(state_in=state_in, state_out=state_out_ideal)

            assert all(state.hasDefined('h') for state in [state_in, state_out_ideal])  # state_in & state_out should have *h* defined
            work_ideal = state_out_ideal.h - state_in.h

            state_out_actual = fluid.stateClass(P=state_out_ideal.P)

            if work_ideal >= 0:  # work provided to flow from device -> eta_s = w_ideal / w_actual
                work_actual = work_ideal / eta_isentropic
                state_out_actual.h = work_actual + state_in.h
            elif work_ideal < 0:  # work extracted from flow by device -> eta_s = w_actual / w_ideal
                work_ideal = abs(work_ideal)
                work_actual = eta_isentropic * work_ideal
                state_out_actual.h = state_in.h - work_actual

            return fluid.defineState_ifDefinable(state_out_actual)

    else:  # Constant c analysis
        if all(state.hasDefined('T') for state in [state_in, state_out_ideal]):
            work_ideal = fluid.cp*(state_out_ideal.T - state_in.T)

            state_out_actual = fluid.stateClass()
            state_out_actual.copy_fromState(state_out_ideal)  # accessing __class__ like this, to use the same class as state_out - could be StatePure or StateIGas

            if work_ideal >= 0:
                work_actual = work_ideal / eta_isentropic
                state_out_actual.T = (work_actual/fluid.cp) + state_in.T
                state_out_actual.mu = float('nan')  # mu of state_out_ideal no longer valid, needs to be recalculated with IGasLaw
            elif work_ideal <= 0:
                work_ideal = abs(work_ideal)
                work_actual = eta_isentropic * work_ideal
                state_out_actual.T = state_in.T - (work_actual/fluid.cp)
                state_out_actual.mu = float('nan')  # mu of state_out_ideal no longer valid, needs to be recalculated with IGasLaw
            return state_out_actual
Beispiel #16
0
    def test_flows_refr_01(self):
        # CENGEL P11-13

        flow_a = Flow(R134a)
        flow_a.massFF = 1
        flow_a.items = [
            state_1 := StatePure(x=1), compressor := Compressor(), state_2 :=
            StatePure(P=800), condenser := Condenser(), state_3 :=
            StatePure(x=0), expValve := Trap(), state_4 := StatePure(T=-12),
            evaporator := Boiler(), state_1
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.solve()

        pass
Beispiel #17
0
    def test_flows_water_12(self):
        # CENGEL P10-45

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            ofwh := MixingChamber(), state_3 := StatePure(x=0), pump2 :=
            Pump(), state_4 := StatePure(), boiler := Boiler(), state_5 :=
            StatePure(P=6000, T=450), turbine := Turbine()
        ]

        flow_b = Flow(water)
        flow_b.items = [turbine, state_6 := StatePure(P=400), ofwh]

        flow_c = Flow(water)
        flow_c.items = [
            turbine, state_7 := StatePure(P=20), condenser := Condenser(),
            state_1 := StatePure(x=0), pump1 := Pump(), state_2 := StatePure(),
            ofwh
        ]

        cycle = Cycle()
        cycle.flows = [flow_a, flow_b, flow_c]
        cycle.solve()
        cycle.solve()

        for e in cycle._equations:
            e.update()

        cycle.solve()

        self.assertTrue(isWithin(cycle.net_sPower, 1, '%', 1017))
        self.assertTrue(isWithin(cycle.efficiency, 1, '%', 0.378))

        pass
Beispiel #18
0
    def test_satMix_06(self):
        # From MECH2201 - A7 Q1 - state 2

        state1Propt = {'T': 100, 'x': 1}
        state1 = StatePure(**state1Propt)
        state1 = fullyDefine_StatePure(state1, water_mpDF)
        expected_s = 7.3549
        expected_P = 101.35
        expected_mu = 1.6729
        expected_u = 2506.5

        self.assertTrue(isWithin(state1.s, 3, '%', expected_s))
        print('Expected: {0}'.format(expected_s))
        print('Received: {0}'.format(state1.s))

        self.assertTrue(isWithin(state1.P, 3, '%', expected_P))
        print('Expected: {0}'.format(expected_P))
        print('Received: {0}'.format(state1.P))

        self.assertTrue(isWithin(state1.mu, 3, '%', expected_mu))
        print('Expected: {0}'.format(expected_mu))
        print('Received: {0}'.format(state1.mu))

        self.assertTrue(isWithin(state1.u, 3, '%', expected_u))
        print('Expected: {0}'.format(expected_u))
        print('Received: {0}'.format(state1.u))

        state2Propt = {'T': 25, 'mu': state1.mu}
        state2 = StatePure(**state2Propt)
        state2 = fullyDefine_StatePure(state2, water_mpDF)
        expected_x = 0.03856
        expected_s = 0.6832
        expected_u = 193.76

        self.assertTrue(isWithin(state2.s, 3, '%', expected_s))
        print('Expected: {0}'.format(expected_s))
        print('Received: {0}'.format(state2.s))

        self.assertTrue(isWithin(state2.x, 3, '%', expected_x))
        print('Expected: {0}'.format(expected_x))
        print('Received: {0}'.format(state2.x))

        self.assertTrue(isWithin(state2.u, 3, '%', expected_u))
        print('Expected: {0}'.format(expected_u))
        print('Received: {0}'.format(state2.u))
Beispiel #19
0
    def test_satLiq_01(self):
        # From MECH2201 - A9 Q2 - state 11

        statePropt = {'P': 600, 'x': 0}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected = 670.56
        self.assertTrue(isWithin(testState.h, 3, '%', expected))
        print('Expected: {0}'.format(expected))
        print('Received: {0}'.format(testState.h))
Beispiel #20
0
    def test_suphVap_04(self):
        # From MECH2201 - A9 Q2 - state 2

        statePropt = {'P': 1000, 's': 6.6776}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected_h = 2820.3

        self.assertTrue(isWithin(testState.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState.h))
Beispiel #21
0
def interpolate_onSaturationCurve(mpDF: DataFrame, interpolate_by: str, interpolate_at: float, endpoint: str) -> StatePure:
    """Method to interpolate along the saturation curve. Interpolates to find the state identified by 'endpoint' (either f or g, for saturated liquid or vapor states) (i.e. identifier
    for left or right side of the saturation curve), and by value ('interpolate_at') of the property ('interpolate_by')."""

    endpoint_x = {'f': 0, 'g': 1}
    x = endpoint_x[endpoint]

    queryPropt, queryValue = interpolate_by, interpolate_at  # rename for clarity in this method

    satStates_ordered_byPropt = mpDF.query('x == {0}'.format(x)).sort_values(queryPropt)  # retrieve only saturated liquid states
    satStates_ProptVals = satStates_ordered_byPropt[queryPropt].to_list()

    proptVal_below, proptVal_above = get_surroundingValues(satStates_ProptVals, queryValue) # satStates_ProptVals[bisect_left(satStates_ProptVals, queryValue) - 1], satStates_ProptVals[bisect_right(satStates_ProptVals, queryValue)]
    satState_below, satState_above = mpDF.query('x == {0} and {1} == {2}'.format(x, queryPropt, proptVal_below)), mpDF.query('x == {0} and {1} == {2}'.format(x, queryPropt, proptVal_above))
    assert all(not state_DFrow.empty for state_DFrow in [satState_below, satState_above]), 'More than one saturation state provided for the same value of query property "{0}" in supplied data file.'.format(queryPropt)

    satState_below, satState_above = StatePure().init_fromDFRow(satState_below), StatePure().init_fromDFRow(satState_above)

    satState_atProptVal = interpolate_betweenPureStates(satState_below, satState_above, interpolate_at={queryPropt: queryValue})
    assert satState_atProptVal.isFullyDefined()
    return satState_atProptVal
Beispiel #22
0
    def test_suphVap_08(self):
        # Superheated state requiring double interpolation

        statePropt = {'P': 20, 'T': 625}  # P & T above critical values - no saturated mixture exists
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)

        expected_mu = 33.159

        self.assertTrue(isWithin(testState.mu, 3, '%', expected_mu))
        print('Expected: {0}'.format(expected_mu))
        print('Received: {0}'.format(testState.mu))
Beispiel #23
0
    def test_flows_water_17(self):
        # CENGEL P10-31

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.massFR = 1.74
        flow_a.items = [
            state_02 := StatePure(), rhboiler :=
            ReheatBoiler(infer_fixed_exitT=True), state_03 :=
            StatePure(T=400, P=6000), hpturbine := Turbine(), state_04 :=
            StatePure(P=2000), rhboiler, state_05 := StatePure(), lpturbine :=
            Turbine(), state_06 := StatePure(P=20), condenser := Condenser(),
            state_01 := StatePure(x=0), pump := Pump(), state_02
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.solve()

        self.CompareResults(state_02, {'h': 257.5}, 2)
        self.CompareResults(state_06, {'h': 2349.7}, 2)

        self.assertTrue(isWithin(cycle.sHeat, 1, '%', 3268))
        self.assertTrue(isWithin(cycle.net_sPower, 1, '%', 1170))
        self.assertTrue(isWithin(cycle.efficiency, 1, '%', 0.358))

        pass
Beispiel #24
0
    def test_flows_water_11(self):
        # CENGEL P10-38

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            state_1 := StatePure(x=0, P=10), pump := Pump(eta_isentropic=1),
            state_2 := StatePure(), rhboiler :=
            ReheatBoiler(infer_fixed_exitT=True), state_3 := StatePure(P=10000,
                                                                       T=500),
            hpt := Turbine(eta_isentropic=1), state_4 := StatePure(), rhboiler,
            state_5 := StatePure(P=1000,
                                 T=500), lpt := Turbine(eta_isentropic=1),
            state_6 := StatePure(), condenser := Condenser(), state_1
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.netPower = 80000
        cycle.solve()

        self.CompareResults(state_6, {'x': 0.949}, 2)

        self.assertTrue(
            isWithin(
                flow_a.get_net_sWorkExtracted() / flow_a.get_sHeatSupplied(),
                2, '%', 0.413))
        self.assertTrue(isWithin(flow_a.massFR, 2, '%', 50))

        pass
Beispiel #25
0
    def test_flows_water_10(self):
        # CENGEL P10-37

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            state_1 := StatePure(x=0, P=10), pump := Pump(eta_isentropic=0.95),
            state_2 := StatePure(), rhboiler :=
            ReheatBoiler(infer_fixed_exitT=True), state_3 := StatePure(P=10000,
                                                                       T=500),
            hpt := Turbine(eta_isentropic=0.8), state_4 := StatePure(),
            rhboiler, state_5 := StatePure(P=1000, T=500), lpt :=
            Turbine(eta_isentropic=0.8), state_6 := StatePure(), condenser :=
            Condenser(), state_1
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.netPower = 80000
        cycle.solve()

        self.CompareResults(state_2, {'h': 202.43}, 2)
        self.CompareResults(state_4, {'h': 2902}, 2)
        self.CompareResults(state_6, {'h': 2664.8, 'T': 88.1}, 2)

        self.assertTrue(
            isWithin(flow_a.get_net_sWorkExtracted(), 2, '%', 1276.8))
        self.assertTrue(isWithin(flow_a.get_sHeatSupplied(), 2, '%', 3749.8))
        self.assertTrue(isWithin(flow_a.massFR, 2, '%', 62.7))

        pass
Beispiel #26
0
    def test_flows_water_09(self):
        # CENGEL P10-35

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.massFR = 12
        flow_a.items = [
            state_1 := StatePure(x=0), pump := Pump(), state_2 :=
            StatePure(P=15000), rhboiler :=
            ReheatBoiler(infer_fixed_exitT=True), state_3 := StatePure(T=500),
            hpt := Turbine(), state_4 := StatePure(), rhboiler, state_5 :=
            StatePure(), lpt := Turbine(), state_6 := StatePure(P=10, x=0.9),
            condenser := Condenser(), state_1
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.solve()

        self.CompareResults(state_2, {'h': 206.95}, 2)
        self.CompareResults(state_5, {
            'P': 2160,
            'h': 3466.61
        }, 2)  # not sure why answers say 2150 - did manually, ~2161
        self.CompareResults(state_4, {'h': 2817.2}, 2)

        self.assertTrue(isWithin(cycle.Q_in, 2, '%', 45039))
        self.assertTrue(isWithin(cycle.netPower / cycle.Q_in, 2, '%', 0.426))

        pass
Beispiel #27
0
    def test_flows_water_08(self):
        # CENGEL P10-34

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            state_1 := StatePure(x=0), pump := Pump(), state_2 :=
            StatePure(P=5000), rhboiler :=
            ReheatBoiler(infer_fixed_exitT=False), state_3 := StatePure(), hpt
            := Turbine(), state_4 := StatePure(P=1200, x=0.96), rhboiler,
            state_5 := StatePure(), lpt := Turbine(), state_6 :=
            StatePure(P=20, x=0.96), condenser := Condenser(), state_1
        ]

        cycle = Cycle()
        cycle.flows = [flow_a]
        cycle.solve()

        self.CompareResults(state_2, {'h': 256.49}, 2)
        self.CompareResults(state_3, {'h': 3006.9, 'T': 327.2}, 2)
        self.CompareResults(state_5, {'h': 3436, 'T': 481.1}, 2)

        self.assertTrue(isWithin(flow_a.get_sHeatSupplied(), 2, '%', 3482))
        self.assertTrue(
            isWithin(
                flow_a.get_net_sWorkExtracted() / flow_a.get_sHeatSupplied(),
                2, '%', 0.35))

        pass
Beispiel #28
0
    def test_flows_water_13(self):
        # CENGEL P10-46

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            mixc := MixingChamber(), state_4 := StatePure(), boiler :=
            Boiler(), state_5 := StatePure(P=6000,
                                           T=450), turbine := Turbine()
        ]

        flow_b = Flow(water)
        flow_b.items = [
            turbine, state_6 := StatePure(P=400), cfwh := HeatExchanger(),
            state_3 := StatePure(x=0), pump2 := Pump(), state_9 := StatePure(),
            mixc
        ]

        flow_c = Flow(water)
        flow_c.items = [
            turbine, state_7 := StatePure(), condenser := Condenser(), state_1
            := StatePure(x=0, P=20), pump1 := Pump(), state_2 := StatePure(),
            cfwh, state_8 := StatePure(), mixc
        ]

        # assuming h8 = h9 = h4 - 8 & 9 have same pressure. determine 8's h by vdp (determine out of nowhere)

        cycle = Cycle()
        cycle.flows = [flow_a, flow_b, flow_c]
        cycle.solve()

        wtot = 0
        for f in cycle.flows:
            wtot += f.massFF * f.get_net_sWorkExtracted()

        qtot = 0
        for f in cycle.flows:
            qtot += f.massFF * f.get_sHeatSupplied()

        self.assertTrue(isWithin(wtot, 1, '%', 1016.8))
        self.assertTrue(isWithin(wtot / qtot, 1, '%', 0.378))

        pass
Beispiel #29
0
    def test_flows_water_07(self):
        # CENGEL P10-55

        flow_a = Flow(water)
        flow_a.massFF = 1
        flow_a.items = [
            ofwh := MixingChamber(), state_03 := StatePure(x=0), pump2 :=
            Pump(), state_04 := StatePure(), rhboiler := ReheatBoiler(),
            state_05 := StatePure(P=10000, T=550), turba := Turbine(), state_06
            := StatePure(P=800)
        ]

        flow_b = Flow(water)
        flow_b.items = [
            state_06, rhboiler, state_07 := StatePure(T=500), turbineb :=
            Turbine(), state_08 := StatePure(P=10), condenser := Condenser(),
            state_01 := StatePure(x=0), pump1 := Pump(), state_02 :=
            StatePure(), ofwh
        ]

        flow_c = Flow(water)
        flow_c.items = [state_06, ofwh]

        cycle = Cycle()
        cycle.flows = [flow_a, flow_b, flow_c]
        cycle.netPower = 80000

        cycle.solve()

        for e in cycle._equations:
            e.update()
        cycle.solve()

        self.CompareResults(state_02, {'h': 192.61}, 2)
        self.CompareResults(state_03, {'h': 720.87, 'mu': 0.001115}, 2)
        self.CompareResults(state_04, {'h': 731.12}, 2)
        self.CompareResults(state_05, {'h': 3502, 's': 6.7585}, 2)
        self.CompareResults(state_06, {'h': 2812.1}, 2)
        self.CompareResults(state_07, {'h': 3481.3, 's': 7.8692}, 2)
        self.CompareResults(state_08, {'h': 2494.7, 'x': 0.9627}, 2)

        self.CompareResults(flow_c, {'massFF': 0.2017}, 2)

        self.assertTrue(isWithin(flow_a.massFR, 2, '%', 54.5))
        self.assertTrue(isWithin(cycle.netPower / cycle.Q_in, 2, '%', 0.444))

        pass
Beispiel #30
0
    def test_satLiq_02(self):
        # From MECH2201 - A9 Q2 - state 7

        statePropt = {'P': 200, 'x': 0}
        testState = StatePure(**statePropt)
        testState = fullyDefine_StatePure(testState, water_mpDF)
        expected_h = 504.7
        expected_mu = 0.001061
        self.assertTrue(isWithin(testState.h, 3, '%', expected_h))
        print('Expected: {0}'.format(expected_h))
        print('Received: {0}'.format(testState.h))

        self.assertTrue(isWithin(testState.mu, 3, '%', expected_mu))
        print('Expected: {0}'.format(expected_mu))
        print('Received: {0}'.format(testState.mu))