This appendix is the book’s quick-reference card, in two parts. Part 1 collects
every symbol we use, its meaning, and its units in Chopra-consistent tables. Part 2 documents
the shared sdtools engine, one function at a time, each with a tiny runnable
example you can copy straight into your own notebook. Keep this page open in a
second tab while you work through the chapters.
1Part 1: Notation and units¶
The whole book runs on one consistent SI set: forces in kilonewtons (kN), lengths in meters (m), masses in tonnes (t), and time in seconds (s). The point of a consistent set is that no conversion factors ever appear in the equations or the code: you type the numbers in these units and read the answers back in these units.
1.1System properties¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
m | mass (lumped inertia of the SDOF) | t | |
c | viscous damping coefficient | kN·s/m | |
k | lateral (elastic) stiffness | kN/m | |
c_cr | critical damping, | kN·s/m |
1.2Response quantities¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
u | displacement (drift) of the mass, relative to the base | m | |
v | velocity, | m/s | |
a | acceleration, | m/s² | |
u0, v0 | initial displacement and velocity | m, m/s | |
t | time | s |
1.3Loading¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
p | applied external force on the mass | kN | |
| (none) | ground (base) displacement | m | |
ag | ground acceleration (an earthquake record) | m/s² | |
-m*ag | effective earthquake force, | kN |
1.4Natural / modal properties¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
wn | natural circular frequency, | rad/s | |
fn | natural frequency, | Hz | |
Tn | natural period, | s | |
zeta | damping ratio, | none | |
wd | damped circular frequency, | rad/s |
1.5Forced-response and design quantities¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
beta | frequency ratio of a harmonic load, | none | |
Rd | deformation (dynamic amplification) factor, | none | |
u_st | static deflection, | m | |
TR | transmissibility (transmitted / applied amplitude) | none | |
Sd, Sv, Sa | spectral deformation / pseudo-velocity / pseudo-acceleration | m, m/s, m/s² | |
mu | displacement ductility, | none | |
uy | yield displacement | m | |
Ry | yield-strength reduction factor, | none |
1.6Multi-degree-of-freedom and modal quantities¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
M, C, K | mass, damping, and stiffness matrices | t, kN·s/m, kN/m | |
U_modal, U_t | floor displacements relative to the ground, one column per floor | m | |
Phi[:, r] | shape of mode , scaled to unit roof displacement | none | |
wn[r], Tn[r] | natural frequency and period of mode | rad/s, s | |
Q[:, r] | modal coordinate, | m | |
ones | influence vector: every floor is driven by the ground motion | none | |
Mr | modal mass, | t | |
L | modal excitation factor, | t | |
Gamma | participation factor, | none | |
Meff | effective modal mass, | t | |
V_modal, V_srss | modal and combined base shear | kN |
1.7Code-based design (ASCE 7)¶
| Symbol | MyST / code | Meaning | Units |
|---|---|---|---|
SDS, SD1 | design spectral accelerations at short periods and at 1 s | ||
T0, TS, TL | corner periods of the design spectrum | s | |
Ta | approximate fundamental period, | s | |
Cs | seismic response coefficient, | none | |
W | seismic weight | kN | |
Fx, Cvx | lateral force at level and its share of | kN, none | |
R | response modification factor | none | |
Cd | deflection amplification factor | none | |
Ie | importance factor | none |
2Part 2: The sdtools API reference¶
Every chapter imports the same small engine, built up in
Chapter 3. The contract is deliberately tiny: cast the equation of motion
into state space, solve it, and hand back
(t, u, v, a). The setup cell at the top of every chapter does
import numpy as np
import sdtools as sd
sd.plot_style()What follows documents each public function, its signature, what it returns, and a minimal example you can run as-is. The examples below are executed live, so the printed numbers are real.
2.1natural(m, c, k)¶
Natural dynamic properties of the oscillator, returned as a dict with keys
wn (rad/s), fn (Hz), Tn (s), zeta (dimensionless), wd (rad/s), and c_cr
(critical damping). This is the first thing you compute for any system.
m, k, zeta = 2.0, 50.0, 0.05 # t, kN/m, -
c = 2 * zeta * np.sqrt(k * m) # kN*s/m
p = sd.natural(m, c, k)
print(f"Tn = {p['Tn']:.3f} s fn = {p['fn']:.3f} Hz wn = {p['wn']:.2f} rad/s")
print(f"zeta = {p['zeta']:.3f} wd = {p['wd']:.3f} rad/s c_cr = {p['c_cr']:.2f} kN*s/m")Tn = 1.257 s fn = 0.796 Hz wn = 5.00 rad/s
zeta = 0.050 wd = 4.994 rad/s c_cr = 20.00 kN*s/m
2.2state_space(m, c, k)¶
The continuous-time state-space matrices and for the state , so that . This is the form the exact solver integrates; you rarely call it directly, but it is the heart of the engine (built up in Chapter 3).
A, B = sd.state_space(m, c, k)
print("A =\n", A)
print("B =\n", B.ravel())A =
[[ 0. 1. ]
[-25. -0.5]]
B =
[0. 0.5]
2.3sdof_response(m, c, k, p, dt, u0=0.0, v0=0.0, method="exp")¶
This is the workhorse: it solves the equation of motion for a force history p
sampled at spacing dt, with optional initial conditions u0 and v0, and
returns (t, u, v, a). The function offers two integration methods, chosen with
the method argument:
method="exp"(default), the exact matrix-exponential solution with a zero-order hold on . Use this almost always.method="newmark", average-acceleration Newmark-, for teaching and for matching a step-by-step integrator (it delegates tonewmarkbelow).
For base excitation, pass the effective force p = -m * ag and read the
relative response.
dt = 0.005
t = np.arange(0, 6.0, dt)
# Free vibration: p(t) = 0, released from a 20 mm nudge.
t, u, v, a = sd.sdof_response(m, c, k, np.zeros(t.size), dt, u0=0.020, v0=0.0)
print(f"peak drift = {np.abs(u).max()*1000:.1f} mm at t = {t[np.abs(u).argmax()]:.3f} s")peak drift = 20.0 mm at t = 0.000 s
fig, ax = plt.subplots(figsize=(7.2, 2.8))
ax.plot(t, u * 1000, color=sd.PLT[0])
ax.axhline(0, color="#9aa3ab", lw=1.0)
ax.set_xlabel(r"time $t$ (s)")
ax.set_ylabel(r"drift $u$ (mm)")
plt.show()

