Skip to main content

spradius

A spectral radius package for time-integration in solid dynamics.

PyPi Version PyPI pyversions

Imports: isort Code style: black CodeFactor codecov gh-actions

spRadius is a not-so-fast spectral radius numerical computation package for Python specialised in time-integration algorithm for solid dynamics. It is based on the work of Benítez and Montáns, who propose an algorithm for computing the amplification matrix and, therefore, the spectral radius, by computing the mechanical response of the system to unit initial conditions.

As clearly mentioned in that work, in general, the spectral radius needs to be computed from the displacement solution during a large number of time steps, owing to the inconsistent initial acceleration evaluation. Since the numerical computation of the spectral radius involves a root with order equal to the number of steps, typical double machine precision is quickly surpassed. To circumvent this pitfall, the arbitrary precision floating-point arithmetic library mpmath is utilised, at expense of a drastic reduction in performance.

Installation

Clone this repository into your system

git clone git@github.com:amcc1996/spradius.git

and install the Python package with pip3, running the following command inside spRadius root directory, where the setup.py is located

pip3 install .

Alternatively, you can install it directly from PyPI with

pip3 install spradius

At this point, spRadius can be imported into your Python scripts and modules the usual Python-way

import spradius

Example

import matplotlib.pyplot as plt
import numpy as np

from spradius import generalised_alpha, hht, newmark


dt = np.logspace(-3, 3, num=100)

rho_newmark = newmark(dt)
rho_newmark2 = newmark(dt, beta=0.3025, gamma=0.6)
rho_hht = hht(dt, alpha=0.05)
rho_hht2 = hht(dt, alpha=0.3)
rho_gen_alpha = generalised_alpha(dt, rho_infty=0.8)
rho_gen_alpha2 = generalised_alpha(dt, rho_infty=0.2)

fig, ax = plt.subplots(
    1, 1, num="spradius example", constrained_layout=True, figsize=(6, 6)
)
ax.semilogx(
    dt,
    rho_newmark.spectral_radius,
    label=r"Newmkark $\beta=0.25$ $\gamma=0.5$",
    clip_on=True,
)
ax.semilogx(
    dt,
    rho_newmark2.spectral_radius,
    label=r"Newmkark $\beta=0.3025$ $\gamma=0.6$",
    clip_on=True,
)
ax.semilogx(
    dt, rho_hht.spectral_radius, label=r"HHT $\alpha=0.05$", clip_on=True
)
ax.semilogx(
    dt, rho_hht2.spectral_radius, label=r"HHT $\alpha=0.3$", clip_on=True
)
ax.semilogx(
    dt,
    rho_gen_alpha.spectral_radius,
    label=r"GEN-$\alpha$ $\rho_{\infty}=0.8$",
    clip_on=True,
)
ax.semilogx(
    dt,
    rho_gen_alpha2.spectral_radius,
    label=r"GEN-$\alpha$ $\rho_{\infty}=0.2$",
    clip_on=True,
)
ax.set_xlabel(r"Non-dimensional time step, $\Delta t / T_1$")
ax.set_ylabel(r"Spectral radius, $\rho$")
ax.set_xlim(dt[0], dt[-1])
ax.set_ylim(0, 1.1)
ax.legend()
ax.grid()

plt.show()

spradius_example

Example spectral radius plot obtained with spRadius.

Running the tests

spRadius tests can by run with pytest so start by installing the framework

pip3 install pytest
pip3 install pytest-cov # optional, to generate coverage reports

and launch the testing utility from spRadius root directory

make tests

The coverage reports can be generated with

make coverage

which will run the test and create the coverage information in htmlcov.

License

Copyright 2020, António Carneiro

spRadius is free and open-source software and is published MIT License.

References

  1. Benítez JM, Montáns FJ. The value of numerical amplification matrices in time integration methods. Computers & Structures. 2013 Nov 1;128:243–50.

Release files for spradius 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spradius 1.0.1
File Size Uploaded
spradius-1.0.1.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spradius 1.0.1
File Interpreter ABI Platform
spradius-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size:26.0 kB

Release files / spradius-1.0.1.tar.gz

Download URL spradius-1.0.1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3d080a07067870bb11e71fac3ae8fe9f46a1d5eb0dc962a21cd03f05e7f10c7d
BLAKE2b-256 checksum
How to use checksums
87e6571647c2c63eb8fdddcd210ef2f632f75cace6c9f42091dfa23871693cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

Release files / spradius-1.0.1-py3-none-any.whl

Download URL spradius-1.0.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
275e8920b9897526029932753bd4725d060ee4433fe6ee095a37c5894e71752b
BLAKE2b-256 checksum
How to use checksums
db45e3e039e11cdb6bc61e2f06d575bb9483a2cf79dbd93988fefe4c357262be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page