Exemple #1
0
 def test_plot_flutter(self):
     """tests plot_flutter_f06"""
     f06_filename = os.path.join(MODEL_PATH, 'aero', 'bah_plane',
                                 'bah_plane.f06')
     log = get_logger2(log=None, debug=None, encoding='utf-8')
     plot_flutter_f06(f06_filename, show=False, log=log)
     if IS_MATPLOTLIB:
         plt.close()
Exemple #2
0
 def test_plot_flutter2(self):
     """tests plot_flutter_f06"""
     f06_filename = os.path.join(PKG_PATH, '..', 'models', 'aero',
                                 '2_mode_flutter', '0012_flutter.f06')
     log = get_logger2(log=None, debug=None, encoding='utf-8')
     plot_flutter_f06(f06_filename,
                      plot_vg=True,
                      plot_vg_vf=True,
                      plot_root_locus=True,
                      plot_kfreq_damping=True,
                      export_zona=True,
                      export_veas=True,
                      export_f06=True,
                      show=False,
                      log=log)
Exemple #3
0
def cmd_line_plot_flutter(argv=None, plot=True, show=True, log=None):
    """the interface to ``f06 plot_145`` on the command line"""
    import sys
    import os
    from docopt import docopt
    import pyNastran
    from pyNastran.f06.parse_flutter import plot_flutter_f06
    if argv is None:
        argv = sys.argv
    msg = (
        USAGE +
        '  f06 plot_145 -h | --help\n'
        '  f06 plot_145 -v | --version\n'
        '\n'

        'Positional Arguments:\n'
        '  F06_FILENAME    path to input F06 files\n'

        'Plot Types for V-g/V-f:\n'
        #'  --vgvf           plots a V-g/V-f plot\n'
        '  --rootlocus      plots a root locus\n'
        '  --kfreq          plots a kfreq-g/kfreq-f plot\n'
        '\n'
        'Plot Types for V-g/V-f:\n'
        '  --tas            plot true airspeed (default)\n'
        '  --eas            plot eqivalent airspeed\n'
        '  --density        plot density\n'
        '  --mach           plot Mach number\n'
        '  --alt            plot altitude\n'
        '\n'
        'Units:\n'
        '  --in_units IN    Selects the input unit system\n'
        '                   si (kg, m, s) -> m/s\n'
        '                   english_ft (slug/ft^3, ft, s) -> ft/s\n'
        '                   english_in (slinch/in^3, in, s) -> in/s (default)\n'

        '  --out_units OUT  Selects the ouptut unit system\n'
        '                   si (kg, m, s) -> m/s\n'
        '                   english_ft (slug/ft^3, ft, s) -> ft/s\n'
        '                   english_in (slinch/in^3, in, s) -> in/s (default)\n'
        '                   english_kt (slinch/in^3, nm, s) -> knots\n'
        '\n'
        'Options:\n'
        '  --modes MODES    the modes to plot (e.g. 1:10,20:22)\n'
        '  --subcases SUB   the subcases to plot (e.g. 1,3); unused\n'
        '  --xlim XLIM      the velocity limits (default=no limit)\n'
        '  --ylimfreq FREQ  the damping limits (default=no limit)\n'
        '  --ylimdamp DAMP  the damping limits (default=-0.3:0.3)\n'
        "  --nopoints       don't plot the points\n"
        "  --noline         don't plot the lines\n"
        "  --export         export a zona file\n"
        "  --f06            export an F06 file (temporary)\n"
        '\n'
        'Info:\n'
        '  -h, --help      show this help message and exit\n'''
        "  -v, --version   show program's version number and exit\n"
    )
    if len(argv) == 1:
        sys.exit(msg)

    ver = str(pyNastran.__version__)
    #type_defaults = {
    #    '--nerrors' : [int, 100],
    #}
    data = docopt(msg, version=ver, argv=argv[1:])
    f06_filename = data['F06_FILENAME']
    if not f06_filename.lower().endswith('.f06'):
        base = os.path.splitext(f06_filename)[0]
        f06_filename = base + '.f06'

    modes = split_int_colon(data['--modes'], start_value=1)

    xlim = [None, None]
    if data['--xlim']:
        xlim = split_float_colons(data['--xlim'])

    ylim_damping = [-.3, .3]
    if data['--ylimdamp']:
        ylim_damping = split_float_colons(data['--ylimdamp'])

    ylim_freq = [None, None]
    if data['--ylimfreq']:
        ylim_freq = split_float_colons(data['--ylimfreq'])

    in_units = 'si'
    if data['--in_units']:
        in_units = data['IN'].lower()
    assert in_units in ['si', 'english_in', 'english_ft', 'english_kt'], 'in_units=%r' % in_units

    out_units = 'si'
    if data['--out_units']:
        out_units = data['OUT'].lower()
    assert out_units in ['si', 'english_in', 'english_ft', 'english_kt'], 'out_units=%r' % out_units

    plot_type = 'tas'
    if data['--eas']:
        plot_type = 'eas'
    elif data['--tas']:
        plot_type = 'tas'
    elif data['--alt']:
        plot_type = 'alt'
    elif data['--mach']:
        plot_type = 'mach'
    elif data['--density']:
        plot_type = 'rho'
    elif data['--q']:
        plot_type = 'q'
    else:
        sys.stderr.write('plot_type assumed to be --tas\n')
        #raise NotImplementedError(data)

    plot_kfreq_damping = data['--kfreq']
    plot_root_locus = data['--rootlocus']

    nopoints = data['--nopoints']
    noline = data['--noline']

    export_f06 = data['--f06']
    export_zona = data['--export']
    export_f06_filename = None if export_f06 is False else 'nastran.f06'
    export_zona_filename = None if export_zona is False else 'nastran.zona'
    export_veas_filename = None if export_zona is False else 'nastran.veas'

    # TODO: need a new parameter
    vg_filename = None if export_zona is  None else 'vg_subcase_%i.png'
    vg_vf_filename = None if export_zona is  None else 'vg_vf_subcase_%i.png'
    kfreq_damping_filename = None if export_zona is  None else 'kfreq_damping_subcase_%i.png'
    root_locus_filename = None if export_zona is  None else 'root_locus_subcase_%i.png'
    if not plot:
        return
    plot_flutter_f06(f06_filename, modes=modes,
                     plot_type=plot_type,
                     f06_units=in_units,
                     out_units=out_units,
                     plot_root_locus=plot_root_locus, plot_vg_vf=True, plot_vg=False,
                     plot_kfreq_damping=plot_kfreq_damping,
                     xlim=xlim,
                     ylim_damping=ylim_damping, ylim_freq=ylim_freq,
                     nopoints=nopoints,
                     noline=noline,
                     export_veas_filename=export_veas_filename,
                     export_zona_filename=export_zona_filename,
                     export_f06_filename=export_f06_filename,
                     vg_filename=vg_filename,
                     vg_vf_filename=vg_vf_filename,
                     root_locus_filename=root_locus_filename,
                     kfreq_damping_filename=kfreq_damping_filename, show=show, log=log)
