Skip to main content

StructDyn: An open-source Python library for structural dynamics analysis.

Project description

Structural Dynamics Library (structdyn)

An open-source Python library for structural dynamics analysis

structdyn is a Python package for performing structural dynamics and earthquake engineering analysis of Single-Degree-of-Freedom (SDF) and Multi-Degree-of-Freedom (MDF) systems. It provides a suite of tools for analyzing both linear and non-linear behavior, making it a versatile library for students, faculties and researchers.

See the documentation here: Documentation Status

Features

Single-Degree-of-Freedom (SDF) Systems:

  • Analytical Solutions: Compute the response of SDF systems to harmonic loads.
  • Numerical Integration: Solve the equation of motion using robust numerical methods, including Newmark-Beta and Central Difference.
  • Response Spectra: Generate earthquake response spectra for displacement, velocity, and acceleration.

Multi-Degree-of-Freedom (MDF) Systems:

  • Shear Building Models: Quickly create MDF systems for typical shear buildings.
  • Modal Analysis: Compute natural frequencies, mode shapes, and modal participation factors.
  • Response History Analysis: Perform linear and non-linear time history analysis using direct integration.
  • Response Spectrum Analysis (RSA): Estimate peak responses using modal combination methods (SRSS).

Non-Linear Analysis:

  • Material Models: A library of hysteretic material models, including elastic perfectly plastic, bilinear, Bouc-Wen & Ramberg-Osgood model.
  • Element Formulations: Define non-linear behavior at the element level for MDF systems.
  • Robust Solvers: Utilizes iterative Newton-Raphson schemes within the Newmark-Beta solver for accurate non-linear solutions.

Ground Motion Tools:

  • Record Processing: Easily load, process, and manipulate earthquake ground motion records.
  • Standard Formats: Includes helper functions for common ground motion data, such as the El Centro record from Chopra's book.

Installation

The recommended way to install structdyn is from the Python Package Index (PyPI) using pip:

pip install structdyn

This will install the latest stable, officially released version.

Developer Installation

If you want to install the very latest development version directly from the source, you can install it from the GitHub repository:

pip install git+https://github.com/learnstructure/structdyn.git

Quick Example: Response Spectrum Analysis (MDF system)

Here's an example of how to perform a Response Spectrum Analysis for a 5-story shear building, based on Example 13.8.2 from Chopra, "Dynamics of Structures", 5th Ed.

import numpy as np
from structdyn.mdf.mdf import MDF
from structdyn.ground_motions.ground_motion import GroundMotion
from structdyn.mdf.analytical_methods.response_spectrum_analysis import ResponseSpectrumAnalysis
from structdyn.utils.helpers import elcentro_chopra

# 1. Define the ground motion (El Centro, from Chopra's book)
elc = elcentro_chopra()
gm = GroundMotion.from_arrays(elc["acc (g)"], 0.02)

# 2. Define the 5-story shear building
masses = np.ones(5) * 45000      # kg
stiffness = np.ones(5) * 54.82e5 # N/m
mdf = MDF.from_shear_building(masses, stiffness)

# 3. Perform Response Spectrum Analysis
rsa = ResponseSpectrumAnalysis(mdf, ji=0.05, gm=gm)

# 4. Calculate modal base shear and combine using SRSS
modal_base_shear = rsa.modal_base_shear()
combined_base_shear = rsa.combine_modal_responses(modal_base_shear, method="SRSS")

# 5. Print the result
print(f"Combined base shear (SRSS): {combined_base_shear[0]:.2f} N")
# Expected result from Chopra, Example 13.8.2: 291221.90 N
Click for more examples (SDF Systems, Ground Motion, etc.)

Harmonic Forcing

from structdyn import SDF
from structdyn.sdf.analytical_methods.analytical_response import AnalyticalResponse

sdf = SDF(m=1.0, k=100.0, ji=0.05)

analytical = AnalyticalResponse(sdf)

# Harmonic sine forcing response
df_harm = analytical.harmonic_response(p0=10.0, w=5.0, excitation="sine")
print(df_harm)

SDF Ground Motion Response

structdyn can be used to analyze the response of a structure to ground motion. The library includes several ground motion records, which can be loaded as follows:

