Module vectorized

Source
Expand description

§Vectorized Ground Motion Calculations

This module provides parallelized routines for ground motion prediction calculations and post-processing over collections of site points. It leverages [Rayon] for efficient multi-threaded computation on large datasets.

§Features

  • Parallel GMPE prediction: Compute ground motion values for large sets of site points in parallel.
  • Summary statistics computation: Derive key statistical descriptors (mean, standard deviation, min, max, median) from ground motion prediction results, with parallelism applied to key operations.

§Primary Types and Functions

  • calc_gmpe_vec: Perform parallel ground motion prediction for a vector of Vs30Point instances.
  • compute_stats: Calculate summary statistics over a collection of predicted GmpePoint values.
  • Stats: Struct representing the computed statistical summary.

§Parallelism

This module uses Rayon for thread-safe, data-parallel operations:

  • par_iter() for distributing GMPE calculations and statistical reductions across threads.
  • Number of threads is controlled by the RAYON_NUM_THREADS environment variable or defaults to the number of logical CPU cores.

§Usage Example

use ground_motion_lib::gmm::{Vs30Point, Earthquake, Magnitude};
use ground_motion_lib::configs::get_mf2013_lib_configs;
use ground_motion_lib::vectorized::{calc_gmpe_vec, compute_stats};

let points = vec![
    Vs30Point::new(142.5, 50.0, 400, Some(200), Some(0)),
    Vs30Point::new(142.6, 50.1, 350, Some(150), Some(1)),
];

let eq = Earthquake {
    lon: 142.4,
    lat: 50.0,
    depth: 10.0,
    magnitude: 6.5,
    magnitude_kind: Magnitude::Mw,
};

let gmpe_ref = get_mf2013_lib_configs().get("config_mf2013_crustal_pga").unwrap();
let results = calc_gmpe_vec(&points, gmpe_ref, &eq);
let stats = compute_stats(&results);

println!("Stats: {stats:?}");

§See Also

§Thread Safety

All operations in this module are thread-safe and make use of [Rayon] for concurrency.

Structs§

Stats
Struct for computed summary statistics

Functions§

calc_gmpe_vec
Calculate ground motion predictions for a set of site points in parallel.
compute_stats
Compute summary statistics (mean, standard deviation, minimum, maximum, and median) for a list of GmpePoint values.