Exemple #4
0
def cmd_line_plot_flutter():  # pragma: no cover
    import sys
    from docopt import docopt
    import pyNastran
    msg = "Usage:\n"
    msg += "  f06 plot_145 F06_FILENAME [--noline] [--modes MODES] [--subcases SUB] [--xlim FREQ] [--ylim DAMP]\n"

    msg += '  f06 plot_145 -h | --help\n'
    msg += '  f06 plot_145 -v | --version\n'
    msg += '\n'

    msg += "Positional Arguments:\n"
    msg += "  F06_FILENAME    path to input F06 files\n"

    msg += 'Options:\n'
    msg += "  --modes MODES   the modes to plot (e.g. 1:10,20:22); unused\n"
    msg += "  --subcases SUB  the subcases to plot (e.g. 1,3); unused\n"
    msg += "  --xlim FREQ     the frequency limits (unused)"
    msg += "  --ylim DAMP     the damping limits (unused)"
    msg += '\n'

    msg += 'Info:\n'
    msg += '  -h, --help      show this help message and exit\n'
    msg += "  -v, --version   show program's version number and exit\n"

    if len(sys.argv) == 1:
        sys.exit(msg)

    ver = str(pyNastran.__version__)
    #type_defaults = {
    #    '--nerrors' : [int, 100],
    #}
    data = docopt(msg, version=ver)
    print(data)
    f06_filename = data['F06_FILENAME']
    if not f06_filename.lower().endswith('.f06'):
        base = os.path.splitext(f06_filename)[0]
        f06_filename = base + '.f06'

    modes = data['--modes']
    modes2 = []
    if modes is not None:
        smodes = modes.strip().split(',')
        for mode in smodes:
            mode = mode.strip()
            if ':' in mode:
                smode = mode.split(':')
                if len(smode) == 2:
                    istart = int(smode[0])
                    if smode[1] == '':
                        iend = None
                        modes2 = slice(istart, None)
                        assert len(smodes) == 1, smodes
                    else:
                        iend = int(smode[1])
                        assert iend > istart, 'smode=%s; istart=%s iend=%s' % (
                            smode, istart, iend)
                        modes2 += list(range(istart, iend + 1))
                elif len(smode) == 3:
                    istart = int(smode[0])
                    iend = int(smode[1])
                    assert iend > istart, 'smode=%s; istart=%s iend=%s' % (
                        smode, istart, iend)
                    istep = int(smode[2])
                    modes2 += list(range(istart, iend + 1, istep))
                else:
                    raise NotImplementedError('smode=%r; len=%s' %
                                              (smode, len(smode)))
            else:
                imode = int(mode)
                modes2.append(imode)
        #modes = np.array(modes2, dtype='int32') - 1
        modes = modes2
    print('modes = %s' % modes)
    plot_flutter_f06(f06_filename,
                     modes=modes,
                     plot_root_locus=True,
                     plot_vg_vf=True,
                     plot_vg=False)
