diff --git a/cea/optimization_new/component.py b/cea/optimization_new/component.py index 2505c1924c..58c4c51e0a 100644 --- a/cea/optimization_new/component.py +++ b/cea/optimization_new/component.py @@ -523,8 +523,8 @@ def operate(self, heating_out): # initialize energy flows fuel_in = EnergyFlow('source', self.placement, self.input_energy_carriers[0].code) - electricity_out = EnergyFlow(self.placement, 'primary', self.input_energy_carriers[0].code) - waste_heat_out = EnergyFlow(self.placement, 'environment', self.output_energy_carriers[0].code) + electricity_out = EnergyFlow(self.placement, 'primary', self.output_energy_carriers[0].code) + waste_heat_out = EnergyFlow(self.placement, 'environment', self.output_energy_carriers[1].code) # run operational/efficiency code if Component._model_complexity == 'constant': diff --git a/cea/optimization_new/supplySystem.py b/cea/optimization_new/supplySystem.py index c7d645906a..e516a5be4e 100644 --- a/cea/optimization_new/supplySystem.py +++ b/cea/optimization_new/supplySystem.py @@ -99,10 +99,14 @@ def evaluate(self): self.installed_components = self._build_supply_system() # operate primary components primary_demand_dict = {self.structure.main_final_energy_carrier.code: self.demand_energy_flow} - self._perform_water_filling_principle('primary', primary_demand_dict) + remaining_primary_demand_dict = self._draw_from_potentials(primary_demand_dict, reset=True) + remaining_primary_demand_dict = self._draw_from_infinite_sources(remaining_primary_demand_dict) + self._perform_water_filling_principle('primary', remaining_primary_demand_dict) # operate secondary components secondary_demand_dict = self._group_component_flows_by_ec('primary', 'in') - self._perform_water_filling_principle('secondary', secondary_demand_dict) + remaining_secondary_demand_dict = self._draw_from_potentials(secondary_demand_dict) + remaining_secondary_demand_dict = self._draw_from_infinite_sources(remaining_secondary_demand_dict) + self._perform_water_filling_principle('secondary', remaining_secondary_demand_dict) # operate tertiary components component_energy_release_dict = self._group_component_flows_by_ec(['primary', 'secondary'], 'out') tertiary_demand_dict = self._release_to_grids_or_env(component_energy_release_dict) @@ -232,11 +236,9 @@ def _perform_water_filling_principle(self, placement, demand_dict): :param demand_dict: dictionary of demand energy flows that need to be met, keys are energy carrier codes :type demand_dict: dict of -EnergyFlow class objects """ - remaining_demand_dict = self._draw_from_potentials(demand_dict, reset=True) - remaining_demand_dict = self._draw_from_infinite_sources(remaining_demand_dict) - for ec_code in remaining_demand_dict.keys(): - demand = remaining_demand_dict[ec_code] + for ec_code in demand_dict.keys(): + demand = demand_dict[ec_code] for component_model in self.structure.activation_order[placement]: if not ((component_model in self.structure.component_selection_by_ec[placement][ec_code]) and