evaluation_util

Short description

class pyrid.evaluation.evaluation_util.Evaluation(file_name='PyRID', path=None)[source]

The Evaluation class has several methods that are useful for evaluating simulation results such as reading observables from hdf5 files, calculating MSDs and plotting observables and reactions graphs.

Attributes
file_namestring

file name

self.pathstring

file directory

self.fig_pathstring

Figures directory

self.Observablesdictionary

Dictionary keeping the observables / system measures (except rdf).

self.rdfdictionary

Dictionary keeping the rdf data.

self.Measureslist

List of all available observables / measures

self.time_MSDdictionary

Dictionary keeping the time vectors for the MSD data.

self.MSD_datadictionary

Dictionary keeping the MSD data for each molecule type.

self.time_P2dictionary

Dictionary keeping the time vectors for the P2 data.

self.P2_datadictionary

Dictionary keeping the P2 data for each molecule type.

self.P2_tdictionary

Dictionary keeping the theoretical P2 data for each molecule type.

self.molecules_colorsfloat64[:,4]

Molecule colors rgba [0,1].

self.molecules_colors_rgbfloat64[:,3]

Molecule colors rgb [0,255].

self.molecules_colors_hexlist

Molecule colors hex.

self.reactions_colordictionary

Reactions colors used in reaction graph plots.

self.color_palletedictionary

Color palettes used for the different observable plots (Energy, Pressure, …)

self.unitsdictionary

Unit system

self.Tempfloat64

Temperature

self.box_lengthsfloat64[3]

Simulation box lengths

self.dtfloat64

Integration time step

self.etafloat64

Viscosity

self.kbtfloat64

Boltzmann constant times Temperature.

self.nstepsint64

Number of simulation steps.

self.Moleculesdictionary

Molecule data per molecule type (bead position, bead radii, molecule volume, mobility tensors).

self.hdfobject

hdf5 file loaded using the h5py library.

Methods

load_file(self, file_name, path = None)

Loads an hdf5 file and extracts simulation properties such as temperature and simulation box size.

read_molecule_data(self)

Reads molecule data from the hdf5 file (mobility tensor, bead position and radii, etc.)

load_hdf(self)

Loads any hdf5 file from self.path directory.

close_hdf(self)

Closes the hdf5 file.

MSD(self, time_interval, stride, Simulation, molecule)

Calculates the Mean Squared Distance (MSD) from the molecule positions and from theory.

plot_MSD(self, Simulation, molecule, save_fig = False, fig_name = None, fig_path=None)

Plots the molecules’ Mean Squared Distance (MSD).

P2(self, time_interval, stride, Simulation, molecule, theory_only = False, Delta_t = None)

Calculates the rotational time correlation function P2 from the molecule orientations and from theory.

plot_P2(self, Simulation, molecule, theory_only = False, save_fig = False, fig_name = None, fig_path=None, limits = None)

Plots the rotational time correlation function P2.

plot_rdf(self, mol_pairs, steps = [0], save_fig = False, fig_name = None , fig_path = None, average = False)

Plots the radial distribution function (RDF) from the hdf5 file.

read_observable(self, measure, sampling = None, molecules = ‘All’, educts = ‘All’, Reaction_Type = None, steps = ‘All’, file_path = None)

Reads an observable / measure from the hdf5 file.

plot_observable(self, measure, molecules = ‘All’, Reaction_Type = None, educt = None, bond_pairs = ‘All’, particle_educt = None, step = 0, save_fig = False, fig_name = None , fig_path = None, sampling = None, formats = [‘png’], show = True)

Plots an observable / measure found in the hdf5 file.

plot_reactions_graph(self, Simulation, graph_type = ‘Bimolecular’, graph_subtype = ‘’)

Plots a reactions graph using the pyvis library.

MSD(time_interval, stride, Simulation, molecule)[source]

Calculates the Mean Squared Distance (MSD) from the molecule positions and from theory.

Parameters
time_intervalint64

The time step until which the molecule positions are sampled for the MSD calculation. Note: Currently sampling always starts at time step 0.

strideint64

Stride with which the molecule positions are sampled.

Simulationobject

Instance of the Simulation class.

moleculestring

Name of the molecule type.

P2(time_interval, stride, Simulation, molecule, theory_only=False, Delta_t=None)[source]

Calculates the rotational time correlation function P2 from the molecule orientations and from theory.

Parameters
time_intervalint64

The time step until which the molecule positions are sampled for the MSD calculation. Note: Currently sampling always starts at time step 0.

strideint64

Stride with which the molecule positions are sampled.

Simulationobject

Instance of the Simulation class.

moleculestring

Name of the molecule type.

theory_onlyboolean

If set to True, only the theoretical values for P2 are calculated. Default = False.

Delta_tfloat64

Time step.

__init__(file_name='PyRID', path=None)[source]
close_hdf()[source]

Closes the hdf5 file.

load_file(file_name, path=None)[source]

Loads an hdf5 file and extracts simulation properties such as temperature and simulation box size.

Parameters
file_namestring

Name of the hdf5 file.

pathstring

self.path is set to this directory. By default, self.path = Path(os.getcwd()) / ‘Files’. Default = None.

load_hdf()[source]

Loads any hdf5 file from self.path directory.