Exemple #5
0
def cmd_line_plot_flutter():  # pragma: no cover
    import os
    import sys
    from docopt import docopt
    import pyNastran
    from pyNastran.f06.parse_flutter import plot_flutter_f06
    msg = (
        'Usage:\n'
        '  f06 plot_145 F06_FILENAME [--noline] [--modes MODES] [--subcases SUB] [--xlim XLIM] [--ylimdamp DAMP] [--ylimfreq FREQ]'
        '[--eas|--tas] [--kfreq] [--rootlocus] [--in_units IN][--out_units OUT] [--nopoints] [--export] [--f06]\n'
        '  f06 plot_145 -h | --help\n'
        '  f06 plot_145 -v | --version\n'
        '\n'
        'Positional Arguments:\n'
        '  F06_FILENAME    path to input F06 files\n'
        'Plot Types for V-g/V-f:\n'
        #'  --vgvf           plots a V-g/V-f plot\n'
        '  --rootlocus      plots a root locus\n'
        '  --kfreq          plots a kfreq-g/kfreq-f plot\n'
        '\n'
        'Plot Types for V-g/V-f:\n'
        '  --tas            plot true airspeed (default)\n'
        '  --eas            plot eqivalent airspeed\n'
        '\n'
        'Units:\n'
        '  --in_units IN    Selects the input unit system\n'
        '                   si (kg, m, s) -> m/s\n'
        '                   english_ft (slug/ft^3, ft, s) -> ft/s\n'
        '                   english_in (slinch/in^3, in, s) -> in/s (default)\n'
        '  --out_units OUT  Selects the ouptut unit system\n'
        '                   si (kg, m, s) -> m/s\n'
        '                   english_ft (slug/ft^3, ft, s) -> ft/s\n'
        '                   english_in (slinch/in^3, in, s) -> in/s (default)\n'
        '                   english_kt (slinch/in^3, nm, s) -> knots\n'
        '\n'
        'Options:\n'
        '  --modes MODES    the modes to plot (e.g. 1:10,20:22)\n'
        '  --subcases SUB   the subcases to plot (e.g. 1,3); unused\n'
        '  --xlim XLIM      the velocity limits (default=no limit)\n'
        '  --ylimfreq FREQ  the damping limits (default=no limit)\n'
        '  --ylimdamp DAMP  the damping limits (default=-0.3:0.3)\n'
        "  --nopoints       don't plot the points\n"
        "  --noline         don't plot the lines\n"
        "  --export         export a zona file\n"
        "  --f06            export an F06 file (temporary)\n"
        '\n'
        'Info:\n'
        '  -h, --help      show this help message and exit\n'
        ''
        "  -v, --version   show program's version number and exit\n")
    if len(sys.argv) == 1:
        sys.exit(msg)

    ver = str(pyNastran.__version__)
    #type_defaults = {
    #    '--nerrors' : [int, 100],
    #}
    data = docopt(msg, version=ver)
    f06_filename = data['F06_FILENAME']
    if not f06_filename.lower().endswith('.f06'):
        base = os.path.splitext(f06_filename)[0]
        f06_filename = base + '.f06'

    export_zona = data['--export']
    modes = split_int_colon(data['--modes'])

    xlim = [None, None]
    if data['--xlim']:
        xlim = split_float_colons(data['--xlim'])

    ylim_damping = [-.3, .3]
    if data['--ylimdamp']:
        ylim_damping = split_float_colons(data['--ylimdamp'])

    ylim_freq = [None, None]
    if data['--ylimfreq']:
        ylim_freq = split_float_colons(data['--ylimfreq'])

    in_units = 'si'
    if data['--in_units']:
        in_units = data['--in_units'].lower()
    assert in_units in ['si', 'english_in', 'english_ft',
                        'english_kt'], 'in_units=%r' % in_units

    out_units = 'si'
    if data['--out_units']:
        out_units = data['--out_units'].lower()
    assert out_units in ['si', 'english_in', 'english_ft',
                         'english_kt'], 'out_units=%r' % out_units

    plot_type = 'tas'
    if data['--eas']:
        plot_type = 'eas'

    plot_kfreq_damping = data['--kfreq']
    plot_root_locus = data['--rootlocus']

    nopoints = data['--nopoints']
    noline = data['--noline']
    export_f06 = data['--f06']
    plot_flutter_f06(
        f06_filename,
        modes=modes,
        plot_type=plot_type,
        f06_units=in_units,
        out_units=out_units,
        plot_root_locus=plot_root_locus,
        plot_vg_vf=True,
        plot_vg=False,
        plot_kfreq_damping=plot_kfreq_damping,
        xlim=xlim,
        ylim_damping=ylim_damping,
        ylim_freq=ylim_freq,
        nopoints=nopoints,
        noline=noline,
        export_zona=export_zona,
        export_f06=export_f06,
    )
