Révision 10

prepareQMX.py (revision 10)
1
#!/usr/bin/env python
2
import os, sys
3
from optparse import OptionParser
4

  
5
class Data:
6
    def __init__(self, name):
7
        self.__name__ = name
8
        self.str_option = ""
9
        self.str_import = None
10
        self.str_class  = None
11
        self.str_methods = []
12
        self.str_structure = None
13
                
14
    def __str__(self):
15
       return self.__name__
16

  
17
def getline(section, subsection, lines):
18
    nline = -1
19
    for iline in xrange(len(lines)):
20
        if lines[iline][0].strip() == subsection:
21
            if nline != -1:
22
                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
23
                sys.exit(1)
24
            nline = iline
25
    if nline == -1:
26
        return None
27
    return lines[nline][1].strip()
28

  
29
def analyzeAtoms(section, lines):
30
    data = Data(section)
31
    line = getline(section, "program", lines)
32
    if line is None:
33
        line=""
34
    if line.lower() == "turbomole":
35
        data.str_import = "from ase.io.turbomole import read_turbomole"
36
        data.str_class = "read_turbomole"
37
    elif line.lower() == "vasp":
38
        data.str_import = "from ase.io.vasp import read_vasp"
39
        data.str_class = "read_vasp"
40
        
41
    data.str_structure = getline(section, "structure", lines)
42
    return data
43

  
44
def analyzeCalculator(section, lines):
45
    data = Data(section)
46
    #read programs
47
    line = getline(section, "program", lines)
48
    if line.lower() == "turbomole":
49
        data.str_import = "from ase.calculators.turbomole import Turbomole"
50
        data.str_class = "Turbomole"
51
    elif line.lower() == "vasp":
52
        data.str_import = "from ase.calculators.vasp import Vasp"
53
        data.str_class = "Vasp"
54
    
55
    str = getline(section, "class", lines)
56
    if str is not None:
57
        data.str_class = str
58

  
59
    str = getline(section, "import", lines)
60
    if str is not None:
61
        data.str_import = str
62

  
63
    str = getline(section, "options", lines)
64
    if str is not None:
65
        data.str_option = str
66
    return data
67

  
68
def analyzeDynamics(section, lines):
69
    data = Data(section)
70
    line = getline(section, "method", lines)
71
    if line.lower() == "optimizer":
72
        data.str_import = "from ase.optimize import QuasiNewton"
73
        data.str_class = "QuasiNewton"
74
    return data
75

  
76
#--- setting default values ------------------------------------------------------------------------
77
#define separators
78
separator=":"
79
subseparator="."
80
lineseparator="\n"
81

  
82
#--- parse arguments -------------------------------------------------------------------------------
83
#parse arguments (python 2.6)
84
parser = OptionParser()
85
parser.add_option("-i", "--infile",  dest="inputFile",  help="specifies the input file", metavar="FILE", default="qmx.in")
86
parser.add_option("-o", "--outfile", dest="outputFile", help="specifies the output file", metavar="FILE")
87
parser.add_option("-f", action="store_true", dest="overwrite")
88
(options, args) = parser.parse_args()
89

  
90
file=open(options.inputFile, "r")
91
lines = file.readlines()
92
file.close()
93

  
94

  
95
#--- split intput file -----------------------------------------------------------------------------
96

  
97
#--- remove comments -------------------------------------------------------------------------------
98
for iline in xrange(len(lines)):
99
    lines[iline] = lines[iline].split("#")[0]    
100

  
101
#--- collect data in class -------------------------------------------------------------------------
102
data_collection=[]
103

  
104
#--- settings for QMX class ------------------------------------------------------------------------
105
data = Data("qmx")
106
data.str_class = "Qmx"
107
data.str_import = "from ase.calculators.qmx import Qmx"
108
data.str_option = "highLevel, lowLevel"
109

  
110
data_collection.append(data)
111

  
112
#--- settings for Embed class ----------------------------------------------------------------------
113
data = Data("embed")
114
data.str_class = "Embed"
115
data.str_import = "from ase.embed import Embed"
116
data.str_option = "system, cluster"
117
data.str_methods = ["embed()", "set_calculator(qmx)"]
118

  
119
data_collection.append(data)
120

  
121

  
122
#--- analyze the input file ------------------------------------------------------------------------
123
for section in "high-level", "low-level", "cluster", "system", "dynamics":
124
    #search lines for section
125
    lines_section=[]
126
    for line in lines:
127
        line = line.split(separator)
128
        if line[0].find(section) >= 0:
129
            line[0] = line[0].replace(section+subseparator, "")
130
            lines_section.append(line)
131
    
132
    #calculators
133
    if section == "high-level" or section == "low-level":
134
        data_collection.append(analyzeCalculator(section, lines_section))
135
        
136
    #systems
137
    if section == "cluster" or section == "system":
138
        data_collection.append(analyzeAtoms(section, lines_section))
139
        
140
    #dynamics
141
    if section == "dynamics":
142
        data_collection.append(analyzeDynamics(section, lines_section))
143

  
144
#--- write output file -----------------------------------------------------------------------------
145
if options.outputFile is not None and os.path.exists(options.outputFile) and not options.overwrite:
146
    sys.stderr.write(lineseparator+"the output file <"+options.outputFile+"> already exists"+lineseparator)
147
    sys.exit(1)
148

  
149
output = None
150
if options.outputFile is None:
151
    output=sys.stdout
152
else:
153
    output=open(options.outputFile, "w")
154

  
155
#--- write header ----------------------------------------------------------------------------------
156
output.write("#!/usr/bin/env python\n")
157

  
158
#--- write import lines ----------------------------------------------------------------------------
159
xlines=[]
160
for data in data_collection:
161
    value = data.str_import
162
    if value is None or value in xlines:
163
        continue
164
    xlines.append(value)
165
    output.write(value+lineseparator)
166
output.write(lineseparator)
167

  
168
#--- define the methods ----------------------------------------------------------------------------
169
for system in 'high', 'low':
170
    for data in data_collection:
171
        if data.__name__ == system+"-level":
172
            output.write(system+"Level = "+data.str_class+"("+data.str_option+")"+lineseparator)
173
output.write(lineseparator)
174

  
175
#--- qmx class (substraction scheme ----------------------------------------------------------------
176
for data in data_collection:
177
    if data.__name__ == "qmx":
