Esempio n. 1
0
    def plot_self_consumption(self, fig_size=None, dpi=None):
        YtL_per = []
        YtG_per = []
        for m in range(1, 13):
            mef = self.get_monthly_energyflows(m)
            YtL = mef['Eptl'] + mef['Eptb']  # monthly yield consumed by loads
            YtG = mef['Eptg']  # monthly yield injected to grid
            Ytot = YtL + YtG
            YtL_per.append(YtL / Ytot * 100.0)
            YtG_per.append(YtG / Ytot * 100.0)

        graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
        graph.add_data_set(name='pv energy to grid',
                           x=[m for m in range(1, 13)],
                           y=YtG_per,
                           bar={
                               'color': 'red',
                               'align': 'center'
                           })
        graph.add_data_set(name='pv energy to load',
                           x=[m for m in range(1, 13)],
                           y=YtL_per,
                           bar={
                               'bottom': YtG_per,
                               'color': 'green',
                               'align': 'center'
                           })
        graph.add_legend()
        graph.scale_x_axis(lim_min=0, lim_max=13, tick_step=1)
        graph.scale_y_axis(lim_min=0, lim_max=100, tick_step=10)
        graph.set_axis_titles(x_title='month', y_title='yield [%]')
        graph.turn_grid_on()
        graph.draw_graph()
        return graph
Esempio n. 2
0
    def plot_self_sufficiency(self, fig_size=None, dpi=None):
        LfP_per = []
        LfG_per = []
        for m in range(1, 13):
            mef = self.get_monthly_energyflows(m)
            LfP = mef['Eptl'] + mef[
                'Ebtl']  # monthly load supplied by PV system
            LfG = mef['Egtl']  # monthly load supplied by grid
            Ltot = LfP + LfG
            LfP_per.append(LfP / Ltot * 100.0)
            LfG_per.append(LfG / Ltot * 100.0)

        graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
        graph.add_data_set(name='energy from grid',
                           x=[m for m in range(1, 13)],
                           y=LfG_per,
                           bar={
                               'color': 'red',
                               'align': 'center'
                           })
        graph.add_data_set(name='energy from pv system',
                           x=[m for m in range(1, 13)],
                           y=LfP_per,
                           bar={
                               'bottom': LfG_per,
                               'color': 'green',
                               'align': 'center'
                           })
        graph.add_legend()
        graph.scale_x_axis(lim_min=0, lim_max=13, tick_step=1)
        graph.scale_y_axis(lim_min=0, lim_max=100, tick_step=10)
        graph.set_axis_titles(x_title='month', y_title='consumption [%]')
        graph.turn_grid_on()
        graph.draw_graph()
        return graph
Esempio n. 3
0
 def plot_reset_line(self, fig_size=None, dpi=None):
     graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
     x_data = np.linspace(self.T_min, self.T_max, endpoint=True)
     y_data = self.c0 + self.c1 * x_data
     graph.add_data_set('reset line', x=x_data, y=y_data)
     graph.scale_y_axis(lim_min=int(np.min(y_data)), lim_max=int(np.max(y_data)) + 2, tick_step=2)
     graph.turn_grid_on()
     graph.set_axis_titles(x_title='Tout [°C]', y_title='Twe [°C]')
     graph.draw_graph()
     return graph
Esempio n. 4
0
    def plot_working_range(self, required_range=False, pv_matrix_id=None, fig_size=None, dpi=None):
        # minimum voltage limit
        Vmpp_min = self.Vmpp_min if not required_range else self._required_min_mpp_voltage()
        Idc_max = self.Idc_max if not required_range else self._required_dc_current_limit()
        Vmin = ([Vmpp_min, Vmpp_min], [0.0, Idc_max])

        # maximum voltage limit
        Vdc_max = self.Vdc_max if not required_range else self._required_max_input_voltage()
        Vmax = ([Vdc_max, Vdc_max], [0.0, Idc_max])

        # maximum current limit
        Imax = ([Vmpp_min, Vdc_max], [Idc_max, Idc_max])

        # maximum power limit
        Pdc_max = self.Pdc_max if not required_range else self._required_dc_power_limit()
        Pdc_max = Pdc_max / len(self.pv_matrices)
        Vax = np.linspace(Vmpp_min, Vdc_max, endpoint=True)
        Iax = Pdc_max / Vax
        Pmax = (Vax, Iax)

        graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
        graph.add_data_set(name='min. voltage limit', x=Vmin[0], y=Vmin[1])
        graph.add_data_set(name='max. voltage limit', x=Vmax[0], y=Vmax[1])
        graph.add_data_set(name='current limit', x=Imax[0], y=Imax[1])
        graph.add_data_set(name='power limit', x=Pmax[0], y=Pmax[1])

        # add PV matrix characteristics to plot that determine the required working range of the inverter
        if pv_matrix_id is None:
            pv_matrix = self.pv_matrices[0]
        else:
            for i, pv_matrix in enumerate(self.pv_matrices):
                if pv_matrix.id == pv_matrix_id:
                    pv_matrix = self.pv_matrices[i]
                    break
            else:
                raise ValueError(f'PV matrix with {pv_matrix_id} not found')

        opcl = [
            (self.Tc_min, 1000.0, f'G=1000.0 | Tc={self.Tc_min}'),
            (self.Tc_max, 1000.0, f'G=1000.0 | Tc={self.Tc_max}'),
            (self.Tc_pl, 1000.0, f'G=1000.0 | Tc={self.Tc_pl}'),
            (self.Tc_Glow, self.Glow, f'G={self.Glow} | Tc={self.Tc_Glow}')
        ]
        for opc in opcl:
            pv_matrix.set_operating_conditions(Tcell=opc[0], Gsurf=opc[1])
            Vax, Iax, Pax = pv_matrix.get_characteristics()
            graph.add_data_set(name=opc[2], x=Vax, y=Iax)

        graph.add_legend()
        graph.set_axis_titles('V [V]', 'I [A]')
        graph.turn_grid_on()
        graph.draw_graph()
        return graph