Exemple #6
0
 def test_plot_flutter(self):
     """tests plot_flutter_f06"""
     f06_filename = os.path.join(PKG_PATH, '..', 'models', 'aero',
                                 'bah_plane', 'bah_plane.f06')
     log = get_logger2(log=None, debug=None, encoding='utf-8')
     plot_flutter_f06(f06_filename, show=False, log=log)
Exemple #7
0
    def test_plot_flutter2(self):
        """tests plot_flutter_f06"""
        f06_filename = os.path.join(MODEL_PATH, 'aero', '2_mode_flutter',
                                    '0012_flutter.f06')
        log = get_logger2(log=None, debug=None, encoding='utf-8')
        plot_flutter_f06(
            f06_filename,
            make_alt=True,
            modes=[2],
            plot_type='alt',
            f06_units='si',
            out_units='english_ft',
            plot_vg=True,
            plot_vg_vf=True,
            plot_root_locus=True,
            plot_kfreq_damping=True,
            plot=IS_MATPLOTLIB,
            show=False,
            log=log,
            close=True,
        )

        flutters = plot_flutter_f06(
            f06_filename,
            f06_units=None,
            out_units=None,
            plot_vg=True,
            plot_vg_vf=True,
            plot_root_locus=True,
            plot_kfreq_damping=True,
            export_f06_filename='nastran.f06',
            export_veas_filename='nastran.veas',
            export_zona_filename='zona.f06',
            vg_filename='vg_subcase_%i.png',
            vg_vf_filename='vg_vf_subcase_%i.png',
            kfreq_damping_filename='kfreq_damping_subcase_%i.png',
            root_locus_filename='root_locus_subcase_%i.png',
            plot=IS_MATPLOTLIB,
            show=False,
            log=log,
            close=True,
        )
        if IS_MATPLOTLIB:
            os.remove('vg_subcase_1.png')
            os.remove('vg_vf_subcase_1.png')
            os.remove('kfreq_damping_subcase_1.png')
            os.remove('root_locus_subcase_1.png')

            os.remove('nastran.f06')
            os.remove('nastran.veas')
            os.remove('zona.f06')

        with self.assertRaises(NotImplementedError):
            plot_flutter_f06(f06_filename,
                             plot_type='tas',
                             f06_units='cat',
                             out_units=None,
                             plot_vg=True,
                             plot_vg_vf=True,
                             plot_root_locus=True,
                             plot_kfreq_damping=True,
                             plot=IS_MATPLOTLIB,
                             show=False,
                             close=True,
                             log=log)
        with self.assertRaises(NotImplementedError):
            plot_flutter_f06(f06_filename,
                             plot_type='density',
                             f06_units='si',
                             out_units='english_ft',
                             plot_vg=True,
                             plot_vg_vf=True,
                             plot_root_locus=True,
                             plot_kfreq_damping=True,
                             show=True,
                             close=True,
                             log=log)

        plot_flutter_f06(f06_filename,
                         plot_type='rho',
                         f06_units='si',
                         out_units='english_ft',
                         plot_vg=True,
                         plot_vg_vf=True,
                         plot_root_locus=True,
                         plot_kfreq_damping=True,
                         plot=IS_MATPLOTLIB,
                         show=False,
                         close=True,
                         log=log)

        plot_flutter_f06(f06_filename,
                         plot_type='freq',
                         f06_units='si',
                         out_units='english_ft',
                         plot_vg=True,
                         plot_vg_vf=True,
                         plot_root_locus=True,
                         plot_kfreq_damping=True,
                         plot=IS_MATPLOTLIB,
                         show=False,
                         clear=True,
                         close=True,
                         log=log)

        plot_flutter_f06(f06_filename,
                         plot_type='kfreq',
                         f06_units='si',
                         out_units='english_ft',
                         plot_vg=True,
                         plot_vg_vf=True,
                         plot_root_locus=True,
                         plot_kfreq_damping=True,
                         plot=IS_MATPLOTLIB,
                         show=False,
                         clear=True,
                         close=True,
                         log=log)

        plot_flutter_f06(f06_filename,
                         plot_type='ikfreq',
                         f06_units='si',
                         out_units='english_ft',
                         plot_vg=True,
                         plot_vg_vf=True,
                         plot_root_locus=True,
                         plot_kfreq_damping=True,
                         plot=IS_MATPLOTLIB,
                         show=False,
                         clear=True,
                         close=True,
                         log=log)

        plot_flutter_f06(f06_filename,
                         modes=[2],
                         plot_type='damp',
                         f06_units='si',
                         out_units='english_ft',
                         plot_vg=True,
                         plot_vg_vf=True,
                         plot_root_locus=True,
                         plot_kfreq_damping=True,
                         plot=IS_MATPLOTLIB,
                         show=False,
                         clear=True,
                         close=True,
                         log=log)

        plot_type = 'eas'
        modes = None
        #xlim = [0., 500000.] # in/s
        xlim = None
        ylim_damping = [-0.2, 0.2]
        ylim_freq = None
        ylim_kfreq = None
        if IS_MATPLOTLIB:
            make_flutter_plots(
                modes,
                flutters,
                xlim,
                ylim_damping,
                ylim_freq,
                ylim_kfreq,
                plot_type,
                plot_vg=True,
                plot_vg_vf=True,
                plot_root_locus=True,
                plot_kfreq_damping=True,
                nopoints=True,
                noline=False,
                #export_zona_filename=export_zona_filename,
                #export_veas_filename=export_veas_filename,
                #export_f06_filename=export_f06_filename,
                #vg_filename=vg_filename,
                #vg_vf_filename=vg_vf_filename,
                #root_locus_filename=root_locus_filename,
                #kfreq_damping_filename=kfreq_damping_filename,
                show=False,
                clear=True,
                close=True)
