Qtools is a Python package developed specifically for numerical analysis in the context of
earthquake engineering. It contains classes and functions for computation, processing and plotting
of time histories, response spectra and power spectra. Qtools defines six new classes,
qtools.ResponseSpectrum
, qtools.EnergySpectrum
, qtools.TimeHistory
, qtools.TimeHistorySet
,
qtools.PowerSpectrum
and qtools.FourierSpectrum
, and several new functions.
Place the Qtools package (i.e. the folder named "qtools") in your PYTHONPATH. Then import Qtools:
>>>import qtools as qt
Note: In the examples given within the documentation, Qtools is always imported as
qt
, and NumPy is always imported asnp
.
Qtools relies on the following packages in addition to standard packages such as math
, copy
and itertools
(for recommended version numbers, see requirements.txt):
- Matplotlib
- Numba
- NumPy
- PyRVT (optional)
- SciPy
For the lastest documentation go to Qtools on Read the Docs.
The source of this documentation is available in the ./docs folder. The source files have to be compiled with Sphinx for HMTL / PDF viewing. The current documentation has been compiled with Sphinx version 4.0.2.
Versions are numbered using two digits separated by a full stop: m.n. All versions with the same
m number should be backwards compatible and give the same results. Versions with higher n
number are those with minor additions, clarifications, efficiency improvements, etc. The version
number is available as qt.__version__
.
- Corrected an attribute error in
qt.calcrs_cmp
which caused the function to terminate. - Added a line specifying the parameters
dt
,dt_fixed
andfNyq
inqt.calcth
. This line was missing in previous versions. - Added the argument
fmt
toqt.loadth
. - Minor updates to the documentation.
- Added the argument
fig_size
toqt.plotrs
. - Changed the default units for plotting in
qt.plotrs
to cm/s for spectral acceleration and mm for spectral displacement. - Implemented multiplication method (
__mul__()
) for class TimeHistory. - Corrected a minor error in
qt.harmonic
, which gave incorrect time step.
- Minor improvements to the docstrings for the
qt.direct_s2s
module, theqt.directS2S
function and theqt.loadrs
function. - Corrected legacy code in package
qt.ds2smods
(theqt.config.vprint
function is no longer supported). - The argument
mdlist
supplied to functionqt.directS2S
can now be a list of lists or a list of tuples. - Small correction in
qt.ds2mods.jiang_15.AR
function. - New function
qt.band_limited
added. - Due to recent developments in Numba, arguments supplied to Numba-compiled functions should be
immutable objects. The docstring for
qt.response_spectrum._solode
was updated to reflect this. - Added reference to docstring for
qt.response_spectrum._solode
. - Added
transparent
option to theqt.plotrs
function.
- New function
qt.Kanai_Tajimi
added. - New module named
qt.random_vibration
added. This module contains classes and functions for conversion of response spectra to power spectra and vice versa. The two main gateway functions areqt.convert2ps
, which converts a response spectrum into a compatible power spectrum, andqt.convert2rs
, which performs the opposite conversion. - The speed of the Python implementation of the 'solode' solver used in
qt.calcrs
andqt.calcei
was significantly improved through Numba compilation and other minor optimisations. Tests indicated that the Numba code was at least three times faster than the Fortran code used in previous versions (maybe because the Fortran code had not been fully optimised and maybe because the Numba code used parallelization, which the Fortran code didn't). In light of those speed gains, and because maintaining the Fortran code is more demanding on my time, I decided to discontinue the Fortran code.
- Improvements were made to the numerical stability of the function
qt._intersection
, which in turn servesqt.envelope
andqt.peakbroad
. In previous versions, response spectra with nearly parallel line segments or line segments intersecting close to one of the existing frequency points could cause numerical instability in the function. - Minor improvements to
qt.plotrs
.
- Multiple updates to the two plotting functions
qt.plotrs
andqt.plotps
providing greater user control over appearance and style. - A power spectrum is now defined purely as a one-sided smoothed function of frequency. In principle, this constitutes a major version update. However, it is surmised that the older implementation (in which a power spectrum was principally defined as a double-sided smoothed or unsmoothed function) was not used; therefore, this change is included in a minor version update.
- New methods
qt.PowerSpectrum.moment
andqt.PowerSpectrum.moments
for computation of spectral moments.
- The module
qt.disrs
was replaced by a new module namedqt.direct_s2s
. This now provides all functions required to compute in-structure response spectra using direct spectrum-to-spectrum methods. The interface withqt.direct_s2s
is now through a single functionqt.directS2S
. - The original direct spectrum-to-spectrum method contained in
qt.disrs
(Jiang et al. (2015)) was re-written, and the speed of the implementation was improved. - A new method (Der Kiureghian (1981)) was added to
qt.direct_s2s
. For full references see the documentation. - There is still a stand-alone documentation for
qt.direct_s2s
, which is under development. However, a working documentation has also been added to the main Qtools documentation. - In
qt.plotps
, grids are now added to all plots.
- Docstring for class
qt.TimeHistorySet
written. - Added arguments
label
andfmt
to functionsqt.meanrs
andqt.loadrs
.
- Error corrected in function
qt.plotps
(function updated to accommodate new definition ofunit
attribute introduced in version 1.0). - Function
qt.calcps
now determines the unit of the power spectrum. - Function
qt.envelope
now takes as its first argument a list containing any number of response spectra (qt.envelope(rslist)
). The old call signature (qt.envelope(rs1,rs2)
) will still work; however, this signature is deprecated and will become obsolete in version 2.0. - The
option
argument is no longer used for anything inqt.envelope
. - New argument
mutate
added toqt.ResponseSpectrum.interp
. - New function
qt.meanrs
added.
- Error corrected in function
qt.calcrs
(affected cases for which the maximum frequencyfmax
was greater than the Nyquist frequency of the input time historyth.fNyq
). - Function
qt.interpft
added for interpolation of time histories. - Attribute
ei
(meant to contain input energy) removed fromqt.ResponseSpectrum
. As a replacement, a new classqt.EnergySpectrum
is introduced. - Fourier amplitudes removed from class
qt.PowerSpectrum
. - New class
qt.FourierSpectrum
with accompanying creator functionqt.calcfs
. - Parameter
color
added toqt.ResponseSpectrum.setLineFormat
. - Minor change to the criterion for removal of duplicate frequencies in
qt.ResponseSpectrum.interp
. - Added class method
qt.TimeHistory.differentiate
. - In
qt.loadth
, the Nyquist frequency is now rounded to two digits from the decimal point. This was done as a pragmatic way to deal with situations whereth.fNyq
was nearly, but not quite equal to a whole number due to finite precision in input data. - New argument
truncate
added to functionqt.peakbroad
. - New function
qt.calcrs_cmp
added. - New function
qt.dmpinterp
added. - New class
qt.TimeHistorySet
added.
First fully documented version.
Andreas H. Nielsen
Principal Engineer, Atkins
Copyright (C) 2020-2022 Andreas H. Nielsen
The Qtools package is released under the GNU General Public License Version 3 or later.
Qtools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Qtools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Qtools (in the file LICENSE.txt). If not, see https://www.gnu.org/licenses/.