Convert CPMD TRAJECTORY for tfreq Autocorrelation and Vibrational Density of States

Recently, I’ve been getting a few of people wanting to use tfreq, autocorrelation and vibrational density of states to analyse data from CPMD. tfreq is written to process output from Quantum-ESPRESSO‘s cp.x output.

The two options are to modify the source file tfreq.c to read the new input, which could be difficult for someone inexperienced with C. As a quick solution, I wrote a quick awk script to make a .vel file from a CPMD TRAJECTORY file.

The following script should would with cubic geometry (just a guess). It doesn’t read anything from the GEOMETRY file and I leave it to the user to make any necessary conversions. I need someone to test it, and I’ll post the results here.

BEGIN {
	nat=###     # Number of Atoms.
	dt=###       # Duration (in fs) of teach time step.
	}

{
	# For each atom:
	for (i=0; i<=nat; i++) {
		# Read the time step out of the first column:
		ts=$1
		# If this is the first row of a time step, print the time:
		if (i==0) printf " %10d %16.10f\n", ts, ts*dt
		# Now print the volocity out of the TRAJECTORY file:
		printf "%16.12f  %16.12f  %16.12f\n", $5, $6, $7
		# Get a new line:
		getline
	}
}

Save this code as CPMD2vel.awk and define nat (the number of atoms) and dt (the time step size)

Run this with code: awk -f CPMD2vel.awk TRAJECTORY > output.vel

This will create a .vel file (output.vel, or the name you wish), which can be used with tfreq.

ESPRESSO’s .vel file format is very simple:

timestep time(in fs)
vx1 vy1 vz1
vx2 vy2 vz2
vx3 vy3 vz3
...

With the format:

integer float
float float float
float float float
...
integer float
float float float
float float float

For example:

1 0.123456
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
2 0.123456
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
3 0.123456
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
1.2345E01 1.2345E01 1.2345E01
...

Be Sociable, Share!

One Comment »

  1. Bipan Dutta says:

    I have installed tfreq.tar file. Please tell me how can use this software to generate the auto correlation spectra form CPMD trajectory file.
    Also I got the command like “awk -f CPMD2vel.awk TRAJECTORY > output.vel”. I it use in tfreq.tar software.

Leave a Reply