Exemple #8
0
def cmd_line_plot_flutter():  # pragma: no cover
    import sys
    from docopt import docopt
    import pyNastran
    msg = "Usage:\n"
    msg += "  f06 plot_145 F06_FILENAME [--noline] [--modes MODES] [--subcases SUB] [--xlim FREQ] [--ylim DAMP]\n"

    msg += '  f06 plot_145 -h | --help\n'
    msg += '  f06 plot_145 -v | --version\n'
    msg += '\n'

    msg += "Positional Arguments:\n"
    msg += "  F06_FILENAME    path to input F06 files\n"

    msg += 'Options:\n'
    msg += "  --modes MODES   the modes to plot (e.g. 1:10,20:22); unused\n"
    msg += "  --subcases SUB  the subcases to plot (e.g. 1,3); unused\n"
    msg += "  --xlim FREQ     the frequency limits (unused)"
    msg += "  --ylim DAMP     the damping limits (unused)"
    msg += '\n'

    msg += 'Info:\n'
    msg += '  -h, --help      show this help message and exit\n'
    msg += "  -v, --version   show program's version number and exit\n"

    if len(sys.argv) == 1:
        sys.exit(msg)

    ver = str(pyNastran.__version__)
    #type_defaults = {
    #    '--nerrors' : [int, 100],
    #}
    data = docopt(msg, version=ver)
    print(data)
    f06_filename = data['F06_FILENAME']
    if not f06_filename.lower().endswith('.f06'):
        base = os.path.splitext(f06_filename)[0]
        f06_filename = base + '.f06'

    modes = data['--modes']
    modes2 = []
    if modes is not None:
        smodes = modes.strip().split(',')
        for mode in smodes:
            mode = mode.strip()
            if ':' in mode:
                smode = mode.split(':')
                if len(smode) == 2:
                    istart = int(smode[0])
                    if smode[1] == '':
                        iend = None
                        modes2 = slice(istart, None)
                        assert len(smodes) == 1, smodes
                    else:
                        iend = int(smode[1])
                        assert iend > istart, 'smode=%s; istart=%s iend=%s' % (smode, istart, iend)
                        modes2 += list(range(istart, iend + 1))
                elif len(smode) == 3:
                    istart = int(smode[0])
                    iend = int(smode[1])
                    assert iend > istart, 'smode=%s; istart=%s iend=%s' % (smode, istart, iend)
                    istep = int(smode[2])
                    modes2 += list(range(istart, iend + 1, istep))
                else:
                    raise NotImplementedError('smode=%r; len=%s' % (smode, len(smode)))
            else:
                imode = int(mode)
                modes2.append(imode)
        #modes = np.array(modes2, dtype='int32') - 1
        modes = modes2
    print('modes = %s' % modes)
    plot_flutter_f06(f06_filename, modes=modes,
                     plot_root_locus=True, plot_vg_vf=True, plot_vg=False)