Skip to content

Commit

Permalink
Remove unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
p-snft committed Oct 10, 2024
1 parent ac9337b commit cfa7066
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

def absorption_chiller_example():
solver = "cbc"
debug = False
number_of_time_steps = 48
solver_verbose = True

Expand Down Expand Up @@ -133,9 +132,8 @@ def absorption_chiller_example():
demand_cooling = string_results["chilled", "cooling_demand"][
"sequences"
].values
ASHP_input = string_results["hot", "AC"]["sequences"].values

fig2, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
_, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
axs[0].plot(AC_output, label="cooling output")
axs[0].plot(demand_cooling, linestyle="--", label="cooling demand")
axs[1].plot(COPs, linestyle="-.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ def cooling_cap_example():
ax1 = fig1.add_subplot(111)
ax1.grid(axis="y")

line1 = ax1.plot(
ax1.plot(
t_cooling,
Q_dots_evap_80,
linestyle="dotted",
marker="d",
color="black",
label="Cooling capacity ($80°$C driving heat)",
)
line2 = ax1.plot(
ax1.plot(
t_cooling,
Q_dots_evap_75,
linestyle="dashed",
Expand All @@ -77,7 +77,7 @@ def cooling_cap_example():
)
plt.ylabel("Cooling capacity in kW")
ax2 = fig1.add_subplot(111, sharex=ax1, frameon=False)
line3 = ax2.plot(
ax2.plot(
t_cooling,
COPs_75,
linestyle="-",
Expand Down
2 changes: 1 addition & 1 deletion examples/cogeneration/emission_allocation_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def emission_allocation_example():
# Example plot
fig, ax = plt.subplots()
df.loc[:, "el"] *= -1
bars = df.plot.barh(stacked=True, ax=ax)
df.plot.barh(stacked=True, ax=ax)

for i, (el, th) in enumerate(zip(df["el"], df["th"])):
ax.text(el, i, round(-el), ha="left")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def airource_hp_const_example():
ASHP_input = string_results["electricity", "ASHP"]["sequences"].values

# Example plot
fig, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
_, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
axs[0].plot(ASHP_output, label="heat output")
axs[0].plot(demand_h, linestyle="--", label="heat demand")
axs[1].plot(cops_ASHP, linestyle="-.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ def airource_hp_variable_example():

results = energysystem.results["main"]

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable results is not used.

electricity_bus = solph.views.node(results, "electricity")
heat_bus = solph.views.node(results, "heat")

string_results = solph.views.convert_keys_to_strings(
energysystem.results["main"]
)
Expand All @@ -134,7 +131,7 @@ def airource_hp_variable_example():
]

# Example plot
fig, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
_, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
axs[0].plot(max_Q_dot_heating_abs, linestyle="-.", label="max heat output")
axs[0].plot(ASHP_output, label="actual heat output")
axs[0].plot(demand_h, linestyle="--", label="heat demand")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ def groundsource_hp_example():
)
GSHP_output = string_results["GSHP", "heat"]["sequences"].values
demand_h = string_results["heat", "demand"]["sequences"].values
GSHP_input = string_results["electricity", "GSHP"]["sequences"].values
env_heat = string_results["ambient", "heat_low_temp"]["sequences"].values

# Example plot
fig2, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
_, axs = plt.subplots(3, 1, figsize=(8, 5), sharex=True)
axs[0].plot(GSHP_output, label="heat output")
axs[0].plot(demand_h, linestyle="--", label="heat demand")
axs[0].plot(env_heat, label="heat from environment")
Expand Down
4 changes: 1 addition & 3 deletions examples/concentrating_solar_power/csp_collector_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ def csp_collector_example():
)["t_amb"]

# Parameters for the precalculation
periods = 24
latitude = 23.614328
longitude = 58.545284
timezone = "Asia/Muscat"
collector_tilt = 10
collector_azimuth = 180
cleanliness = 0.9
Expand Down Expand Up @@ -123,7 +121,7 @@ def csp_collector_example():

df_result = df_result.append(data_precalc_temp_amb, ignore_index=True)

fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(
temp_amb_series,
df_result["eta_c"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ def csp_andasol_example():
)["t_amb"]

# Parameters for the precalculation
periods = 24
latitude = 23.614328
longitude = 58.545284
timezone = "Asia/Muscat"
collector_tilt = 10
collector_azimuth = 180
cleanliness = 0.9
Expand Down Expand Up @@ -97,7 +95,7 @@ def csp_andasol_example():
t = list(range(1, 25))

# Example plot
fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(t, heat_calc, label="CSP precalculation")
ax.plot(t, heat_compare, label="constant efficiency")
ax.set(
Expand Down Expand Up @@ -138,7 +136,7 @@ def csp_andasol_example():

df_result = df_result.append(data_precalc_temp_amb, ignore_index=True)

fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(
temp_amb_series,
df_result["eta_c"],
Expand Down
2 changes: 1 addition & 1 deletion examples/concentrating_solar_power/csp_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def csp_facade_example():
df.to_csv(os.path.join(results_path, "facade_results.csv"))

# Example plot
fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(
list(range(periods)),
thermal_bus[(("solar_collector", "thermal"), "flow")][:-1],
Expand Down
2 changes: 1 addition & 1 deletion examples/concentrating_solar_power/csp_plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def csp_plant_example():
df.to_csv(os.path.join(results_path, "csp_plant_results.csv"))

# Example plot
fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(
list(range(periods)),
thermal_bus[(("collector", "thermal"), "flow")][:-1],
Expand Down
2 changes: 1 addition & 1 deletion examples/solar_thermal_collector/_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def plot_collector_heat(data_precalc, periods, eta_0):
heat_compare = irradiance_on_collector * eta_0
t = list(range(1, periods + 1))

fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(t, heat_calc, label="Solar thermal precalculation")
ax.plot(t, heat_compare, label="constant efficiency")
ax.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def flat_plate_collector_facade_example():
heat_calc = collector_inflow
t = list(range(1, periods + 1))

fig, ax = plt.subplots()
_, ax = plt.subplots()
ax.plot(t, heat_calc[:-1])
ax.set(
xlabel="time in h", ylabel="Q_coll in W", title="Heat of the collector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,10 @@ def fixed_ratio_invest_facade_example():
results = processing.results(optimization_model)
string_results = processing.convert_keys_to_strings(results)
sequences = {k: v["sequences"] for k, v in string_results.items()}

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable sequences is not used.
df = pd.concat(sequences, axis=1)

# Print storage sizing
built_storage_capacity = results[thermal_storage, None]["scalars"][
"invest"
]
initial_storage_capacity = results[thermal_storage, None]["scalars"][
"init_content"
]
maximum_heat_flow_charging = results[bus_heat, thermal_storage]["scalars"][
"invest"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ def print_parameters():
built_storage_capacity = results[thermal_storage, None]["scalars"][
"invest"
]
initial_storage_capacity = results[thermal_storage, None]["scalars"][
"init_content"
]
maximum_heat_flow_charging = results[bus_heat, thermal_storage]["scalars"][
"invest"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ def invest_independent_facade_example():
built_storage_capacity = results[thermal_storage, None]["scalars"][
"invest"
]
initial_storage_capacity = results[thermal_storage, None]["scalars"][
"init_content"
]
built_capacity = results[bus_heat, thermal_storage]["scalars"]["invest"]

dash = "-" * 50
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,11 @@ def print_parameters():
results = processing.results(optimization_model)
string_results = processing.convert_keys_to_strings(results)
sequences = {k: v["sequences"] for k, v in string_results.items()}

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable sequences is not used.
df = pd.concat(sequences, axis=1)

# Print storage sizing
built_storage_capacity = results[thermal_storage, None]["scalars"][
"invest"
]
initial_storage_capacity = results[thermal_storage, None]["scalars"][
"init_content"
]
maximum_heat_flow_charging = results[bus_heat, thermal_storage]["scalars"][
"invest"
]
Expand Down
2 changes: 1 addition & 1 deletion examples/stratified_thermal_storage/model_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def run_storage_model(initial_storage_level, temp_h, temp_c):
t_meas = np.arange(0, (len(level_meas) / 4), 0.25)

plt.style.use("ggplot")
fig, ax = plt.subplots()
_, ax = plt.subplots()

# Plot horizontal line (initial level)
init_level = level_meas["level"][0]
Expand Down
3 changes: 0 additions & 3 deletions examples/stratified_thermal_storage/operation_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ def print_parameters():
bus_heat, heat_source, shortage, excess, heat_demand, thermal_storage
)

# Create and solve the optimization model
optimization_model = Model(energysystem)


if __name__ == "__main__":
operation_facade_example()
2 changes: 1 addition & 1 deletion examples/stratified_thermal_storage/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def print_results():
storage_df = storage_df.reindex(sorted(storage_df.columns), axis=1)

# Plot storage_content vs. time
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
_, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
storage_content.plot(ax=ax1)
ax1.set_title("Storage content")
ax1.set_xlabel("Timesteps")
Expand Down
4 changes: 2 additions & 2 deletions src/oemof/thermal/compression_heatpumps_and_chillers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def calc_cops(
length = max([len(temp_high), len(temp_low)])
if len(temp_high) == 1:
list_temp_high_K = [temp_high[0] + 273.15] * length
elif len(temp_high) == length:
else: # len(temp_high) == length:
list_temp_high_K = [t + 273.15 for t in temp_high]
if len(temp_low) == 1:
list_temp_low_K = [temp_low[0] + 273.15] * length
elif len(temp_low) == length:
else: # len(temp_low) == length:
list_temp_low_K = [t + 273.15 for t in temp_low]

# Calculate COPs depending on selected mode (without icing).
Expand Down

0 comments on commit cfa7066

Please sign in to comment.