npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seismic-response

v0.3.0

Published

Seismic response analysis of a single particle system is performed using Newmark's beta method.

Downloads

20

Readme

English | 日本語

Seismic Response

Using Newmark's β method, we will perform seismic response analysis of a single-degree-of-freedom (SDOF) system. From the seismic acceleration waveform, we can determine the response displacement, response velocity, response acceleration, and absolute response acceleration.

To conduct seismic response analysis, you can use the calculation site implemented using the WASM version of this crate.

Usage

use csv::Reader;
use crate::{ResponseAccAnalyzer, ResponseAccAnalyzerParams};

fn example() {
    let mut csv = Reader::from_path("benches/seismic_acc_waveform.csv").unwrap();
    let data = csv.deserialize::<f64>().map(|x| x.unwrap()).collect::<Vec<_>>();

    let params = ResponseAccAnalyzerParams {
        // Natural period [ms]
        natural_period_ms: 500,
        // Time step of the input acceleration waveform [ms]
        dt_ms: 10,
        // Damping ratio
        damping_h: 0.05,
        // Newmark's β method parameter
        beta: 0.25,
        // Initial response displacement [m]
        init_x: 0.0,
        // Initial response velocity [m/s]
        init_v: 0.0,
        // Initial response acceleration [gal]
        init_a: 0.0,
        // Initial input acceleration [gal]
        init_xg: 0.0,
    };

    let analyzer = ResponseAccAnalyzer::from_params(params);

    let result: Result = analyzer.analyze(data);
    // struct Result {
    //     /// Response displacement [m]
    //     pub x: Vec<f64>,

    //     /// Response velocity [m/s]
    //     pub v: Vec<f64>,

    //     /// Response acceleration [gal]
    //     pub a: Vec<f64>,

    //     /// Absolute response acceleration [gal]
    //     pub abs_acc: Vec<f64>,
    // }
}

WebAssembly

This program is published as an npm package. It can be used similarly to the Rust crate.

Mathematical Formulas

This program is implemented based on the following formulas:

Stiffness Coefficient

The stiffness coefficient ( k ) is calculated based on the mass ( m ) and the natural period in milliseconds ( T_ {\text{ms}} ):

$$ k = \frac{4 \pi^2 m}{\left(\frac{T_{\text{ms}}}{1000}\right)^2} $$

Damping Coefficient

The damping coefficient ( c ) is calculated based on the damping ratio ( h ), the mass ( m ), and the stiffness coefficient ( k ):

$$ c = 2h\sqrt{km} $$

Step-by-Step Calculation

Response Acceleration

The acceleration at the next step ( a_{n+1} ) is calculated as:

$$ a_{n+1} = \frac{p_{n+1} - c\left(v_n + \frac{\Delta t}{2}a_n\right) - k\left(x_n + \Delta t v_n + \left(\frac{1}{2} - \beta\right)\Delta t^2 a_n\right)}{m + \frac{\Delta t}{2}c + \beta \Delta t^2 k} $$

Here, the external force ( p_{n+1} ) is given by:

$$ p_{n+1} = -xg_{n+1} m $$

Response Velocity

The velocity at the next step ( v_{n+1} ) is calculated as:

$$ v_{n+1} = v_n + \frac{\Delta t}{2}(a_n + a_{n+1}) $$

Response Displacement

The displacement at the next step ( x_{n+1} ) is calculated as:

$$ x_{n+1} = x_n + \Delta t v_n + \left(\frac{1}{2} - \beta\right) \Delta t^2 a_n + \beta \Delta t^2 a_{n+1} $$

Absolute Response Acceleration

The final absolute response acceleration ( a_{\text{abs}} ) is calculated as:

$$ a_{\text{abs}} = a + xg $$

These are the main calculations implemented in the program.

Note: While the formulas here treat mass ( m ) as a variable, the actual program calculates assuming mass is 1. This is because mass does not affect the absolute response acceleration. This can be confirmed in the test code within the documentation.

License

Licensed under either of the following licenses:

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

(Documentation comments and README file translations provided by DeepL and ChatGPT.)