@@ -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. ,
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,21 @@ 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 )
281+ lags = 1. / lags
275282
276- vafs = [
283+ vafs = ( lags , [
277284 np .average ([vafs [used_atoms [i ]] for i in atoms ], axis = 0 )
278285 for atoms in filter_atoms
279- ]
286+ ])
280287
281288 if filenames :
282- for filename , vaf in zip (filenames , vafs ):
289+ for vaf , filename in zip (vafs [ 1 ], filenames ):
283290 with open (filename , "w" , encoding = "utf-8" ) as out_file :
284- print (* vaf , file = out_file , sep = "\n " )
291+ for lag , dat in zip (lags , vaf ):
292+ print (lag , dat , file = out_file )
285293
286294 return vafs
0 commit comments