示例#1
0
def main(argv):
    """Determine basic vehicle propellant and mass parameters of vehicle."""

    parsed = parseargs(argv)

    #writer = HTML(sys.stdout)
    writer = Text(sys.stdout)
    putrow = writer.putfmtrow
    putitem = writer.putitem

    basicrept = BasicLV(writer)

    fh = open(parsed.vehicle, 'r')
    design = yaml.load(fh)
    fh = open(parsed.propellants, 'r')
    propeldb = yaml.load(fh)

    if parsed.verbose:
        import pprint
        pp = pprint.PrettyPrinter(width=41, stream=sys.stderr)
        pp.pprint(["design", design])

    performance = multistage.performance(design)

    sequence = design['stageorder']

    deltaVlist = []

    putitem('Mass and deltaV:')
    for activestage in sequence:
        putitem('Stage: ' + activestage)
        stageperf = performance[activestage]
        basicrept.putStageMassesDeltaV(activestage, stageperf)
        deltaVlist.append(stageperf['deltaV'])

    totalDeltaV = sum(deltaVlist)
    putitem('Total deltaV:')
    putrow('Total deltaV (m/s, ft/s)', '%11.4f', [totalDeltaV, totalDeltaV*m2ft])

    reptfmts = {}
    reptfmts['propel.deduce'] = propel.reptfmt_deduce

    stages = design['stages']
    for activestage in sequence:
        stageperf = performance[activestage]
        if 'Isp' not in stages[activestage] or stages[activestage]['Isp'] == 0:
            continue
        mixture = stages[activestage]['mixture']
        Mpropel = stageperf['Mignite']-stageperf['Mburnout']
        propellants = propel.deduce(propeldb, mixture, Mpropel)
        stageperf['gRange'] = design['gRange']
        flows, reptflows = propel.flows(propellants, stageperf)
        reptfmts['propel.flows'] = reptflows
        basicrept.putPropellants(activestage, stageperf, propellants, reptfmts)

    putitem('Totals:')
    drytot = multistage.masses(design['stageorder'], stages, mtype='Mdry')
    putrow('dry mass', '%11.4f', [drytot, drytot/lb2kg])
示例#2
0
def main(argv):
    """Determine basic vehicle propellant and mass parameters of vehicle."""

    parsed = parseargs(argv)

    writer = Text(sys.stdout)
    putrow = writer.putfmtrow
    putitem = writer.putitem
    putrow("msglabel", "%8s", [ "hello", "world" ])

    fh = open(parsed.vehicle, 'r')
    design = yaml.load(fh)
    fh = open(parsed.propellants, 'r')
    propeldb = yaml.load(fh)

    staging = multistage.performance(design)
    sequence = design['stageorder']
    maxG = design['maxG']

    for activestage in sequence:
        stageinfo = staging[activestage]
        putitem ('%-32s Mignite %7.1f Mburnout %7.1f kilo' % (activestage,
            stageinfo['Mignite'], stageinfo['Mburnout'] ))
        putitem ('%-32s Mignite %7.1f Mburnout %7.1f lbm' % (activestage,
            stageinfo['Mignite']/lb2kg, stageinfo['Mburnout']/lb2kg ))
        putitem ('%-32s  deltaV %7.1f' % (activestage, stageinfo['deltaV']))

    deltaV = staging['totalDeltaV']
    putrow ('Total deltaV (m/s, ft/s)', '%11.4f', [deltaV, deltaV*m2ft])

    stages = design['stages']
    for activestage in sequence:
        stageinfo = staging[activestage]
        if 'Isp' not in stages[activestage] or stages[activestage]['Isp'] == 0:
            continue
        mixture = stages[activestage]['mixture']
        Mpropel = stageinfo['Mignite']-stageinfo['Mburnout']
        propresults = propel.deduce(propeldb, mixture, Mpropel)

        putitem ('Stage: ' + activestage)
        for label, fmt, prop in (
                ('matl names', '%7s', 'matlNames'),
                ('liqdens (kg/l)', '%7.3f', 'liqdens'),
                ('masses (kg)', '%7.3f', 'masses'),
                ('volume (l)', '%7.3f', 'volumes') ):
            results = list(propresults[prop])
            if prop == 'matlNames':
                results.append('[sum]')
            elif prop in ('masses', 'volumes'):
                results.append(sum(propresults[prop]))
            putrow (label, fmt, results)
        avgdens = sum(propresults['masses'])/sum(propresults['volumes'])
        putrow ('avg dens (kg/l)', '%11.4f', [avgdens])

        # compute thrust based on stageinfo['Mburnout']
        thrust = stageinfo['Mburnout'] * gEarth * maxG
        wIgnite = stageinfo['Mignite'] * gEarth
        wBurnout = stageinfo['Mburnout'] * gEarth
        deltaV = stageinfo['deltaV']
        mflow = thrust / (stageinfo['Isp'] * gEarth)
        wetmass = stageinfo['Mignite']
        drymass = stageinfo['Mburnout']
        burntime = Mpropel / mflow
        GIgnite = thrust / wIgnite
        GBurnout = thrust / wBurnout

        for label, fmt, values in (
            ('massflow (kg/s)', '%11.4f', [mflow]),
            ('burn time (s)', '%11.4f', [burntime]),
            ('G (ignite, burnout)', '%7.3f', [GIgnite, GBurnout]),
            ('thrust (N, lbf)', '%11.4f', [thrust, thrust*N2lb]),
            ('wt ignite (N, lbm)', '%11.4f', [wIgnite, wIgnite*N2lb]),
            ('wt burnout (N, lbm)', '%11.4f', [wBurnout, wBurnout*N2lb]),
            ('deltaV (m/s, ft/s)', '%11.4f', [deltaV, deltaV*m2ft]),
            ('wet mass', '%11.4f', [wetmass, wetmass/lb2kg]),
            ('dry mass', '%11.4f', [drymass, drymass/lb2kg]), ):
            putrow (label, fmt, values)

    putitem ('Totals:')
    drytot = multistage.masses(design['stageorder'], stages, mtype='Mdry')
    putrow ('dry mass', '%11.4f', [drytot, drytot/lb2kg])