Esempio n. 5
0
    def plot_monthly_overview(self, fig_size=None, dpi=None):
        PtL = []  # PV yield to load and battery
        PtG = []  # PV yield injected into grid
        LfG = []  # load energy taken from grid
        LfP = []  # load energy taken from PV system
        for m_index in range(1, 13):
            mef = self.get_monthly_energyflows(m_index)
            PtL.append(mef['Eptl'] + mef['Eptb'])
            PtG.append(mef['Eptg'])
            LfG.append(mef['Egtl'])
            LfP.append(mef['Eptl'] + mef['Ebtl'])

        graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
        w = 0.4
        graph.add_data_set(name='pv energy to load',
                           x=np.array([m for m in range(1, 13)]) - w / 2,
                           y=PtL,
                           bar={
                               'color': 'green',
                               'width': w
                           })
        graph.add_data_set(name='pv energy to grid',
                           x=np.array([m for m in range(1, 13)]) - w / 2,
                           y=PtG,
                           bar={
                               'bottom': PtL,
                               'color': 'palegreen',
                               'width': w
                           })
        graph.add_data_set(name='energy from pv system',
                           x=np.array([m for m in range(1, 13)]) + w / 2,
                           y=LfP,
                           bar={
                               'color': 'orange',
                               'width': w
                           })
        graph.add_data_set(name='energy from grid',
                           x=np.array([m for m in range(1, 13)]) + w / 2,
                           y=LfG,
                           bar={
                               'bottom': LfP,
                               'color': 'red',
                               'width': w
                           })
        graph.add_legend()
        graph.scale_x_axis(lim_min=0, lim_max=13, tick_step=1)
        graph.set_axis_titles(x_title='month', y_title='energy [kWh]')
        graph.turn_grid_on()
        graph.draw_graph()
        return graph
Esempio n. 6
0
 def plot_efficiency_curves(self, fig_size=None, dpi=None):
     P_ax = np.linspace(0.05 * self.Pdc_nom, self.Pdc_nom, endpoint=True)
     eff_ax_at_Vmpp_min = np.array([self._eff_interpolants[0].solve(P) for P in P_ax]) * 100.0
     eff_ax_at_Vdc_nom = np.array([self._eff_interpolants[1].solve(P) for P in P_ax]) * 100.0
     eff_ax_at_Vmpp_max = np.array([self._eff_interpolants[2].solve(P) for P in P_ax]) * 100.0
     graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
     graph.add_data_set(f'eff @ Vmpp_min = {self.Vmpp_min} V', P_ax, eff_ax_at_Vmpp_min)
     graph.add_data_set(f'eff @ Vdc_nom = {self.Vdc_nom} V', P_ax, eff_ax_at_Vdc_nom)
     graph.add_data_set(f'eff @ Vmpp_max = {self.Vmpp_max} V', P_ax, eff_ax_at_Vmpp_max)
     graph.set_axis_titles(x_title='DC input power (W)', y_title='efficiency (%)')
     graph.add_legend()
     graph.turn_grid_on()
     graph.draw_graph()
     return graph
Esempio n. 7
0
 def plot_characteristic(self, which, size=None, dpi=None, title=None):
     if which in ['current', 'power']:
         if which == 'current':
             name, y_title, y_axis = 'V,I', 'I[A]', self._axI
         else:
             name, y_title, y_axis = 'V,P', 'P[W]', self._axP
         graph = graphing.Graph(fig_size=size, dpi=dpi)
         graph.add_data_set(name=name, x=self._axV, y=y_axis)
         graph.set_axis_titles(x_title='V[V]', y_title=y_title)
         if title:
             graph.set_graph_title(title)
         graph.turn_grid_on()
         graph.draw_graph()
         return graph
     return None