Figure 1:A single call to sd.sdof_response produces the full free-vibration drift history.
2.4newmark(m, c, k, p, dt, u0=0.0, v0=0.0, gamma=0.5, beta=0.25)¶
Newmark- time integration, returning (t, u, v, a). The defaults
, give the average-acceleration rule,
which is unconditionally stable. It is also the routine that
sdof_response(..., method="newmark") calls internally. The exact "exp" solver
and Newmark agree to within a few hundredths of a percent at the dt used here,
and the gap grows like as the step coarsens, to about 1 % at
over the same 6 s. They differ not because of how the force
is held, since in this free-vibration example both integrators see the same zero
force. They differ because the average-acceleration rule assumes a constant
average acceleration within each step, a piecewise-quadratic displacement that is
not exact even for a zero or constant force, whereas "exp" integrates the linear
dynamics exactly for any piecewise-constant load.
t1, u1, _, _ = sd.sdof_response(m, c, k, np.zeros(t.size), dt, u0=0.020) # exact
t2, u2, _, _ = sd.newmark(m, c, k, np.zeros(t.size), dt, u0=0.020) # Newmark
print(f"max |exp - newmark| = {np.abs(u1 - u2).max()*1e6:.2f} micron")
# The same 6 s comparison at coarser steps: the gap grows like (dt/Tn)^2.
Tn = sd.natural(m, c, k)["Tn"]
for frac in (100, 50):
dt_c = Tn / frac
n_c = int(round(6.0 / dt_c))
_, ue, _, _ = sd.sdof_response(m, c, k, np.zeros(n_c), dt_c, u0=0.020)
_, un, _, _ = sd.newmark(m, c, k, np.zeros(n_c), dt_c, u0=0.020)
print(f"dt = Tn/{frac}: max |exp - newmark| = {np.abs(ue - un).max() / 0.020:.2%} of u0")max |exp - newmark| = 7.67 micron
dt = Tn/100: max |exp - newmark| = 0.24% of u0
dt = Tn/50: max |exp - newmark| = 0.97% of u0
2.5central_difference(m, c, k, p, dt, u0=0.0, v0=0.0)¶
Explicit central-difference integration, returning (t, u, v, a). Shown in
Chapter 3 for contrast: it is conditionally stable, requiring
, so it blows up for large steps. Useful for understanding why
the implicit methods are the practical default.
Tn = sd.natural(m, c, k)["Tn"]
print(f"stability limit dt < Tn/pi = {Tn/np.pi:.3f} s (here dt = {dt} s, fine)")
t3, u3, _, _ = sd.central_difference(m, c, k, np.zeros(t.size), dt, u0=0.020)
print(f"max |exp - central| = {np.abs(u1 - u3).max()*1e3:.3f} mm")stability limit dt < Tn/pi = 0.400 s (here dt = 0.005 s, fine)
max |exp - central| = 0.004 mm
2.6response_spectrum(ag, dt, periods, zeta=0.05)¶
Builds the elastic response spectra of a ground-acceleration record ag
(sampled at dt). For each period in periods it solves a unit-mass SDOF and
records the peak relative deformation. Returns (Sd, Sv, Sa), where is the
spectral deformation, the pseudo-velocity, and
the pseudo-acceleration. This is the function at the spine
of Chapter 6.
t_g, ag = sd.demo_record(dt=0.02, duration=20.0) # a synthetic record
periods = np.linspace(0.05, 3.0, 60)
Sd, Sv, Sa = sd.response_spectrum(ag, 0.02, periods, zeta=0.05)
print(f"peak Sa = {Sa.max():.2f} m/s^2 at T = {periods[Sa.argmax()]:.2f} s")peak Sa = 6.62 m/s^2 at T = 0.20 s
fig, ax = plt.subplots(figsize=(7.2, 2.8))
ax.plot(periods, Sa, color=sd.PLT[1])
ax.set_xlabel(r"natural period $T_n$ (s)")
ax.set_ylabel(r"$S_a$ (m/s$^2$)")
plt.show()

Figure 2:Pseudo-acceleration spectrum from sd.response_spectrum, built by looping the engine over a range of natural periods.
2.7demo_record(dt=0.02, duration=30.0, pga=0.30*9.81, seed=7)¶
A reproducible synthetic strong-motion record: Kanai-Tajimi-filtered white
noise shaped by a Saragoni-Hart intensity envelope, scaled to a target peak
ground acceleration pga. Returns (t, ag) with ag in m/s². It is seeded, so
the same call always gives the same record, handy for examples that must be
deterministic. Swap in a real record via load_record when you have one.
t_g, ag = sd.demo_record(dt=0.02, duration=30.0, pga=0.30 * 9.81)
print(f"samples = {ag.size} PGA = {np.abs(ag).max():.3f} m/s^2 = {np.abs(ag).max()/9.81:.2f} g")samples = 1500 PGA = 2.943 m/s^2 = 0.30 g
2.8load_record(path, dt, scale=1.0, skiprows=0)¶
Loads a ground-acceleration record from a plain one-column text file whose values
are uniformly spaced in time at dt, and returns (t, ag*scale). Use scale to
convert units (e.g. from to m/s²) and skiprows to skip a header. The
example writes a tiny file and reads it back so it runs anywhere.
import tempfile, os
demo = np.array([0.0, 0.1, -0.2, 0.05, 0.0])
path = os.path.join(tempfile.gettempdir(), "rec_demo.txt")
np.savetxt(path, demo)
t_r, ag_r = sd.load_record(path, dt=0.02, scale=9.81) # file in g -> m/s^2
print("t =", t_r)
print("ag =", ag_r, "m/s^2")
os.remove(path)t = [0. 0.02 0.04 0.06 0.08]
ag = [ 0. 0.981 -1.962 0.4905 0. ] m/s^2
2.9plot_style(scale=1.0) and PLT¶
plot_style() applies the book’s publication-quality matplotlib rcParams for
result/data plots (axes on, clean grid, sensible fonts); it is idempotent and
is called once in every chapter’s hidden setup cell. PLT is the colorblind-aware
line-color list: index it (sd.PLT[0], sd.PLT[1], …) so every figure in the
book shares the same palette. Schematic diagrams use a different system,
figstyle, described below.
sd.plot_style() # idempotent; already active here
print("palette:", sd.PLT[:3], "...")
x = np.linspace(0, 2 * np.pi, 200)
fig, ax = plt.subplots(figsize=(7.2, 2.4))
for i in range(3):
ax.plot(x, np.sin(x - i * 0.6), color=sd.PLT[i], label=f"PLT[{i}]")
ax.set_xlabel(r"$x$"); ax.set_ylabel(r"$\sin x$")
ax.legend(ncol=3, loc="upper right")
plt.show()palette: ['#0072B2', '#D55E00', '#009E73'] ...

3Two companion modules¶
Beyond the NumPy engine, the book ships two small helpers, kept deliberately
separate from sdtools. The first, figstyle, draws the book’s diagrams, and the
second, osdof, runs its OpenSees cross-checks. Neither is needed to run the
engine itself, which depends only on NumPy, SciPy, and Matplotlib.
3.1figstyle, the schematic design system¶
Everything in sdtools.plot_style
is for data plots; figstyle is for concept diagrams (mass-spring-dashpot
sketches, free-body diagrams, modal-building cartoons). It provides a palette P,
a blank new_fig canvas (axis off, equal aspect), straight and curved arrows
(arrow, moment_arrow, whose curved head stays tangent), label/node
annotations, the structural glyphs spring, dashpot, mass_block, ground,
and save (SVG). A chapter’s make_figures.py imports it, draws, and saves SVGs
that the prose references with a {figure} directive. Note its mathtext limits:
no \bm, \text, or bmatrix inside figure labels.
3.2osdof, the OpenSeesPy cross-check helpers¶
The workhorse is opensees_sdof(m, c, k, p, dt, u0=0.0, v0=0.0). It builds a
one-node SDOF, a zeroLength Elastic spring with Rayleigh mass-proportional
damping tuned to the target c, integrates it with Newmark, and returns the same
(t, u, v, a) tuple as sd.sdof_response. Three companions build on the same skeleton:
opensees_sdof_ground(m, c, k, ag, dt) drives the base directly with a
UniformExcitation pattern (Chapter 6), while opensees_mdof_eigen(masses, ks)
and opensees_mdof_ground(masses, ks, zeta, ag, dt) extend it to the
multi-story building of Chapter 8. Use them for independent finite-element
checks of the NumPy engine; Appendix A walks through the
SDOF model line by line.
from osdof import opensees_sdof
t, u, v, a = opensees_sdof(m, c, k, np.zeros(1200), dt=0.005, u0=0.020)The exact sd.sdof_response (method "exp") and the OpenSees Newmark run agree
to a few hundredths of a percent at this dt, the same small
gap explained under newmark above. OpenSees also uses
average-acceleration Newmark, and opensees_sdof commits the consistent initial
acceleration, so the residual stays at that period-elongation floor. Tighten dt
and the two curves become indistinguishable.