178
        output.write("qmx = "+data.str_class+"("+data.str_option+")"+lineseparator)
179
output.write(lineseparator)
180

  
181
#--- read all the systems --------------------------------------------------------------------------
182
for system in "cluster", "system":
183
    for data in data_collection:
184
        if data.__name__ == system:
185
            if data.str_structure is None:
186
                continue
187
            output.write(system+" = "+data.str_class+"(\""+data.str_structure+"\")"+lineseparator)
188
output.write(lineseparator)
189

  
190
#--- embeding class --------------------------------------------------------------------------------
191
for data in data_collection:
192
    if data.__name__ == "embed":
193
        output.write("embed = "+data.str_class+"("+data.str_option+")"+lineseparator)
194
        for method in data.str_methods:
195
            output.write("embed."+method+lineseparator)
196
output.write(lineseparator)
197

  
198
#--- dynamics class --------------------------------------------------------------------------------
199
for data in data_collection:
200
    if data.__name__ == "dynamics":
201
        output.write("dyn="+data.str_class+"(embed)"+lineseparator)
202
        output.write("dyn.run("+data.str_option+")"+lineseparator)
203

  
204
output.close()
205
sys.exit(0)
prepareQMX.GUI.py (revision 10)
1
#!/usr/bin/env python
2
from Tkinter import *
3
from copy import deepcopy
4
import StringIO
5

  
6
#-------------------------------------------------------------------------------
7
#--- GENERAL -------------------------------------------------------------------
8
#-------------------------------------------------------------------------------
9
class Definition(object):
10
    def getValue(self, key):
11
        if self.keywords.__contains__(key):
12
            return self.keywords[key]
13
        return ''
14
        
15
#-------------------------------------------------------------------------------
16
#--- STR DEFINITIONS -----------------------------------------------------------
17
#-------------------------------------------------------------------------------
18
class VASPStrDefinition(Definition):
19
    def __init__(self):
20
        self.name='VASP'
21
        self.keywords = {}
22
        self.keywords['import']='ase.io.vasp'
23
        self.keywords['class']='read_vasp'
24
        self.keywords['class.options']="'POSCAR'"
25
    
26
#-------------------------------------------------------------------------------
27
class TURBOMOLEStrDefintion(Definition):
28
    def __init__(self):
29
        self.name='TURBOMOLE'
30
        self.keywords = {}
31
        self.keywords['import']='ase.io.turbomole'
32
        self.keywords['class']='read_turbomole'
33
        self.keywords['class.options']="'coord'"
34

  
35
#-------------------------------------------------------------------------------
36
class EmbedStrDefinition(Definition):
37
    def __init__(self):
38
        self.name='Embed'
39
        self.system='Embed'
40
        self.keywords = {}
41
        self.keywords['import']='ase.embed'
42
        self.keywords['class']='Embed'
43
        self.keywords['class.options']='system, cluster'
44
        self.keywords['method']='embed'
45
        self.keywords['calculator']='qmx'
46

  
47
#-------------------------------------------------------------------------------
48
#--- PRG DEFINITIONS -----------------------------------------------------------
49
#-------------------------------------------------------------------------------
50
class VASPPrgDefinition(Definition):
51
    def __init__(self):
52
        self.name='VASP'
53
        self.keywords = {}
54
        self.keywords['import']='ase.calculators.vasp'
55
        self.keywords['class']='Vasp'
56
        self.keywords['class.options']='write_input=False'
57

  
58
#-------------------------------------------------------------------------------
59
class QmxPrgDefinition(Definition):
60
    def __init__(self):
61
        self.name='QMX'
62
        self.keywords = {}
63
        self.keywords['import']='ase.calculators.qmx'
64
        self.keywords['class']='Qmx'
65
        self.keywords['class.options']='high_level, low_level'
66

  
67
#-------------------------------------------------------------------------------
68
class TURBOMOLEPrgDefinition(Definition):
69
    def __init__(self):
70
        self.name='TURBOMOLE'
71
        self.keywords = {}
72
        self.keywords['import']='ase.calculators.turbomole'
73
        self.keywords['class']='Turbomole'
74

  
75
#-------------------------------------------------------------------------------
76
#--- JOB DEFINITIONS -----------------------------------------------------------
77
#-------------------------------------------------------------------------------
78
class QNJobDefintion(Definition):
79
    def __init__(self):
80
        self.name='QuasiNewton'
81
        self.keywords = {}
82
        self.keywords['import']='ase.optimize'
83
        self.keywords['class']= 'QuasiNewton'
84
        self.keywords['method']='run'
85

  
86
#-------------------------------------------------------------------------------
87
#-------------------------------------------------------------------------------
88
#-------------------------------------------------------------------------------
89

  
90
class MyLabelFrame(LabelFrame):
91
    def __init__(self, mainWnd, master, title, def_list, extra=[]):
92
        LabelFrame.__init__(self, master, text=title)
93
        self.mainWnd = mainWnd
94
        self.definitions=[]
95
        self.title = title
96

  
97
        for definition in def_list:
98
            definition_new = deepcopy(definition)
99
            definition_new.system = title
100
            self.definitions.append(definition_new)
101

  
102
        fields=['import', 'class', 'class.options']
103
        for key in extra:
104
            fields.append(key)
105

  
106
        self.entries=[]
107
        for key in fields:
108
            text=StringVar()
109
            text.set('')
110
            self.entries.append((key, text, Entry(self, textvariable=text, width=15)))
111
            
112
    def grid(self, **arguments):
113
        LabelFrame.grid(self, arguments, sticky=(N+W+E))
114
        self.listbox.selection_set(first=0)
115
        self.select(None)
116
        
117
    def doLayout(self):
118
        irow=0
119
        for (key, text, textfield) in self.entries:
120
            Label(self, text=key, width=15, anchor=W).grid(row=irow)
121
            textfield.grid(row=irow, column=1)
122
            textfield.bind("<KeyRelease>", self.update)
123
            irow+=1
124
        
125
        scrollbar=Scrollbar(self, orient=VERTICAL)
126
        self.listbox=Listbox(self, yscrollcommand=scrollbar.set, height=0, width=15, selectmode=SINGLE)
127
        self.listbox.grid(row=0, column=2, rowspan=irow, columnspan=2, sticky=NS)
128
        self.listbox.bind('<ButtonRelease-1>', self.select)
