Example #1
0
    def run(self, solar_area, wind_area, battery_capacity):
        power_supply = (
            self.wind_power_simulation * wind_area
            + self.solar_power_simulation * solar_area
        )

        if self.config != {}:
            battery = Battery(battery_capacity, config=self.config)
            safe_factor = self.config['optimization']['safe_factor']
        else:
            battery = Battery(battery_capacity)
            safe_factor = 0

        supply, load = power_supply.tolist(), (self.Task.load_demand*(1+safe_factor)).tolist()
        battery.run(supply, load)
        lpsp = battery.lost_power_supply_probability()
        return lpsp
Example #2
0
    def run(self, solar_area, wind_area, battery_capacity, validation=False):

        if self.config != {}:
            battery = Battery(battery_capacity, config=self.config)
            safe_factor = self.config['optimization']['safe_factor']
            coupling_ratio = self.config['simulation']['coupling']
        else:
            battery = Battery(battery_capacity)
            safe_factor = 0
            coupling_ratio = 0.05

        # Get unit area wind power generation
        wind_raw_unit, wind_correction_unit = self.wind_power_simulation
        wind_raw = wind_raw_unit * wind_area
        wind_correction = wind_correction_unit * wind_area

        # Correct wind power generation
        prop_load = self.Task.prop_load + wind_correction
        prop_load[prop_load < 0] = 0  # disable the wind driven generator mode

        power_generation = (wind_raw + self.solar_power_simulation * solar_area) * (1 - coupling_ratio)
        # Consider the coupling between wind and solar power generation
        demand_load = prop_load + self.Task.hotel_load

        generation = power_generation.tolist()
        load = (demand_load * (1 + safe_factor)).tolist()

        battery.run(generation, load)

        if validation:

            battery_history = battery.battery_history()
            battery_history_df = pd.DataFrame(
                data=battery_history.T,
                index=self.Task.mission.df.index,
                columns=['SOC', 'Battery', 'Unmet', 'Waste', 'Supply'],
            )
            try:
                load_demand_history = np.vstack((demand_load, prop_load, self.Task.hotel_load.values,
                                             (self.Task.critical_hotel_load +
                                              prop_load * self.Task.robot.critical_prop_load_ratio).values))
            except AttributeError:
                load_demand_history = np.vstack((demand_load, prop_load, self.Task.hotel_load.values,
                                             (self.Task.critical_hotel_load +
                                              self.Task.critical_prop_load).values))
            load_demand_history_df = pd.DataFrame(
                data=load_demand_history.T,
                index=self.Task.mission.df.index,
                columns=['Load_demand', 'Prop_load', 'Hotel_load', 'Critical_load'],
            )

            generation_history_df = pd.DataFrame(
                data=generation,
                index=self.Task.mission.df.index,
                columns=['Generation']
            )
            results = [self.resource_df,
                       self.solar * solar_area,
                       self.wind * wind_area,
                       generation_history_df,
                       load_demand_history_df,
                       battery_history_df]
            self.history = pd.concat(results, axis=1)
            return self.history

        lost_power_supply_probability = battery.lost_power_supply_probability()
        return lost_power_supply_probability