Ejemplo n.º 1
0
    def calculate(self):
        '''
        Parses the energy_systems assets and converts them to etm slider settings

        Returns a dict of slider settings
        '''
        # Parse supply and demand assets and calculate the new input values
        for asset in assets.ASSETS:
            self.parse_asset(asset)

        # Parse buildings
        number_of_buildings = self.determine_number_of_buildings()
        if 'RESIDENTIAL' in number_of_buildings:
            self.inputs[
                'households_number_of_residences'] = number_of_buildings[
                    'RESIDENTIAL']
        self.__setup_building_parsers(number_of_buildings)

        for sub_area in self.energy_system.es.instance[0].area.area:
            self.parse_aggregated_buidings(sub_area)

        # Balance sliders in share groups
        Balancer(self.inputs).call()

        pprint.pprint(self.inputs)
        return self.inputs
Ejemplo n.º 2
0
    def relative_change_to_for_context(self, other):
        '''
        Calculates new slider settings. Compares the current 'present' Situation to the
        relative change to another 'future' Situation, based on the context set for the
        current Situation.
        Returns a new Situation for the context, with the change of self to other incorporated
        '''
        Situation.sanity_check(self, other)

        slider_settings = defaultdict(float)
        for slider in self.PRESENT_SHARE_SLIDERS:
            slider_settings[
                slider] = self.calculate_slider_based_on_present_share(
                    other, slider)

        for group in self.INDUSTRY_GROUPS:
            slider_settings.update(
                self.calculate_industry_heat_share_group_sliders(other, group))

            slider_settings[slider_for(
                group
            )] = self.calculate_slider_based_on_present_share_of_query(
                other, slider_for(group), context_query_for(group))

        Balancer(slider_settings).call()

        return Situation(slider_settings, self.context['area_code'],
                         self.context['end_year'])
Ejemplo n.º 3
0
def test_without_any_sliders_set():
    '''
    If the sliders of the balancing groups were not touched, we don't want
    any distributing happening
    '''
    empty_sliders = defaultdict(float)
    Balancer(empty_sliders).call()

    assert len(empty_sliders.keys()) == 0
Ejemplo n.º 4
0
def test_with_one_slider_set_to_100_in_one_group():
    sliders = defaultdict(float)
    a_group = list(balancing_groups.keys())[0]
    a_slider = balancing_groups[a_group][0]

    sliders[a_slider] = 100.0

    Balancer(sliders).call()

    assert len(sliders.keys()) == len(balancing_groups[a_group])

    assert sliders[a_slider] == 100
Ejemplo n.º 5
0
def test_with_one_slider_set_to_more_than_100():
    sliders = defaultdict(float)
    a_group = list(balancing_groups.keys())[0]
    a_slider = balancing_groups[a_group][0]

    sliders[a_slider] = 110.0
    Balancer(sliders).call()

    assert sliders[a_slider] == 100.0

    for slider in balancing_groups[a_group]:
        if slider == a_slider: continue
        assert sliders[slider] == 0
Ejemplo n.º 6
0
def test_with_one_slider_set_to_less_than_100():
    sliders = defaultdict(float)
    a_group = list(balancing_groups.keys())[0]
    a_slider = balancing_groups[a_group][0]

    total_sliders_in_group = len(balancing_groups[a_group])

    sliders[a_slider] = 10.0
    Balancer(sliders).call()

    assert sliders[a_slider] == 10 + (90.0 / total_sliders_in_group)

    for slider in balancing_groups[a_group]:
        if slider == a_slider: continue
        assert sliders[slider] == 90.0 / total_sliders_in_group
Ejemplo n.º 7
0
def test_with_two_sliders_set_to_more_than_100():
    sliders = defaultdict(float)
    a_group = list(balancing_groups.keys())[0]
    slider_one = balancing_groups[a_group][0]
    slider_two = balancing_groups[a_group][1]

    sliders[slider_one] = 52.0
    sliders[slider_two] = 52.0

    Balancer(sliders).call()

    assert sliders[slider_one] == 50.0
    assert sliders[slider_two] == 50.0

    for slider in balancing_groups[a_group]:
        if slider in (slider_one, slider_two): continue
        assert sliders[slider] == 0
Ejemplo n.º 8
0
def test_with_two_sliders_set_to_less_than_100():
    sliders = defaultdict(float)
    a_group = list(balancing_groups.keys())[0]
    slider_one = balancing_groups[a_group][0]
    slider_two = balancing_groups[a_group][1]

    total_sliders_in_group = len(balancing_groups[a_group])

    sliders[slider_one] = 5.0
    sliders[slider_two] = 5.0

    Balancer(sliders).call()

    assert sliders[slider_one] == 5 + (90.0 / total_sliders_in_group)
    assert sliders[slider_two] == 5 + (90.0 / total_sliders_in_group)

    for slider in balancing_groups[a_group]:
        if slider in (slider_one, slider_two): continue
        assert sliders[slider] == 90.0 / total_sliders_in_group