129

  
130
        scrollbar.config(command=self.listbox.yview)
131
        scrollbar.grid(row=0, column=4, rowspan=irow, sticky=NS)
132
       
133
        for item in self.definitions:
134
            self.listbox.insert(END, item.name)
135
        
136
    def select(self, event):
137
        selection=self.listbox.curselection()
138
        if len(selection) == 1:
139
            self.curr_definition=deepcopy(self.definitions[int(selection[0])])
140
            for (key, text, textfield) in self.entries:
141
                text.set(self.curr_definition.getValue(key))
142
        self.mainWnd.preview()
143
    
144
    def getSelection(self):
145
        return self.curr_definition
146
        
147
    def update(self, event):
148
        for (key, text, textfield) in self.entries:
149
            self.curr_definition.keywords[key]=text.get()
150
        self.mainWnd.preview()
151

  
152
class MainWindow(Frame):
153
    frames=[]
154
    text=None
155
    def __init__(self, master):
156
        Frame.__init__(self, master)
157
        
158
        #--- Structures ---
159
        bigFrame = LabelFrame(self, text='Structures')
160
        irow=0; icol=0
161
        def_list=[EmbedStrDefinition()]
162
        extras=['method', 'method.options', 'calculator']
163
        frame=MyLabelFrame(self, bigFrame, 'Embed', def_list, extras)
164
        frame.doLayout()
165
        frame.grid(row=irow, column=icol)
166
        self.frames.append(frame)
167

  
168
        icol+=1;
169
        def_list=[VASPStrDefinition(), TURBOMOLEStrDefintion()]
170
        for label in ['Cluster', 'System']:
171
            extras = ['cell']
172
            frame=MyLabelFrame(self, bigFrame, label, def_list, extras)
173
            frame.doLayout()
174
            frame.grid(row=irow, column=icol)
175
            self.frames.append(frame)
176
            icol+=1
177
        bigFrame.grid(row=0, columnspan=3)
178

  
179
        #--- Methods ---
180
        bigFrame = LabelFrame(self, text='Methods')
181
        irow=0; icol=0
182
        def_list=[QmxPrgDefinition()]
183
        frame=MyLabelFrame(self, bigFrame, 'Qmx', def_list)
184
        frame.doLayout()
185
        frame.grid(row=irow, column=icol)
186
        self.frames.append(frame)
187

  
188
        icol+=1
189
        def_list=[VASPPrgDefinition(), TURBOMOLEPrgDefinition()]
190
        for label in ['High-Level', 'Low-Level']:
191
            def_list=[VASPPrgDefinition(), TURBOMOLEPrgDefinition()]
192
            frame=MyLabelFrame(self, bigFrame, label, def_list)
193
            frame.doLayout()
194
            frame.grid(row=irow, column=icol)
195
            self.frames.append(frame)
196
            icol+=1
197
        bigFrame.grid(row=1, columnspan=3)
198
        
199
        #--- General ---
200
        bigFrame = LabelFrame(self, text='General')
201
        extras=['method', 'method.options']
202
        frame=MyLabelFrame(self, bigFrame, 'Job', [QNJobDefintion()], extras)
203
        frame.doLayout()
204
        frame.grid()
205
        self.frames.append(frame)
206
        bigFrame.grid(row=2, sticky=NW)
207

  
208
        frame=LabelFrame(self, text="PREVIEW")
209
        scrollbar=Scrollbar(frame, orient=VERTICAL)
210
        scrollbar.set(0.0, 1.0)
211
        self.text=Text(frame, yscrollcommand=scrollbar.set, width=60, heigh=10, state=DISABLED)
212
        self.text.grid(sticky=(N+W+S+E))
213
        scrollbar.config(command=self.text.yview)
214
        scrollbar.grid(row=0, column=1, sticky=NS)        
215
        frame.grid(row=2, column=1)
216

  
217
        frame = Frame(self)
218
        buttonSave=Button(frame, text='save settings', state=DISABLED)
219
        buttonSave.grid(row=1, sticky=(EW))
220

  
221
        buttonPrint=Button(frame, text='Write qmx.py input file', command=self.writeButton)
222
        buttonPrint.grid(row=2, sticky=EW)
223

  
224
        frame.grid(row=2, column=2, sticky=SE)
225

  
226
        #--- MainWindow ---
227
        self.grid(sticky=(W+N+S+E))
228
        self.preview()
229
    
230
    def writeButton(self):
231
        file = open("data","w")
232
        self.writeData(file)
233
        file.close()
234

  
235
    def writeData(self, stream):
236
        keys=['import']
237
        definitions=[]
238

  
239
        for frame in self.frames:
240
            definition = frame.getSelection()
241
            if definition is not None:
242
                definitions.append(definition)
243

  
244
        arrImports=[]
245
        for definition in definitions:
246
            strClass=definition.getValue('class')
247
            strImport=definition.getValue('import')
248
            
249
            if (strClass is not '' and strImport is not ''):
250
                s='from '+strImport+' import '+strClass+'\n'
251
                if not s in arrImports:
252
                    stream.write(s)
253
                    arrImports.append(s)
254

  
255
        stream.write("\n")
256
        for name in ['High-Level', 'Low-Level', 'Qmx']:
257
            for definition in definitions:
258
                if definition.system != name:
259
                    continue
260
                strSystem=definition.system.lower().replace("-", "_")
261
                strClass=definition.getValue('class')
262
                strOptions=definition.getValue('class.options')
263

  
264
                if (strClass is not ''):
265
                    stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
266

  
267
        stream.write("\n")
268
        for name in ['System', 'Cluster', 'Embed']:
269
            for definition in definitions:
270
                if definition.system != name:
271
                    continue
272
                strSystem=definition.system.lower()
273
                strClass=definition.getValue('class')
274
                strOptions=definition.getValue('class.options')
275

  
276
                if (strClass is not ''):
277
                    stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
278
                    
279
                if name is 'Embed':
280
                    strMethod=definition.getValue('method')
281
                    strOptions=definition.getValue('method.options')
282
                    stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
283

  
284
                    strOptions=definition.getValue('calculator')
285
                    stream.write(strSystem+'.set_calculator('+strOptions+')\n')
286
            
287
        stream.write("\n")
288
        for definition in definitions:
289
            if (definition.system == 'Job'):