plot_MSD(Simulation, molecule, save_fig=False, fig_name=None, fig_path=None)[source]

Plots the molecules’ Mean Squared Distance (MSD).

Parameters
Simulationobject

Instance of the Simulation class.

moleculestring

Name of the molecule type.

save_figboolean

Default = False

fig_namestring

Default = None

fig_pathstring

Default = None

plot_P2(Simulation, molecule, theory_only=False, save_fig=False, fig_name=None, fig_path=None, limits=None)[source]

Plots the rotational time correlation function P2.

Parameters
Simulationobject

Instance of the Simulation class.

moleculestring

Name of the molecule type.

theory_onlyboolean

If set to True, only the theoretical values for P2 are calculated. Default = False.

save_figboolean

Default = False

fig_namestring

Default = None

fig_pathstring

Default = None

limitsfloat64[2,2]

x- and y-axis limits. Default = None.

plot_observable(measure, molecules='All', Reaction_Type=None, educt=None, bond_pairs='All', particle_educt=None, step=0, save_fig=False, fig_name=None, fig_path=None, sampling=None, formats=['png'], show=True)[source]

Plots an observable / measure found in the hdf5 file.

Parameters
measurestring

observable / measure which to read from the hdf5 file.

samplingstepwise’ or ‘binned’ or None

Sampling method used. If None, the sampling method is chosen automatically based on the measure type. Default = None.

moleculeslist of strings

List of molecule types for which to read the observable data. If set to ‘All’, all molecules found in the hdf5 file are loaded. Default = ‘All’.

eductlist of strings

List of reaction educts for which to read the reactions data. If set to ‘All’, all reactions found in the hdf5 file are loaded. Default = ‘All’.

bond_pairslist of strings

List of bond pair types for which to read particle bond data. If set to ‘All’, all bonds found in the hdf5 file are loaded. Default = ‘All’.

particle_eductslist of strings

List of particle reaction educts for which to read the reactions data. If set to ‘All’, all particle reactions found in the hdf5 file are loaded. Default = ‘All’.

Reaction_Type‘bind’, ‘enzymatic’, ‘conversion’, ‘conversion_rb’, ‘decay_rb’, ‘production_rb’, ‘release’, ‘fusion’, ‘enzymatic_rb’

Type of the reaction whose data is read from the hdf5 file.

stepint64

Time step at which to read the observable data. Default = 0

save_figboolean

Default = False

fig_namestring

Default = None

fig_pathstring

Default = None

samplingstepwise’ or ‘binned’ or None

Sampling method used. If None, the sampling method is chosen automatically based on the measure type. Default = None.

formatslist of strings

File formats in which figures are saved. Default = [‘png’]

showboolean

If True, figures are shown directly after they have been plotted. Otherwise figures are not shown (make sure to set save_fig = True). Default = True.

Returns
tuple(fig, ax)

figure and corresponding axes object.

plot_rdf(mol_pairs, steps=[0], save_fig=False, fig_name=None, fig_path=None, average=False)[source]

Plots the radial distribution function (RDF) from the hdf5 file.

Parameters
mol_pairsnested list of strings

Molecule pairs for which the rdf is plotted.

stepsint64[1]

Time steps. Default = [0]

theory_onlyboolean

If set to True, only the theoretical values for P2 are calculated. Default = False.

save_figboolean

Default = False

fig_namestring

Default = None

fig_pathstring

Default = None

averageboolean

Average over rdfs at different points in time if more than one time step is given in parameter “steps”. Default = False

Returns
tuple(fig, ax)

figure and corresponding axes object.

plot_reactions_graph(Simulation, graph_type='Bimolecular', graph_subtype='')[source]

Plots a reactions graph using the pyvis library.

Parameters
Simulationobject

Instance of Simulation class

graph_type‘Bimolecular’, ‘Biparticle’, ‘Unimolecular’, ‘Interactions’

Reaction graph type. Default = ‘Bimolecular’

graph_subtype‘pair relations’, ‘product relations’

Reaction graph subtype. Default = ‘product_relations’.

read_molecule_data()[source]

Reads molecule data from the hdf5 file (mobility tensor, bead position and radii, etc.)

read_observable(measure, sampling=None, molecules='All', educts='All', Reaction_Type=None, steps='All', file_path=None)[source]

Reads an observable / measure from the hdf5 file.

Parameters
measurestring

observable / measure which to read from the hdf5 file.

samplingstepwise’ or ‘binned’ or None

Sampling method used. If None, the sampling method is chosen automatically based on the measure type. Default = None.

moleculeslist of strings

List of molecule types for which to read the observable data. If set to ‘All’, all molecules found in the hdf5 file are loaded. Default = ‘All’.

eductslist of strings

List of reaction educts for which to read the reactions data. If set to ‘All’, all reactions found in the hdf5 file are loaded. Default = ‘All’.

Reaction_Type‘bind’, ‘enzymatic’, ‘conversion’, ‘conversion_rb’, ‘decay_rb’, ‘production_rb’, ‘release’, ‘fusion’, ‘enzymatic_rb’

Type of the reaction whose data is read from the hdf5 file.

stepsint64[:] or All

Time steps at which to read the observable data. Default = All

file_pathstring

File path. Default = None