Sample#

The static and dynamic structure factors as well as current correlation functions generated by the main analysis functions are stored in Sample objects.

Information about the dynamic correlations generated by the compute_dynamic_structure_factors function is provided in the form of a DynamicSample object. The latter allows one to access, for example, the intermediate scattering functions via the following attributes:

Attribute

Explanation

Symbol

Fqt_coh_A_B

partial coherent intermediate scattering function for atom types A and B

\(F(\boldsymbol{q},t)_\mathrm{AB}^\mathrm{coh}\)

Fqt_coh

total coherent intermediate scattering function (also commonly referred to as just Fqt)

\(F(\boldsymbol{q},t)^\mathrm{coh}\)

Fqt_incoh_A

partial incoherent intermediate scattering function for atom type A

\(F(\boldsymbol{q},t)_\mathrm{A}^\mathrm{incoh}\)

Fqt_incoh

total incoherent intermediate scattering function

\(F(\boldsymbol{q},t)^\mathrm{incoh}\)

Similarly, one can access

  • dynamic structure factors \(S(\boldsymbol{q}, \omega)\) via attributes starting with Sqw

  • the longitudinal and transverse current correlation functions in the time domain, \(C_L(\boldsymbol{q}, t)\) and \(C_T(\boldsymbol{q}, t)\), via attributes starting with Clqt and Ctqt, respectively, and

  • the longitudinal and transverse current correlation functions in the frequency domain, \(C_L(\boldsymbol{q}, \omega)\) and \(C_T(\boldsymbol{q}, \omega)\), via attributes starting with Clqw and Ctqw, respectively.

Information about static correlations can be obtained via the compute_static_structure_factors function, which returns a StaticSample object. The latter allows one to access the static structure factor via the attribute Sq.

dynasor.read_sample_from_npz(fname)[source]#

Read Sample from file.

Parameters:

fname (str) – Path to the file (numpy npz format) from which to read the Sample object.

Return type:

Sample

class dynasor.sample.DynamicSample(data_dict, simulation_data, history=None)[source]#

Class for holding dynamic correlation functions and additional metadata. Objects of this class are most commonly generated by calling compute_dynamic_structure_factors. They can then be written to and subsequently read from file.

You can see which correlation functions are available via the available_correlation_functions property. You can then access the correlation functions either by key or as property. For example, you could access the dynamic structure factor \(S(q,\omega)\) in the following ways:

sample.Sqw  # as property
sample['Sqw']  # via key

The correlation functions are provided as numpy arrays.

There are several additional fields, the availability of which depends on the type of correlation function that was sampled.

You can also see which fields are available by “printing” the DynamicSample object.

Parameters:
  • data_dict (dict[str, Any]) – Dictionary with correlation functions.

  • simulation_data (dict[str, Any]) – Dictionary with simulation data. The following fields are strongly encouraged (but not enforced): atom_types, cell, particle_counts.

  • calling_function – Name of calling function.

  • caller_metadata – Metadata associated with the calling function.

  • history (list[dict[str, Any]]) – Previous history of operations on Sample object.

property atom_types: list[str]#

Atom types.

Type:

Simulation data

property available_correlation_functions: list[str]#

All the available correlation functions in sample.

property cell: ndarray#

Cell metric.

Type:

Simulation data

property dimensions: list[str]#

The dimensions for the samples, e.g., for \(S(q, \omega)\) the dimensions would be the \(q\) and \(\omega\) axes.

property has_currents#

Whether this sample contains the current correlation functions or not.

property has_incoherent#

Whether this sample contains the incoherent correlation functions or not.

property history: list[dict[str, Any]]#

List of operations applied to this Sample object.

property metadata: dict[str, Any]#

Metadata.

property pairs: list[tuple[str, str]]#

Pairs of types for which correlation functions are available.

property particle_counts: dict[str, int]#

Number of particles per type.

Type:

Simulation data

property simulation_data: dict[str, Any]#

Simulation data.

to_dataframe(q_index)[source]#

Returns correlation functions as pandas dataframe for the given q-index.

Parameters:

q_index (int) – index of q-point to return

write_to_npz(fname)#

Write object to file in numpy npz format.

Parameters:

fname (str) – Name of the file in which to store the Sample object.

class dynasor.sample.StaticSample(data_dict, simulation_data, history=None)[source]#

Class for holding static correlation functions and additional metadata. Objects of this class are most commonly generated by calling compute_static_structure_factors. They can then be written to and subsequently read from file.

You can see which correlation functions are available via the available_correlation_functions property. You can then access the correlation functions either by key or as property. For example, you could access the static structure factor \(S(q)\) in the following ways:

sample.Sq  # as property
sample['Sq']  # via key

The correlation functions are provided as numpy arrays.

There are additional fields including: , the availability of which depends on the type of correlation function that was sampled. q_norms is only available if spherical averaging was carried out, typically via

You can also see which fields are available by “printing” the StaticSample object.

Parameters:
  • data_dict (dict[str, Any]) – Dictionary with correlation functions.

  • simulation_data (dict[str, Any]) – Dictionary with simulation data. The following fields are strongly encouraged (but not enforced): atom_types, cell, particle_counts.

  • calling_function – Name of calling function.

  • caller_metadata – Metadata associated with the calling function.

  • history (list[dict[str, Any]]) – Previous history of operations on Sample object.

property atom_types: list[str]#

Atom types.

Type:

Simulation data

property available_correlation_functions: list[str]#

All the available correlation functions in sample.

property cell: ndarray#

Cell metric.

Type:

Simulation data

property dimensions: list[str]#

The dimensions for the samples, e.g., for \(S(q, \omega)\) the dimensions would be the \(q\) and \(\omega\) axes.

property has_currents#

Whether this sample contains the current correlation functions or not.

property has_incoherent#

Whether this sample contains the incoherent correlation functions or not.

property history: list[dict[str, Any]]#

List of operations applied to this Sample object.

property metadata: dict[str, Any]#

Metadata.

property pairs: list[tuple[str, str]]#

Pairs of types for which correlation functions are available.

property particle_counts: dict[str, int]#

Number of particles per type.

Type:

Simulation data

property simulation_data: dict[str, Any]#

Simulation data.

to_dataframe()[source]#

Returns correlation functions as pandas dataframe

write_to_npz(fname)#

Write object to file in numpy npz format.

Parameters:

fname (str) – Name of the file in which to store the Sample object.