Processing

Data processing

moldyn.processing.data_proc.PDF(pos, nb_samples, rcut, bin_count)[source]

Pair Distribution Function. Returns normalized histogram of distance between atoms.

Parameters
  • pos (np.array) – Array containing atoms position

  • nb_samples (int) – Number of atoms from which to generate the histogram

  • rcut (number) – Maximum distance to consider

  • bin_count (int) – Number of bins of the histogram

Returns

bins, histbins being the distances, hist the normalized (regarding radius) histogram

Return type

tuple(np.array, np.array)

moldyn.processing.data_proc.cached(f, _cache={<function PDF>: numexpr.utils.CacheDict, <function density>: numexpr.utils.CacheDict, <function compute_strain>: numexpr.utils.CacheDict})[source]
Parameters

f

moldyn.processing.data_proc.compute_strain(model0, model1, rcut)[source]

Compute the local deformation tensor for each atom.

It will try to use GPU but will fallback on CPU if not available

Parameters
Returns

  • A vector containing the 2D deformation tensor of each atom

  • (in the order of model.pos).

Note

Due to numerical calculation imprecision the deformation tensor may not be quantitatively accurate (or even symmetrical).

moldyn.processing.data_proc.density(model, refinement=0)[source]

Create a Voronoi mesh and calculate the local particle density on its vertices.

The local density is calculated as follows: for each vertex, compute the density of each neighbour region as one over the area and assign the average of the neighbouring density to the vertex.

Parameters
  • model (simulation.builder.Model) – the Model object containing

  • refinement (int (defaults : 0)) – number of subdivision for refining the mesh (0 == None)

Returns

  • tri (matplotlib.tri.Triangulation) – the triangulation mesh (refined if set as)

  • vert_density (numpy.array) – the array containing the local denstity associated with the tri mesh

Example

To plot the result using matplotlib use :

import matplotlib.pyplot as plt
tri, density = data_proc.density(model)
plt.tricontour(tri, density) # to draw contours
plt.tricontourf(tri, density) # ot draw filled contours
plt.show()

Note

As of now, the numerical results may not be quantitatively accurate but should qualitatively represent the density.

Visualization

moldyn.processing.visualisation.make_movie(simulation, dynstate, name, pfilm=5, fps=24, callback=None)[source]

Makes a .mp4 movie of simulation from the history saved in dynstate.

Parameters
  • simulation (Simulation) – The simulation object

  • dynstate (DynState) – The dynState object containing the position history file.

  • name (str) – The path (and name) of the file to be writen.

  • pfilm (int) – To make the movie, takes every pfilm position.

  • fps (int) – The number of frame per seconds of the film.

  • callback (function) – An optional callback function that is called every time a frame is made and is passed the current iteration number.

moldyn.processing.visualisation.plot_density(model, levels=None, refinement=0)[source]

Compute and plot the contours of the local density of model.

Parameters
  • model (Model) – The model to plot

  • levels (int or array-like) – the number of levels or a sorted array-like object of levels

  • refinement (int) – the level of refinement

moldyn.processing.visualisation.plot_density_surf(model, refinement=0)[source]

Compute and plot the 3D surface of the local density of model.

Parameters
  • model (Model) – The model to plot.

  • refinement (int) – the level of refinement

moldyn.processing.visualisation.plot_densityf(model, levels=None, refinement=0)[source]

Compute and plot the filled contours of the local density of model.

Parameters
  • model (Model) – The model to plot

  • levels (int or array-like) – the number of levels or a sorted array-like object of levels

  • refinement (int) – the level of refinement

moldyn.processing.visualisation.plot_particles(model)[source]

Plot the position stored in model.

Parameters

model (Model) – The model to plot