Analysis With MATLAB¶
The code contains two MATLAB functions for reading in simulation data, which are roughly equivalent to the Python classes.
load_output
function¶
function output = load_output(probname, name, datadir)
- Inputs:
probname
(string), problem name name
(string), output unit namedatadir
(string, optional) location of data directory (default is current directory)- Returns:
output
, data structure holding the following simulation data: field
(string), type of field that is savedendian
(string), endianness of binary datant
(integer), number of time stepsnx
(integer), number of x grid pointsny
(integer), number of y grid pointsnz
(integer), number of z grid pointsx
(float array), x grid valuesy
(float array), y grid valuesz
(float array), z grid values actual field data (identifier is the string contained infield
) (float array), possible values are:vx
, x-component of particle velocityvy
, y-component of particle velocityvz
, z-component of particle velocitysxx
, xx component of stress tensorsxy
, xy component of stress tensorsxz
, xz component of stress tensorsyy
, yy component of stress tensorsyz
, yz component of stress tensorszz
, zz component of stress tensorlambda
, scalar plastic strain rategammap
, scalar plastic strainV
, slip velocity magnitudeVx
, x component of slip velocityVy
, y component of slip velocityVz
, z component of slip velocityU
, slip (calculated as line integral)Ux
, x component of slipUy
, y component of slipUz
, z component of slipSn
, interface normal stressS
, interface shear traction magnitudeSx
, x-component of interface shear tractionSy
, y-component of interface shear tractionSz
, z-component of interface shear tractionstate
, value of state variable
Because the data is written in row major order in the C++ code, but MATLAB stores data in column major order, index order is (z, y, x, t).
load_front
function¶
function front = load_front(probname, iface, datadir)
- Inputs:
probname
(string), problem name iface
(integer), interface numberdatadir
(string, optional) location of data directory (default is current directory)- Returns:
front
, data structure holding the following simulation data: endian
(string), endianness of binary datanx
(integer), number of x grid pointsny
(integer), number of y grid pointsx
(float array), x grid valuesy
(float array), y grid valuesz
(float array), z grid valuest
(float array), rupture time values
Because the data is written in row major order in the C++ code, but MATLAB stores data in column major order, index order is (y, x). Note also that because the interface is a 2D slice, nx
and ny
are used generically to describe the number of grid points on the interface no matter what the orientation of the interface is. Thus, if the array has an approximate normal in the x direction, nx
is the number of grid points in the y direction and ny
is the number of grid points in the z direction.
Example¶
An example of how to use the MATLAB functions is provided in the file matlab_example.m
, located in the matlab
directory. The file is reproduced here.
% example using load_output function in MATLAB
% required arguments are problem name and output unit name
% data directory is optional, if no argument provided assumes it is the current working directory
vybody = load_output('hpctest','vybody');
% loads data structure containing information
vybody
% because of differences in how MATLAB and C++ order arrays, field arrays are indexed by (z,y,x,t)
% any singleton dimensions are removed
% plot velocity
pcolor(vybody.x, vybody.y, vybody.vy(:,:,4));
shading flat;
axis image;
colorbar;