Esempio n. 8
0
 def plot(self, x_title='x', y_title='y', fig_size=None, dpi=None):
     """
     Show data points and fitting curve in a graph.
     """
     if self._solved:
         # calculate some points on the fitting curve
         x = np.linspace(np.min(self._x_data), np.max(self._x_data), 21, endpoint=True)
         y = self.eval_fitting_curve_multi(x)
         # show the data points and the calculated points in a graph
         g = graphing.Graph(fig_size=fig_size, dpi=dpi)
         g.add_data_set('data', self._x_data, self._y_data, marker='o', linestyle='None')
         g.add_data_set('curve fit', x, y)
         g.set_axis_titles(x_title, y_title)
         g.draw_graph()
         g.show_graph()
Esempio n. 9
0
    def plot_profiles(self,
                      start_date: Date = None,
                      end_date: Date = None,
                      fig_size=None,
                      dpi=None):
        if not start_date or not end_date:
            start_date = Date(ANY_YEAR, 1, 1)
            end_date = Date(ANY_YEAR, 12, 31)

        # get time and power axis of every DailyYield-object from start to end date
        Yt_ax = []
        YPac_ax = []
        for dyo in self.ay.get_daily_yields(start_date, end_date):
            d = dyo.date
            t_ax_ = []
            Pac_ax_ = []
            for t, Pac in dyo.ac_power_coords():
                t_ax_.append(t)
                Pac_ax_.append(Pac / 1000.0)  # kW
            Yt_ax.extend([DateTime(d, t) for t in t_ax_])
            YPac_ax.extend(Pac_ax_)

        # get time and power axis of every DailyLoad-object from start to end date
        Lt_ax = []
        LPac_ax = []
        for dlo in self.al.get_daily_loads(start_date, end_date):
            d = dlo.date
            t_ax_ = []
            Pac_ax_ = []
            for t, Pac in dlo.power_coords():
                t_ax_.append(t)
                Pac_ax_.append(Pac)  # kW
            Lt_ax.extend([DateTime(d, t) for t in t_ax_])
            LPac_ax.extend(Pac_ax_)

        Yt_ax = [Yt.convert_to_mpl_datetime() for Yt in Yt_ax]
        Lt_ax = [Lt.convert_to_mpl_datetime() for Lt in Lt_ax]
        graph = graphing.Graph(fig_size=fig_size, dpi=dpi)
        graph.add_data_set(name='yield', x=Yt_ax, y=YPac_ax)
        graph.add_data_set(name='load', x=Lt_ax, y=LPac_ax)
        graph.setup_time_axis(date_min=start_date.convert_to_mpl_datetime(),
                              date_max=end_date.convert_to_mpl_datetime())
        graph.set_axis_titles(x_title='time', y_title='P [kW]')
        graph.add_legend()
        graph.turn_grid_on()
        graph.draw_graph()
        return graph
Esempio n. 10
0
def plot_sun_path_diagram(sun_paths: List[SunPath],
                          horizon_profile: HorizonProfile = None,
                          size=None,
                          dpi=None):
    graph = graphing.Graph(fig_size=size, dpi=dpi)
    for sp in sun_paths:
        graph.add_data_set(name=sp.label,
                           x=sp.azi_ax,
                           y=sp.elev_ax,
                           marker='o')
    if horizon_profile:
        graph.add_data_set(name='horizon',
                           x=horizon_profile.azimuth_ax,
                           y=horizon_profile.elevation_ax,
                           fill={'color': 'black'})
    graph.add_legend()
    graph.set_axis_titles(x_title='sun azimuth angle',
                          y_title='sun altitude angle')
    graph.scale_x_axis(lim_min=0, lim_max=360, tick_step=20)
    graph.scale_y_axis(lim_min=0, lim_max=90, tick_step=5)
    graph.turn_grid_on()
    graph.draw_graph()
    return graph
Esempio n. 11
0
# Calculate MPP powers for three different azimuth angles of the solar panel and tilt angles between 0° and 45°
azimuths = [90.0, 180.0, 270.0]
tilts = np.linspace(0.0, 45.0)
Pmpp = [[] for _ in azimuths]
for i, azimuth in enumerate(azimuths):
    for tilt in tilts:
        solar_panel = pv.SolarPanel(loc=loc,
                                    orient=pv.Orientation(azimuth=azimuth,
                                                          tilt=tilt),
                                    dim=pv.Dimensions(width=0.99, height=1.66),
                                    pv_char=pv_char,
                                    hz_profile=None)
        solar_panel.set_operating_conditions(date=date,
                                             time=solar_noon,
                                             Gglh=1000.0,
                                             Tambient=25.0)
        Pmpp[i].append(solar_panel.get_mpp_power())

# Show the results in diagram
graph = graphing.Graph()
for i in range(len(Pmpp)):
    graph.add_data_set(name=f'azimuth panel {azimuths[i]:.1f}°',
                       x=tilts,
                       y=np.array(Pmpp[i]))
graph.add_legend()
graph.set_graph_title(f'Sun position at {solar_noon}: {sun_pos}')
graph.turn_grid_on()
graph.set_axis_titles(x_title='tilt angle [°]', y_title='Pmpp [W]')
graph.draw_graph()
graph.show_graph()