Relaxation module

These are a series of summary values of the dynamics quantities.

This provides methods of easily comparing values across variables.

class sdanalysis.relaxation.Result[source]

Bases: tuple

Hold the result of a relaxation calculation.

This uses the NamedTuple class to make the access of the returned values more transparent and easier to understand.

property error

Alias for field number 1

property mean

Alias for field number 0

sdanalysis.relaxation.compute_molecular_relaxations(df)[source]
Return type

DataFrame

sdanalysis.relaxation.compute_relaxation_value(timesteps, values, relax_type)[source]

Compute a single representative value for each dynamic quantity.

Parameters
  • timesteps (ndarray) – The timestep for each value of the relaxation.

  • values (ndarray) – The values of the relaxation quantity for each time interval.

  • relax_type (str) – A string describing the relaxation.

Return type

Result

Returns

The representative relaxation time for a quantity.

There are some special values of the relaxation which are treated in a special way. The main one of these is the “msd”, for which the relaxation is fitted to a straight line. The “struct_msd” relaxation, is a threshold_relaxation, with the time required to pass the threshold of 0.16. The other relaxations which are treated separately are the “alpha” and “gamma” relaxations, where the relaxation time is the maximum of these functions.

All other relaxations are assumed to have the behaviour of exponential decay, with the representative time being how long it takes to decay to the value 1/e.

sdanalysis.relaxation.compute_relaxations(infile)[source]

Summary time value for the dynamic quantities.

This computes the characteristic timescale of the dynamic quantities which have been calculated and are present in INFILE. The INFILE is a path to the pre-computed dynamic quantities and needs to be in the HDF5 format with either the ‘.hdf5’ or ‘.h5’ extension.

The output is written to the table ‘relaxations’ in INFILE.

Return type

None

sdanalysis.relaxation.diffusion_constant(time, msd, dimensions=2)[source]

Compute the diffusion_constant from the mean squared displacement.

Parameters
  • time (ndarray) – The timesteps corresponding to each msd value.

  • msd (ndarray) – Values of the mean squared displacement

Returns

The diffusion constant error (float): The error in the fit of the diffusion constant

Return type

diffusion_constant (float)

sdanalysis.relaxation.exponential_relaxation(time, value, sigma=None, value_width=0.3)[source]

Fit a region of the exponential relaxation with an exponential.

This fits an exponential to the small region around the value 1/e. A small region is chosen as the interest here is the time for the decay to reach a value, rather than a fit to the overall curve, so this provides a method of getting an accurate time, while including a collection of points.

Parameters
  • time (ndarray) – The timesteps corresponding to each value

  • value (ndarray) – The value at each point in time

  • sigma (Optional[ndarray]) – The uncertainty associated with each point

  • value_width (float) – The width of values over which the fit takes place

Returns

The relaxation time for the given quantity error (float): Estimated error of the relaxation time.

Return type

relaxation_time (float)

sdanalysis.relaxation.max_time_relaxation(time, value)[source]

Time at which the maximum value is recorded.

Parameters
  • time (ndarray) – The time index

  • value (ndarray) – The value at each of the time indices

Returns

The time at which the maximum value occurs. float: Estimate of the error of the time

Return type

float

sdanalysis.relaxation.max_value_relaxation(time, value)[source]

Maximum value recorded.

Parameters
  • time (ndarray) – The time index

  • value (ndarray) – The value at each of the time indices

Returns

The value at which the maximum value occurs. float: Estimate of the error in the maximum value.

Return type

float

sdanalysis.relaxation.series_relaxation_value(series)[source]

Calculate the relaxation of a pandas Series.

When a pandas.Series object, which has an index being the timesteps, and the name of the series being the dynamic quantity, this function provides a simple method of calculating the relaxation aggregation. In particular this function is useful to use with the aggregate function.

Parameters

series (Series) – The series containing the relaxation quantities

Return type

float

Returns

The calculated value of the relaxation.

sdanalysis.relaxation.threshold_relaxation(time, value, threshold=0.36787944117144233, decay=True)[source]

Compute the relaxation through the reaching of a specific value.

Parameters
  • time (ndarray) – The timesteps corresponding to each msd value.

  • value (ndarray) – Values of the relaxation parameter

Returns

The relaxation time for the given quantity. error (float): The error in the fit of the relaxation

Return type

relaxation time (float)

sdanalysis.relaxation.translate_relaxation(quantity)[source]

Convert names of dynamic quantities to their relaxations.

Parameters

quantity (str) – The name of the quantity to convert the name of.

Return type

str

Returns

The translated name.