Feeds:
Posts

## Shock Response Spectrum

The most widely used algorithm for the Shock Response Spectrum (SRS) calculation for base excitation is the ramp invariant digital recursive filtering relationship given in:

David O. Smallwood, An Improved Recursive Formula for Calculating Shock Response Spectra, Shock and Vibration Bulletin, No. 51, May 1981.  The link is:  DS_SRS1.pdf

Smallwood duly gave the resulting filtering coefficients in his paper, but he omitted the derivation details for brevity.

This omission is typical for papers published in journals and conference proceedings, given that derivations may require dozens of steps.

The SRS derivation requires impulse response functions, Laplace transforms and Z-transforms.

The following paper fills in the details:  ramp_invariant_base.pdf

Additional papers are given at: Vibrationdata SRS

* * *

Here is a Matlab script for the SRS calculation of an arbitrary base input pulse: srs.m

Supporting functions:
srs_coefficients.m
enter_time_history.m

* * *

A Matlab GUI version is included in:  Vibrationdata Matlab Signal Analysis Package

* * *

Here is a Matlab SRS function which call be called by main scripts:  srs_function.m

* * *

Here is a Matlab script for the time history response of a specific SDOF system to an arbitrary pulse: arbit.zip

* * *

Here is a Matlab script for the SRS of a half-sine pulse & its supporting function:  halfsine.m  & time_calc.m

* * *

A Fortran SRS program is given at:  QSRS.F

* * *

SRS Educational Animation

Shock Webinar

Python SRS

Synthesize an Acceleration Time History to Satisfy a Shock Response Spectrum

SRS Tripartite

Pyrotechnic Shock Characterization Testing

Pyrotechnic Shock Joint Attenuation

* * *

– Tom Irvine

## Solve a System of Linear Equations, Ax=B

Here is a Fortran program which solves a system of linear equations: LIN_EQ.F

It is compiled via:

gfortran -o LIN_EQ LIN_EQ.F -llapack

The program uses the LAPACK subroutine: DGESV

* * *

A version written in C/C++ is given at:  linear_eq.cpp

It is compiled via:

gcc -o linear_eq linear_eq.cpp -llapack -lstdc++

* * *

Tom Irvine

## MPI

Introduction

Message Passing Interface (MPI) is a portable library of subprograms which can be used to facilitate parallel computing.

The MPI subprograms can be called from C and Fortran programs.

Parallel Computing

Parallel computing enables large scale numerical problems to be solved in a timely manner.  It can be performed on a multi-core PC, or using several networked PCs on a cluster or grid.

The key is to separate large problems into smaller ones.  The calculations are then carried out simultaneously.

The MPI subprograms regulate the communication and synchronization between the various CPUs and memory locations.

Installation

http://www.mcs.anl.gov/research/projects/mpich2/

The best installation method is to build the source code using the directions in:
http://www.mcs.anl.gov/research/projects/mpich2/documentation/files/mpich2-1.4.1-installguide.pdf

This can be done under Cygwin or Linux.

Sample Program

Then go to:  http://www.cs.usfca.edu/~peter/ppmpi/

Also find and copy libmpich.a into this same folder.

Compile the program via:

mpicc -o greetings greetings.c libmpich.a

Then run the program via:

./mpirun-n 4 ./greetings

Grant persmission to run under firewalls if so prompted by pop-up windows.

The program can also be run as:

./mpiexec -n 4 ./greetings

In the above example, four processors were used.

More later . . .

* * *

Another source…     Argonne National Labs MPICH2

Tom Irvine

## Matrix Inversion in LAPACK

Here is a Fortran program which performs matrix inversion using the LU decomposition method:  INVERSE_MATRIX.F

It is compiled via:

gfortran -o INVERSE_MATRIX INVERSE_MATRIX.F -llapack

It compiles & runs under both Ubuntu & Cygwin.

* * *

The INVERSE_MATRIX.F program uses the subroutines: DGETRF & DGETRI

DGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.

DGETRI computes the inverse of a matrix using the LU factorization computed by DGETRF.

This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A).

* * *

Here is a similar C++ program:  matrix_inverse.cpp

It is compiled as:

gcc -o matrix_inverse matrix_inverse.cpp -llapack -lstdc++

* * *

* * *

Tom Irvine

## Mixed C++ Fortran Programming

This is another matrix multiplication project using the BLAS function dgemm. It is complied and run in an Ubuntu system.

The set consists of two programs:  (right mouse click.  save target or link as)

The set calculates: C = A*B

The C++ program matrix_mult_cf reads in two matrices, A & B.

The input matrices may each have an arbitrary number of rows and columns up to a certain cell limit. Furthermore, the number of A columns must be equal to the number of B rows.

The matrix_mult_cf program then calls a subroutine from fort_matmul_main to do the matrix multiplication.

The fort_matmul_main subroutine uses dgemm to perform the actual multiplication.

An important feature of this program set is that the C++ and Fortran codes pass the matrices back and forth using 1D arrays. This approach requires some extra steps, but it avoids the complexity of passing 2D arrays, especially if any of the matrices is non-square.

The set is compiled using:

gfortran matrix_mult_cf.cpp fort_matmul_main.f -o mmult_cf -lstdc++ -lblas

The resulting executable code is run as

./mmult_cf

* * *

Tom Irvine

## MinGW Windows Installation

MinGW stands for Minimalist GNU for Windows.

MinGW is a native software port of the GNU Compiler Collection (GCC) and GNU Binutils for use in the development of native Microsoft Windows applications.

* * *

to the PATH environment variable by opening the System control panel, going to the Advanced tab, and clicking the Environment Variables button.

* * *

C/C++ programs can then be compiled in command line as:

This will generate an executable file called:  filename.exe

* * *

Fortran progams can be compiled as:

This will generate an executable file called:  filename.exe

* * *

MinGW also provides a Unix-like shell.

* * *

Tom Irvine

## Matrix Multiplication in BLAS & CBLAS

Here is a program that uses dgemm to multiply two matrices:  matrix_mult.cpp

The dgemm function is implemented using gsl blas.

It can be compiled under Cygwin as:

gcc -o matrix_mult_alt matrix_mult_alt.cpp -lgsl -lstdc++

And under Ubuntu as:

gcc -o matrix_mult_alt matrix_mult_alt.cpp -lgsl -lgslcblas -lstdc++

* * *

For benchmark comparison, here is a matrix multiplication program which uses pure pointer access without BLAS.    matrix_11.cpp

* * *

A Fortran program which uses the intrinsic function MATMUL is given at:  MATRIX_MULT.F

A Fortran program which uses DGEMM is:  MATRIX_MULT_D.F

The program was compiled using:

gfortran -o MATRIX_MULT_D MATRIX_MULT_D.F -lblas -llapack

As an aside, the following was used to determine memory leaks during the debugging process:

gfortran -g -o MATRIX_MULT_D MATRIX_MULT_D.F -lblas -llapack -Wall -fbounds-check -fmax-errors=1 -Werror

* * *

Here is a program  matrix_mult_cblas.cpp  which uses cblas_dgemm.

It is compiled in Cygwin via:

gcc -o matrix_mult_cblas matrix_mult_cblas.cpp c:/cygwin/lib/libblas.a c:/cygwin/lib/libcygwin.a c:/cygwin/home/tirvine/CBLAS/lib/cblas_LINUX.a -lstdc++

The paths should be modified according to your library installation.

Note that CBLAS can be installed in Cygwin using the instructions at:

https://vibrationdata.wordpress.com/2011/11/07/install-cblas-in-ubuntu/

* * *

Tom Irvine