2 @package MPCDAnalysis.VelocityAutocorrelation
4 Analysis functionality for data on (center-of-mass) velocity autocorrelation,
6 `OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation`.
12 Analysis class for data on mean square displacement, as produced by
13 `OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation`.
15 Unless specified otherwise, all times are measured in units of MPC time.
17 @see OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation
25 Throws if `rundir` is not a `str`, or a `list` of `str`.
27 Throws if the given `rundir` does not exist, or does not contain
28 a readable, valid data file.
30 Throws if `rundir` is an empty list.
33 The run directory, as a `string`. From this directory, the
34 file `velocityAutocorrelations.data` will be read as input.
35 If this file does not exist,
36 `velocityAutocorrelations.data.xz` will be read instead.
37 Alternatively, this can be a list of strings, each element
38 of which specifies a directory that is treated as described
40 @param[in] minimumTime
41 Discard all measurements involving simulation times smaller
45 if isinstance(rundirs, str):
48 if not isinstance(rundirs, list):
50 for rundir
in rundirs:
51 if not isinstance(rundir, str):
56 if not isinstance(minimumTime, float):
70 for rundir
in rundirs:
71 if not isinstance(rundir, str):
74 filepath = rundir +
"/" +
"velocityAutocorrelations.data"
75 filepathXZ = filepath +
".xz"
78 if not os.path.isfile(filepath)
and not os.path.isfile(filepathXZ):
83 self.
_config = Configuration(rundir)
86 "instrumentation." + \
87 "velocityAutocorrelation." + \
93 if not self.
_config.isEquivalent(Configuration(rundir)):
95 "Rundirs have incompatible configurations!")
97 if os.path.isfile(filepath):
98 with open(filepath,
"r")
as f:
100 elif os.path.isfile(filepathXZ):
102 f = lzma.LZMAFile(filepathXZ,
"r")
110 Returns an `OnTheFlyStatisticsDDDA` object that holds information on the
111 sample of measured mean square displacements for time difference
115 Throws if any of the arguments have invalid types.
117 Throws if any of the arguments have invalid values.
120 The time difference to return results for. This must be of
121 type `float` and an element of `getCorrelationTimes()`.
124 if not isinstance(deltaT, float):
134 Returns a sorted list of valid correlation times.
140 def _getDeltaT(self, t1, t2):
142 Returns a rounded time difference of `t2` and `t1`.
144 The returned result is rounded such that it is (approximately to within
145 floating-point precision) multiple of the MPC simulation timestep used.
148 Throws if any of the arguments have invalid types.
150 Throws if any of the arguments have invalid values.
153 The first time, as a non-negative `float`.
155 The second time, as a `float` larger than or equal to `t1`.
158 if not isinstance(t1, float)
or not isinstance(t2, float):
160 if t1 < 0
or t2 < t1:
169 Parses the given file `f`.
171 If a file has been parsed already, this new file is treated as if it
172 was a continuation of previously parsed runs. Hence, this file's first
173 measurement is treated as if it followed the last file's last
177 The file to parse, of type `file` or `lzma.LZMAFile`.
181 parts = [float(x)
for x
in line.split()]
185 t1, t2, value = parts