Skip to content

Comprehensive python scripts to compare the non-intrusive sparse quadrature and Monte Carlo simulation for acoustic wave propagation.

Notifications You must be signed in to change notification settings

sudhipv/sparse_quadrature_wave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sparse Quadrature Wave

This repository contains two closely related workflows for stochastic acoustic wave propagation:

  • acoustic_MCS/ implements Monte Carlo simulations (serial and MPI) together with scripts for generating Karhunen–Loève/PCE data and meshes.
  • NISP_wave/ implements non-intrusive spectral projection (NISP) with sparse quadrature, sharing the same preprocessing utilities.
  • matlab_scripts/ provides MATLAB post-processing utilities for inspecting Monte Carlo outputs (MCS_pdf, MCS_variance) and for comparing solver results against reference data (MCS_process).

Repository Layout

  • acoustic_MCS/
    • preprocess.sh – builds KLE/PCE data (klePceData/) and meshes (meshData/) via gfortran and gmsh.
    • acoustic_parallel_MCS.py, acoustic_parallel_3RV.py, acoustic_pdf.py – Monte Carlo drivers (MPI-enabled).
    • klePceData/, meshData/, ssfem_solver/ – generated input data, mesh converters, and reference CSV outputs from the SSFEM solver.
  • NISP_wave/
    • preprocess.sh, quad.sh – same preprocessing pipeline plus UQTk quadrature generation.
    • nisp_serial.py, nisp_parallel*.py, nisp_SparseQuad.py – NISP solvers matching different execution modes.
    • serial/, quadData/, klePceData/, meshData/ – solver outputs and reusable data.
  • matlab_scripts/
    • MCS_pdf.m – aggregates PDF samples u_pdf_*.mat from outputs/<case>/... to a single u_pdf.mat.
    • MCS_variance.m – computes confidence bounds across experiments stored under outputs/3rv_sigma1/3rv_pdf_<idx>/.
    • MCS_process.m – loads Monte Carlo results plus SSFEM reference CSV files to compare mean/variance histories.
  • .gitignore – ignores heavy generated data (outputs/, solver .mat files, etc.).

Requirements

  • Python 3 with dolfin/FEniCS, numpy, scipy, mpi4py.
  • GNU Fortran (gfortran) for building KLE/PCE data generators.
  • gmsh for mesh generation.
  • UQTk binaries for quadrature generation (referenced in NISP_wave/quad.sh).
  • MATLAB (or Octave) for the scripts inside matlab_scripts/.
  • MPI runtime (e.g., OpenMPI) for parallel simulations.

Typical Workflow

  1. Preprocess shared data

    cd acoustic_MCS
    ./preprocess.sh        # builds klePceData/ and meshData/
    cd ../NISP_wave
    ./preprocess.sh        # builds equivalent data for NISP
    ./quad.sh              # generates quadrature points via UQTk

    Adjust mesh density (lc) and UQTk parameters inside the scripts as needed.

  2. Run simulations

    • Monte Carlo (MPI):
      mpirun -np <ranks> python3 acoustic_parallel_MCS.py
      This produces u_MCS_mean.mat, u_MCS_sd.mat, nS.mat, etc., which remain untracked because of .gitignore.
    • NISP:
      python3 nisp_serial.py
      # or mpirun -np <ranks> python3 nisp_parallel1.py
      Outputs such as serial/d3l*/u_nisp_{mean,sd}.mat are likewise ignored.
  3. Post-process in MATLAB

    • matlab_scripts/MCS_pdf.m expects Monte Carlo pdf chunks under outputs/3rv_sigma3/3rv_sigma3_pdf_20/.
    • matlab_scripts/MCS_variance.m reads aggregated pdf files under outputs/3rv_sigma1/3rv_pdf_<idx>/.
    • matlab_scripts/MCS_process.m compares Monte Carlo results against reference CSVs under acoustic_MCS/ssfem_solver/13k_3rv_3s/. Each script now infers the repository root automatically:
    script_dir = fileparts(mfilename('fullpath'));
    repo_root = fileparts(script_dir);

    Update the case-specific subdirectories at the top of each script to match your experiment layout.


Regenerating Removed Files

All deleted .mat artifacts are solver outputs and can be regenerated:

  • NISP results (NISP_wave/serial/d3l*/u_nisp_mean.mat, u_nisp_sd.mat): rerun nisp_serial.py or the desired parallel variant.
  • Monte Carlo summaries (acoustic_MCS/u_MCS_mean.mat, u_MCS_sd.mat, nS.mat): rerun acoustic_parallel_MCS.py (or related scripts).
  • PDF chunk consolidation: run matlab_scripts/MCS_pdf.m after Monte Carlo chunk generation.

If additional heavy outputs should remain local only, add their patterns to .gitignore.


Questions ?

Contact : Sudhi Sharma P V : sudhisharmapadillath@gmail.com

About

Comprehensive python scripts to compare the non-intrusive sparse quadrature and Monte Carlo simulation for acoustic wave propagation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published