Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pinch point temperature #26

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions inputs/plants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
desalination_plants:
- name: default_med
operating_hours: !!int 10 # Number of operating hours per day
pinch_point_temperature_difference: !!float 1
plant_disabled:
requirements:
electricity: !!float 30 # [kW] Electricity requirements
Expand Down Expand Up @@ -39,6 +40,7 @@ desalination_plants:
# NOTE: This plant is capable of producing 3 m^3 of desalinated water per day.
- name: !!str joo_med_24_hour
operating_hours: !!int 24 # Number of operating hours per day
pinch_point_temperature_difference: !!float 1
plant_disabled:
requirements:
electricity: !!float 0 # [kW] Electricity requirements
Expand Down Expand Up @@ -67,6 +69,7 @@ desalination_plants:
# day and runs for 24 hours of the day.
- name: !!str el_nashar_24_hour
operating_hours: !!int 24 # Number of operating hours per day
pinch_point_temperature_difference: !!float 1
plant_disabled:
requirements:
electricity: !!float 0 # [kW] Electricity requirements
Expand Down Expand Up @@ -96,6 +99,7 @@ desalination_plants:
# day and runs for 24 hours of the day.
- name: !!str rahimi_24_hour
operating_hours: !!int 24 # Number of operating hours per day
pinch_point_temperature_difference: !!float 1
plant_disabled:
requirements:
electricity: !!float 0 # [kW] Electricity requirements
Expand Down
52 changes: 26 additions & 26 deletions plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@

ALPHA = 0.9
sns.set_style("whitegrid")
sns.set_context("notebook")
sns.set_context("poster")

