mdsuite.calculators package

Submodules

Module contents

MDSuite: A Zincwarecode package.

License

This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zincwarecode Project.

Contact Information

email: zincwarecode@gmail.com github: https://github.com/zincware web: https://zincwarecode.com/

Citation

If you use this module please cite us with:

Summary

class mdsuite.calculators.AngularDistributionFunction(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Compute the Angular Distribution Function for all species combinations.

batch_size

Number of batches, to split the configurations into.

Type:

int

n_minibatches

Number of minibatches for computing the angles to split each batch into

Type:

int

n_confs

Number of configurations to analyse

Type:

int

r_cut

cutoff radius for the ADF

Type:

float

start

Index of the first configuration

Type:

int

stop

Index of the last configuration

Type:

int

bins

bins for the ADF

Type:

int

use_tf_function

activate the tf.function decorator for the minibatches. Can speed up the calculation significantly, but may lead to excessive use of memory! During the first batch, this function will be traced. Tracing is slow, so this might only be useful for a larger number of batches.

Type:

bool, default False

Examples

experiment.run_computation.AngularDistributionFunction(n_confs = 100,

r_cut = 3.2, batch_size = 10, n_minibatches = 50, start = 0, stop = 200, bins = 100, use_tf_function = False)

check_input()[source]

Check the inputs and set defaults if necessary.

Return type:

Updates the class attributes.

plot_data(data)[source]

Plot data.

prepare_computation()[source]

Run steps necessary to prepare the computation for running.

run_calculator()[source]

Run the analysis.

class mdsuite.calculators.Calculator(experiment: Experiment = None, experiments: List[Experiment] = None)[source]

Bases: CalculatorDatabase

Parent class for analysis modules.

experiment

Experiment for which the calculator will be run.

Type:

Experiment

experiments

List of experiments on which to run the calculator.

Type:

List[Experiment]

plot

If true, the results will be plotted.

Type:

bool

system_property

If the calculator returns a value for the whole system such as ionic conductivity or viscosity as opposed to a species-specific number.

Type:

bool (default = False)

experimental

If true, a warning is raised upon calling this calculator with more information about why it is experimental.

Type:

bool (default = False)

selected_species

Species currently being studied in a specific loop.

Type:

tuple

analysis_name

Name of the analysis to store in the database.

Type:

str

time

Time array over which to integrate and plot.

Type:

np.ndarray

plotter

Data visualizer class for use in the plotting.

Type:

DataVisualizer2D

result_keys

keys to use when storing the results. e.g. [“diffusion_coefficient”, “uncertainty”]

Type:

list

result_series_keys

keys to use when storing series results e.g. [“time”, “msd”]

Type:

list

prefactor

can be set if the same pre-factor is required many times.

Type:

float (optional)

x_label

x-label for the plots.

Type:

str

y_label

y-label for the plots.

Type:

str

_dtype

dtype required by the analysis.

Type:

object = tf.float64

plot_array

A list of plot objects to be show together at the end of the species loop.

Type:

list

property dtype

Get the dtype used for the calculator.

plot_data(data)[source]

Plot the data coming from the database.

Parameters:

data (db.Compution.data_dict) – associated with the current project

run_analysis()[source]

Run the appropriate analysis.

run_calculator()[source]

Run the calculation. This should be implemented in each calculator.

run_visualization(x_data: ndarray, y_data: ndarray, title: str, layouts: Optional[object] = None)[source]

Run a visualization session on the data.

Parameters:
Return type:

Updates the plot array with a Bokeh plot object.

class mdsuite.calculators.CoordinationNumbers(**kwargs)[source]

Bases: Calculator

Class for the calculation of coordination numbers.

experiment

Class object of the experiment.

Type:

class object

data_range

Range over which the property should be evaluated. This is not applicable to the current analysis as the full rdf will be calculated.

Type:

int (default=500)

x_label

How to label the x axis of the saved plot.

Type:

str

y_label

How to label the y axis of the saved plot.

Type:

str

analysis_name

Name of the analysis. used in saving of the tensor_values and figure.

Type:

str

file_to_study

The tensor_values file corresponding to the rdf being studied.

Type:

str

integral_data

integrated rdf tensor_values.

Type:

list

species_tuple

A list of species combinations being studied.

Type:

list

indices

A list of indices which correspond to to correct coordination numbers.

Type:

list

rdf_data

RDF data from the user to use in the computation.

Type:

Computation

Examples

experiment.run.CoordinationNumbers(
    savgol_order = 2, savgol_window_length = 17
)
plot_data(data)[source]

Plot the CN.

rdf_data: Computation
run_calculator()[source]

Calculate the coordination numbers and perform error analysis.

class mdsuite.calculators.EinsteinDiffusionCoefficients(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Einstein diffusion coefficient implementation.

msd_array

MSd data updated during each ensemble computation.

Type:

np.ndarray

Examples

project.experiment.run.EinsteinDiffusionCoefficients(data_range=500,

plot=True, correlation_time=10)

ensemble_operation(ensemble)[source]

Calculate and return the msd.

Parameters:

ensemble (tf.Tensor) – An ensemble of data to be operated on.

Return type:

MSD of the tensor_values.

fit_diff_coeff()[source]

Apply unit conversion, fit line to the data, prepare for database storage.

plot_data(data)[source]

Plot the Einstein fits.

Parameters:

data

run_calculator()[source]

Run analysis.

class mdsuite.calculators.EinsteinDistinctDiffusionCoefficients(**kwargs)[source]

Bases: TrajectoryCalculator

Class for the Green-Kubo diffusion coefficient implementation.

experiment

Experiment class to call from

Type:

object

species

Which species to perform the analysis on

Type:

list

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis

Type:

str

Examples

experiment.run_computation.EinsteinDistinctDiffusionCoefficients(data_range=500,

plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

run_calculator()[source]

Perform the distinct coefficient analysis analysis.

class mdsuite.calculators.EinsteinHelfandIonicConductivity(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Einstein-Helfand Ionic Conductivity.

Examples

experiment.run_computation.EinsteinHelfandTIonicConductivity(data_range=500,

plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble: Tensor)[source]

Calculate and return the msd.

Parameters:

ensemble

Return type:

MSD of the tensor_values.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.EinsteinHelfandThermalConductivity(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Einstein-Helfand Ionic Conductivity.

experiment

Experiment class to call from

Type:

object

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis

Type:

str

Examples

experiment.run.EinsteinHelfandTThermalConductivity(data_range=500,

plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble)[source]

Calculate and return the msd.

Parameters:

ensemble

Return type:

MSD of the tensor_values.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.EinsteinHelfandThermalKinaci(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Einstein-Helfand Ionic Conductivity.

experiment

Experiment class to call from

Type:

object

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis

Type:

str

Examples

experiment.run_computation.EinsteinHelfandThermalKinaci(data_range=500,

plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble)[source]

Calculate and return the msd.

Parameters:

ensemble

Return type:

MSD of the tensor_values.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.GreenKuboDiffusionCoefficients(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Green-Kubo diffusion coefficient implementation .. attribute:: experiment

Experiment class to call from

type:

object

species

Which species to perform the analysis on

Type:

list

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis.

Type:

str

Examples

experiment.run_computation.GreenKuboSelfDiffusionCoefficients(data_range=500,

plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble)[source]

Calculate and return the msd.

Parameters:

ensemble

Return type:

MSD of the tensor_values.

plot_data(data: dict)[source]

Plot the data.

Parameters:

data (dict) – Data loaded from the sql database to be plotted.

postprocessing(species: str)[source]

Apply post-processing to the data.

Parameters:

species (str) – Current species on which you are operating.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.GreenKuboDistinctDiffusionCoefficients(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Green-Kubo diffusion coefficient implementation .. attribute:: experiment

Experiment class to call from

type:

object

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis.

Type:

str

Examples

experiment.run_computation.GreenKuboDistinctDiffusionCoefficients(data_range=500, plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(data: dict, dict_ref: list, same_species: bool = False)[source]

Compute the vacf on the given dictionary of data.

Parameters:
  • dict_ref (tuple:) – Names of the entries in the dictionary. Used to select a specific element.

  • data (dict) – Dictionary of data returned by tensorflow

  • same_species (bool) – If true, the species are the same and i=j should be skipped.

Return type:

updates the class state

plot_data(data)[source]

Plot the data.

run_calculator()[source]

Perform the distinct coefficient analysis analysis.

class mdsuite.calculators.GreenKuboIonicConductivity(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Green-Kubo ionic conductivity implementation.

experiment

Experiment class to call from

Type:

object

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis

Type:

str

Examples

experiment.run_computation.GreenKuboIonicConductivity(data_range=500, plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble: Tensor)[source]

Calculate and return the msd.

Parameters:

ensemble (tf.Tensor) – Ensemble on which to operate.

Return type:

ACF of the tensor_values.

plot_data(data)[source]

Plot the data.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.GreenKuboThermalConductivity(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Green-Kubo Thermal conductivity implementation.

experiment

Experiment class to call from

Type:

object

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

Examples

experiment.run_computation.GreenKuboThermalConductivity(data_range=500, plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble: Tensor)[source]

Calculate and return the msd.

Parameters:

ensemble (tf.Tenor) – Ensemble to analyze.

Return type:

MSD of the tensor_values.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.GreenKuboViscosity(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Green-Kubo ionic conductivity implementation.

experiment

Experiment class to call from

Type:

object

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis

Type:

str

Examples

experiment.run_computation.GreenKuboViscosity(data_range=500, plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble: Tensor)[source]

Calculate and return the msd.

Parameters:

ensemble (tf.Tensor) – An ensemble of data to be studied.

Return type:

MSD of the tensor_values.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.GreenKuboViscosityFlux(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the Green Kubo viscosity from flux implementation.

experiment

Experiment class to call from

Type:

object

Examples

experiment.run_computation.GreenKuboViscosityFlux(data_range=500,

plot=True, correlation_time=10)

check_input()[source]

Check the user input to ensure no conflicts are present.

ensemble_operation(ensemble)[source]

Calculate and return the vacf.

Parameters:

ensemble

Return type:

updates class vacf with the tensor_values.

run_calculator()[source]

Run analysis.

class mdsuite.calculators.KirkwoodBuffIntegral(**kwargs)[source]

Bases: Calculator

Class for the calculation of the Kirkwood-Buff integrals.

experiment

Class object of the experiment.

Type:

class object

data_range

Range over which the property should be evaluated. This is not applicable to the current analysis as the full rdf will be calculated.

Type:

int (default=500)

x_label

How to label the x axis of the saved plot.

Type:

str

y_label

How to label the y axis of the saved plot.

Type:

str

analysis_name

Name of the analysis. used in saving of the tensor_values and figure.

Type:

str

file_to_study

The tensor_values file corresponding to the rdf being studied.

Type:

str

data_files

list of files to be analyzed.

Type:

list

rdf = None

rdf tensor_values being studied.

Type:

list

radii = None

radii tensor_values corresponding to the rdf.

Type:

list

species_tuple

A list of species combinations being studied.

Type:

list

Examples

experiment.run.KirkwoodBuffIntegral()

plot_data(data)[source]

Plot the data.

run_calculator()[source]

Calculate the potential of mean-force and perform error analysis.

class mdsuite.calculators.NernstEinsteinIonicConductivity(**kwargs)[source]

Bases: Calculator

Class for the calculation of the Nernst-Einstein ionic conductivity.

Examples

experiment.run_computation.NernstEinsteinIonicConductivity()

run_post_generation_analysis()[source]

Run the analysis.

property truth_table

Builds a truth table to communicate which tensor_values is available to the analysis.

Returns:

truth_table – A truth table communication which tensor_values is available for the analysis.

Return type:

list

class mdsuite.calculators.PotentialOfMeanForce(**kwargs)[source]

Bases: Calculator

Class for the calculation of the potential of mean-force.

The potential of mean-force is a measure of the binding strength between atomic species in a experiment.

experiment

Class object of the experiment.

Type:

class object

data_range

Range over which the property should be evaluated. This is not applicable to the current analysis as the full rdf will be calculated.

Type:

int (default=500)

x_label

How to label the x axis of the saved plot.

Type:

str

y_label

How to label the y axis of the saved plot.

Type:

str

analysis_name

Name of the analysis. used in saving of the tensor_values and figure.

Type:

str

file_to_study

The tensor_values file corresponding to the rdf being studied.

Type:

str

data_files

list of files to be analyzed.

Type:

list

rdf = None

rdf tensor_values being studied.

Type:

list

radii = None

radii tensor_values corresponding to the rdf.

Type:

list

selected_species

A list of species combinations being studied.

Type:

list

Examples

experiment.run_computation.PotentialOfMeanForce(savgol_order = 2,

savgol_window_length = 17)

get_pomf_peaks(pomf_data: ndarray) ndarray[source]

Calculate the maximums of the rdf.

Parameters:

pomf_data (np.ndarray) – POMF data to use in the peak detection.

Returns:

peaks – Peaks to be used in the calculation.

Return type:

np.ndarray

Raises:

ValueError – Raised if the number of peaks required for the analysis are not met.

plot_data(data)[source]

Plot the POMF.

run_calculator()[source]

Calculate the potential of mean-force and perform error analysis.

class mdsuite.calculators.RadialDistributionFunction(**kwargs)[source]

Bases: TrajectoryCalculator, ABC

Class for the calculation of the radial distribution function.

experiment

Experiment class to call from

Type:

object

data_range

Number of configurations to use in each ensemble

x_label

X label of the tensor_values when plotted

Type:

str

y_label

Y label of the tensor_values when plotted

Type:

str

analysis_name

Name of the analysis

Type:

str

loaded_property

Property loaded from the database_path for the analysis

Type:

str

minibatch

Size of an individual minibatch, if set. By default mini-batching is not applied

Type:

int, default None

Examples

project = mdsuite.Project()
project.run.RadialDistributionFunction(number_of_configurations=500)
static bin_minibatch(start, stop, indices, d_ij, bin_range, number_of_bins, cutoff) tf.Tensor[source]

Compute the minibatch histogram.

Parameters:
  • start (list) –

  • stop (list) –

  • indices (tf.Tensor) –

  • d_ij (tf.Tensor) –

  • bin_range

  • number_of_bins (int) –

  • cutoff (float) – Cutoff to enforce on the distance tensor.

check_input()[source]

Check the input of the call method and store defaults if needed.

Return type:

Updates class attributes if required.

static combine_dictionaries(dict_a: dict, dict_b: dict)[source]

Combine two dictionaries in a tf.function call.

Parameters:
compute_species_values(indices: Tensor, start_batch, d_ij: Tensor) dict[source]

Compute species-wise histograms.

Parameters:
  • indices (tf.Tensor) – indices of the d_ij distances in the shape (x, 2)

  • start_batch (int) – starts from 0 and increments by atoms_per_batch every batch

  • d_ij (tf.Tensor) – d_ij matrix in the shape (x, batches) where x comes from the triu computation

  • start_batch – Atom index within a single configuration from to start the computation based on the current minibatch that is being computed.

Returns:

rdf – Dict of rdf values for each combination of species, e.g.: {‘H-O’: tf.Tensor(…), ‘H-H’: …, ‘O-O’: …}

Return type:

dict

static get_dij(indices, positions_tensor, atoms, box_array)[source]

Compute the distance matrix for the minibatch.

Parameters:
  • indices (tf.Tensor) –

  • positions_tensor (tf.Tensor) –

  • atoms (tf.Tensor) –

  • box_array (tf.Tensor) –

property ideal_correction: float

Get the correct ideal gas term.

In the case of a cutoff value greater than half of the box size, the ideal gas term of the experiment must be corrected due to the lack of spherical symmetry in the experiment.

Returns:

correction – Correct ideal gas term for the RDF prefactor

Return type:

float

property particles_list

List of number of atoms of each species being studied.

Return type:

——-.

plot_data(data)[source]

Plot the RDF data.

prepare_computation()[source]

Run the steps necessary to prepare for the RDF computation.

Returns:

  • dict_keys (list) – dict keys to use when selecting data from the output.

  • split_arr (np.ndarray) – Array of indices to load from the database split into sub-arrays which fulfill the necessary batch size.

  • batch_tqdm (bool) – If true, the main tqdm loop over batches is disabled and only the mini-batch loop will be displayed.

run_calculator()[source]

Run the analysis.

run_minibatch_loop(atoms, stop, n_atoms, minibatch_start, positions_tensor)[source]

Run a minibatch loop.

Parameters:
  • atoms (tf.Tensor) –

  • stop (int) –

  • n_atoms (int) –

  • minibatch_start (int) –

  • positions_tensor (tf.Tensor) –