def getCombination(args): reqCruiseSpeed = args[0] reqThrust = args[1] altitude = args[2] currFlightTime = None while currFlightTime is None or math.isnan(currFlightTime): #Fetch prop data prop = s.Propeller(dbcur) #Fetch motor data motor = s.Motor(dbcur) #Fetch ESC data esc = s.ESC(dbcur) #Fetch battery data batt = s.Battery(dbcur) if batt.R == 0 and esc.R == 0 and motor.R == 0: continue currUnit = s.PropulsionUnit(prop, motor, batt, esc, altitude) currFlightTime = currUnit.CalcBattLife(reqCruiseSpeed, reqThrust) return currFlightTime, currUnit
def __init__(self, prop, motor, battery, numCells, esc, altitude, showData): #Open database and read records from database db = sql.connect("Database/components.db") dbcur = db.cursor() #Fetch prop data formatString = """select * from Props where Name = "{propName}" """ command = formatString.format(propName=prop) dbcur.execute(command) propRecord = dbcur.fetchall() propInfo = np.asarray(propRecord[0]) if showData: print("----Propeller Data----\n", propInfo) self.prop = s.Propeller(propInfo[1], propInfo[2], propInfo[3], propInfo[4:]) #Fetch motor data formatString = """select * from Motors where Name = "{motorName}" """ command = formatString.format(motorName=motor) dbcur.execute(command) motorRecord = dbcur.fetchall() motorInfo = np.asarray(motorRecord[0]) if showData: print("----Motor Data----\n", motorInfo) self.motor = s.Motor(motorInfo[1], motorInfo[2], motorInfo[3], motorInfo[5], motorInfo[4], motorInfo[6]) #Fetch battery data formatString = """select * from Batteries where Name = "{batteryName}" """ command = formatString.format(batteryName=battery) dbcur.execute(command) batteryRecord = dbcur.fetchall() batteryInfo = np.asarray(batteryRecord[0]) if showData: print("----Battery Data----\n", batteryInfo) self.batt = s.Battery(batteryInfo[1], numCells, batteryInfo[3], batteryInfo[6], batteryInfo[5], batteryInfo[4]) #Fetch ESC data formatString = """select * from ESCs where Name = "{escName}" """ command = formatString.format(escName=esc) dbcur.execute(command) escRecord = dbcur.fetchall() escInfo = np.asarray(escRecord[0]) if showData: print("----ESC Data----\n", escInfo) self.esc = s.ESC(escInfo[1], escInfo[5], escInfo[2], escInfo[4]) #Initialize exterior parameters to be set later self.prop.vInf = 0 self.prop.angVel = 0 _, _, _, self.airDensity = coesa.table(altitude) db.close()
def getCombination(args): v_req = args[0] T = args[1] h = args[2] optimizeForRatio = args[3] W_frame = args[4] names = args[5] manufacturers = args[6] if optimizeForRatio: R_tw_req = T else: T_req = T t_flight_curr = None while t_flight_curr is None or math.isnan(t_flight_curr): #Fetch prop data prop = s.Propeller(dbcur, name=names[0], manufacturer=manufacturers[0]) #Fetch motor data motor = s.Motor(dbcur, name=names[1], manufacturer=manufacturers[1]) #Fetch ESC data esc = s.ESC(dbcur, name=names[2], manufacturer=manufacturers[2]) #Fetch battery data batt = s.Battery(dbcur, name=names[3], manufacturer=manufacturers[3]) if batt.R == 0 and esc.R == 0 and motor.R == 0: continue currUnit = s.PropulsionUnit(prop, motor, batt, esc, h) if optimizeForRatio: T_req = (currUnit.GetWeight() + W_frame) * R_tw_req with warnings.catch_warnings(): warnings.simplefilter("ignore") t_flight_curr = currUnit.CalcBattLife(v_req, T_req) thr_curr = currUnit.CalcCruiseThrottle(v_req, T_req) return t_flight_curr, thr_curr, currUnit
numCells = 6 escs = ["Kontronik Beat 60-8-24"] altitude = 0 thrusts = [0.3] speeds = [10] weights = [1] #Open database and read records from database db = sql.connect("Database/components.db") dbcur = db.cursor() for prop, motor, battery, esc, thrust, cruiseSpeed, weight in zip( props, motors, batteries, escs, thrusts, speeds, weights): #Fetch prop data propC = s.Propeller(dbcur, name=prop) propC.printInfo() propC.PlotCoefs() #Fetch motor data motorC = s.Motor(dbcur, name=motor) motorC.printInfo() #Fetch battery data battC = s.Battery(dbcur) battC.printInfo() #Fetch ESC data escC = s.ESC(dbcur, name=esc) escC.printInfo()
speeds = [5, 15, 20] #Open database and read records from database db = sql.connect("Database/components.db") dbcur = db.cursor() for prop, motor, battery, esc, thrust, cruiseSpeed in zip( props, motors, batteries, escs, thrusts, speeds): #Fetch prop data formatString = """select * from Props where Name = "{propName}" """ command = formatString.format(propName=prop) dbcur.execute(command) propRecord = dbcur.fetchall() propInfo = np.asarray(propRecord[0]) propC = s.Propeller(propInfo[1], propInfo[2], propInfo[3], propInfo[4:]) #Fetch motor data formatString = """select * from Motors where Name = "{motorName}" """ command = formatString.format(motorName=motor) dbcur.execute(command) motorRecord = dbcur.fetchall() motorInfo = np.asarray(motorRecord[0]) motorC = s.Motor(motorInfo[1], motorInfo[2], motorInfo[3], motorInfo[5], motorInfo[4], motorInfo[6]) #Fetch battery data formatString = """select * from Batteries where Name = "{batteryName}" """ command = formatString.format(batteryName=battery) dbcur.execute(command) batteryRecord = dbcur.fetchall()