@@ -190,6 +190,7 @@ def compute_vaf(
190190 fft : bool = False ,
191191 index : SliceLike = (0 , None , 1 ),
192192 filter_atoms : MaybeSequence [MaybeSequence [Optional [int ]]] = ((None ),),
193+ time_step : float = 1.0 ,
193194) -> NDArray [float64 ]:
194195 """
195196 Compute the velocity autocorrelation function (VAF) of `data`.
@@ -212,6 +213,9 @@ def compute_vaf(
212213 filter_atoms : MaybeSequence[MaybeSequence[Optional[int]]]
213214 Compute the VAF averaged over subsets of the system.
214215 Default is all atoms.
216+ time_step : float
217+ Time step for scaling lags to align with input data.
218+ Default is 1 (i.e. no scaling).
215219
216220 Returns
217221 -------
@@ -270,17 +274,24 @@ def compute_vaf(
270274
271275 vafs /= n_steps - np .arange (n_steps )
272276
277+ lags = np .arange (n_steps ) * time_step
278+
273279 if fft :
274280 vafs = np .fft .fft (vafs , axis = 0 )
275-
276- vafs = [
277- np .average ([vafs [used_atoms [i ]] for i in atoms ], axis = 0 )
278- for atoms in filter_atoms
279- ]
281+ lags = 1. / lags
282+
283+ vafs = (
284+ lags ,
285+ [
286+ np .average ([vafs [used_atoms [i ]] for i in atoms ], axis = 0 )
287+ for atoms in filter_atoms
288+ ],
289+ )
280290
281291 if filenames :
282- for filename , vaf in zip (filenames , vafs ):
292+ for vaf , filename in zip (vafs [ 1 ], filenames ):
283293 with open (filename , "w" , encoding = "utf-8" ) as out_file :
284- print (* vaf , file = out_file , sep = "\n " )
294+ for lag , dat in zip (lags , vaf ):
295+ print (lag , dat , file = out_file )
285296
286297 return vafs
0 commit comments