Task 8
This commit is contained in:
parent
619478dae3
commit
c9cce501bc
37
a1.py
37
a1.py
@ -171,6 +171,39 @@ def calc_daily_profit(energy: tuple[float, ...], peak_tariff: float,
|
||||
|
||||
return total_profit
|
||||
|
||||
# Task 9
|
||||
def print_table(start_relative_elevation: float, step_size: float,
|
||||
num_steps: int, initial_height: float, final_height: float,
|
||||
reservoir_area: float, outlet_area: float, time_inc: float,
|
||||
peak_tariff: float, off_peak_tariff: float, efficiency: float):
|
||||
|
||||
# Print the header
|
||||
print("#"*79)
|
||||
print("# Relative elevation (m) # Daily Profit ($) # Total Energy (kWh) #")
|
||||
print("#"*79)
|
||||
|
||||
table_data = ()
|
||||
|
||||
rel_elevation = start_relative_elevation
|
||||
for i in range(num_steps):
|
||||
|
||||
heights, water_mass_outs = calc_heights_water_out(initial_height, final_height, reservoir_area, outlet_area, time_inc)
|
||||
energy, _ = calc_energy_power(heights, water_mass_outs, rel_elevation, efficiency, time_inc)
|
||||
|
||||
total_energy = sum(energy)
|
||||
|
||||
profit = calc_daily_profit(energy, peak_tariff, off_peak_tariff, efficiency)
|
||||
|
||||
table_data += (rel_elevation, profit, total_energy),
|
||||
|
||||
rel_elevation += step_size
|
||||
|
||||
# Print the table
|
||||
for elevation, profit, total_energy in table_data:
|
||||
print(f"#{elevation:^25d}#{profit:^25.2f}#{total_energy:^25.2f}#")
|
||||
|
||||
print("#"*79)
|
||||
|
||||
# See if I get what the task sheet wants
|
||||
# [NOTE] It seems I am witing my own test suite :/ that wasn't the initention lol
|
||||
# Tests do equal what I get when i test it in the shell
|
||||
@ -196,4 +229,6 @@ def sheet_tasks():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sheet_tasks()
|
||||
#sheet_tasks()
|
||||
|
||||
print_table(280, 20, 6, 30, 20, 40000, 1, 30, 0.02, 0.005, 85)
|
Loading…
x
Reference in New Issue
Block a user