Exemple #1
0
    def test_exergy_analysis_bus_conversion(self):
        """Test exergy analysis at product exergy with T < Tamb."""
        ean = ExergyAnalysis(self.nw,
                             E_P=[self.power_out],
                             E_F=[self.cas_out],
                             E_L=[self.ex_loss])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        exergy_balance = (ean.network_data.E_F - ean.network_data.E_P -
                          ean.network_data.E_L - ean.network_data.E_D)
        msg = ('Exergy balance must be closed (residual value smaller than ' +
               str(err**0.5) + ') for this test but is ' +
               str(round(abs(exergy_balance), 4)) + '.')
        assert abs(exergy_balance) <= err**0.5, msg

        msg = ('Exergy efficiency must be equal to 1.0 for this test but is ' +
               str(round(ean.network_data.epsilon, 4)) + '.')
        assert round(ean.network_data.epsilon, 4) == 1, msg

        c = self.nw.get_conn('outlet')
        c.set_attr(T=self.Tamb - 20)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)

        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        msg = (
            'Exergy destruction must be equal to 0.0 for this test but is ' +
            str(round(ean.network_data.E_D, 4)) + '.')
        assert round(ean.network_data.E_D, 4) == 0, msg

        msg = ('Exergy loss must be equal to ' + str(round(c.Ex_physical, 4)) +
               ' for this test but is ' + str(round(ean.network_data.E_L, 4)) +
               '.')
        assert round(ean.network_data.E_L, 4) == round(c.Ex_physical, 4), msg
Exemple #2
0
 def test_exergy_analysis_component_on_two_busses(self):
     """Test exergy analysis errors with components on more than one bus."""
     with raises(TESPyNetworkError):
         ean = ExergyAnalysis(self.nw,
                              E_P=[self.power],
                              E_F=[self.heat, self.power])
         ean.analyse(pamb=self.pamb, Tamb=self.Tamb)
Exemple #3
0
    def test_exergy_analysis_violated_balance(self):
        """Test exergy analysis with violated balance."""
        # specify efficiency values for the internal bus
        self.nw.del_busses(self.fwp_power)
        self.fwp_power = Bus('feed water pump power', P=0)
        self.fwp_power.add_comps(
            {
                'comp': self.nw.get_comp('feed water pump turbine'),
                'char': 0.99
            }, {
                'comp': self.nw.get_comp('pump'),
                'char': 0.98,
                'base': 'bus'
            })
        self.nw.add_busses(self.fwp_power)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        # miss out on internal bus in exergy_analysis
        ean = ExergyAnalysis(self.nw, E_P=[self.power], E_F=[self.heat])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        exergy_balance = (ean.network_data.E_F - ean.network_data.E_P -
                          ean.network_data.E_L - ean.network_data.E_D)
        msg = ('Exergy balance must be violated for this test (larger than ' +
               str(err**0.5) + ') but is ' +
               str(round(abs(exergy_balance), 4)) + ' .')
        assert abs(exergy_balance) > err**0.5, msg
Exemple #4
0
    def test_exergy_analysis_perfect_cycle(self):
        """Test exergy analysis in the perfect clausius rankine cycle."""
        ean = ExergyAnalysis(self.nw,
                             E_P=[self.power],
                             E_F=[self.heat],
                             internal_busses=[self.fwp_power])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)
        msg = ('Exergy destruction of this network must be 0 (smaller than ' +
               str(err**0.5) + ') for this test but is ' +
               str(round(abs(ean.network_data.E_D), 4)) + ' .')
        assert abs(ean.network_data.E_D) <= err**0.5, msg

        msg = ('Exergy efficiency of this network must be 1 for this test but '
               'is ' + str(round(ean.network_data.epsilon, 4)) + ' .')
        assert round(ean.network_data.epsilon, 4) == 1, msg

        exergy_balance = (ean.network_data.E_F - ean.network_data.E_P -
                          ean.network_data.E_L - ean.network_data.E_D)
        msg = ('Exergy balance must be closed (residual value smaller than ' +
               str(err**0.5) + ') for this test but is ' +
               str(round(abs(exergy_balance), 4)) + ' .')
        assert abs(exergy_balance) <= err**0.5, msg

        msg = (
            'Fuel exergy and product exergy must be identical for this test. '
            'Fuel exergy value: ' + str(round(ean.network_data.E_F, 4)) +
            '. Product exergy value: ' + str(round(ean.network_data.E_P, 4)) +
            '.')
        delta = round(abs(ean.network_data.E_F - ean.network_data.E_P), 4)
        assert delta < err**0.5, msg
