This commit is contained in:
Cal Wing 2025-02-14 21:15:53 +01:00
parent 7b7fa164a1
commit b60cfd67af

29
a1.py
View File

@ -11,7 +11,7 @@ __email__ = "cal@wing.id.au"
__date__ = "14/02/2025"
__version__ = "1.0.0"
# Task 1
# Task 1 [Broken]
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
@ -38,6 +38,32 @@ def determine_power_used(water_mass: float, elevation: float, pumping_time: floa
return power_used / 10e3 # W -> kW
# 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
def main():
print("Hello World!")
@ -46,6 +72,7 @@ def main():
def sheet_tasks():
TASKS = (
(determine_power_used, (5e6, 250, 8, 85), 500.9191176470588),
(determine_water_released, (300, 250, 8, 85), 2994495.4128440367)
)
for i, (task, args, expected) in enumerate(TASKS):