def create():

    data = np.loadtxt(ap.MODULE_DATA_PATH + 'basic_raw_data.csv',
                      skiprows=1,
                      delimiter=',').T
    x = data[0]
    y = data[1]
    ps = np.polyfit(x, y, deg=2)
    y_fit = ps[0] * x**2 + ps[1] * x + ps[2]
    bf, subplot = plt.subplots()
    for i in range(len(x)):
        subplot.plot(x[i], y[i], 'o', c='b', alpha=0.5, label='Raw data')
    subplot.plot(x, y_fit, c='r', label='Fitted')
    subplot.axvspan(0.5, 1.5, color='orange', alpha=0.3)
    cline = ef.create_custom_legend_patch('Critical zone',
                                          c='orange',
                                          alpha=0.3)
    ef.revamp_legend(subplot, loc='upper left', add_handles=[cline])
    subplot.yaxis.label.set_color((0.15, 0.15, 0.15))
    subplot.xaxis.label.set_color((0.15, 0.15, 0.15))
    subplot.tick_params(axis='x',
                        colors=(0.05, 0.05, 0.05),
                        width=0.5,
                        which='major',
                        top=True)
    subplot.tick_params(axis='y',
                        colors=(0.05, 0.05, 0.05),
                        width=0.5,
                        which='major',
                        left=True)
    ef.xy(subplot, x_origin=True, y_origin=True)
    subplot.set_xlabel('Pizza eaten [slices]')
    subplot.set_ylabel('My love for Pizza [J]')
    plt.tight_layout()
    plt.show()
Exemplo n.º 2
0
def basic(sub_plot,
          folder_path,
          fname,
          dbset,
          label=None,
          ccbox=None,
          lls=None,
          quiet=False):
    if quiet:
        series, time = load.load_record(folder_path + fname, dbset, quiet=True)
        if series is None:  # Could not find file
            return
    else:
        series, time = load.load_record(folder_path + fname, dbset)
    if series is None:
        raise FileNotFoundError
    if label is None:
        label = fname

    kwargs = bwplot.pack_plotting_kwargs(ccbox, lls)

    sub_plot.plot(time, series, label=label, **kwargs)
    ef.time_series(sub_plot)
    ef.revamp_legend(sub_plot)

    plt.xlabel('Time [s]')
    plt.ylabel(add_ylabel(fname))
Exemplo n.º 3
0
def pore_pressure_series(sub_plot,
                         folder_path,
                         fname,
                         dbset,
                         label=None,
                         ccbox=None,
                         lls=None,
                         quiet=False):
    if quiet:
        series, time = load.load_record(folder_path + fname, dbset, quiet=True)
        if series is None:  # Could not find file
            return
    else:
        series, time = load.load_record(folder_path + fname, dbset)
    if "PPT" not in fname:
        raise ValueError("PPT record required for pore_pressure view")

    if label is None:
        label = fname

    kwargs = bwplot.pack_plotting_kwargs(ccbox, lls)

    sub_plot.plot(time, series, label=label, **kwargs)
    ef.time_series(sub_plot)
    ef.revamp_legend(sub_plot)

    plt.xlabel('Time [s]')
    plt.ylabel("Pore pressure [Pa]")
Exemplo n.º 4
0
def create(save=0, show=0):

    bf, subplot = plt.subplots(figsize=(ops.TWO_COL, 4))
    subplot.plot([0], [0], label="", c=cbox(0))

    subplot.set_xlabel('Period [s]')
    # subplot.set_xscale('log')
    subplot.set_ylabel('Disp. Response [m]')
    ef.xy(subplot, x_origin=True, y_origin=True)
    ef.revamp_legend(subplot, loc="upper left", prop={'size': 9})

    bf.tight_layout()
    name = __file__.replace('.py', '')
    name = name.split("figure_")[-1]
    extension = ""
    if save:
        bf.savefig(ap.PUB_FIG_PATH + name + extension + ops.PUB_FIG_FILE_TYPE,
                   dpi=ops.PUB_FIG_DPI)
        if ops.PUB_DOCUMENT_TYPE == "latex":
            para = ef.latex_for_figure(ap.FIG_FOLDER,
                                       name=ap.PUB_FIG_PATH + name + extension,
                                       ftype=ops.PUB_FIG_FILE_TYPE)
            print(para)
    if show:
        plt.show()