Exemple #5
0
    def test_exergy_analysis_plotting_data(self):
        """Test exergy analysis plotting."""
        self.nw.get_comp('steam generator').set_attr(pr=0.9)
        self.nw.get_comp('turbine').set_attr(eta_s=0.9)
        self.nw.get_comp('feed water pump turbine').set_attr(eta_s=0.85)
        self.nw.get_comp('pump').set_attr(eta_s=0.75)
        self.nw.get_conn('cond').set_attr(T=self.Tamb + 3)

        # specify efficiency values for the internal bus and power bus
        self.nw.del_busses(self.fwp_power, self.power)

        self.fwp_power = Bus('feed water pump power', P=0)
        self.fwp_power.add_comps(
            {
                'comp': self.nw.get_comp('feed water pump turbine'),
                'char': 0.99
            }, {
                'comp': self.nw.get_comp('pump'),
                'char': 0.98,
                'base': 'bus'
            })
        self.power = Bus('power_output')
        self.power.add_comps({
            'comp': self.nw.get_comp('turbine'),
            'char': 0.98
        })

        self.nw.add_busses(self.fwp_power, self.power)

        # solve network
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        ean = ExergyAnalysis(self.nw,
                             E_P=[self.power],
                             E_F=[self.heat],
                             internal_busses=[self.fwp_power])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        exergy_balance = (ean.network_data.E_F - ean.network_data.E_P -
                          ean.network_data.E_L - ean.network_data.E_D)
        msg = ('Exergy balance must be closed (residual value smaller than ' +
               str(err**0.5) + ') for this test but is ' +
               str(round(abs(exergy_balance), 4)) + ' .')
        assert abs(exergy_balance) <= err**0.5, msg

        nodes = [
            'E_F', 'steam generator', 'splitter 1', 'feed water pump turbine',
            'turbine', 'merge 1', 'condenser', 'pump', 'E_D', 'E_P'
        ]

        links, nodes = ean.generate_plotly_sankey_input(node_order=nodes)
        # checksum for targets and source
        checksum = sum(links['target'] + links['source'])
        msg = ('The checksum of all target and source values in the link lists'
               'must be 148, but is ' + str(checksum) + '.')
        assert 148 == checksum, msg
Exemple #6
0
    def test_exergy_analysis_bus_conversion(self):
        """Test exergy analysis at product exergy with T < Tamb."""
        ean = ExergyAnalysis(self.nw, E_P=[self.cas_in], E_F=[self.power_in])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        exergy_balance = (ean.network_data.E_F - ean.network_data.E_P -
                          ean.network_data.E_L - ean.network_data.E_D)
        msg = ('Exergy balance must be closed (residual value smaller than ' +
               str(err**0.5) + ') for this test but is ' +
               str(round(abs(exergy_balance), 4)) + ' .')
        assert abs(exergy_balance) <= err**0.5, msg
    def test_exergy_analysis(self):
        """Test the exergy analysis results."""
        # carry out exergy analysis
        ean = ExergyAnalysis(self.nw,
                             E_P=[self.nw.busses['total output power']],
                             E_F=[self.nw.busses['heat input']],
                             E_L=[self.nw.busses['exergy loss']])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        # generate Grassmann diagram
        links, nodes = ean.generate_plotly_sankey_input()

        # check if exergy product value in links is equal to total power
        # output
        position = links['target'].index(nodes.index('E_P'))
        power_links = round(links['value'][position], 0)
        power_bus = round(-self.nw.busses['total output power'].P.val, 0)
        msg = ('The exergy product value in the links (' + str(power_links) +
               ') must be equal to the power on the respective bus (' +
               str(power_bus) + ').')
        assert power_links == power_bus, msg
