def get_velocity_displacement(time_step, acceleration, units="cm/s/s",
velocity=None, displacement=None):
'''
Returns the velocity and displacement time series using simple integration.
By providing `velocity` or `displacement` as argument(s), you can speed up
this function by skipping either or both calculations.
:param time_step: float: Time-series time-step (s)
:param acceleration: numpy.ndarray: the acceleration
:param units: the acceleration units, either "m/s/s", "m/s**2", "m/s^2", "g", "cm/s/s",
"cm/s**2", "cm/s^2". The acceleration is supposed to
be in centimeters over seconds square: if 'units' is not one of the last three strings,
it will be conveted to cm/s^2 before calculation
:param velocity: numpt.ndarray or None: if None, the velocity will be computed. Otherwise it
is the already-computed vector of velocities and it will be returned by this function
:param displacement: numpt.ndarray or None: if None, the displacement will be computed.
Otherwise it is the already-computed vector of displacements and it will be returned by this
function
:returns:
velocity - Velocity Time series (cm/s)
displacement - Displacement Time series (cm)
'''
acceleration = ResponseSpectrum.convert_accel_units(acceleration, units)
if velocity is None:
velocity = time_step * cumtrapz(acceleration, initial=0.)
if displacement is None:
displacement = time_step * cumtrapz(velocity, initial=0.)
return velocity, displacement
评论列表
文章目录