2025-02-14 20:18:03 +01:00
|
|
|
# These could be from the std math lib, but I like the numpy ones better personally
|
|
|
|
from numpy import sin, cos, pi
|
|
|
|
|
2025-02-14 21:04:42 +01:00
|
|
|
# Pull a1 support
|
|
|
|
from a1_support import GRAVITY_ACC, WATER_DENSITY, HELP_MESSAGE
|
|
|
|
from a1_support import load_data, plot_water_height
|
|
|
|
|
2025-02-14 20:18:03 +01:00
|
|
|
# Fill these in with your details
|
|
|
|
__author__ = "Cal Wing"
|
|
|
|
__email__ = "cal@wing.id.au"
|
|
|
|
__date__ = "14/02/2025"
|
|
|
|
__version__ = "1.0.0"
|
|
|
|
|
2025-02-14 21:15:53 +01:00
|
|
|
# Task 1 [Broken]
|
2025-02-14 21:04:42 +01:00
|
|
|
def determine_power_used(water_mass: float, elevation: float, pumping_time: float, efficiency: float) -> float:
|
|
|
|
"""
|
|
|
|
Calculates the power required to pump a certain mass of water a certain height
|
|
|
|
taking into account the pumping_time and efficiency.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
water_mass (float): the mass of the water pumped [kg]
|
|
|
|
elevation (float): the height difference [m]
|
|
|
|
pumping_time (float): the amount of time the pump is running for [hrs]
|
|
|
|
efficiency (float): the conversion efficiency [%]
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
(float): the power required by the pump [kW]
|
|
|
|
"""
|
|
|
|
# Ideal energy needed to lift the water
|
|
|
|
potenital_energy = water_mass * GRAVITY_ACC * elevation # J = kg * m/s^2 * m = mgh
|
|
|
|
|
|
|
|
# Actual amount of energy needed based on eff
|
|
|
|
# Here an 85% eff means an extra 15% is needed to pump the water up
|
|
|
|
electrical_energy = potenital_energy * (1 + (1 - efficiency/100)) # J = J * SCALER
|
2025-02-14 20:18:03 +01:00
|
|
|
|
2025-02-14 21:04:42 +01:00
|
|
|
# Actual electrial power used to pump the water
|
|
|
|
power_used = electrical_energy / (pumping_time*60*60) # W = J / S = J / (hr*60*60)
|
|
|
|
|
|
|
|
return power_used / 10e3 # W -> kW
|
2025-02-14 20:18:03 +01:00
|
|
|
|
2025-02-14 21:15:53 +01:00
|
|
|
# Task 2
|
|
|
|
def determine_water_released(gen_power: float, elevation: float, pumping_time: float, efficiency: float) -> float:
|
|
|
|
"""
|
|
|
|
Calculates the mass of water released required to generate a specified power
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
gen_power (float): the specified power to be generated [kW]
|
|
|
|
elevation (float): the height difference [m]
|
|
|
|
pumping_time (float): the time the pump is running for [hrs]
|
|
|
|
efficiency (float): the conversion efficiency [%]
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
(float): the mass of the water required [kg]
|
|
|
|
"""
|
|
|
|
|
|
|
|
# How much electrical engery was generated?
|
|
|
|
electrical_energy = (gen_power * 10e3) * (pumping_time*60*60) # J = W * S = (kW * 10^3) * (hrs*60*60)
|
|
|
|
|
|
|
|
# Need more potential energy to get electrial energy
|
|
|
|
# Again here for 85% eff need 15% more potenitial enegry to get pot-eng
|
|
|
|
potential_energy = electrical_energy / (1 + (1 - efficiency/100)) # J = J * Scaler
|
|
|
|
|
|
|
|
water_mass = potential_energy / (WATER_DENSITY * elevation) # kg = J / (m/s^2 * m)
|
|
|
|
|
|
|
|
return water_mass
|
|
|
|
|
2025-02-14 21:04:42 +01:00
|
|
|
def main():
|
|
|
|
print("Hello World!")
|
2025-02-14 20:18:03 +01:00
|
|
|
|
|
|
|
|
2025-02-14 21:04:42 +01:00
|
|
|
# See if I get what the task sheet wants
|
|
|
|
def sheet_tasks():
|
|
|
|
TASKS = (
|
|
|
|
(determine_power_used, (5e6, 250, 8, 85), 500.9191176470588),
|
2025-02-14 21:15:53 +01:00
|
|
|
(determine_water_released, (300, 250, 8, 85), 2994495.4128440367)
|
2025-02-14 21:04:42 +01:00
|
|
|
)
|
2025-02-14 20:18:03 +01:00
|
|
|
|
2025-02-14 21:04:42 +01:00
|
|
|
for i, (task, args, expected) in enumerate(TASKS):
|
|
|
|
print(f'Task {i+1}')
|
|
|
|
result = task(*args)
|
|
|
|
if expected is not None:
|
|
|
|
print(f'{task.__qualname__}{args} -> {result} {"==" if result == expected else "!="} {expected}')
|
|
|
|
print(f'Task{"" if result == expected else " NOT"} equal to expected result.')
|
|
|
|
else:
|
|
|
|
print(f'{task.__qualname__}{args} -> {result}')
|
|
|
|
|
|
|
|
print()
|
2025-02-14 20:13:04 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2025-02-14 21:04:42 +01:00
|
|
|
sheet_tasks()
|