290
                strSystem=definition.system.lower()
291
                strMethod=definition.getValue('method')
292
                strOptions=definition.getValue('method.options')
293
                stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
294
                
295
    def preview(self):
296
        stream = StringIO.StringIO()
297
        self.writeData(stream)
298
        s = stream.getvalue()
299
        
300
        if self.text is not None:
301
            pos, end = self.text.yview()
302
            self.text.config(state=NORMAL)
303
            self.text.delete(1.0, END)
304
            self.text.insert(END, s)
305
            self.text.config(state=DISABLED)
306
            self.text.yview(MOVETO, pos)
307

  
308
print
309
mainWnd=MainWindow(Tk())
310
mainWnd.mainloop()
prepareQMX/qmxSTR.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# definition of STRUCTURES for qmx-setup
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
from qmxDEF import Definition
11

  
12
#-------------------------------------------------------------------------------
13
#--- STR DEFINITIONS -----------------------------------------------------------
14
#-------------------------------------------------------------------------------
15
class VASPStrDefinition(Definition):
16
    def __init__(self):
17
        self.name='VASP'
18
        self.keywords = {}
19
        self.keywords['import']='ase.io.vasp'
20
        self.keywords['class']='read_vasp'
21
        self.keywords['class.options']='POSCAR'
22
    
23
#-------------------------------------------------------------------------------
24
class TURBOMOLEStrDefintion(Definition):
25
    def __init__(self):
26
        self.name='TURBOMOLE'
27
        self.keywords = {}
28
        self.keywords['import']='ase.io.turbomole'
29
        self.keywords['class']='read_turbomole'
30
        self.keywords['class.options']='coord'
31

  
32
#-------------------------------------------------------------------------------
33
strDefinitions = [VASPStrDefinition(), TURBOMOLEStrDefintion()]
0 34

  
prepareQMX/qmxJOB.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# definition of JOBS for qmx-setup
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
from qmxDEF import Definition
11

  
12
#-------------------------------------------------------------------------------
13
#--- JOB DEFINITIONS -----------------------------------------------------------
14
#-------------------------------------------------------------------------------
15
class QNJobDefintion(Definition):
16
    def __init__(self):
17
        self.name='QuasiNewton'
18
        self.keywords = {}
19
        self.keywords['import']='ase.optimize'
20
        self.keywords['class']= 'QuasiNewton'
21
        self.keywords['class.options']= 'trajectory="embed.traj"'
22
        self.keywords['method']='run'
23
        self.keywords['method.options']='fmax=0.01, steps=100'
24

  
25
#-------------------------------------------------------------------------------
26
jobDefinitions = [QNJobDefintion()]
0 27

  
prepareQMX/qmxWRITE.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# GRAPHICAL interface for setup of QMX calculations
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
import StringIO
11

  
12
def writeData(stream, definitions):
13
    stream.write("#!/usr/bin/env python\n")
14
    keys=['import']
15

  
16
    arrImports=[]
17
    for definition in definitions:
18
        strClass=definition.getValue('class')
19
        strImport=definition.getValue('import')
20
        
21
        if (strClass is not '' and strImport is not ''):
22
            s='from '+strImport+' import '+strClass+'\n'
23
            if not s in arrImports:
24
                stream.write(s)
25
                arrImports.append(s)
26

  
27
    stream.write("\n")
28
    for name in ['high-level', 'low-level', 'qmx']:
29
        for definition in definitions:
30
            if definition.system.lower() != name:
31
                continue
32
            strSystem=definition.system.lower().replace("-", "_")
33
            strClass=definition.getValue('class')
34
            strOptions=definition.getValue('class.options')
35

  
36
            if (strClass is not ''):
37
                stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
38

  
39
    stream.write("\n")
40
    for name in ['system', 'cluster', 'embed']:
41
        for definition in definitions:
42
            if definition.system.lower() != name:
43
                continue
44
            strSystem=definition.system.lower()
45
            strClass=definition.getValue('class')
46
            strOptions=definition.getValue('class.options')
47

  
48
            if (strClass is not ''):
49
                stream.write(strSystem+'='+strClass+"('"+strOptions+"')\n")
50
                
51
            if name is 'embed':
52
                strMethod=definition.getValue('method')
53
                strOptions=definition.getValue('method.options')
54
                stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
55

  
56
                strOptions=definition.getValue('calculator')
57
                stream.write(strSystem+'.set_calculator('+strOptions+')\n')
58
        
59
    stream.write("\n")
60
    for definition in definitions:
61
        if (definition.system.lower() == 'job'):
62
            strSystem=definition.system.lower()
63
            strClass=definition.getValue('class')
64
            strOptions=definition.getValue('class.options')
65
            if (strOptions is not ''):
66
                strOptions = ', ' + strOptions
67
            
68
            if (strClass is not ''):
69
                stream.write(strSystem+'='+strClass+'(embed'+strOptions+')\n')
70

  
71
            strSystem=definition.system.lower()
72
            strMethod=definition.getValue('method')
73
            strOptions=definition.getValue('method.options')
74
            stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
0 75

  
prepareQMX/qmxEMBED.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# definition of EMBED for qmx-setup
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
from qmxDEF import Definition
11

  
12
#-------------------------------------------------------------------------------
13
#--- EMBED DEFINITIONS ---------------------------------------------------------
14
#-------------------------------------------------------------------------------
15
class EmbedDefinition(Definition):
16
    def __init__(self):
17
        self.name='Embed'
18
        self.system='Embed'
19
        self.keywords = {}
20
        self.keywords['import']='ase.embed'
21
        self.keywords['class']='Embed'
22
        self.keywords['class.options']='system, cluster, cell_cluster="Auto"'
23
        self.keywords['method']='embed'
24
        self.keywords['calculator']='qmx'
25

  
26
#-------------------------------------------------------------------------------
27
embedDefinitions = [EmbedDefinition()]
0 28

  
prepareQMX/qmx.in (revision 10)
1
high-level.program : TURBOMOLE
2
high-level.options : opt
3
low-level.program : VASP
4

  
5
cluster.program : TURBOMOLE
6
cluster.options : clusterX
7
system.program : VASP
8

  
9

  
10
job.program : QuasiNewton 
prepareQMX/prepareQMX.py (revision 10)
1
#!/usr/bin/env python
2
import os, sys
3
from optparse import OptionParser
4

  
5
class Data:
6
    def __init__(self, name):