Exemple #8
0
    def run_analysis(self):

        ean = ExergyAnalysis(self.nw,
                             E_P=[self.exergy_prod],
                             E_F=[self.exergy_fuel])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        exergy_balance = (ean.network_data.E_F - ean.network_data.E_P -
                          ean.network_data.E_L - ean.network_data.E_D)
        msg = ('Exergy balance must be closed (residual value smaller than ' +
               str(err**0.5) + ') for this test but is ' +
               str(round(abs(exergy_balance), 4)) + '.')
        assert abs(exergy_balance) <= err**0.5, msg

        E_D_agg = ean.aggregation_data['E_D'].sum()
        E_D_nw = ean.network_data.loc['E_D']
        msg = ('The exergy destruction of the aggregated components and '
               'respective busses (' + str(round(E_D_agg)) +
               ') must be equal to '
               'the exergy destruction of the network (' + str(round(E_D_nw)) +
               ').')
        assert E_D_agg == E_D_nw, msg
Exemple #9
0
    def test_exergy_analysis_bus_conversion(self):
        """Test exergy analysis bus conversion factors."""
        # specify efficiency values for the internal bus
        self.nw.del_busses(self.fwp_power)
        self.fwp_power = Bus('feed water pump power', P=0)
        self.fwp_power.add_comps(
            {
                'comp': self.nw.get_comp('feed water pump turbine'),
                'char': 0.99
            }, {
                'comp': self.nw.get_comp('pump'),
                'char': 0.98,
                'base': 'bus'
            })
        self.nw.add_busses(self.fwp_power)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        # no exergy losses in this case
        ean = ExergyAnalysis(self.nw,
                             E_P=[self.power],
                             E_F=[self.heat],
                             internal_busses=[self.fwp_power])
        ean.analyse(pamb=self.pamb, Tamb=self.Tamb)

        label = 'pump'
        eps = ean.bus_data.loc[label, 'epsilon']
        msg = ('Pump exergy efficiency must be 0.98 but is ' +
               str(round(eps, 4)) + ' .')
        assert round(eps, 4) == 0.98, msg

        label = 'feed water pump turbine'
        eps = ean.bus_data.loc[label, 'epsilon']
        msg = (
            'Feed water pump turbine exergy efficiency must be 0.99 but is ' +
            str(round(eps, 4)) + ' .')
        assert round(eps, 4) == 0.99, msg
Exemple #10
0
diagram.set_limits(x_min=200, x_max=500, y_min=0.8e1, y_max=0.8e2)
diagram.calc_isolines()
diagram.draw_isolines('logph')

for key in result_dict.keys():
    datapoints = result_dict[key]['datapoints']
    diagram.ax.plot(datapoints['h'], datapoints['p'], color='#ff0000')
    diagram.ax.scatter(datapoints['h'][0], datapoints['p'][0], color='#ff0000')

diagram.save('R410A_logph.svg')

# %% exergy analysis

ean = ExergyAnalysis(network=nw, E_F=[power, heat_geo], E_P=[heat_cons])
ean.analyse(pamb, Tamb)
print("\n##### EXERGY ANALYSIS #####\n")
ean.print_results()

# create sankey diagram
links, nodes = ean.generate_plotly_sankey_input()
fig = go.Figure(
    go.Sankey(arrangement="snap",
              node={
                  "label": nodes,
                  'pad': 11,
                  'color': 'orange'
              },
              link=links))
plot(fig, filename='R410A_sankey.html')