File: msd.py

package info (click to toggle)
abinit 9.10.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 518,712 kB
  • sloc: xml: 877,568; f90: 577,240; python: 80,760; perl: 7,019; ansic: 4,585; sh: 1,925; javascript: 601; fortran: 557; cpp: 454; objc: 323; makefile: 77; csh: 42; pascal: 31
file content (126 lines) | stat: -rwxr-xr-x 3,840 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Abinit Post Process Application
author: Martin Alexandre
last edited: May 2013
"""

import sys,os,time,commands
import string, math

#GUI 
import gui.graph as Graph
import gui.conv  as Conv

#Utility
import utility.write as Write
import utility.analysis as Analysis

try:
    from PyQt4 import Qt,QtGui,QtCore
except:
    pass;

from numpy import *

#----------------------------------------------------------------#
#---------------WINDOWS-MEAN SQUARED DEPLACEMENT-----------------#
#----------------------------------------------------------------#
class winMSD(QtGui.QWidget):

    PTOE = Analysis.PeriodicTableElement()

    def __init__(self, file, parent = None,name =''):

        self.file = file
        self.name = name
        self.initUI(parent)
        self.displayGraph()
        self.raise_()

    def initUI(self, parent):

        #-----------------Creation of the windows----------------------------#
        QtGui.QWidget.__init__(self, parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle(self.name + ' MSD option')
        self.setFixedSize(200, 150)
        self.center()
        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)

        self.lbl1 = QtGui.QLabel(" Atom type 1 :", self)
        self.lbl1.setFixedWidth(95)

        self.CBox1 = QtGui.QComboBox()
        self.CBox1.setFixedWidth(70)
        
        for i in range(len(self.file.getZnucl())):
            self.CBox1.addItem(str(self.PTOE.getName(self.file.getZnucl()[i])))
        self.connect(self.CBox1,QtCore.SIGNAL('currentIndexChanged(const QString&)'),self.displayGraph)        


        self.pbClose = QtGui.QPushButton("close")
        self.pbClose.setFixedSize(70,20)
        self.connect(self.pbClose,QtCore.SIGNAL("clicked()"),QtCore.SLOT('close()'))


        self.layout.addWidget(self.lbl1    , 1, 0, 1, 1, QtCore.Qt.AlignRight)
        self.layout.addWidget(self.CBox1   , 1, 1, 1, 1, QtCore.Qt.AlignCenter)
        self.layout.addWidget(self.pbClose , 7, 0, 1, 2, QtCore.Qt.AlignCenter)

        self.show()
        #------------------------------------------------------------------------#


    def displayGraph(self):

        atom = self.CBox1.currentIndex() + 1
        
        self.MeanSquaredDeplacement = Analysis.MSD(self.file,atom)

        x = self.MeanSquaredDeplacement.getX()
        y = self.MeanSquaredDeplacement.getMSD()
         
        try:
            self.graphMSD.update(x,y,'step', "Mean squared deplacement",name = self.name)
            self.graphMSD.addPlot(x,linspace(1,1,len(x)))
            self.graphMSD.show()
        except:
            self.graphMSD = Graph.graphic(x,y,'step', "Mean squared deplacement", average=False,name = self.name)
            self.connect(self.graphMSD, QtCore.SIGNAL("myCustomizedSignal()"), self.close)
            self.graphMSD.show()


    def update(self,pfile):
        self.file = pfile
        atom = self.CBox1.currentIndex() + 1
        try:
            self.MeanSquaredDeplacement = Analysis.MSD(self.file,atom)
            x = self.MeanSquaredDeplacement.getX()
            y = self.MeanSquaredDeplacement.getMSD()
            self.graphMSD.update(x,y,'step', "Mean squared deplacement",name = self.name)
            self.graphMSD.addPlot(x,linspace(1,1,len(x)))
        except:
            pass

    def close(self):
        del self.graphMSD
        del self
    
    def closeEvent(self, event):
        try:
            del self.graphMSD
        except:
            pass
        try:
            del self
        except:
            pass     
        
    def center(self):
        screen = QtGui.QDesktopWidget().screenGeometry()
        size =  self.geometry()
        self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)