5. micmec.analysis – Trajectory analysis.

5.1. micmec.analysis.advanced – Advanced trajectory analysis routines.

Advanced trajectory analysis routines.

micmec.analysis.advanced.get_cell0(f, **kwargs)

Get the equilibrium cell matrix of a simulation domain, based on trajectory data.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

Returns
cell0numpy.ndarray, shape=(3, 3)

The equilibrium cell matrix, in atomic units.

Notes

The optional arguments of the get_slice function are also accepted in the form of keyword arguments. Please be aware that the simulation domain in this method can refer to:

  • an atomistic force field simulation, in which case the trajectory of the domain is stored in trajectory/cell;

  • a micromechanical force field simulation, in which case the trajectory of the domain is stored in trajectory/domain.

As such, this method can be used to analyze HDF5 files from both Yaff and MicMec.

micmec.analysis.advanced.get_elasticity0(f, **kwargs)

Get the elasticity tensor of a simulation domain, based on trajectory data.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

Returns
elasticity0numpy.ndarray, shape=(3, 3, 3, 3)

The elasticity tensor, in atomic units.

Notes

The optional arguments of the get_slice function are also accepted in the form of keyword arguments. Please be aware that the simulation domain in this method can refer to:

  • an atomistic force field simulation, in which case the trajectory of the domain is stored in trajectory/cell;

  • a micromechanical force field simulation, in which case the trajectory of the domain is stored in trajectory/domain.

As such, this method can be used to analyze HDF5 files from both Yaff and MicMec.

micmec.analysis.advanced.get_mass(f)

Get the total mass of a simulation domain from an HDF5 file.

Parameters
fh5py.File

An HDF5 file, may be None if it is not available.

Returns
massfloat

The total mass of the domain, in atomic units.

5.2. micmec.analysis.basic – Basic trajectory analysis routines.

Basic trajectory analysis routines.

micmec.analysis.basic.plot_domain_pars(f, fn_png='domain_pars.png', **kwargs)

Make a plot of the domain parameters as a function of time.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to.

Notes

The optional arguments of the get_slice function are also accepted in the form of keyword arguments. The units for making the plot are taken from the screen logger. This type of plot is essential for checking the sanity of a simulation.

micmec.analysis.basic.plot_energies(f, fn_png='energies.png', **kwargs)

Make a plot of the potential, kinetic, total and conserved energy as a function of time.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to.

Notes

The optional arguments of the get_slice function are also accepted in the form of keyword arguments. The units for making the plot are taken from the screen logger. This type of plot is essential for checking the sanity of a simulation.

micmec.analysis.basic.plot_press_dist(f, temp, fn_png='press_dist.png', press=None, ndof=None, select=None, **kwargs)

Plot the distribution of the internal pressure.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to.

tempfloat

The (expected) average temperature.

pressfloat, optional

The (expected) average pressure.

selectarray_like, optional

A list of node indices that should be considered for the analysis. By default, information from all nodes is combined.

start, end, step, max_sampleint, optional

The optional arguments of the get_slice function are also accepted in the form of keyword arguments.

Notes

This type of plot is essential for checking the sanity of a simulation.

micmec.analysis.basic.plot_pressure(f, fn_png='pressure.png', window=1, **kwargs)

Make a plot of the pressure as a function of time.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to.

windowint, optional

The window over which the pressure is averaged.

Notes

The optional arguments of the get_slice function are also accepted in the form of keyword arguments. The units for making the plot are taken from the screen logger. This type of plot is essential for checking the sanity of a simulation.

micmec.analysis.basic.plot_temp_dist(f, fn_png='temp_dist.png', temp=None, ndof=None, select=None, **kwargs)

Plot the distribution of the weighted nodal velocities (temperature).

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to.

tempfloat

The (expected) average temperature.

selectarray_like, optional

A list of node indices that should be considered for the analysis. By default, information from all nodes is combined.

start, end, step, max_sampleint, optional

The optional arguments of the get_slice function are also accepted in the form of keyword arguments.

Notes

This type of plot is essential for checking the sanity of a simulation.

micmec.analysis.basic.plot_temperature(f, fn_png='temperature.png', **kwargs)

Make a plot of the temperature as a function of time.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to.

Notes

The optional arguments of the get_slice function are also accepted in the form of keyword arguments. The units for making the plot are taken from the screen logger. This type of plot is essential for checking the sanity of a simulation.

micmec.analysis.basic.plot_volume_dist(f, fn_png='volume_dist.png', temp=None, press=None, **kwargs)

Plot the distribution of the volume.

Parameters
fh5py.File

An HDF5 file containing the trajectory data.

