Discussion:
[Pw_forum] Plot phonon dispersion
Marcel Mohr
2007-11-19 14:25:10 UTC
Permalink
Hi,

what do you usually do to convert the *.freq file, that comes from
matdyn.x ?

I found an old post from Eyvaz Isaev from (Feb 4 2007), but
couldn't fetch the attachments from the archive.

Cheers
Marcel


________________________________________________________________________
Marcel Mohr Institut f?r Festk?rperphysik, TU Berlin
marcel(at)physik.tu-berlin.de Sekr. EW 5-4
TEL: +49-30-314 24442 Hardenbergstr. 36
FAX: +49-30-314 27705 10623 Berlin
Eyvaz Isaev
2007-11-19 15:24:32 UTC
Permalink
Dear Marcel,

I will send you all files and script asap.

Bests,
Eyvaz
Post by Marcel Mohr
Hi,
what do you usually do to convert the *.freq file,
that comes from
matdyn.x ?
I found an old post from Eyvaz Isaev from (Feb 4
2007), but
couldn't fetch the attachments from the archive.
Cheers
Marcel
________________________________________________________________________
Post by Marcel Mohr
Marcel Mohr Institut f?r Festk?rperphysik, TU
Berlin
marcel(at)physik.tu-berlin.de Sekr. EW 5-4
TEL: +49-30-314 24442 Hardenbergstr. 36
FAX: +49-30-314 27705 10623 Berlin
Post by Marcel Mohr
_______________________________________________
Pw_forum mailing list
Pw_forum at pwscf.org
http://www.democritos.it/mailman/listinfo/pw_forum
-------------------------------------------------------------------
Prof. Eyvaz Isaev,
Theoretical Physics Department, Moscow State Institute of Steel & Alloys, Russia, and
Condensed Matter Theory Group, Uppsala University, Sweden
Eyvaz.Isaev at fysik.uu.se, eyvaz_isaev at yahoo.com


____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
Marcel Mohr
2007-11-19 14:25:10 UTC
Permalink
Hi,

what do you usually do to convert the *.freq file, that comes from
matdyn.x ?

I found an old post from Eyvaz Isaev from (Feb 4 2007), but
couldn't fetch the attachments from the archive.

Cheers
Marcel


________________________________________________________________________
Marcel Mohr Institut f?r Festk?rperphysik, TU Berlin
marcel(at)physik.tu-berlin.de Sekr. EW 5-4
TEL: +49-30-314 24442 Hardenbergstr. 36
FAX: +49-30-314 27705 10623 Berlin
Eyvaz Isaev
2007-11-19 15:24:32 UTC
Permalink
Dear Marcel,

I will send you all files and script asap.

Bests,
Eyvaz
Post by Marcel Mohr
Hi,
what do you usually do to convert the *.freq file,
that comes from
matdyn.x ?
I found an old post from Eyvaz Isaev from (Feb 4
2007), but
couldn't fetch the attachments from the archive.
Cheers
Marcel
________________________________________________________________________
Post by Marcel Mohr
Marcel Mohr Institut f?r Festk?rperphysik, TU
Berlin
marcel(at)physik.tu-berlin.de Sekr. EW 5-4
TEL: +49-30-314 24442 Hardenbergstr. 36
FAX: +49-30-314 27705 10623 Berlin
Post by Marcel Mohr
_______________________________________________
Pw_forum mailing list
Pw_forum at pwscf.org
http://www.democritos.it/mailman/listinfo/pw_forum
-------------------------------------------------------------------
Prof. Eyvaz Isaev,
Theoretical Physics Department, Moscow State Institute of Steel & Alloys, Russia, and
Condensed Matter Theory Group, Uppsala University, Sweden
Eyvaz.Isaev at fysik.uu.se, eyvaz_isaev at yahoo.com


____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
Marcel Mohr
2007-12-05 17:51:35 UTC
Permalink
Dear list members,

i have written a small python /script-program to convert the matdyn output
matdyn.freq into a two-column format that I want to share with you.
This can easily be plotted by xmgrace, gnuplot etc.

For simplicity I took the absolute value of the k-vector, so one has to
modify the 1st column for non-cubic systems.

Best
Marcel


I just see, my email program is wrapping lines, so below has to be
modified, the attachment works.



------> program starts here

# small program to convert freq-Output into two-column dat
# written by Marcel Mohr
# usage: python mat2agr.py freqfile > phonons.dat
# Caution:# in the output, the absolute value of k-vector is taken -> 1,1,1
#->sqrt(3)
#
import sys,string
import os
import math
import re

#
def flatten(lst):
for elem in lst:
if type(elem) in (tuple, list):
for i in flatten(elem):
yield i
else:
yield elem

