observables_util
Short description
Observables
- class pyrid.observables.observables_util.Observables(Simulation)[source]
The Observables class keeps track of all the observables. It contains methods to sample specific quantities, e.g. pressure, and to write these to an hdf5 file. Sampling can be done in what is here called a stepwise manner. Thereby, the value that the quantity/property has at the current simulation step (current point in time) is saved. However, sometimes it is more convenient to save not the current value but the average over some time window/bin. This is true in particular for event based properties like the number of reactions. Therefore, in PyRID, observables can also be binned and only then their value will be saved/written to the file.
- Attributes
- binneddict
Dictionary containing for each quantity the binned values.
- Observingarray like
Structured array with boolean fields for each observable. If a field’s value is True, the corresponding quantity is observed.
- observables_setupdict
Dictionary containing for each observed quantity the information needed for the sampling process. This information includes the stride, the items (molecules, particles, reaction type, …) to be included, the total number of sampling steps (int((Simulation.nsteps)/stride)), whether the quantity is sampled in a stepwise manner or by binning or both, the current sampling step.
- bond_pairs: `list`
List of particle type pairs for which the number of bonds is observed.
- observing_rdf: `boolean`
If True, the radial distribution function is observed.
- rdf_nsteps: `int`
The total number of sampling steps (int((Simulation.nsteps)/stride)) for the RDF.
- rdf_current_step: `int`
Current sampling step of the RDF.
- rdf_cutoff: `float64[N]`
The cutoff distances for each of the N molecule pairs for which the RDF is calculated.
- rdf_bins: `int64[N]`
The number of bins (spatial resolution of the RDF) for each of the N molecule pairs for which the RDF is calculated.
- rdf_strideint
Stride with which the RDF is sampled.
- rdf_pairs: `list`
List of molecule type pairs for which the RDF is calculated.
- rdf_molecules: `set`
Set of molecules types for which the RDF is calculated.
- rdf_hgrid: `array like`
Hierarchical grid data structure for the different molecule types. The hierarchical grid allows for an efficient calculation of the pairwise distances between the molecules.
- rdf_measure_pair: `int64[N,N]`
Matrix of molecule type indices indicating which molecule pairs are observed.
- rdf_hist: `dict`
Dictionary containing for each observed molecule pair the rdf histogram.
Methods
update_bins(self, Simulation)
Updates the values of all quantities which are sampled using data binning.
observe(self, Property, stride, Simulation, types = None, reactions = None, stepwise = True, binned= False)
Registers a quantity/property for observation.
observe_rdf(self, rdf_pairs, rdf_bins, rdf_cutoff, stride, Simulation)
Registers a molecule pair for observation of the corresponding radial distribution function.
update(self, Simulation, hdf, RBs)
Updates the values of all observed quantities by writing these to an hdf5 file.
update_rdf(self, Simulation, hdf):
Calculates the radial distribution function (rdf histogram) for a range of molecule pairs and writes these to the hdf5 file.
- observe(Property, stride, Simulation, types=None, reactions=None, stepwise=True, binned=False)[source]
Registers a quantity/property for observation.
- Parameters
- Propertystring
Name of the quantity/property to observe. Supported are ‘Force’, ‘Torque’, ‘Orientation’, ‘Position’, ‘Volume’, ‘Energy’,’Pressure’, ‘Virial’, ‘Number’, ‘Virial Tensor’, ‘Reactions’, ‘Bonds’.
- strideìnt
Stride with which the selected quantity is sampled.
- Simulationobject
Instance of the SImulation class.
- typeslist[string]
Names of the particle or molecule types for which to observe a certain property/quantity. Default = None
- reactionsint64[:]
List of reaction type indices. Default = None
- stepwiseboolean
Indicates whether the selected quantity is sampled in a stepwise manner. Default = True
- binnedboolean
Indicates whether the selected quantity is sampled using data binning. Default = False
- Raises
- KeyError (‘Molecule type not found’)
A molecule type name has been passed that has not yet been defined.
- observe_rdf(rdf_pairs, rdf_bins, rdf_cutoff, stride, Simulation)[source]
Registers a molecule pair for observation of the corresponding radial distribution function.
- Parameters
- rdf_pairslist
List of molecule type pairs for which the RDF is calculated.
- rdf_bins: `int64[N]`
The number of bins (spatial resolution of the RDF) for each of the N molecule pairs for which the RDF is calculated.
- rdf_cutoff: `float64[N]`
The cutoff distances for each of the N molecule pairs for which the RDF is calculated.
- strideint
Stride with which the RDF is sampled.
- Simulationobject
Instance of the SImulation class.
- Raises
- KeyError (‘Molecule type not found’)
A molecule type name has been passed that has not yet been defined.
- update(Simulation, hdf, RBs)[source]
Updates the values of all observed quantities by writing these to an hdf5 file.
- Parameters
- Simulationobject
Instance of the SImulation class.
- hdfobject
hdf5 file.
- RBsobject
Instance of the RBs class.