Exemplo n.º 5
0
def create():
    """
    Run an SDOF using three different damping options

    """
    dtypes = ['rot_dashpot', 'horz_dashpot', 'rayleigh']
    # dtypes = ['rayleigh']
    lss = ['-', '--', ':']

    bd = sm.SDOFBuilding()
    bd.mass_eff = 120.0e3
    bd.h_eff = 10.0
    bd.t_fixed = 0.7
    bd.xi = 0.2  # use high damping to evaluate performance of diff damping options
    bd.inputs += ['xi']
    l_ph = 0.2

    record_filename = 'test_motion_dt0p01.txt'
    asig = eqsig.load_asig(ap.MODULE_DATA_PATH + 'gms/' + record_filename, m=0.5)

    bf, sps = plt.subplots(nrows=3, figsize=(5, 8))

    for c, dtype in enumerate(dtypes):

        outputs = get_response(bd, asig, dtype=dtype, l_ph=l_ph)
        # Time series plots
        sps[0].plot(outputs['time'], outputs['deck_accel'] / 9.8, c=cbox(c), lw=0.7, label=dtype, ls=lss[c])
        sps[1].plot(outputs['hinge_rotation'] * 1e3, outputs['col_moment'] / 1e3, c=cbox(c), label=dtype, ls=lss[c])
        sps[2].plot(outputs['rel_deck_disp'] * 1e3, outputs['col_shear'] / 1e3, c=cbox(c), label=dtype, ls=lss[c])
        if dtype == 'rot_dashpot':
            sps[1].plot(outputs['hinge_rotation'] * 1e3, (outputs['col_moment'] - outputs['dashpot_force'][:, 2] / 2) / 1e3, c='r', label=dtype)
            sps[2].plot(outputs['rel_deck_disp'] * 1e3, (outputs['col_shear'] - 3. / 2. * outputs['dashpot_force'][:, 2] / bd.h_eff) / 1e3, c='r', label=dtype)

    sps[0].set_ylabel('Deck accel. [g]', fontsize=7)
    sps[0].set_xlabel('Time [s]')
    ef.text_at_rel_pos(sps[1], 0.1, 0.9, 'Column hinge')
    sps[1].set_xlabel('Rotation [mrad]')
    sps[1].set_ylabel('Moment [kNm]')
    sps[1].set_ylabel('Shear [kN]')
    sps[1].set_xlabel('Disp. [mm]')

    ef.revamp_legend(sps[0])

    ef.xy(sps[0], x_origin=True)
    ef.xy(sps[0], x_axis=True, y_axis=True)

    bf.tight_layout()
    name = __file__.replace('.py', '')
    name = name.split("fig_")[-1]
    bf.savefig(f'figures/{name}.png', dpi=90)
    plt.show()
Exemplo n.º 6
0
def total_stress(sub_plot,
                 folder_path,
                 esigy_fname,
                 ppt_fname,
                 dbset,
                 label=None,
                 ccbox=None,
                 lls=None,
                 quiet=False):
    if quiet:
        esigy_series, time = load.load_record(folder_path + esigy_fname,
                                              dbset,
                                              quiet=True)
        ppt_series, time = load.load_record(folder_path + ppt_fname,
                                            dbset,
                                            quiet=True)
        if esigy_series is None or ppt_series is None:  # Could not find file
            return
    else:
        esigy_series, time = load.load_record(folder_path + esigy_fname,
                                              dbset,
                                              quiet=False)
        ppt_series, time = load.load_record(folder_path + ppt_fname,
                                            dbset,
                                            quiet=False)
    if label is None:
        label = ppt_fname

    kwargs = bwplot.pack_plotting_kwargs(ccbox, lls)
    del kwargs['ls']
    del kwargs['c']

    sub_plot.fill_between(time,
                          -esigy_series + ppt_series,
                          0,
                          label="Total stress",
                          **kwargs)
    # sub_plot.plot(time, -esigy_series + ppt_series, 0, label="Total stress", **kwargs)
    sub_plot.fill_between(time,
                          -esigy_series,
                          label="Effective stress",
                          **kwargs)
    # sub_plot.plot(time, ppt_series, label="Pore-pressure", **kwargs)
    ef.time_series(sub_plot)
    ef.revamp_legend(sub_plot)

    plt.xlabel('Time [s]')
