From 2f2b7790dbb4b8d1e0043b49464e7ecea1cfa6ca Mon Sep 17 00:00:00 2001 From: Cal Wing Date: Fri, 14 Feb 2025 21:04:42 +0100 Subject: [PATCH] Task 1 --- .vscode/launch.json | 2 +- a1.py | 76 ++++++++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index dff7fc0..ee82fb7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "program": "${file}", "console": "integratedTerminal", - "args": ["--debug"] + "args": [] } ] } \ No newline at end of file diff --git a/a1.py b/a1.py index 942ae92..c3dc10c 100644 --- a/a1.py +++ b/a1.py @@ -1,45 +1,63 @@ -# Cal Wing (uqcwing) -# A1 Attempt 1 -# 14/02/25 - # These could be from the std math lib, but I like the numpy ones better personally from numpy import sin, cos, pi +# Pull a1 support +from a1_support import GRAVITY_ACC, WATER_DENSITY, HELP_MESSAGE +from a1_support import load_data, plot_water_height + # Fill these in with your details __author__ = "Cal Wing" __email__ = "cal@wing.id.au" __date__ = "14/02/2025" __version__ = "1.0.0" - -# I have some useful things setup and wanted to play with python's arg parse -# This is not in any way apart of the assignment. -# This is to override consts / funcs as needed -# It is not impactful on the assignment and can be removed with no consequence -if __name__ == "__main__": - import argparse - - # This is purely here to allow for my personal quirks - arg_parser = argparse.ArgumentParser(description="ENGG1001 Assignment 1") - arg_parser.add_argument("--debug", help="Enable debug mode", default=False, required=False, action=argparse.BooleanOptionalAction) +# Task 1 +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. - args, unknown = arg_parser.parse_known_args() - - # Only import the debug_lib (and override the input func) if debug mode is enabled - if args.debug: - print("Debug mode enabled - Using debug input...") - import makeGraph - from makeGraph import makeGraph, UQ_COLOURS as UQC - #from debug_lib import auto_input - #input_cases = [] - #input = auto_input(input_cases) + 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 - - -# ============== Assignment Starts Here ============== + # 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 + + # 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 def main(): print("Hello World!") + +# See if I get what the task sheet wants +def sheet_tasks(): + TASKS = ( + (determine_power_used, (5e6, 250, 8, 85), 500.9191176470588), + ) + + 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() + if __name__ == '__main__': - main() \ No newline at end of file + sheet_tasks() \ No newline at end of file