7
        self.__name__ = name
8
        self.str_option = ""
9
        self.str_import = None
10
        self.str_class  = None
11
        self.str_methods = []
12
        self.str_structure = None
13
                
14
    def __str__(self):
15
       return self.__name__
16

  
17
def getline(section, subsection, lines):
18
    nline = -1
19
    for iline in xrange(len(lines)):
20
        if lines[iline][0].strip() == subsection:
21
            if nline != -1:
22
                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
23
                sys.exit(1)
24
            nline = iline
25
    if nline == -1:
26
        return None
27
    return lines[nline][1].strip()
28

  
29
def analyzeAtoms(section, lines):
30
    data = Data(section)
31
    line = getline(section, "program", lines)
32
    if line is None:
33
        line=""
34
    if line.lower() == "turbomole":
35
        data.str_import = "from ase.io.turbomole import read_turbomole"
36
        data.str_class = "read_turbomole"
37
    elif line.lower() == "vasp":
38
        data.str_import = "from ase.io.vasp import read_vasp"
39
        data.str_class = "read_vasp"
40
        
41
    data.str_structure = getline(section, "structure", lines)
42
    return data
43

  
44
def analyzeCalculator(section, lines):
45
    data = Data(section)
46
    #read programs
47
    line = getline(section, "program", lines)
48
    if line.lower() == "turbomole":
49
        data.str_import = "from ase.calculators.turbomole import Turbomole"
50
        data.str_class = "Turbomole"
51
    elif line.lower() == "vasp":
52
        data.str_import = "from ase.calculators.vasp import Vasp"
53
        data.str_class = "Vasp"
54
    
55
    str = getline(section, "class", lines)
56
    if str is not None:
57
        data.str_class = str
58

  
59
    str = getline(section, "import", lines)
60
    if str is not None:
61
        data.str_import = str
62

  
63
    str = getline(section, "options", lines)
64
    if str is not None:
65
        data.str_option = str
66
    return data
67

  
68
def analyzeDynamics(section, lines):
69
    data = Data(section)
70
    line = getline(section, "method", lines)
71
    if line.lower() == "optimizer":
72
        data.str_import = "from ase.optimize import QuasiNewton"
73
        data.str_class = "QuasiNewton"
74
    return data
75

  
76
#--- setting default values ------------------------------------------------------------------------
77
#define separators
78
separator=":"
79
subseparator="."
80
lineseparator="\n"
81

  
82
#--- parse arguments -------------------------------------------------------------------------------
83
#parse arguments (python 2.6)
84
parser = OptionParser()
85
parser.add_option("-i", "--infile",  dest="inputFile",  help="specifies the input file", metavar="FILE", default="qmx.in")
86
parser.add_option("-o", "--outfile", dest="outputFile", help="specifies the output file", metavar="FILE")
87
parser.add_option("-f", action="store_true", dest="overwrite")
88
(options, args) = parser.parse_args()
89

  
90
file=open(options.inputFile, "r")
91
lines = file.readlines()
92
file.close()
93

  
94

  
95
#--- split intput file -----------------------------------------------------------------------------
96

  
97
#--- remove comments -------------------------------------------------------------------------------
98
for iline in xrange(len(lines)):
99
    lines[iline] = lines[iline].split("#")[0]    
100

  
101
#--- collect data in class -------------------------------------------------------------------------
102
data_collection=[]
103

  
104
#--- settings for QMX class ------------------------------------------------------------------------
105
data = Data("qmx")
106
data.str_class = "Qmx"
107
data.str_import = "from ase.calculators.qmx import Qmx"
108
data.str_option = "highLevel, lowLevel"
109

  
110
data_collection.append(data)
111

  
112
#--- settings for Embed class ----------------------------------------------------------------------
113
data = Data("embed")
114
data.str_class = "Embed"
115
data.str_import = "from ase.embed import Embed"
116
data.str_option = "system, cluster"
117
data.str_methods = ["embed()", "set_calculator(qmx)"]
118

  
119
data_collection.append(data)
120

  
121

  
122
#--- analyze the input file ------------------------------------------------------------------------
123
for section in "high-level", "low-level", "cluster", "system", "dynamics":
124
    #search lines for section
125
    lines_section=[]
126
    for line in lines:
127
        line = line.split(separator)
128
        if line[0].find(section) >= 0:
129
            line[0] = line[0].replace(section+subseparator, "")
130
            lines_section.append(line)
131
    
132
    #calculators
133
    if section == "high-level" or section == "low-level":
134
        data_collection.append(analyzeCalculator(section, lines_section))
135
        
136
    #systems
137
    if section == "cluster" or section == "system":
138
        data_collection.append(analyzeAtoms(section, lines_section))
139
        
140
    #dynamics
141
    if section == "dynamics":
142
        data_collection.append(analyzeDynamics(section, lines_section))
143

  
144
#--- write output file -----------------------------------------------------------------------------
145
if options.outputFile is not None and os.path.exists(options.outputFile) and not options.overwrite:
146
    sys.stderr.write(lineseparator+"the output file <"+options.outputFile+"> already exists"+lineseparator)
147
    sys.exit(1)
148

  
149
output = None
150
if options.outputFile is None:
151
    output=sys.stdout
152
else:
153
    output=open(options.outputFile, "w")
154

  
155
#--- write header ----------------------------------------------------------------------------------
156
output.write("#!/usr/bin/env python\n")
157

  
158
#--- write import lines ----------------------------------------------------------------------------
159
xlines=[]
160
for data in data_collection:
161
    value = data.str_import
162
    if value is None or value in xlines:
163
        continue
164
    xlines.append(value)
165
    output.write(value+lineseparator)
166
output.write(lineseparator)
167

  
168
#--- define the methods ----------------------------------------------------------------------------
169
for system in 'high', 'low':
170
    for data in data_collection:
171
        if data.__name__ == system+"-level":
172
            output.write(system+"Level = "+data.str_class+"("+data.str_option+")"+lineseparator)
173
output.write(lineseparator)
174

  
175
#--- qmx class (substraction scheme ----------------------------------------------------------------
176
for data in data_collection:
177
    if data.__name__ == "qmx":
178
        output.write("qmx = "+data.str_class+"("+data.str_option+")"+lineseparator)
