Beispiel #1
0
    def __init__(self,
                 acceleration,
                 time_step,
                 periods,
                 damping=0.05,
                 units="cm/s/s"):
        '''
        Setup the response spectrum calculator
        :param numpy.ndarray time_hist:
            Acceleration time history [Time, Acceleration]
        :param numpy.ndarray periods:
            Spectral periods (s) for calculation
        :param float damping:
            Fractional coefficient of damping
        :param str units:
            Units of the acceleration time history {"g", "m/s", "cm/s/s"}

        '''
        self.periods = periods
        self.num_per = len(periods)
        self.acceleration = convert_accel_units(acceleration, units)
        self.damping = damping
        self.d_t = time_step
        self.velocity, self.displacement = get_velocity_displacement(
            self.d_t, self.acceleration)
        self.num_steps = len(self.acceleration)
        self.omega = (2. * np.pi) / self.periods
        self.response_spectrum = None
Beispiel #2
0
def plot_time_series(acceleration,
                     time_step,
                     velocity=[],
                     displacement=[],
                     units="cm/s/s",
                     figure_size=(8, 6),
                     filename=None,
                     filetype="png",
                     dpi=300,
                     linewidth=1.5):
    """
    Creates a plot of acceleration, velocity and displacement for a specific
    ground motion record
    """
    acceleration = convert_accel_units(acceleration, units)
    accel_time = get_time_vector(time_step, len(acceleration))
    if not len(velocity):
        velocity, dspl = get_velocity_displacement(time_step, acceleration)
    vel_time = get_time_vector(time_step, len(velocity))
    if not len(displacement):
        displacement = dspl
    disp_time = get_time_vector(time_step, len(displacement))
    fig = plt.figure(figsize=figure_size)
    fig.set_tight_layout(True)
    ax = plt.subplot(3, 1, 1)
    # Accleration
    ax.plot(accel_time, acceleration, 'k-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Acceleration (cm/s/s)", fontsize=12)
    end_time = np.max(np.array([accel_time[-1], vel_time[-1], disp_time[-1]]))
    pga = np.max(np.fabs(acceleration))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pga, 1.1 * pga)
    ax.grid()
    # Velocity
    ax = plt.subplot(3, 1, 2)
    ax.plot(vel_time, velocity, 'b-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Velocity (cm/s)", fontsize=12)
    pgv = np.max(np.fabs(velocity))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgv, 1.1 * pgv)
    ax.grid()
    # Displacement
    ax = plt.subplot(3, 1, 3)
    ax.plot(disp_time, displacement, 'r-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Displacement (cm)", fontsize=12)
    pgd = np.max(np.fabs(displacement))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgd, 1.1 * pgd)
    ax.grid()
    _save_image(filename, filetype, dpi)
    plt.show()
def plot_time_series(acceleration, time_step, velocity=[], displacement=[],
        units="cm/s/s", figure_size=(8, 6), filename=None, filetype="png",
        dpi=300, linewidth=1.5):
    """
    Creates a plot of acceleration, velocity and displacement for a specific
    ground motion record
    """
    acceleration = convert_accel_units(acceleration, units)
    accel_time = get_time_vector(time_step, len(acceleration))
    if len(velocity) > 0:
        velocity, dspl = get_velocity_displacement(time_step, acceleration)
    vel_time = get_time_vector(time_step, len(velocity))
    if len(displacement) > 0:
        displacement = dspl
    disp_time = get_time_vector(time_step, len(displacement))
    fig = plt.figure(figsize=figure_size)
    fig.set_tight_layout(True)
    ax = plt.subplot(3, 1, 1)
    # Accleration
    ax.plot(accel_time, acceleration, 'k-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Acceleration (cm/s/s)", fontsize=12)
    end_time = np.max(np.array([accel_time[-1], vel_time[-1], disp_time[-1]]))
    pga = np.max(np.fabs(acceleration))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pga, 1.1 * pga)
    ax.grid()
    # Velocity
    ax = plt.subplot(3, 1, 2)
    ax.plot(vel_time, velocity, 'b-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Velocity (cm/s)", fontsize=12)
    pgv = np.max(np.fabs(velocity))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgv, 1.1 * pgv)
    ax.grid()
    # Displacement
    ax = plt.subplot(3, 1, 3)
    ax.plot(disp_time, displacement, 'r-', linewidth=linewidth)
    ax.set_xlabel("Time (s)", fontsize=12)
    ax.set_ylabel("Displacement (cm)", fontsize=12)
    pgd = np.max(np.fabs(displacement))
    ax.set_xlim(0, end_time)
    ax.set_ylim(-1.1 * pgd, 1.1 * pgd)
    ax.grid()
    _save_image(filename, filetype, dpi)
    #plt.show()
    plt.clf()
 def __init__(self, acceleration, time_step, periods, damping=0.05,
         units="cm/s/s"):
     '''
     Setup the response spectrum calculator
     :param numpy.ndarray time_hist:
         Acceleration time history [Time, Acceleration]
     :param numpy.ndarray periods:
         Spectral periods (s) for calculation
     :param float damping:
         Fractional coefficient of damping
     :param str units:
         Units of the acceleration time history {"g", "m/s", "cm/s/s"}
     '''
     self.periods = periods
     self.num_per = len(periods)
     self.acceleration = convert_accel_units(acceleration, units)
     self.damping = damping
     self.d_t = time_step
     self.velocity, self.displacement = get_velocity_displacement(
         self.d_t, self.acceleration)
     self.num_steps = len(self.acceleration)
     self.omega = (2. * np.pi) / self.periods
     self.response_spectrum = None