colorblind_palette = sns.color_palette(
[
Expand Down Expand Up @@ -2949,7 +2949,7 @@
sns.set_palette(colorblind_palette)

# Read input data
with open("31_mar_23_v2.json", "r", encoding="UTF-8") as f:
with open("clean_water_optimisations_data.json", "r", encoding="UTF-8") as f:
full_data = json.load(f)

data = {
Expand Down Expand Up @@ -7928,7 +7928,7 @@ def _post_process_split_axes(ax1, ax2):

# Plot using an added 10% height ONLY to the error bars

fig, axes = plt.subplots(2, 2, figsize=(48 / 5, 32 / 5))
fig, axes = plt.subplots(2, 2, figsize=(15, 10))
fig.subplots_adjust(hspace=0.35)


Expand Down Expand Up @@ -8079,7 +8079,7 @@ def _post_process_split_axes(ax1, ax2):
data_to_plot = data_to_plot.drop("Total").transpose()
data_to_plot.plot.bar(ax=(axis := axes[0, 1]), rot=0, stacked=True, edgecolor="none")
axis.errorbar(
x=data_to_error_bar.index,
x=data_to_plot.index,
y=[(y_min[index] + max_entry) / 2 for index, max_entry in enumerate(y_max)],
yerr=[abs(max_entry - y_min[index]) / 2 for index, max_entry in enumerate(y_max)],
capsize=10,
Expand Down Expand Up @@ -8305,9 +8305,9 @@ def _post_process_split_axes(ax1, ax2):


plt.savefig(
"specific_costs_comparison_15_10_percent_error.png",
"specific_costs_comparison_poster_15_10_percent_error.png",
transparent=True,
dpi=300,
dpi=1200,
bbox_inches="tight",
)

Expand Down Expand Up @@ -9012,7 +9012,7 @@ def _post_process_split_axes(ax1, ax2):

import math

fig, axes = plt.subplots(2, 2, figsize=(48 / 5, 32 / 5))
fig, axes = plt.subplots(2, 2, figsize=(15, 10))
fig.subplots_adjust(hspace=0.35)

K_DEPTH: int = 3
Expand Down Expand Up @@ -9245,14 +9245,14 @@ def _post_process_split_axes(ax1, ax2):
data_to_plot.plot.bar(ax=axis, rot=0, stacked=True, edgecolor="none")
axis.grid(axis="x")
axis.set_xlabel("MED Plant")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_title("Abu Dhabi, UAE")
axis.yaxis.set_minor_formatter(ticker.ScalarFormatter())
axis.yaxis.set_major_formatter(ticker.ScalarFormatter())
axis.set_ylim(0, specific_emissions_y_lim)
axis.text(
-0.08,
1.1,
0,
1.15,
"a.",
transform=axis.transAxes,
fontsize=16,
Expand Down Expand Up @@ -9385,12 +9385,12 @@ def _post_process_split_axes(ax1, ax2):
data_to_plot.plot.bar(ax=axis, rot=0, stacked=True, edgecolor="none")
axis.grid(axis="x")
axis.set_xlabel("MED Plant")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_title("Gando, Gran Canaria")
axis.set_ylim(0, specific_emissions_y_lim)
axis.text(
-0.08,
1.1,
0,
1.15,
"b.",
transform=axis.transAxes,
fontsize=16,
Expand Down Expand Up @@ -9519,12 +9519,12 @@ def _post_process_split_axes(ax1, ax2):
data_to_plot.plot.bar(ax=axis, rot=0, stacked=True, edgecolor="none")
axis.grid(axis="x")
axis.set_xlabel("MED Plant")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_ylim(0, specific_emissions_y_lim)
axis.set_title("Tijuana, Mexico")
axis.text(
-0.08,
1.1,
0,
1.15,
"c.",
transform=axis.transAxes,
fontsize=16,
Expand Down Expand Up @@ -9653,12 +9653,12 @@ def _post_process_split_axes(ax1, ax2):
data_to_plot.plot.bar(ax=axis, rot=0, stacked=True, edgecolor="none")
axis.grid(axis="x")
axis.set_xlabel("MED Plant")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_ylim(0, specific_emissions_y_lim)
axis.set_title("La Paz, Mexico")
axis.text(
-0.08,
1.1,
0,
1.15,
"d.",
transform=axis.transAxes,
fontsize=16,
Expand Down Expand Up @@ -9691,7 +9691,7 @@ def _post_process_split_axes(ax1, ax2):
plt.savefig(
"specific_emissions_comparison_15.png",
transparent=True,
dpi=300,
dpi=1200,
bbox_inches="tight",
)

Expand Down Expand Up @@ -11278,7 +11278,7 @@ def plot_battery_inverter_line_map(
)

axis.set_xlabel("Specific cost / USD/m$^3$")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_title("Smallest-capacity plant")
locmin = mticker.LogLocator(base=10, subs=np.arange(0.1, 10, 0.1), numticks=100)

Expand Down Expand Up @@ -11525,7 +11525,7 @@ def _post_process_split_kde_axes(ax1, ax2):
bw_adjust=bw_adjust,
)
axis.set_xlabel("Specific cost / USD/m$^3$")
axes[0].set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axes[0].set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_title("Medium-capacity plant")
axis.set_ylabel("")

Expand Down Expand Up @@ -11711,7 +11711,7 @@ def _post_process_split_kde_axes(ax1, ax2):
)

axis.set_xlabel("Specific cost / USD/m$^3$")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_title("Medium-capacity plant")

axis.legend()
Expand Down Expand Up @@ -11956,7 +11956,7 @@ def _post_process_split_kde_axes(ax1, ax2):
bw_adjust=bw_adjust,
)
axis.set_xlabel("Specific cost / USD/m$^3$")
axes[0].set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axes[0].set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
# axis.set_title("Medium-capacity plant")
axis.set_ylabel("")

Expand Down Expand Up @@ -12143,7 +12143,7 @@ def _post_process_split_kde_axes(ax1, ax2):
)

axis.set_xlabel("Specific cost / USD/m$^3$")
axis.set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axis.set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
axis.set_title("Medium-capacity plant")

axis.legend()
Expand Down Expand Up @@ -12396,7 +12396,7 @@ def _post_process_split_kde_axes(ax1, ax2):
ha="center",
va="center",
)
axes[0].set_ylabel("Specific emissions / kg CO$_2$eq/m$^3$")
axes[0].set_ylabel("Spec. emissions / kg CO$_2$eq/m$^3$")
plt.figtext(
0.5,
axis.get_position().y1 + 0.014,
Expand Down
17 changes: 15 additions & 2 deletions src/heatdesalination/heat_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def get_emissions(self, thermal_power: float) -> float:
def _coefficient_of_performance(
condensation_temperature: float,
evaporation_temperature: float,
pinch_point_temperature_difference: float,
system_efficiency: float,
) -> float:
"""
Expand All @@ -135,6 +136,10 @@ def _coefficient_of_performance(
the temperature at which heat is absorbed from the environment in order to
evaporate the heat-transfer fluid (refrigerant) within the heat pump,
measured in degrees Kelvin.
- pinch_point_temperature_difference:
The temperature difference between the desired condensation and evaporation
temperatures and the real temperatures achieved, dictated by the effective
possible rate of heat transfer across the heat exchangers in the system.
- system_efficiency:
The efficiency of the heat pump system given as a fraction of its efficiency
against the Carnot efficiency.
Expand All @@ -146,7 +151,7 @@ def _coefficient_of_performance(

return (
system_efficiency
* condensation_temperature
* (condensation_temperature + pinch_point_temperature_difference)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addition of pinch-point temperature difference to the COP calculation for the heat-pump performance

/ (condensation_temperature - evaporation_temperature)
)

Expand All @@ -156,6 +161,7 @@ def calculate_heat_pump_electricity_consumption_and_cost_and_emissions(
evaporation_temperature: float,
heat_demand: float,
heat_pump: HeatPump,
pinch_point_temperature_difference,
) -> Tuple[float, float, float]:
"""
Calculate the electricity comsumption and the cost and emissions of the heat pump.
Expand Down Expand Up @@ -189,6 +195,10 @@ def calculate_heat_pump_electricity_consumption_and_cost_and_emissions(
The heat demand flux, measured in kiloWatts.
- heat_pump:
The heat pump currently being considered.
- pinch_point_temperature_difference:
The temperature difference between the desired condensation and evaporation
temperatures and the real temperatures achieved, dictated by the effective
possible rate of heat transfer across the heat exchangers in the system.

Outputs:
- The cost of the heat pump in USD,
Expand All @@ -199,7 +209,10 @@ def calculate_heat_pump_electricity_consumption_and_cost_and_emissions(

power_consumption = heat_demand / (
cop := _coefficient_of_performance(
condensation_temperature, evaporation_temperature, heat_pump.efficiency
condensation_temperature,
evaporation_temperature,
pinch_point_temperature_difference,
heat_pump.efficiency,
)
)
cost = heat_pump.get_cost(cop, heat_demand)
Expand Down
19 changes: 19 additions & 0 deletions src/heatdesalination/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
# Keyword for plant outputs.
OUTPUTS: str = "outputs"

# PINCH_POINT_TEMPERATURE_DIFFERENCE:
# Keyword for the pinch-point temperature difference.
PINCH_POINT_TEMPERATURE_DIFFERENCE: str = "pinch_point_temperature_difference"

# PLANT_DISABLED:
# Keyword for when the plant is disabled, i.e., not operating.
PLANT_DISABLED: str = "plant_disabled"
Expand Down Expand Up @@ -149,6 +153,11 @@ class DesalinationPlant:
.. attribute:: operating_hours
The number of hours a day that the plant is operating.

.. attribute:: pinch_point_temperature_difference
The temperature difference between the desired condensation and evaporation
temperatures and the real temperatures achieved, dictated by the effective
possible rate of heat transfer across the heat exchangers in the system.

.. attribute:: plant_outputs
The outputs of the plant when in operation (True) and not in operation (False).

Expand All @@ -165,6 +174,7 @@ def __init__(
self,
name: str,
operating_hours: int,
pinch_point_temperature_difference: float,
plant_outputs: dict[bool, PlantOutputs],
plant_requirements: dict[bool, PlantRequirements],
start_hour: int,
Expand All @@ -177,6 +187,11 @@ def __init__(
The name of the desalination plant.
- operating_hours:
The number of hours a day that the plant is in operation.
- pinch_point_temperature_difference:
The temperature difference between the desired condensation and
evaporation temperatures and the real temperatures achieved, dictated by
the effective possible rate of heat transfer across the heat exchangers
in the system.
- plant_outputs:
The outputs from the desalination plant.
- plant_reqiurements:
Expand All @@ -191,6 +206,9 @@ def __init__(
)
self.name: str = name
self.operating_hours = operating_hours
self.pinch_point_temperature_difference: float = (
pinch_point_temperature_difference
)
self.plant_outputs: dict[bool, PlantOutputs] = plant_outputs
self.plant_requirements: dict[bool, PlantRequirements] = plant_requirements
self.start_hour: int = start_hour
Expand Down Expand Up @@ -264,6 +282,7 @@ def from_dict(
return cls(
input_data[NAME],
input_data[OPERATING_HOURS],
input_data.get(PINCH_POINT_TEMPERATURE_DIFFERENCE, 0),
plant_outputs,
plant_requirements,
start_hour,
Expand Down
1 change: 1 addition & 0 deletions src/heatdesalination/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ def run_simulation( # pylint: disable=too-many-statements
ambient_temperatures[hour],
auxiliary_heating_demand,
heat_pump,
desalination_plant.pinch_point_temperature_difference,
)

auxiliary_heating_electricity_demand: float = max(
Expand Down
Loading