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
Exemplo n.º 4
0
    #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()

    test = s.PropulsionUnit(propC, motorC, battC, escC, altitude)
    print("Initialization complete. Plotting thrust curves.")
    minAirspeed = 0
    maxAirspeed = 30
    numVelocities = 11
    numThrottles = 1001
    thrust = test.GetWeight() + weight * thrust
    test.PlotThrustCurves(minAirspeed, maxAirspeed, numVelocities,
                          numThrottles)
    print("Flight time (thrust=", thrust, ", cruiseSpeed=", cruiseSpeed, ")",
          test.CalcBattLife(thrust, cruiseSpeed), "min")

db.close()
Exemplo n.º 5
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()
    batteryInfo = np.asarray(batteryRecord[0])
    battC = s.Battery(batteryInfo[1], numCells, batteryInfo[3], batteryInfo[6],
                      batteryInfo[5], batteryInfo[4], batteryInfo[2])

    #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])
    escC = s.ESC(escInfo[1], escInfo[5], escInfo[2], escInfo[4])

    test = unit.PropulsionUnit(propC, motorC, battC, escC, altitude)
    print("Initialization complete. Plotting thrust curves.")
    maxAirspeed = 30
    numVelocities = 11
    numThrottles = 101
    test.PlotThrustCurves(maxAirspeed, numVelocities, numThrottles)
    print("Flight time (thrust=", thrust, ", cruiseSpeed=", cruiseSpeed, ")",
          test.CalcBattLife(thrust, cruiseSpeed), "min")

db.close()