179
output.write(lineseparator)
180

  
181
#--- read all the systems --------------------------------------------------------------------------
182
for system in "cluster", "system":
183
    for data in data_collection:
184
        if data.__name__ == system:
185
            if data.str_structure is None:
186
                continue
187
            output.write(system+" = "+data.str_class+"(\""+data.str_structure+"\")"+lineseparator)
188
output.write(lineseparator)
189

  
190
#--- embeding class --------------------------------------------------------------------------------
191
for data in data_collection:
192
    if data.__name__ == "embed":
193
        output.write("embed = "+data.str_class+"("+data.str_option+")"+lineseparator)
194
        for method in data.str_methods:
195
            output.write("embed."+method+lineseparator)
196
output.write(lineseparator)
197

  
198
#--- dynamics class --------------------------------------------------------------------------------
199
for data in data_collection:
200
    if data.__name__ == "dynamics":
201
        output.write("dyn="+data.str_class+"(embed)"+lineseparator)
202
        output.write("dyn.run("+data.str_option+")"+lineseparator)
203

  
204
output.close()
205
sys.exit(0)
0 206

  
prepareQMX/qmxDEF.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# GRAPHICAL interface for setup of QMX calculations
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
#-------------------------------------------------------------------------------
11
#--- GENERAL -------------------------------------------------------------------
12
#-------------------------------------------------------------------------------
13
class Definition(object):
14
    def getValue(self, key):
15
        if self.keywords.__contains__(key):
16
            return self.keywords[key]
17
        return ''
18

  
0 19

  
prepareQMX/qmx.py (revision 10)
1
#!/usr/bin/env python
2
from ase.embed import Embed
3
from ase.io.vasp import read_vasp
4
from ase.calculators.qmx import Qmx
5
from ase.calculators.vasp import Vasp
6
from ase.optimize import QuasiNewton
7

  
8
high_level=Vasp(write_input=False)
9
low_level=Vasp(write_input=False)
10
qmx=Qmx(high_level, low_level)
11

  
12
system=read_vasp('POSCAR')
13
cluster=read_vasp('POSCAR')
14
embed=Embed(system, cluster, cell_cluster="Auto")
15
embed.embed()
16
embed.set_calculator(qmx)
17

  
18
job=QuasiNewton(embed, trajectory="embed.traj")
19
job.run(fmax=0.01, steps=100)
0 20

  
prepareQMX/prepareQMX.GUI.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# GRAPHICAL interface for setup of QMX calculations
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
#---------------------------------------------------------------------------------------------------
11
from Tkinter import *
12
from copy import deepcopy
13
import StringIO, os
14

  
15
#---------------------------------------------------------------------------------------------------
16
from qmxEMBED import embedDefinitions
17
from qmxJOB import jobDefinitions
18
from qmxSTR import strDefinitions
19
from qmxCALC import calcDefinitions, QmxCalcDefinition
20

  
21
from qmxWRITE import writeData
22

  
23
#---------------------------------------------------------------------------------------------------
24
#---------------------------------------------------------------------------------------------------
25
#---------------------------------------------------------------------------------------------------
26
class MyLabelFrame(LabelFrame):
27
    def __init__(self, mainWnd, master, title, def_list, extras):
28
        LabelFrame.__init__(self, master, text=title)
29
        self.mainWnd = mainWnd
30
        self.definitions=[]
31
        self.title = title
32

  
33
        for definition in def_list:
34
            definition_new = deepcopy(definition)
35
            definition_new.system = title
36
            self.definitions.append(definition_new)
37

  
38
        fields=['import', 'class', 'class.options']
39
        if extras is not None:
40
            for key in extras:
41
                fields.append(key)
42

  
43
        self.entries=[]
44
        for key in fields:
45
            text=StringVar()
46
            text.set('')
47
            self.entries.append((key, text, Entry(self, textvariable=text, width=15)))
48
            
49
    def grid(self, **arguments):
50
        LabelFrame.grid(self, arguments, sticky=(N+W+E))
51
        self.listbox.selection_set(first=0)
52
        self.select(None)
53
        
54
    def doLayout(self):
55
        irow=0
56
        for (key, text, textfield) in self.entries:
57
            Label(self, text=key, width=15, anchor=W).grid(row=irow)
58
            textfield.grid(row=irow, column=1)
59
            textfield.bind("<KeyRelease>", self.update)
60
            irow+=1
61
        
62
        scrollbar=Scrollbar(self, orient=VERTICAL)
63
        self.listbox=Listbox(self, yscrollcommand=scrollbar.set, height=0, width=15, selectmode=SINGLE)
64
        self.listbox.grid(row=0, column=2, rowspan=irow, columnspan=2, sticky=NS)
65
        self.listbox.bind('<ButtonRelease-1>', self.select)
66

  
67
        scrollbar.config(command=self.listbox.yview)
68
        scrollbar.grid(row=0, column=4, rowspan=irow, sticky=NS)
69
       
70
        for item in self.definitions:
71
            self.listbox.insert(END, item.name)
72
        
73
    def select(self, event):
74
        selection=self.listbox.curselection()
75
        if len(selection) == 1:
76
            self.curr_definition=deepcopy(self.definitions[int(selection[0])])
77
            for (key, text, textfield) in self.entries:
78
                text.set(self.curr_definition.getValue(key))
79
        self.mainWnd.preview()
80
    
81
    def getSelection(self):
82
        return self.curr_definition
83
        
84
    def update(self, event):
85
        for (key, text, textfield) in self.entries:
86
            self.curr_definition.keywords[key]=text.get()
87
        self.mainWnd.preview()
88

  
89
#---------------------------------------------------------------------------------------------------
90
class MainWindow(Frame):
91
    frames=[]
92
    text=None
93
    def __init__(self, master):
94
        Frame.__init__(self, master)
95
        
96
        #--- Structures ---
97
        bigFrame = LabelFrame(self, text='Structures')
98
        irow=0; icol=0
99
        def_list=embedDefinitions
100
        extras=['method', 'method.options', 'calculator']
101
        frame=MyLabelFrame(self, bigFrame, 'Embed', def_list, extras)
102
        frame.doLayout()
103
        frame.grid(row=irow, column=icol)
104
        self.frames.append(frame)
105

  
106
        icol+=1;
107
        for label in ['System', 'Cluster']:
108
            def_list=strDefinitions
