def test_output(self): (F_1, X_1, X_2, theta_1, theta_2) = (500, 3, 3, 45, 45) (F_Ax, F_Ay, F_By) = InputParameters.derived_values(F_1, X_1, X_2) F_AC = Calculations.func_F_AC(F_Ay, theta_1) F_AD = Calculations.func_F_AD(F_AC, theta_1) F_BC = Calculations.func_F_BC(F_By, theta_2) F_BD = Calculations.func_F_BD(F_BC, theta_2) F_CD = Calculations.func_F_CD(F_1) assert relerr(F_AC, -353.553) < 0.01 assert relerr(F_AD, 250) < 0.01 assert relerr(F_BC, -353.553) < 0.01 assert relerr(F_BD, 250) < 0.01 assert relerr(F_CD, 500) < 0.01
# start coverage cov = coverage.Coverage() cov.start() filename = sys.argv[1] f = open(filename, "r") # read input (F_1, X_1, X_2, theta_1, theta_2) = InputParameters.get_input(f) f.close() inParams = (F_1, X_1, X_2, theta_1, theta_2) calledfunc = "Control" # do the calculationsif inputs are valid if (InputConstraints.input_constraints(inParams, calledfunc)): (F_Ax, F_Ay, F_By) = InputParameters.derived_values(F_1, X_1, X_2) F_AC = Calculations.func_F_AC(F_Ay, theta_1) F_AD = Calculations.func_F_AD(F_AC, theta_1) F_BC = Calculations.func_F_BC(F_By, theta_2) F_BD = Calculations.func_F_BD(F_BC, theta_2) F_CD = Calculations.func_F_CD(F_1) OutputFormat.write_output(F_AC, F_AD, F_BC, F_BD, F_CD) cov.stop() cov.save() # generate coverage report cov.html_report() # end timer end = time.time()
## \file Control.py # \author Thulasi Jegatheesan # \brief Controls the flow of the program import sys import Calculations import InputParameters import OutputFormat filename = sys.argv[1] A_C, C_W, h_C, T_init, t_final, L, T_C, t_step, rho_W, D, A_tol, R_tol, E_W = InputParameters.get_input( filename) V_tank = InputParameters.derived_values(D, L) InputParameters.input_constraints(A_C, C_W, h_C, T_init, t_final, L, T_C, t_step, rho_W, D, E_W) V_W = Calculations.func_V_W(V_tank) m_W = Calculations.func_m_W(rho_W, V_W) tau_W = Calculations.func_tau_W(C_W, h_C, A_C, m_W) T_W = Calculations.func_T_W(T_C, t_final, T_init, A_tol, R_tol, t_step, tau_W) OutputFormat.write_output(E_W, T_W)