mdsuite.calculators.calculator module

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

Parent class for the calculators.

class mdsuite.calculators.calculator.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.

mdsuite.calculators.calculator.call(func)[source]

Decorator for the calculator call method.

This decorator provides a unified approach for handling run_computation and load_data for a single or multiple experiments. It handles the run.<calc>() method, iterates over experiments and loads data if requested! Therefore, the __call__ method does not and can not return any values anymore!

Notes

When calling the calculator it will check if a computation with the given user arguments was already performed: >>> Calculator.get_computation_data() is not None

if no computations are available it will 1. prepare a database entry >>> Calculator.prepare_db_entry() 2. save the user arguments >>> Calculator.save_computation_args() 3. Run the analysis >>> Calculator.run_analysis() 4. Save all the data to the database >>> Calculator.save_db_data() 5. Finally query the the data from the database and pass them to the user / plotting >>> data = Calculator.get_computation_data()

Parameters:

func (Calculator.__call__ method) –

Return type:

decorated __call__ method