109
            frame=MyLabelFrame(self, bigFrame, label, def_list, None)
110
            frame.doLayout()
111
            frame.grid(row=irow, column=icol)
112
            self.frames.append(frame)
113
            icol+=1
114
        bigFrame.grid(row=0, columnspan=3)
115

  
116
        #--- Methods ---
117
        bigFrame = LabelFrame(self, text='Methods')
118
        irow=0; icol=0
119
        def_list=[QmxCalcDefinition()]
120
        frame=MyLabelFrame(self, bigFrame, 'Qmx', def_list, None)
121
        frame.doLayout()
122
        frame.grid(row=irow, column=icol)
123
        self.frames.append(frame)
124

  
125
        icol+=1
126
        for label in ['High-Level', 'Low-Level']:
127
            def_list=calcDefinitions
128
            frame=MyLabelFrame(self, bigFrame, label, def_list, None)
129
            frame.doLayout()
130
            frame.grid(row=irow, column=icol)
131
            self.frames.append(frame)
132
            icol+=1
133
        bigFrame.grid(row=1, columnspan=3)
134
        
135
        #--- General ---
136
        bigFrame = LabelFrame(self, text='General')
137
        extras=['method', 'method.options']
138
        frame=MyLabelFrame(self, bigFrame, 'Job', jobDefinitions, extras)
139
        frame.doLayout()
140
        frame.grid()
141
        self.frames.append(frame)
142
        bigFrame.grid(row=2, sticky=NW)
143

  
144
        frame=LabelFrame(self, text="PREVIEW")
145
        scrollbar=Scrollbar(frame, orient=VERTICAL)
146
        scrollbar.set(0.0, 1.0)
147
        self.text=Text(frame, yscrollcommand=scrollbar.set, width=60, heigh=10, state=DISABLED)
148
        self.text.grid(sticky=(N+W+S+E))
149
        scrollbar.config(command=self.text.yview)
150
        scrollbar.grid(row=0, column=1, sticky=NS)        
151
        frame.grid(row=2, column=1)
152

  
153
        frame = Frame(self)
154

  
155
        image = PhotoImage(file="exit.gif")
156
        buttonExit=Button(frame, image=image, command=self.quit)
157
        buttonExit.image = image
158
        buttonExit.grid(row=1, column = 1, rowspan=2, sticky= W+E+N+S)
159
        
160
        buttonSave=Button(frame, text='save settings', state=DISABLED)
161
        buttonSave.grid(row=1, column = 2, sticky=(EW))
162

  
163
        buttonPrint=Button(frame, text='Write qmx.py input file', command=self.writeButton)
164
        buttonPrint.grid(row=2, column = 2, sticky=EW)
165

  
166
        frame.grid(row=2, column=2, sticky=SE)
167

  
168
        #--- MainWindow ---
169
        self.grid(sticky=(W+N+S+E))
170
        self.preview()
171
        
172
    def quit(self):
173
        quit()
174
    
175
    def writeButton(self):
176
        file = open("qmx.py","w")
177
        definitions=[]
178
        for frame in self.frames:
179
            definition = frame.getSelection()
180
            if definition is not None:
181
                definitions.append(definition)
182

  
183
        writeData(file, definitions)
184
        file.close()
185
        os.system("chmod u+x qmx.py")
186

  
187
    def preview(self):
188
        stream = StringIO.StringIO()
189
        definitions=[]
190
        for frame in self.frames:
191
            definition = frame.getSelection()
192
            if definition is not None:
193
                definitions.append(definition)
194

  
195
        writeData(stream, definitions)
196
        s = stream.getvalue()
197
        
198
        if self.text is not None:
199
            pos, end = self.text.yview()
200
            self.text.config(state=NORMAL)
201
            self.text.delete(1.0, END)
202
            self.text.insert(END, s)
203
            self.text.config(state=DISABLED)
204
            self.text.yview(MOVETO, pos)
205

  
206
#---------------------------------------------------------------------------------------------------
207
mainWnd=MainWindow(Tk())
208
mainWnd.mainloop()
0 209

  
prepareQMX/qmxCALC.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# definition of CALCULATORS for qmx-setup
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
from qmxDEF import Definition
11

  
12
#-------------------------------------------------------------------------------
13
#--- PRG DEFINITIONS -----------------------------------------------------------
14
#-------------------------------------------------------------------------------
15
class VASPCalcDefinition(Definition):
16
    def __init__(self):
17
        self.name='VASP'
18
        self.keywords = {}
19
        self.keywords['import']='ase.calculators.vasp'
20
        self.keywords['class']='Vasp'
21
        self.keywords['class.options']='write_input=False'
22

  
23
#-------------------------------------------------------------------------------
24
class TURBOMOLECalcDefinition(Definition):
25
    def __init__(self):
26
        self.name='TURBOMOLE'
27
        self.keywords = {}
28
        self.keywords['import']='ase.calculators.turbomole'
29
        self.keywords['class']='Turbomole'
30

  
31
#-------------------------------------------------------------------------------
32
class MOPACCalcDefinition(Definition):
33
    def __init__(self):
34
        self.name='MOPAC'
35
        self.keywords = {}
36
        self.keywords['import']='ase.calculators.mopac'
37
        self.keywords['class']='Mopac'
38
        self.keywords['class.options']='functional="PM6"'
39

  
40
#-------------------------------------------------------------------------------
41
class QmxCalcDefinition(Definition):
42
    def __init__(self):
43
        self.name='QMX'
44
        self.system='Qmx'
45
        self.keywords = {}
46
        self.keywords['import']='ase.calculators.qmx'
47
        self.keywords['class']='Qmx'
48
        self.keywords['class.options']='high_level, low_level'
49

  
50
#-------------------------------------------------------------------------------
51
calcDefinitions = [VASPCalcDefinition(), TURBOMOLECalcDefinition(), MOPACCalcDefinition()]
0 52

  
prepareQMX/prepareQMX.new.py (revision 10)
1
#!/usr/bin/env python
2

  
3
# command line interface for setup of QMX calculations
4
#
5
# Torsten Kerber, ENS LYON: 2011, 07, 11
6
#
7
# This work is supported by Award No. UK-C0017, made by King Abdullah
8
# University of Science and Technology (KAUST)
9

  
10
#---------------------------------------------------------------------------------------------------
11
import os, sys
12
from copy import deepcopy
13
from optparse import OptionParser
14

  
15
#---------------------------------------------------------------------------------------------------
16
from qmxEMBED import embedDefinitions
17
from qmxJOB  import jobDefinitions
18
from qmxSTR  import strDefinitions
19
from qmxCALC import calcDefinitions, QmxCalcDefinition
20

  
21
from qmxWRITE import writeData
22

  
23
#---------------------------------------------------------------------------------------------------
24
#---------------------------------------------------------------------------------------------------
25
#---------------------------------------------------------------------------------------------------
26
def getline(section, subsection, lines):
27
    nline = -1