atom=[]
steps= 0
kk=0
input = open(sys.argv[1],'r')
line=input.readline()
#print line
bla=line.split()
if bla==[]:
pass
elif bla[1]=="nbnd=":
# komma muss weg
bla[2]=re.compile( "," ).sub( '', bla[2] )
nbnd=string.atoi(bla[2])
# print nbnd
nkpt=string.atoi(bla[4])
# print nkpt

# Anzahl der Lines sind jetzt nktp + nkpt *(nbnd/6)
lines=input.readlines()
for n, bla in enumerate(lines):
dummy=0
# bloedes \n am Ende weg
for i in range(n+1):
lines[i]=re.compile( "\n" ).sub( '' , lines[i] )
# Wir haben jetzt die Anzahl der Linien, Jetzt die Anzahl pro k-punkt
#(nprok)
# 6 pro Spalte (also nbnd/6), falls nicht durch 6 teilbar, muss man plus 1
#zahlen
if (nbnd%6)==0:
nprok=nbnd/6
else:
nprok=nbnd/6 + 1

kabslist=[]
freqlist=[]
for j in range(nkpt):
klist=[]
#linnum: only lines in which k-point info is stored
linnum=j*(nprok+1)
kptstr=lines[linnum].split()
klist=[]
for i in range(3):
k=string.atof(kptstr[i])
klist.append(k)
kabslist.append( math.sqrt( klist[0]**2 + klist[1]**2 +
klist[2]**2 ))
freqK=[]
for i in range(nprok):
freqK.append( lines[linnum+1+i].split())
dummy=list(flatten(freqK))
freqlist.append(dummy)

#output
for i in range(nbnd):
for j in range(nkpt):
print ("%9.9f %9.9f") %(kabslist[j],string.atof(
freqlist[j][i]) )
print " "
print " "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mat2agr.py
Type: text/x-python
Size: 1804 bytes
Desc:
Url : http://www.democritos.it/pipermail/pw_forum/attachments/20071205/0d15e3c5/attachment.py
Marcel Mohr
2007-12-05 17:51:35 UTC
Permalink
Dear list members,

i have written a small python /script-program to convert the matdyn output
matdyn.freq into a two-column format that I want to share with you.
This can easily be plotted by xmgrace, gnuplot etc.

For simplicity I took the absolute value of the k-vector, so one has to
modify the 1st column for non-cubic systems.

Best
Marcel


I just see, my email program is wrapping lines, so below has to be
modified, the attachment works.



------> program starts here

# small program to convert freq-Output into two-column dat
# written by Marcel Mohr
# usage: python mat2agr.py freqfile > phonons.dat
# Caution:# in the output, the absolute value of k-vector is taken -> 1,1,1
#->sqrt(3)
#
import sys,string
import os
import math
import re

#
def flatten(lst):
for elem in lst:
if type(elem) in (tuple, list):
for i in flatten(elem):
yield i
else:
yield elem

atom=[]
steps= 0
kk=0
input = open(sys.argv[1],'r')
line=input.readline()
#print line
bla=line.split()
if bla==[]:
pass
elif bla[1]=="nbnd=":
# komma muss weg
bla[2]=re.compile( "," ).sub( '', bla[2] )
nbnd=string.atoi(bla[2])
# print nbnd
nkpt=string.atoi(bla[4])
# print nkpt

# Anzahl der Lines sind jetzt nktp + nkpt *(nbnd/6)
lines=input.readlines()
for n, bla in enumerate(lines):
dummy=0
# bloedes \n am Ende weg
for i in range(n+1):
lines[i]=re.compile( "\n" ).sub( '' , lines[i] )
# Wir haben jetzt die Anzahl der Linien, Jetzt die Anzahl pro k-punkt
#(nprok)
# 6 pro Spalte (also nbnd/6), falls nicht durch 6 teilbar, muss man plus 1
#zahlen
if (nbnd%6)==0:
nprok=nbnd/6
else:
nprok=nbnd/6 + 1

kabslist=[]
freqlist=[]
for j in range(nkpt):
klist=[]
#linnum: only lines in which k-point info is stored
linnum=j*(nprok+1)
kptstr=lines[linnum].split()
klist=[]
for i in range(3):
k=string.atof(kptstr[i])
klist.append(k)
kabslist.append( math.sqrt( klist[0]**2 + klist[1]**2 +
klist[2]**2 ))
freqK=[]
for i in range(nprok):
freqK.append( lines[linnum+1+i].split())
dummy=list(flatten(freqK))
freqlist.append(dummy)

#output
for i in range(nbnd):
for j in range(nkpt):
print ("%9.9f %9.9f") %(kabslist[j],string.atof(
freqlist[j][i]) )
print " "
print " "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mat2agr.py
Type: text/x-python
Size: 1804 bytes
Desc:
Url : http://pwscf.org/pipermail/pw_forum/attachments/20071205/0d15e3c5/attachment-0004.py
Loading...