fn_pngstr, optional

The PNG filename to write the figure to

tempfloat, optional

The (expected) average temperature.

pressfloat, optional

The (expected) average pressure.

start, end, step, max_sampleint, optional

The optional arguments of the get_slice function are also accepted in the form of keyword arguments.

Notes

This type of plot is essential for checking the sanity of a simulation.

5.3. micmec.analysis.tensor – Auxiliary routines for tensors.

Auxiliary routines for tensors.

micmec.analysis.tensor.plot_directional_young_modulus(compliance_tensor, fn_png='directional_young_modulus.png')

Plot the three-dimensional directional Young modulus, based on the compliance tensor.

Parameters
compliance_tensornumpy.ndarray, shape=(3, 3, 3, 3)

A (3 x 3 x 3 x 3) compliance tensor, expressed in atomic units.

fn_pngstr, optional

The PNG filename to write the figure to.

micmec.analysis.tensor.pretty_3x3x3x3_tensor(C)

Improve the formatting of a (3 x 3 x 3 x 3) tensor.

Parameters
Cnumpy.ndarray, shape=(3, 3, 3, 3)

A (3 x 3 x 3 x 3) tensor.

Returns
C_print_newstr

A nicely formatted string version of the (3 x 3 x 3 x 3) tensor.

micmec.analysis.tensor.pretty_6x6_matrix(C)

Improve the formatting of a (6 x 6) matrix.

Parameters
Cnumpy.ndarray, shape=(6, 6)

A (6 x 6) matrix.

Returns
C_print_newstr

A nicely formatted string version of the (6 x 6) tensor.

micmec.analysis.tensor.voigt(tensor, mode=None)

Map a (3 x 3 x 3 x 3) tensor to a (6 x 6) Voigt notation matrix.

Parameters
tensornumpy.ndarray, shape=(3, 3, 3, 3)

The tensor to be mapped to a Voigt notation matrix.

mode{“compliance”, “elasticity”}, optional

Declare whether the input tensor is a compliance tensor or an elasticity tensor.

Returns
matrixnumpy.ndarray, shape=(6, 6)

The resulting Voigt notation matrix.

Notes

Voigt notation differs depending on whether the tensor is a compliance tensor or an elasticity tensor, hence the (optional) keyword mode.

micmec.analysis.tensor.voigt_inv(matrix, mode=None)

Map a (6 x 6) Voigt notation matrix to a (3 x 3 x 3 x 3) tensor.

Parameters
matrixnumpy.ndarray, shape=(6, 6)

The Voigt notation matrix to be mapped to a tensor.

mode{“compliance”, “elasticity”}, optional

Declare whether the input matrix is a compliance matrix or an elasticity matrix.

Returns
tensornumpy.ndarray, shape=(3, 3, 3, 3)

The resulting tensor.

Notes

Voigt notation differs depending on whether the tensor is a compliance tensor or an elasticity tensor, hence the (optional) keyword mode.

5.4. micmec.analysis.utils – Auxiliary analysis routines.

Auxiliary analysis routines.

micmec.analysis.utils.get_slice(f, start=0, end=- 1, max_sample=None, step=None)
Parameters
fh5py.File object (open)

A .h5 file, may be None if it is not available. If it contains a trajectory group, this group will be used to determine the number of time steps in the trajectory.

startint, optional

The first sample to be considered for analysis. This may be negative to indicate that the analysis should start from the -start last samples.

endint, optional

The last sample to be considered for analysis. This may be negative to indicate that the last -end samples should not be considered.

max_sampleint, optional

When given, step is set such that the number of samples does not exceed max_sample.

stepint, optional

The spacing between the samples used for the analysis.

Returns
start, end, stepint

When f is given, start and end are always positive.

Notes

The optional arguments can be given to all of the analysis routines. Just make sure you never specify max_sample and step at the same time. The max_sample argument assures that the step is set such that the number of samples does not exceed max_sample. The max_sample option only works when f is not None, or when end is positive. If f is present or start and end are positive, and max_sample and step or not given, max_sample defaults to 1000.

micmec.analysis.utils.get_time(f, start, end, step)

Get the time axis of a trajectory.

Parameters
fh5py.File

An HDF5 file, may be None if it is not available.

startint, optional

The first sample to be considered for analysis. This may be negative to indicate that the analysis should start from the -start last samples.

endint, optional

The last sample to be considered for analysis. This may be negative to indicate that the last -end samples should not be considered.

stepint, optional

The spacing between the samples used for the analysis.

Returns
time, labelnumpy.ndarray, str

The sliced time axis, with appropriate units, and the label of the time axis.