def create():
    """
    Run an SDOF using three different damping options

    """
    dtypes = ['rot_link', 'horz_link']  #, 'rayleigh']
    dtypes = ['rot_link']  # , 'rayleigh']
    lss = ['-', '--', ':']

    bd = sm.SDOFBuilding()
    bd.mass_eff = 120.0e3
    bd.h_eff = 10.0
    bd.t_fixed = 0.7
    bd.xi = 0.2  # use high damping to evaluate performance of diff damping options
    bd.inputs += ['xi']

    record_filename = 'test_motion_dt0p01.txt'
    asig = eqsig.load_asig(ap.MODULE_DATA_PATH + 'gms/' + record_filename,
                           m=0.5)

    bf, sps = plt.subplots(nrows=3, figsize=(5, 8))

    c = 0
    dtype = 'rot_link'
    outputs = get_response(bd, dtype=dtype)
    # Time series plots
    sps[0].plot(outputs['time'],
                outputs['deck_force'] / 1e3,
                c=cbox(c),
                lw=0.7,
                label=dtype,
                ls=lss[c])

    sps[1].plot(outputs['hinge_rotation'] * 1e3,
                outputs['col_moment'] / 1e3,
                c=cbox(c),
                label='Column',
                ls=lss[c])
    sps[1].plot(outputs['hinge_rotation'] * 1e3,
                outputs['col_moment_end'] / 1e3,
                c='purple',
                label='Column',
                ls=lss[c])
    # sps[1].plot(outputs['hinge_rotation'] * 1e3, (outputs['col_moment'] - outputs['link_force'][:, 2] / 2) / 1e3, c='r', label=dtype)
    sps[1].plot(outputs['hinge_rotation'] * 1e3,
                (outputs['col_moment'] + outputs['link_force'][:, 2]) / 1e3,
                c='b',
                label=dtype)
    sps[1].plot(outputs['hinge_rotation'] * 1e3,
                (outputs['link_force'][:, 2]) / 1e3,
                c='g',
                label='Link',
                ls='--')

    sps[2].plot(outputs['rel_deck_disp'] * 1e3,
                outputs['col_shear'] / 1e3,
                c=cbox(c),
                label=dtype,
                ls=lss[c])
    sps[2].plot(outputs['rel_deck_disp'] * 1e3,
                outputs['link_force'][:, 2] / bd.h_eff / 1e3,
                c='g',
                label='Link equiv. shear',
                ls='--')
    sps[2].plot(
        outputs['rel_deck_disp'] * 1e3,
        (outputs['col_shear'] + outputs['link_force'][:, 2] / bd.h_eff) / 1e3,
        c='orange',
        label='Column and Link')
    sps[1].plot(outputs['hinge_rotation'] * 1e3,
                outputs['deck_force'] * bd.h_eff / 1e3,
                c=cbox('mid grey'),
                alpha=0.8,
                lw=1.5,
                label=dtype,
                ls='-.')
    sps[2].plot(outputs['rel_deck_disp'] * 1e3,
                outputs['deck_force'] / 1e3,
                c=cbox('mid grey'),
                alpha=0.8,
                lw=1.5,
                label=dtype,
                ls='-.')
    sps[2].plot(outputs['rel_deck_disp'] * 1e3,
                outputs['rel_deck_disp'] * bd.k_eff / 1e3,
                c='k',
                alpha=0.8,
                lw=1.5,
                label=dtype,
                ls='-.')

    sps[0].set_ylabel('Deck accel. [g]', fontsize=7)
    sps[0].set_xlabel('Time [s]')
    ef.text_at_rel_pos(sps[1], 0.1, 0.9, 'Column Element')
    sps[1].set_xlabel('Rotation [mrad]')
    sps[1].set_ylabel('Moment [kNm]')

    ef.revamp_legend(sps[0])

    ef.xy(sps[0], x_origin=True)
    ef.xy(sps[0], x_axis=True, y_axis=True)

    bf.tight_layout()

    name = __file__.replace('.py', '')
    name = name.split("fig_")[-1]
    # bf.savefig(f'figures/{name}.png', dpi=90)
    plt.show()
Exemplo n.º 8
0
def create():
    """
    Run an SDOF using three different damping options

    """
    lss = ['-', '--', ':']

    bd = sm.SDOFBuilding()
    bd.mass_eff = 120.0e3
    bd.h_eff = 10.0
    bd.t_fixed = 0.7
    bd.xi = 0.2  # use high damping to evaluate performance of diff damping options
    bd.inputs += ['xi']
    l_ph = 0.2

    record_filename = 'test_motion_dt0p01.txt'
    asig = eqsig.load_asig(ap.MODULE_DATA_PATH + 'gms/' + record_filename,
                           m=0.5)

    bf, sps = plt.subplots(nrows=3, figsize=(5, 8))
    dtype = 'Column'
    c = 0
    outputs = get_response(bd, asig, l_ph=l_ph)
    # Time series plots
    sps[0].plot(outputs['time'],
                outputs['deck_accel'] / 9.8,
                c=cbox(c),
                lw=0.7,
                label=dtype,
                ls=lss[c])
    sps[1].plot(outputs['hinge_rotation'] * 1e3,
                outputs['col_moment'] / 1e3,
                c=cbox(c),
                label=dtype,
                ls=lss[c])
    sps[1].plot(outputs['hinge_rotation1'] * 1e3,
                outputs['col_moment'] / 1e3,
                c='m',
                label=dtype,
                ls=lss[c])
    sps[1].plot(outputs['rel_deck_disp'] / bd.h_eff * 1e3,
                outputs['col_moment'] / 1e3,
                c='g',
                label=dtype)
    sps[2].plot(outputs['rel_deck_disp'] * 1e3,
                outputs['col_shear'] / 1e3,
                c=cbox(c),
                label=dtype,
                ls=lss[c])

    ei = bd.k_eff * bd.h_eff**3 / 3

    moms = np.array([-1000e3, 1000e3])
    k_offset = ei / (bd.h_eff * 1. / 3)  # deflection / length
    sps[1].plot(moms / k_offset * 1e3, moms / 1e3, c='k', label='Predicted')

    k_offset = ei / (bd.h_eff * 1. /
                     3) * 2  # end_slope * length - (deflection / length)
    sps[1].plot(moms / k_offset * 1e3,
                moms / 1e3,
                c='r',
                label='Predicted - end2')
    sps[0].set_ylabel('Deck accel. [g]', fontsize=7)
    sps[0].set_xlabel('Time [s]')
    sps[1].set_xlabel('Rotation [mrad]')
    sps[1].set_ylabel('Moment [kNm]')
    sps[1].set_ylabel('Shear [kN]')
    sps[1].set_xlabel('Disp. [mm]')

    ef.revamp_legend(sps[1])

    ef.xy(sps[0], x_origin=True)
    ef.xy(sps[0], x_axis=True, y_axis=True)

    bf.tight_layout()
    name = __file__.replace('.py', '')
    name = name.split("fig_")[-1]
    bf.savefig(f'figures/{name}.png', dpi=90)
    plt.show()