28
    for iline in xrange(len(lines)):
29
        if lines[iline][0].strip() == subsection:
30
            if nline != -1:
31
                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
32
                sys.exit(1)
33
            nline = iline
34
    if nline == -1:
35
        return None
36
    return lines[nline][1].strip()
37

  
38
#---------------------------------------------------------------------------------------------------
39
def analyzeSection(definitions, section, lines):
40
    line = getline(section, "program", lines)
41
    if line is None:
42
        print "section <" + section + "> does not contain program"
43
        sys.exit(1)
44
        
45
    myDefinition = None
46
    for definition in definitions:
47
        if definition.name == line:
48
            myDefinition = deepcopy(definition)
49
            break
50
            
51
    if myDefinition is None:
52
        print "the program <" + line + "> is not defined for the section <" + section + ">"
53
        sys.exit(1)
54
        
55
    myDefinition.system = section
56

  
57
    subsections = []
58
    for line in lines:
59
        subsections.append(line[0].strip().lower())
60

  
61
    for subsection in subsections:
62
        line = getline(section, subsection, lines)
63
        if line is None:
64
            print "input error in <"+section+"."+subsection+">"
65
            sys.exit(1)
66
        if subsection == "program":
67
            continue
68
        if subsection == "options":
69
            subsection = 'class.options'
70
        
71
        myDefinition.keywords[subsection] = line    
72
        print subsection, myDefinition.keywords[subsection]
73
    
74
    return myDefinition
75

  
76
#---------------------------------------------------------------------------------------------------
77
#--- setting default values ------------------------------------------------------------------------
78
#---------------------------------------------------------------------------------------------------
79

  
80
#define separators
81
separator=":"
82
subseparator="."
83
lineseparator="\n"
84

  
85
#--- parse arguments -------------------------------------------------------------------------------
86
#parse arguments (python 2.6)
87
parser = OptionParser()
88
parser.add_option("-i", "--infile",  dest="inputFile",  help="specifies the input file", metavar="FILE", default="qmx.in")
89
parser.add_option("-o", "--outfile", dest="outputFile", help="specifies the output file", metavar="FILE")
90
parser.add_option("-f", action="store_true", dest="overwrite")
91
(options, args) = parser.parse_args()
92

  
93
#--- check wether output file exists ---------------------------------------------------------------
94
if options.outputFile is not None and os.path.exists(options.outputFile) and not options.overwrite:
95
    sys.stderr.write(lineseparator+"the output file <"+options.outputFile+"> already exists"+lineseparator)
96
    sys.exit(1)
97

  
98
#--- read intput file ------------------------------------------------------------------------------
99
file=open(options.inputFile, "r")
100
lines = file.readlines()
101
file.close()
102

  
103
#--- remove comments -------------------------------------------------------------------------------
104
for iline in xrange(len(lines)):
105
    lines[iline] = lines[iline].split("#")[0]    
106

  
107
#--- collect data in class -------------------------------------------------------------------------
108
definitions=[]
109
definitions.append(QmxCalcDefinition())
110

  
111
#--- analyze the input file ------------------------------------------------------------------------
112
for section in "high-level", "low-level", "cluster", "system", "job":
113
    #search lines for section
114
    lines_section=[]
115
    for line in lines:
116
        line = line.split(separator)
117
        if line[0].find(section) >= 0:
118
            line[0] = line[0].replace(section+subseparator, "")
119
            lines_section.append(line)
120

  
121
    #calculators
122
    if section == "high-level" or section == "low-level":
123
        definitions.append(analyzeSection(calcDefinitions, section, lines_section))
124
        
125
    #structures (atoms)
126
    if section == "cluster" or section == "system":
127
        definitions.append(analyzeSection(strDefinitions, section, lines_section))
128
        
129
    #job
130
    if section == "job":
131
        definitions.append(analyzeSection(jobDefinitions, section, lines_section))
132
        
133
    #embed
134
    if section == "embed":
135
        definitions.append(analyzeSection(embedDefinitions, section, lines_section))
136

  
137
output = None
138
if options.outputFile is None:
139
    output=sys.stdout
140
else:
141
    output=open(options.outputFile, "w")
142
    
143
writeData(output, definitions)
144
output.close()
145

  
146

  
147

  
148

  
149

  
150

  
151

  
152
#
153
##--- write header ----------------------------------------------------------------------------------
154
#output.write("#!/usr/bin/env python\n")
155
#
156
##--- write import lines ----------------------------------------------------------------------------
157
#xlines=[]
158
#for data in data_collection:
159
#    value = data.str_import
160
#    if value is None or value in xlines:
161
#        continue
162
#    xlines.append(value)
163
#    output.write(value+lineseparator)
164
#output.write(lineseparator)
165
#
166
##--- define the methods ----------------------------------------------------------------------------
167
#for system in 'high', 'low':
168
#    for data in data_collection:
169
#        if data.__name__ == system+"-level":
170
#            output.write(system+"Level = "+data.str_class+"("+data.str_option+")"+lineseparator)
171
#output.write(lineseparator)
172
#
173
##--- qmx class (substraction scheme ----------------------------------------------------------------
174
#for data in data_collection:
175
#    if data.__name__ == "qmx":
176
#        output.write("qmx = "+data.str_class+"("+data.str_option+")"+lineseparator)
177
#output.write(lineseparator)
178
#
179
##--- read all the systems --------------------------------------------------------------------------
180
#for system in "cluster", "system":
181
#    for data in data_collection:
182
#        if data.__name__ == system:
183
#            if data.str_structure is None:
184
#                continue
185
#            output.write(system+" = "+data.str_class+"(\""+data.str_structure+"\")"+lineseparator)
186
#output.write(lineseparator)
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff