コード例 #1
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
コード例 #2
0
    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
コード例 #3
0
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')

# %% plot exergy destruction

# create data for bar chart
comps = ['E_F']
E_F = ean.network_data.E_F