from structdyn.sdf.sdf import SDF
from structdyn.ground_motions.ground_motion import GroundMotion

# Load the El Centro ground motion record
gm = GroundMotion.from_event("el_centro_1940", component="RSN6_IMPVALL.I_I-ELC180")

# Define an SDF system
sdf = SDF(45594, 18 * 10**5, 0.05)

# Solve for the response of the SDF system to the ground motion
results = sdf.find_response_ground_motion(gm, method='central_difference')

# Print the results
print(results)

Response Spectrum Generation (SDF)

structdyn can be used to compute the response spectrum of a ground motion.

# Section 6.4 (& Figure 6.6.2); Chopra A. K., Dynamics of structure, 5th edn
import numpy as np
from structdyn.ground_motions.ground_motion import GroundMotion
from structdyn.sdf.response_spectrum import ResponseSpectrum
from structdyn.utils.helpers import elcentro_chopra

# Define el centro ground motion from Chopra's book- Appendix 6
elc = elcentro_chopra()
gm = GroundMotion.from_arrays(elc["acc (g)"], 0.02)

# Define the period range of interest
periods = np.arange(0, 5.01, 0.1)

# Create response spectrum object
rs = ResponseSpectrum(periods, 0.02, gm)

# Analysis
spectra = rs.compute()
print(spectra["Sd"][20])  # result is 0.1896749378231744

Non-linear analysis SDF system

# Example 5.5; Chopra A. K., Dynamics of structure, 5th edn
from structdyn import SDF
import numpy as np
from structdyn.utils.material_models import ElasticPerfectlyPlastic

# Define external load
dt = 0.1
time_steps = np.arange(0, 1.01, dt)
load_values = 50 * np.sin(np.pi * time_steps / 0.6) * 1000
load_values[time_steps >= 0.6] = 0

# Create SDF object
material_model = ElasticPerfectlyPlastic(uy=0.02, fy=36000)
sdf = SDF(45594, 18 * 10**5, 0.05, fd=material_model)

# Analysis
responses = sdf.find_response(
    time_steps, load_values, method="newmark_beta", acc_type="average"
)

print(responses)
print(responses["displacement"][10])  # result is 0.03606328101158249

Citing structdyn

If you use structdyn in your research or work, please cite it as follows:

Mandal, A. (2026). StructDyn: An open-source Python library for structural dynamics analysis. (Version 0.5.1) [Computer software]. https://github.com/learnstructure/structdyn.git

Here is the citation in BibTeX format:

@software{Mandal_structdyn_2026,
  author = {Mandal, Abinash},
  title = {{StructDyn: An open-source Python library for structural dynamics analysis.}},
  version = {0.5.1},
  year = {2026},
  publisher = {GitHub},
  journal = {GitHub repository},
  url = {https://github.com/learnstructure/structdyn.git}
}

Running Tests

To run the tests, you will need to install pytest. You can then run the tests from the root directory of the project:

pip install pytest
pytest

Contributing

Contributions are welcome! Please fork the repository, create a new branch for your feature or bug fix, and submit a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

structdyn-0.7.2.tar.gz (331.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

structdyn-0.7.2-py3-none-any.whl (354.8 kB view details)

Uploaded Python 3

File details

Details for the file structdyn-0.7.2.tar.gz.

File metadata

  • Download URL: structdyn-0.7.2.tar.gz
  • Upload date:
  • Size: 331.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for structdyn-0.7.2.tar.gz
Algorithm Hash digest
SHA256 a876fc1cb3a479f8d41536282a326f80ee93299a516d5835878f679b75af40e5
MD5 0065d18444e98ee4421c2b159e7121a4
BLAKE2b-256 344f4a105b7dc8dda313849c9bd6fa5d659f3128286d84f851f327263e51e499

See more details on using hashes here.

File details

Details for the file structdyn-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: structdyn-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 354.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for structdyn-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50892e159266d541046062032862ca8b796c3af0d7a8e03b3191ec1cda999735
MD5 28860a7ae45a3c82abffe4f3eeff1e29
BLAKE2b-256 a16e163468fa640d828ff5fbf932661b7a88a3ae9e423659f3b10104c8a7c59f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page