Index: prepareQMX.py
===================================================================
--- prepareQMX.py	(revision 9)
+++ prepareQMX.py	(revision 10)
@@ -1,205 +0,0 @@
-#!/usr/bin/env python
-import os, sys
-from optparse import OptionParser
-
-class Data:
-    def __init__(self, name):
-        self.__name__ = name
-        self.str_option = ""
-        self.str_import = None
-        self.str_class  = None
-        self.str_methods = []
-        self.str_structure = None
-                
-    def __str__(self):
-       return self.__name__
-
-def getline(section, subsection, lines):
-    nline = -1
-    for iline in xrange(len(lines)):
-        if lines[iline][0].strip() == subsection:
-            if nline != -1:
-                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
-                sys.exit(1)
-            nline = iline
-    if nline == -1:
-        return None
-    return lines[nline][1].strip()
-
-def analyzeAtoms(section, lines):
-    data = Data(section)
-    line = getline(section, "program", lines)
-    if line is None:
-        line=""
-    if line.lower() == "turbomole":
-        data.str_import = "from ase.io.turbomole import read_turbomole"
-        data.str_class = "read_turbomole"
-    elif line.lower() == "vasp":
-        data.str_import = "from ase.io.vasp import read_vasp"
-        data.str_class = "read_vasp"
-        
-    data.str_structure = getline(section, "structure", lines)
-    return data
-
-def analyzeCalculator(section, lines):
-    data = Data(section)
-    #read programs
-    line = getline(section, "program", lines)
-    if line.lower() == "turbomole":
-        data.str_import = "from ase.calculators.turbomole import Turbomole"
-        data.str_class = "Turbomole"
-    elif line.lower() == "vasp":
-        data.str_import = "from ase.calculators.vasp import Vasp"
-        data.str_class = "Vasp"
-    
-    str = getline(section, "class", lines)
-    if str is not None:
-        data.str_class = str
-
-    str = getline(section, "import", lines)
-    if str is not None:
-        data.str_import = str
-
-    str = getline(section, "options", lines)
-    if str is not None:
-        data.str_option = str
-    return data
-
-def analyzeDynamics(section, lines):
-    data = Data(section)
-    line = getline(section, "method", lines)
-    if line.lower() == "optimizer":
-        data.str_import = "from ase.optimize import QuasiNewton"
-        data.str_class = "QuasiNewton"
-    return data
-
-#--- setting default values ------------------------------------------------------------------------
-#define separators
-separator=":"
-subseparator="."
-lineseparator="\n"
-
-#--- parse arguments -------------------------------------------------------------------------------
-#parse arguments (python 2.6)
-parser = OptionParser()
-parser.add_option("-i", "--infile",  dest="inputFile",  help="specifies the input file", metavar="FILE", default="qmx.in")
-parser.add_option("-o", "--outfile", dest="outputFile", help="specifies the output file", metavar="FILE")
-parser.add_option("-f", action="store_true", dest="overwrite")
-(options, args) = parser.parse_args()
-
-file=open(options.inputFile, "r")
-lines = file.readlines()
-file.close()
-
-
-#--- split intput file -----------------------------------------------------------------------------
-
-#--- remove comments -------------------------------------------------------------------------------
-for iline in xrange(len(lines)):
-    lines[iline] = lines[iline].split("#")[0]    
-
-#--- collect data in class -------------------------------------------------------------------------
-data_collection=[]
-
-#--- settings for QMX class ------------------------------------------------------------------------
-data = Data("qmx")
-data.str_class = "Qmx"
-data.str_import = "from ase.calculators.qmx import Qmx"
-data.str_option = "highLevel, lowLevel"
-
-data_collection.append(data)
-
-#--- settings for Embed class ----------------------------------------------------------------------
-data = Data("embed")
-data.str_class = "Embed"
-data.str_import = "from ase.embed import Embed"
-data.str_option = "system, cluster"
-data.str_methods = ["embed()", "set_calculator(qmx)"]
-
-data_collection.append(data)
-
-
-#--- analyze the input file ------------------------------------------------------------------------
-for section in "high-level", "low-level", "cluster", "system", "dynamics":
-    #search lines for section
-    lines_section=[]
-    for line in lines:
-        line = line.split(separator)
-        if line[0].find(section) >= 0:
-            line[0] = line[0].replace(section+subseparator, "")
-            lines_section.append(line)
-    
-    #calculators
-    if section == "high-level" or section == "low-level":
-        data_collection.append(analyzeCalculator(section, lines_section))
-        
-    #systems
-    if section == "cluster" or section == "system":
-        data_collection.append(analyzeAtoms(section, lines_section))
-        
-    #dynamics
-    if section == "dynamics":
-        data_collection.append(analyzeDynamics(section, lines_section))
-
-#--- write output file -----------------------------------------------------------------------------
-if options.outputFile is not None and os.path.exists(options.outputFile) and not options.overwrite:
-    sys.stderr.write(lineseparator+"the output file <"+options.outputFile+"> already exists"+lineseparator)
-    sys.exit(1)
-
-output = None
-if options.outputFile is None:
-    output=sys.stdout
-else:
-    output=open(options.outputFile, "w")
-
-#--- write header ----------------------------------------------------------------------------------
-output.write("#!/usr/bin/env python\n")
-
-#--- write import lines ----------------------------------------------------------------------------
-xlines=[]
-for data in data_collection:
-    value = data.str_import
-    if value is None or value in xlines:
-        continue
-    xlines.append(value)
-    output.write(value+lineseparator)
-output.write(lineseparator)
-
-#--- define the methods ----------------------------------------------------------------------------
-for system in 'high', 'low':
-    for data in data_collection:
-        if data.__name__ == system+"-level":
-            output.write(system+"Level = "+data.str_class+"("+data.str_option+")"+lineseparator)
-output.write(lineseparator)
-
-#--- qmx class (substraction scheme ----------------------------------------------------------------
-for data in data_collection:
-    if data.__name__ == "qmx":
-        output.write("qmx = "+data.str_class+"("+data.str_option+")"+lineseparator)
-output.write(lineseparator)
-
-#--- read all the systems --------------------------------------------------------------------------
-for system in "cluster", "system":
-    for data in data_collection:
-        if data.__name__ == system:
-            if data.str_structure is None:
-                continue
-            output.write(system+" = "+data.str_class+"(\""+data.str_structure+"\")"+lineseparator)
-output.write(lineseparator)
-
-#--- embeding class --------------------------------------------------------------------------------
-for data in data_collection:
-    if data.__name__ == "embed":
-        output.write("embed = "+data.str_class+"("+data.str_option+")"+lineseparator)
-        for method in data.str_methods:
-            output.write("embed."+method+lineseparator)
-output.write(lineseparator)
-
-#--- dynamics class --------------------------------------------------------------------------------
-for data in data_collection:
-    if data.__name__ == "dynamics":
-        output.write("dyn="+data.str_class+"(embed)"+lineseparator)
-        output.write("dyn.run("+data.str_option+")"+lineseparator)
-
-output.close()
-sys.exit(0)
Index: prepareQMX.GUI.py
===================================================================
--- prepareQMX.GUI.py	(revision 9)
+++ prepareQMX.GUI.py	(revision 10)
@@ -1,310 +0,0 @@
-#!/usr/bin/env python
-from Tkinter import *
-from copy import deepcopy
-import StringIO
-
-#-------------------------------------------------------------------------------
-#--- GENERAL -------------------------------------------------------------------
-#-------------------------------------------------------------------------------
-class Definition(object):
-    def getValue(self, key):
-        if self.keywords.__contains__(key):
-            return self.keywords[key]
-        return ''
-        
-#-------------------------------------------------------------------------------
-#--- STR DEFINITIONS -----------------------------------------------------------
-#-------------------------------------------------------------------------------
-class VASPStrDefinition(Definition):
-    def __init__(self):
-        self.name='VASP'
-        self.keywords = {}
-        self.keywords['import']='ase.io.vasp'
-        self.keywords['class']='read_vasp'
-        self.keywords['class.options']="'POSCAR'"
-    
-#-------------------------------------------------------------------------------
-class TURBOMOLEStrDefintion(Definition):
-    def __init__(self):
-        self.name='TURBOMOLE'
-        self.keywords = {}
-        self.keywords['import']='ase.io.turbomole'
-        self.keywords['class']='read_turbomole'
-        self.keywords['class.options']="'coord'"
-
-#-------------------------------------------------------------------------------
-class EmbedStrDefinition(Definition):
-    def __init__(self):
-        self.name='Embed'
-        self.system='Embed'
-        self.keywords = {}
-        self.keywords['import']='ase.embed'
-        self.keywords['class']='Embed'
-        self.keywords['class.options']='system, cluster'
-        self.keywords['method']='embed'
-        self.keywords['calculator']='qmx'
-
-#-------------------------------------------------------------------------------
-#--- PRG DEFINITIONS -----------------------------------------------------------
-#-------------------------------------------------------------------------------
-class VASPPrgDefinition(Definition):
-    def __init__(self):
-        self.name='VASP'
-        self.keywords = {}
-        self.keywords['import']='ase.calculators.vasp'
-        self.keywords['class']='Vasp'
-        self.keywords['class.options']='write_input=False'
-
-#-------------------------------------------------------------------------------
-class QmxPrgDefinition(Definition):
-    def __init__(self):
-        self.name='QMX'
-        self.keywords = {}
-        self.keywords['import']='ase.calculators.qmx'
-        self.keywords['class']='Qmx'
-        self.keywords['class.options']='high_level, low_level'
-
-#-------------------------------------------------------------------------------
-class TURBOMOLEPrgDefinition(Definition):
-    def __init__(self):
-        self.name='TURBOMOLE'
-        self.keywords = {}
-        self.keywords['import']='ase.calculators.turbomole'
-        self.keywords['class']='Turbomole'
-
-#-------------------------------------------------------------------------------
-#--- JOB DEFINITIONS -----------------------------------------------------------
-#-------------------------------------------------------------------------------
-class QNJobDefintion(Definition):
-    def __init__(self):
-        self.name='QuasiNewton'
-        self.keywords = {}
-        self.keywords['import']='ase.optimize'
-        self.keywords['class']= 'QuasiNewton'
-        self.keywords['method']='run'
-
-#-------------------------------------------------------------------------------
-#-------------------------------------------------------------------------------
-#-------------------------------------------------------------------------------
-
-class MyLabelFrame(LabelFrame):
-    def __init__(self, mainWnd, master, title, def_list, extra=[]):
-        LabelFrame.__init__(self, master, text=title)
-        self.mainWnd = mainWnd
-        self.definitions=[]
-        self.title = title
-
-        for definition in def_list:
-            definition_new = deepcopy(definition)
-            definition_new.system = title
-            self.definitions.append(definition_new)
-
-        fields=['import', 'class', 'class.options']
-        for key in extra:
-            fields.append(key)
-
-        self.entries=[]
-        for key in fields:
-            text=StringVar()
-            text.set('')
-            self.entries.append((key, text, Entry(self, textvariable=text, width=15)))
-            
-    def grid(self, **arguments):
-        LabelFrame.grid(self, arguments, sticky=(N+W+E))
-        self.listbox.selection_set(first=0)
-        self.select(None)
-        
-    def doLayout(self):
-        irow=0
-        for (key, text, textfield) in self.entries:
-            Label(self, text=key, width=15, anchor=W).grid(row=irow)
-            textfield.grid(row=irow, column=1)
-            textfield.bind("<KeyRelease>", self.update)
-            irow+=1
-        
-        scrollbar=Scrollbar(self, orient=VERTICAL)
-        self.listbox=Listbox(self, yscrollcommand=scrollbar.set, height=0, width=15, selectmode=SINGLE)
-        self.listbox.grid(row=0, column=2, rowspan=irow, columnspan=2, sticky=NS)
-        self.listbox.bind('<ButtonRelease-1>', self.select)
-
-        scrollbar.config(command=self.listbox.yview)
-        scrollbar.grid(row=0, column=4, rowspan=irow, sticky=NS)
-       
-        for item in self.definitions:
-            self.listbox.insert(END, item.name)
-        
-    def select(self, event):
-        selection=self.listbox.curselection()
-        if len(selection) == 1:
-            self.curr_definition=deepcopy(self.definitions[int(selection[0])])
-            for (key, text, textfield) in self.entries:
-                text.set(self.curr_definition.getValue(key))
-        self.mainWnd.preview()
-    
-    def getSelection(self):
-        return self.curr_definition
-        
-    def update(self, event):
-        for (key, text, textfield) in self.entries:
-            self.curr_definition.keywords[key]=text.get()
-        self.mainWnd.preview()
-
-class MainWindow(Frame):
-    frames=[]
-    text=None
-    def __init__(self, master):
-        Frame.__init__(self, master)
-        
-        #--- Structures ---
-        bigFrame = LabelFrame(self, text='Structures')
-        irow=0; icol=0
-        def_list=[EmbedStrDefinition()]
-        extras=['method', 'method.options', 'calculator']
-        frame=MyLabelFrame(self, bigFrame, 'Embed', def_list, extras)
-        frame.doLayout()
-        frame.grid(row=irow, column=icol)
-        self.frames.append(frame)
-
-        icol+=1;
-        def_list=[VASPStrDefinition(), TURBOMOLEStrDefintion()]
-        for label in ['Cluster', 'System']:
-            extras = ['cell']
-            frame=MyLabelFrame(self, bigFrame, label, def_list, extras)
-            frame.doLayout()
-            frame.grid(row=irow, column=icol)
-            self.frames.append(frame)
-            icol+=1
-        bigFrame.grid(row=0, columnspan=3)
-
-        #--- Methods ---
-        bigFrame = LabelFrame(self, text='Methods')
-        irow=0; icol=0
-        def_list=[QmxPrgDefinition()]
-        frame=MyLabelFrame(self, bigFrame, 'Qmx', def_list)
-        frame.doLayout()
-        frame.grid(row=irow, column=icol)
-        self.frames.append(frame)
-
-        icol+=1
-        def_list=[VASPPrgDefinition(), TURBOMOLEPrgDefinition()]
-        for label in ['High-Level', 'Low-Level']:
-            def_list=[VASPPrgDefinition(), TURBOMOLEPrgDefinition()]
-            frame=MyLabelFrame(self, bigFrame, label, def_list)
-            frame.doLayout()
-            frame.grid(row=irow, column=icol)
-            self.frames.append(frame)
-            icol+=1
-        bigFrame.grid(row=1, columnspan=3)
-        
-        #--- General ---
-        bigFrame = LabelFrame(self, text='General')
-        extras=['method', 'method.options']
-        frame=MyLabelFrame(self, bigFrame, 'Job', [QNJobDefintion()], extras)
-        frame.doLayout()
-        frame.grid()
-        self.frames.append(frame)
-        bigFrame.grid(row=2, sticky=NW)
-
-        frame=LabelFrame(self, text="PREVIEW")
-        scrollbar=Scrollbar(frame, orient=VERTICAL)
-        scrollbar.set(0.0, 1.0)
-        self.text=Text(frame, yscrollcommand=scrollbar.set, width=60, heigh=10, state=DISABLED)
-        self.text.grid(sticky=(N+W+S+E))
-        scrollbar.config(command=self.text.yview)
-        scrollbar.grid(row=0, column=1, sticky=NS)        
-        frame.grid(row=2, column=1)
-
-        frame = Frame(self)
-        buttonSave=Button(frame, text='save settings', state=DISABLED)
-        buttonSave.grid(row=1, sticky=(EW))
-
-        buttonPrint=Button(frame, text='Write qmx.py input file', command=self.writeButton)
-        buttonPrint.grid(row=2, sticky=EW)
-
-        frame.grid(row=2, column=2, sticky=SE)
-
-        #--- MainWindow ---
-        self.grid(sticky=(W+N+S+E))
-        self.preview()
-    
-    def writeButton(self):
-        file = open("data","w")
-        self.writeData(file)
-        file.close()
-
-    def writeData(self, stream):
-        keys=['import']
-        definitions=[]
-
-        for frame in self.frames:
-            definition = frame.getSelection()
-            if definition is not None:
-                definitions.append(definition)
-
-        arrImports=[]
-        for definition in definitions:
-            strClass=definition.getValue('class')
-            strImport=definition.getValue('import')
-            
-            if (strClass is not '' and strImport is not ''):
-                s='from '+strImport+' import '+strClass+'\n'
-                if not s in arrImports:
-                    stream.write(s)
-                    arrImports.append(s)
-
-        stream.write("\n")
-        for name in ['High-Level', 'Low-Level', 'Qmx']:
-            for definition in definitions:
-                if definition.system != name:
-                    continue
-                strSystem=definition.system.lower().replace("-", "_")
-                strClass=definition.getValue('class')
-                strOptions=definition.getValue('class.options')
-
-                if (strClass is not ''):
-                    stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
-
-        stream.write("\n")
-        for name in ['System', 'Cluster', 'Embed']:
-            for definition in definitions:
-                if definition.system != name:
-                    continue
-                strSystem=definition.system.lower()
-                strClass=definition.getValue('class')
-                strOptions=definition.getValue('class.options')
-
-                if (strClass is not ''):
-                    stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
-                    
-                if name is 'Embed':
-                    strMethod=definition.getValue('method')
-                    strOptions=definition.getValue('method.options')
-                    stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
-
-                    strOptions=definition.getValue('calculator')
-                    stream.write(strSystem+'.set_calculator('+strOptions+')\n')
-            
-        stream.write("\n")
-        for definition in definitions:
-            if (definition.system == 'Job'):
-                strSystem=definition.system.lower()
-                strMethod=definition.getValue('method')
-                strOptions=definition.getValue('method.options')
-                stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
-                
-    def preview(self):
-        stream = StringIO.StringIO()
-        self.writeData(stream)
-        s = stream.getvalue()
-        
-        if self.text is not None:
-            pos, end = self.text.yview()
-            self.text.config(state=NORMAL)
-            self.text.delete(1.0, END)
-            self.text.insert(END, s)
-            self.text.config(state=DISABLED)
-            self.text.yview(MOVETO, pos)
-
-print
-mainWnd=MainWindow(Tk())
-mainWnd.mainloop()
Index: ase/embed.py
===================================================================
--- ase/embed.py	(revision 9)
+++ ase/embed.py	(revision 10)
@@ -1,3 +1,4 @@
+import math
 from ase import Atom, Atoms
 from ase.data import covalent_radii, atomic_numbers
 
@@ -5,7 +6,7 @@
 
 class Embed(Atoms):
     #--- constructor of the Embed class ---
-    def __init__(self, system=None, cluster=None):
+    def __init__(self, system=None, cluster=None, cell_cluster = "Auto"):
         super(Embed, self).__init__()
         # define the atom map
         self.atom_map_sys_cl = []
@@ -19,8 +20,9 @@
         # define the systems for calculations
         self.set_system(system)
         self.set_cluster(cluster)
-        #
-        self.set_cell([10, 10, 10])
+        # set the cell of the system
+        self.set_cell(system.get_cell())
+        self.cell_cluster = cell_cluster
         return
 
     #--- set the cluster ---
@@ -77,6 +79,29 @@
         self.find_cluster()
         self.set_linkatoms()
         print "link atoms found: ", len(self.linkatoms)
+        if self.cell_cluster == "System":
+            self.atoms_cluster.set_cell(self.atoms_system.get_cell())
+        elif self.cell_cluster == "Auto":
+            positions = self.atoms_cluster.get_positions()
+            #find the biggest dimensions of the cluster in x,y,z direction
+            l = 0
+            for idir in xrange(3):
+                l = max(l, positions[:, idir].max() - positions[:, idir].min())
+            # calculate the box parameters (cluster + min 5 Ang)
+            l = (math.floor(l/2.5)+1)*2.5 + 5.0
+            # build cell
+            cell = np.zeros((3, 3),  float)
+            # apply cell parameters
+            for idir in xrange(3):
+                cell[idir, idir] = l
+            # set parameters to cluster
+            self.atoms_cluster.set_cell(cell)
+            # print information on the screen
+            print "length of box surrounding the cluster: ", 
+            print l*10, 
+            print "pm"
+        else:
+            self.atoms_cluster.set_cell(self.cell_cluster)
 
     def find_cluster(self):
         # set tolerance
@@ -122,7 +147,6 @@
         xyzs_sys=[]
         for atom_sys in self.atoms_system:
             xyzs_sys.append(atom_sys.get_position())
-        # FIXME: mapping does not work when cluster atoms are outside of the box
         # set the standard link atom
         if linkAtom is None:
             linkAtom ='H'
@@ -135,17 +159,15 @@
         bonds = []
         # set the 27 cell_vec, starting with the (0,0,0) vector for the unit cell
         cells_L = [(0.0,  0.0,  0.0)]
-        # get the cell vectors
-        cell = self.get_cell()
-        # TODO: check 0D, 1D, 2D, 3D
-        if False:
-         for ix in xrange(-1, 2):
-            for iy in xrange(-1, 2):
-                for iz in xrange(-1, 2):
-                    if ix == 0 and iy == 0 and iz == 0:
-                        continue
-
-                    cells_L.append(np.dot([ix, iy, iz], cell))
+        # get the cell vectors of the host system and build up a 3 by 3 supercell to search for neighbors in the surrounding
+        cell = self.atoms_system.get_cell()
+        if self.atoms_system.get_pbc().any():
+            for ix in xrange(-1, 2):
+                for iy in xrange(-1, 2):
+                    for iz in xrange(-1, 2):
+                        if ix == 0 and iy == 0 and iz == 0:
+                            continue
+                        cells_L.append(np.dot([ix, iy, iz], cell))
         # save the radius of system atoms
         rs_sys = []
         for atom in self.atoms_system:
Index: ase/calculators/turbomole.py
===================================================================
--- ase/calculators/turbomole.py	(revision 9)
+++ ase/calculators/turbomole.py	(revision 10)
@@ -83,7 +83,8 @@
         # if update of forces is neccessary
         if self.update_forces:
             # calculate forces
-            self.execute(self.calculate_forces + " > ASE.TM.forces.out")
+            if self.calculate_forces is not None:
+                self.execute(self.calculate_forces + " > ASE.TM.forces.out")
             # read forces
             self.read_forces()
         else :
Index: ase/calculators/vasp.py
===================================================================
--- ase/calculators/vasp.py	(revision 9)
+++ ase/calculators/vasp.py	(revision 10)
@@ -151,7 +151,7 @@
 class Vasp(Calculator):
     def __init__(self, restart=None, output_template='vasp', track_output=False, write_input = True, 
                  **kwargs):
-        self.bool_write_input = write_input
+        self.write_input = write_input
         self.name = 'Vasp'
         self.float_params = {}
         self.exp_params = {}
@@ -248,7 +248,6 @@
         # Determine the number of atoms of each atomic species
         # sorted after atomic species
         special_setups = []
-        symbols = {}
         if self.input_params['setups']:
             for m in self.input_params['setups']:
                 try : 
@@ -259,21 +258,41 @@
                     continue
             #print 'special_setups' , special_setups
 
+        #symbols = {}
+        #for m,atom in enumerate(atoms):
+        #    symbol = atom.get_symbol()
+        #    if m in special_setups:
+        #        pass
+        #    else:
+        #        if not symbols.has_key(symbol):
+        #            symbols[symbol] = 1
+        #        else:
+        #            symbols[symbol] += 1
+        
+        symbols = []
         for m,atom in enumerate(atoms):
             symbol = atom.get_symbol()
             if m in special_setups:
                 pass
             else:
-                if not symbols.has_key(symbol):
-                    symbols[symbol] = 1
+                ind = 0
+                bfound = False
+                for symbolX, iatom in symbols:
+                    if symbol == symbolX:
+                        bfound = True
+                        break
+                    ind += 1
+                if bfound:
+                    symbolX, iatom  = symbols[ind]
+                    symbols[ind] = symbolX, iatom+1
                 else:
-                    symbols[symbol] += 1
+                    symbols.append((symbol, 1))
         
         # Build the sorting list
         self.sort = []
         self.sort.extend(special_setups)
 
-        for symbol in symbols:
+        for symbol, iatom in symbols:
             for m,atom in enumerate(atoms):
                 if m in special_setups: 
                     pass
@@ -284,66 +303,72 @@
         for n in range(len(self.resort)):
             self.resort[self.sort[n]] = n
         self.atoms_sorted = atoms[self.sort]
-
+        
         # Check if the necessary POTCAR files exists and
         # create a list of their paths.
         self.symbol_count = []
         for m in special_setups:
-            self.symbol_count.append([atomtypes[m],1])
+            for symbol, iatom in symbols:
+                if symbol == m:
+                    self.symbol_count.append([atomtypes[m],1])
+            #self.symbol_count.append([atomtypes[m],1])
         for m in symbols:
-            self.symbol_count.append([m,symbols[m]])
-        #print 'self.symbol_count',self.symbol_count 
+            for symbol, iatom in symbols:
+                if symbol == m:
+                    self.symbol_count.append([m,iatom])
+            #self.symbol_count.append([m,symbols[m]])
         sys.stdout.flush()
-        xc = '/'
-        #print 'p[xc]',p['xc']
-        if p['xc'] == 'PW91':
-            xc = '_gga/'
-        elif p['xc'] == 'PBE':
-            xc = '_pbe/'
-        if 'VASP_PP_PATH' in os.environ:
-            pppaths = os.environ['VASP_PP_PATH'].split(':')
-        else:
-            pppaths = []
-        self.ppp_list = []
-        # Setting the pseudopotentials, first special setups and 
-        # then according to symbols
-        for m in special_setups:
-            name = 'potpaw'+xc.upper() + p['setups'][str(m)] + '/POTCAR'
-            found = False
-            for path in pppaths:
-                filename = join(path, name)
-                #print 'filename', filename
-                if isfile(filename) or islink(filename):
-                    found = True
-                    self.ppp_list.append(filename)
-                    break
-                elif isfile(filename + '.Z') or islink(filename + '.Z'):
-                    found = True
-                    self.ppp_list.append(filename+'.Z')
-                    break
-            if not found:
-                raise RuntimeError('No pseudopotential for %s!' % symbol)    
-        #print 'symbols', symbols 
-        for symbol in symbols:
-            try:
-                name = 'potpaw'+xc.upper()+symbol + p['setups'][symbol]
-            except (TypeError, KeyError):
-                name = 'potpaw' + xc.upper() + symbol
-            name += '/POTCAR'
-            found = False
-            for path in pppaths:
-                filename = join(path, name)
-                #print 'filename', filename
-                if isfile(filename) or islink(filename):
-                    found = True
-                    self.ppp_list.append(filename)
-                    break
-                elif isfile(filename + '.Z') or islink(filename + '.Z'):
-                    found = True
-                    self.ppp_list.append(filename+'.Z')
-                    break
-            if not found:
-                raise RuntimeError('No pseudopotential for %s!' % symbol)
+        if self.write_input:
+            xc = '/'
+            #print 'p[xc]',p['xc']
+            if p['xc'] == 'PW91':
+                xc = '_gga/'
+            elif p['xc'] == 'PBE':
+                xc = '_pbe/'
+            if 'VASP_PP_PATH' in os.environ:
+                pppaths = os.environ['VASP_PP_PATH'].split(':')
+            else:
+                pppaths = []
+            self.ppp_list = []
+            # Setting the pseudopotentials, first special setups and 
+            # then according to symbols
+            for m in special_setups:
+                name = 'potpaw'+xc.upper() + p['setups'][str(m)] + '/POTCAR'
+                found = False
+                for path in pppaths:
+                    filename = join(path, name)
+                    #print 'filename', filename
+                    if isfile(filename) or islink(filename):
+                        found = True
+                        self.ppp_list.append(filename)
+                        break
+                    elif isfile(filename + '.Z') or islink(filename + '.Z'):
+                        found = True
+                        self.ppp_list.append(filename+'.Z')
+                        break
+                if not found:
+                    raise RuntimeError('No pseudopotential for %s!' % symbol)    
+            #print 'symbols', symbols 
+            for symbol in symbols:
+                try:
+                    name = 'potpaw'+xc.upper()+symbol + p['setups'][symbol]
+                except (TypeError, KeyError):
+                    name = 'potpaw' + xc.upper() + symbol
+                name += '/POTCAR'
+                found = False
+                for path in pppaths:
+                    filename = join(path, name)
+                    #print 'filename', filename
+                    if isfile(filename) or islink(filename):
+                        found = True
+                        self.ppp_list.append(filename)
+                        break
+                    elif isfile(filename + '.Z') or islink(filename + '.Z'):
+                        found = True
+                        self.ppp_list.append(filename+'.Z')
+                        break
+                if not found:
+                    raise RuntimeError('No pseudopotential for %s!' % symbol)
         self.converged = None
         self.setups_changed = None
 
@@ -359,7 +384,7 @@
         from ase.io.vasp import write_vasp
         self.initialize(atoms)
         write_vasp('POSCAR', self.atoms_sorted, symbol_count = self.symbol_count)
-        if self.bool_write_input:
+        if self.write_input:
             self.write_incar(atoms)
             self.write_potcar()
             self.write_kpoints()
Index: ase/calculators/mopac.py
===================================================================
--- ase/calculators/mopac.py	(revision 0)
+++ ase/calculators/mopac.py	(revision 10)
@@ -0,0 +1,189 @@
+"""
+This module is the MOPAC module for ASE, 
+based on the PyMD MOPAC Module by R. Bulo, 
+implemented by T. Kerber
+
+2011, ENS Lyon
+"""
+import commands
+import numpy as np
+
+from ase.atoms import Atoms
+from ase.units import kcal, mol
+from ase.calculators.general import Calculator
+
+kcal_mol = kcal / mol
+class Mopac(Calculator):
+    def __init__(self, files=None, restart=0, geomopt=False, functional="PM6"):
+        self.restart = restart
+        self.geomopt = geomopt
+        self.functional = functional
+
+        self.spin = 0
+        self.occupations = None
+
+        self.first = True
+        self.stress = None
+        self.energy_zero = None
+        self.energy_free = None
+        self.forces = None
+        
+    def write_moldata(self):
+        """
+        Writes the files that have to be written each timestep
+        """
+        # Change labels variable if necessary
+        # FIXME: what does norderats stands for????
+        norderats = 0
+        for el in self.atoms.get_chemical_symbols():
+            norderats += 1
+        if norderats != self.atoms.get_number_of_atoms():
+            self.labels = self.get_labels()
+
+        input = self.get_input_block()
+        pyfile = open('pymopac.in','w')
+        pyfile.write(input)
+        pyfile.close()
+
+    def run(self):
+        self.write_moldata()
+        out = commands.getoutput('mopac pymopac.in')
+        
+        outputfile = open('pymopac.in.out')
+        outfile = open('mopac%02i.out'%(self.restart),'w')
+        for line in outputfile:
+            outfile.write(line)
+        outfile.close()
+        outputfile.close()
+
+        energy = self.read_energy()
+        if energy == None:
+            energy = self.rerun()
+        self.forces = self.read_forces()
+        
+        self.energy_zero = energy
+        self.energy_free = energy
+        self.first = False
+
+    def read_energy(self, charges=True):
+        outfile = open('pymopac.in.out')
+        lines = outfile.readlines()
+        outfile.close()
+
+        chargelines = 0
+        if charges:
+            nats = len(self.atoms)
+            block = ''
+        for line in lines:
+            if line.find('HEAT OF FORMATION') != -1:
+                words = line.split()
+                energy = float(words[5])
+            if line.find('H.o.F. per unit cell') != -1:
+                words = line.split()
+                energy = float(words[5])
+            if line.find('"""""""""""""UNABLE TO ACHIEVE SELF-CONSISTENCE') != -1:
+                energy = None
+            if charges:
+                if line.find('NET ATOMIC CHARGES') != -1:
+                    chargelines += 1
+            if chargelines > 0 and chargelines <= nats+3:
+                chargelines += 1
+                block += line
+             
+        if charges:
+            chargefile = open('charge%02i.out'%(self.restart),'a')
+            chargefile.write(block)
+            chargefile.close()
+ 
+        return energy
+
+    def read_forces(self):
+
+        outfile = open('pymopac.in.aux')
+        lines = outfile.readlines()
+        outfile.close()
+
+        outputforces = None
+        nats = len(self.atoms)
+        nx = nats * 3
+
+        for i,line in enumerate(lines):
+            if line.find('GRADIENTS:') != -1:
+                forces = []
+                l = 0
+                for j in range(nx):
+                    if j%10 == 0:
+                        l += 1
+                        gline = lines[i+l]
+                    k = j -((l-1)*10)
+                    try:
+                        forces.append(-float(gline[k*18:(k*18)+18]))
+                    except ValueError:
+                        if outputforces == None:
+                            outputforces = self.read_output_forces()
+                        forces.append(outputforces[j])
+                break
+
+        forces = np.reshape(forces,  (3, nats))
+        forces *= kcal_mol
+
+        return forces
+
+    def read_output_forces(self):
+        outfile = open('pymopac.in.out')
+        lines = outfile.readlines()
+        outfile.close()
+
+        nats = len(self.atoms)
+        nx = nats * 3
+
+        forces = []
+        for i,line in enumerate(lines):
+            if line.find('GRADIENT\n') != -1:
+                for j in range(nx):
+                    gline = lines[i+j+1]
+                    forces.append(-float(gline[49:62]))
+                break
+        
+        return forces
+        
+    def get_input_block(self):
+        # For restarting I can use 'DENOUT' and 'OLDENS' at some point 
+        block = ''
+        block += '%s '%(self.functional)
+        #if self.functional == 'PM6-DH2':
+        block += 'NOANCI '
+        block += '1SCF GRADIENTS '
+        block += 'AUX(0,PRECISION=9) '
+        block += 'RELSCF = 0.0001 '
+        charge = 0
+        if charge != 0:
+            block += 'CHARGE=%i '%(charge)
+        if self.spin == 1.:
+            block += 'DOUBLET '
+        elif self.spin == 2.:
+            block += 'TRIPLET '
+        block += '\n'
+        block += 'Title: ASE job\n\n'
+
+        constraints = self.atoms._get_constraints()
+        nconstraints = len(constraints)
+        for iat in xrange(len(self.atoms)):
+            f = [1, 1, 1]
+            if iat < nconstraints:
+                if constraints[iat] is not None:
+                    f = [0, 0, 0]
+            atom = self.atoms[iat]
+            xyz = atom.position
+            block += ' %2s'%atom.symbol
+            block += '    %16.5f %i    %16.5f %i    %16.5f %i \n'%(xyz[0],f[0],xyz[1],f[1],xyz[2],f[2])
+
+        if self.atoms.pbc.any():
+            for v in self.atoms.get_cell(): 
+                block += 'Tv %8.3f %8.3f %8.3f\n'%(v[0],v[1],v[2])
+        return block
+
+    def update(self, atoms):
+        if not (self.atoms.get_positions() == atoms.get_positions()).all() or self.first:
+            self.atoms = atoms.copy()
+            self.run()

Property changes on: ase/calculators/mopac.py
___________________________________________________________________
Added: svn:executable
   + *

Index: ase/calculators/__init__.py
===================================================================
--- ase/calculators/__init__.py	(revision 9)
+++ ase/calculators/__init__.py	(revision 10)
@@ -15,6 +15,7 @@
 from ase.calculators.singlepoint import SinglePointCalculator
 from ase.calculators.test import numeric_force, numeric_forces, TestPotential
 from ase.calculators.qmx import Qmx
+from ase.calculators.mopac import Mopac
 
 if _deprecate_things_from_ase_module:
     from ase.utils.deprecate import Deprecate
Index: prepareQMX/qmxSTR.py
===================================================================
--- prepareQMX/qmxSTR.py	(revision 0)
+++ prepareQMX/qmxSTR.py	(revision 10)
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+# definition of STRUCTURES for qmx-setup
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+from qmxDEF import Definition
+
+#-------------------------------------------------------------------------------
+#--- STR DEFINITIONS -----------------------------------------------------------
+#-------------------------------------------------------------------------------
+class VASPStrDefinition(Definition):
+    def __init__(self):
+        self.name='VASP'
+        self.keywords = {}
+        self.keywords['import']='ase.io.vasp'
+        self.keywords['class']='read_vasp'
+        self.keywords['class.options']='POSCAR'
+    
+#-------------------------------------------------------------------------------
+class TURBOMOLEStrDefintion(Definition):
+    def __init__(self):
+        self.name='TURBOMOLE'
+        self.keywords = {}
+        self.keywords['import']='ase.io.turbomole'
+        self.keywords['class']='read_turbomole'
+        self.keywords['class.options']='coord'
+
+#-------------------------------------------------------------------------------
+strDefinitions = [VASPStrDefinition(), TURBOMOLEStrDefintion()]

Property changes on: prepareQMX/qmxSTR.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmxJOB.py
===================================================================
--- prepareQMX/qmxJOB.py	(revision 0)
+++ prepareQMX/qmxJOB.py	(revision 10)
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+# definition of JOBS for qmx-setup
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+from qmxDEF import Definition
+
+#-------------------------------------------------------------------------------
+#--- JOB DEFINITIONS -----------------------------------------------------------
+#-------------------------------------------------------------------------------
+class QNJobDefintion(Definition):
+    def __init__(self):
+        self.name='QuasiNewton'
+        self.keywords = {}
+        self.keywords['import']='ase.optimize'
+        self.keywords['class']= 'QuasiNewton'
+        self.keywords['class.options']= 'trajectory="embed.traj"'
+        self.keywords['method']='run'
+        self.keywords['method.options']='fmax=0.01, steps=100'
+
+#-------------------------------------------------------------------------------
+jobDefinitions = [QNJobDefintion()]

Property changes on: prepareQMX/qmxJOB.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmxWRITE.py
===================================================================
--- prepareQMX/qmxWRITE.py	(revision 0)
+++ prepareQMX/qmxWRITE.py	(revision 10)
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+
+# GRAPHICAL interface for setup of QMX calculations
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+import StringIO
+
+def writeData(stream, definitions):
+    stream.write("#!/usr/bin/env python\n")
+    keys=['import']
+
+    arrImports=[]
+    for definition in definitions:
+        strClass=definition.getValue('class')
+        strImport=definition.getValue('import')
+        
+        if (strClass is not '' and strImport is not ''):
+            s='from '+strImport+' import '+strClass+'\n'
+            if not s in arrImports:
+                stream.write(s)
+                arrImports.append(s)
+
+    stream.write("\n")
+    for name in ['high-level', 'low-level', 'qmx']:
+        for definition in definitions:
+            if definition.system.lower() != name:
+                continue
+            strSystem=definition.system.lower().replace("-", "_")
+            strClass=definition.getValue('class')
+            strOptions=definition.getValue('class.options')
+
+            if (strClass is not ''):
+                stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
+
+    stream.write("\n")
+    for name in ['system', 'cluster', 'embed']:
+        for definition in definitions:
+            if definition.system.lower() != name:
+                continue
+            strSystem=definition.system.lower()
+            strClass=definition.getValue('class')
+            strOptions=definition.getValue('class.options')
+
+            if (strClass is not ''):
+                stream.write(strSystem+'='+strClass+"('"+strOptions+"')\n")
+                
+            if name is 'embed':
+                strMethod=definition.getValue('method')
+                strOptions=definition.getValue('method.options')
+                stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
+
+                strOptions=definition.getValue('calculator')
+                stream.write(strSystem+'.set_calculator('+strOptions+')\n')
+        
+    stream.write("\n")
+    for definition in definitions:
+        if (definition.system.lower() == 'job'):
+            strSystem=definition.system.lower()
+            strClass=definition.getValue('class')
+            strOptions=definition.getValue('class.options')
+            if (strOptions is not ''):
+                strOptions = ', ' + strOptions
+            
+            if (strClass is not ''):
+                stream.write(strSystem+'='+strClass+'(embed'+strOptions+')\n')
+
+            strSystem=definition.system.lower()
+            strMethod=definition.getValue('method')
+            strOptions=definition.getValue('method.options')
+            stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')

Property changes on: prepareQMX/qmxWRITE.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmxEMBED.py
===================================================================
--- prepareQMX/qmxEMBED.py	(revision 0)
+++ prepareQMX/qmxEMBED.py	(revision 10)
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+# definition of EMBED for qmx-setup
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+from qmxDEF import Definition
+
+#-------------------------------------------------------------------------------
+#--- EMBED DEFINITIONS ---------------------------------------------------------
+#-------------------------------------------------------------------------------
+class EmbedDefinition(Definition):
+    def __init__(self):
+        self.name='Embed'
+        self.system='Embed'
+        self.keywords = {}
+        self.keywords['import']='ase.embed'
+        self.keywords['class']='Embed'
+        self.keywords['class.options']='system, cluster, cell_cluster="Auto"'
+        self.keywords['method']='embed'
+        self.keywords['calculator']='qmx'
+
+#-------------------------------------------------------------------------------
+embedDefinitions = [EmbedDefinition()]

Property changes on: prepareQMX/qmxEMBED.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmx.in
===================================================================
--- prepareQMX/qmx.in	(revision 0)
+++ prepareQMX/qmx.in	(revision 10)
@@ -0,0 +1,10 @@
+high-level.program : TURBOMOLE
+high-level.options : opt
+low-level.program : VASP
+
+cluster.program : TURBOMOLE
+cluster.options : clusterX
+system.program : VASP
+
+
+job.program : QuasiNewton 
Index: prepareQMX/prepareQMX.py
===================================================================
--- prepareQMX/prepareQMX.py	(revision 0)
+++ prepareQMX/prepareQMX.py	(revision 10)
@@ -0,0 +1,205 @@
+#!/usr/bin/env python
+import os, sys
+from optparse import OptionParser
+
+class Data:
+    def __init__(self, name):
+        self.__name__ = name
+        self.str_option = ""
+        self.str_import = None
+        self.str_class  = None
+        self.str_methods = []
+        self.str_structure = None
+                
+    def __str__(self):
+       return self.__name__
+
+def getline(section, subsection, lines):
+    nline = -1
+    for iline in xrange(len(lines)):
+        if lines[iline][0].strip() == subsection:
+            if nline != -1:
+                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
+                sys.exit(1)
+            nline = iline
+    if nline == -1:
+        return None
+    return lines[nline][1].strip()
+
+def analyzeAtoms(section, lines):
+    data = Data(section)
+    line = getline(section, "program", lines)
+    if line is None:
+        line=""
+    if line.lower() == "turbomole":
+        data.str_import = "from ase.io.turbomole import read_turbomole"
+        data.str_class = "read_turbomole"
+    elif line.lower() == "vasp":
+        data.str_import = "from ase.io.vasp import read_vasp"
+        data.str_class = "read_vasp"
+        
+    data.str_structure = getline(section, "structure", lines)
+    return data
+
+def analyzeCalculator(section, lines):
+    data = Data(section)
+    #read programs
+    line = getline(section, "program", lines)
+    if line.lower() == "turbomole":
+        data.str_import = "from ase.calculators.turbomole import Turbomole"
+        data.str_class = "Turbomole"
+    elif line.lower() == "vasp":
+        data.str_import = "from ase.calculators.vasp import Vasp"
+        data.str_class = "Vasp"
+    
+    str = getline(section, "class", lines)
+    if str is not None:
+        data.str_class = str
+
+    str = getline(section, "import", lines)
+    if str is not None:
+        data.str_import = str
+
+    str = getline(section, "options", lines)
+    if str is not None:
+        data.str_option = str
+    return data
+
+def analyzeDynamics(section, lines):
+    data = Data(section)
+    line = getline(section, "method", lines)
+    if line.lower() == "optimizer":
+        data.str_import = "from ase.optimize import QuasiNewton"
+        data.str_class = "QuasiNewton"
+    return data
+
+#--- setting default values ------------------------------------------------------------------------
+#define separators
+separator=":"
+subseparator="."
+lineseparator="\n"
+
+#--- parse arguments -------------------------------------------------------------------------------
+#parse arguments (python 2.6)
+parser = OptionParser()
+parser.add_option("-i", "--infile",  dest="inputFile",  help="specifies the input file", metavar="FILE", default="qmx.in")
+parser.add_option("-o", "--outfile", dest="outputFile", help="specifies the output file", metavar="FILE")
+parser.add_option("-f", action="store_true", dest="overwrite")
+(options, args) = parser.parse_args()
+
+file=open(options.inputFile, "r")
+lines = file.readlines()
+file.close()
+
+
+#--- split intput file -----------------------------------------------------------------------------
+
+#--- remove comments -------------------------------------------------------------------------------
+for iline in xrange(len(lines)):
+    lines[iline] = lines[iline].split("#")[0]    
+
+#--- collect data in class -------------------------------------------------------------------------
+data_collection=[]
+
+#--- settings for QMX class ------------------------------------------------------------------------
+data = Data("qmx")
+data.str_class = "Qmx"
+data.str_import = "from ase.calculators.qmx import Qmx"
+data.str_option = "highLevel, lowLevel"
+
+data_collection.append(data)
+
+#--- settings for Embed class ----------------------------------------------------------------------
+data = Data("embed")
+data.str_class = "Embed"
+data.str_import = "from ase.embed import Embed"
+data.str_option = "system, cluster"
+data.str_methods = ["embed()", "set_calculator(qmx)"]
+
+data_collection.append(data)
+
+
+#--- analyze the input file ------------------------------------------------------------------------
+for section in "high-level", "low-level", "cluster", "system", "dynamics":
+    #search lines for section
+    lines_section=[]
+    for line in lines:
+        line = line.split(separator)
+        if line[0].find(section) >= 0:
+            line[0] = line[0].replace(section+subseparator, "")
+            lines_section.append(line)
+    
+    #calculators
+    if section == "high-level" or section == "low-level":
+        data_collection.append(analyzeCalculator(section, lines_section))
+        
+    #systems
+    if section == "cluster" or section == "system":
+        data_collection.append(analyzeAtoms(section, lines_section))
+        
+    #dynamics
+    if section == "dynamics":
+        data_collection.append(analyzeDynamics(section, lines_section))
+
+#--- write output file -----------------------------------------------------------------------------
+if options.outputFile is not None and os.path.exists(options.outputFile) and not options.overwrite:
+    sys.stderr.write(lineseparator+"the output file <"+options.outputFile+"> already exists"+lineseparator)
+    sys.exit(1)
+
+output = None
+if options.outputFile is None:
+    output=sys.stdout
+else:
+    output=open(options.outputFile, "w")
+
+#--- write header ----------------------------------------------------------------------------------
+output.write("#!/usr/bin/env python\n")
+
+#--- write import lines ----------------------------------------------------------------------------
+xlines=[]
+for data in data_collection:
+    value = data.str_import
+    if value is None or value in xlines:
+        continue
+    xlines.append(value)
+    output.write(value+lineseparator)
+output.write(lineseparator)
+
+#--- define the methods ----------------------------------------------------------------------------
+for system in 'high', 'low':
+    for data in data_collection:
+        if data.__name__ == system+"-level":
+            output.write(system+"Level = "+data.str_class+"("+data.str_option+")"+lineseparator)
+output.write(lineseparator)
+
+#--- qmx class (substraction scheme ----------------------------------------------------------------
+for data in data_collection:
+    if data.__name__ == "qmx":
+        output.write("qmx = "+data.str_class+"("+data.str_option+")"+lineseparator)
+output.write(lineseparator)
+
+#--- read all the systems --------------------------------------------------------------------------
+for system in "cluster", "system":
+    for data in data_collection:
+        if data.__name__ == system:
+            if data.str_structure is None:
+                continue
+            output.write(system+" = "+data.str_class+"(\""+data.str_structure+"\")"+lineseparator)
+output.write(lineseparator)
+
+#--- embeding class --------------------------------------------------------------------------------
+for data in data_collection:
+    if data.__name__ == "embed":
+        output.write("embed = "+data.str_class+"("+data.str_option+")"+lineseparator)
+        for method in data.str_methods:
+            output.write("embed."+method+lineseparator)
+output.write(lineseparator)
+
+#--- dynamics class --------------------------------------------------------------------------------
+for data in data_collection:
+    if data.__name__ == "dynamics":
+        output.write("dyn="+data.str_class+"(embed)"+lineseparator)
+        output.write("dyn.run("+data.str_option+")"+lineseparator)
+
+output.close()
+sys.exit(0)

Property changes on: prepareQMX/prepareQMX.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmxDEF.py
===================================================================
--- prepareQMX/qmxDEF.py	(revision 0)
+++ prepareQMX/qmxDEF.py	(revision 10)
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+# GRAPHICAL interface for setup of QMX calculations
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+#-------------------------------------------------------------------------------
+#--- GENERAL -------------------------------------------------------------------
+#-------------------------------------------------------------------------------
+class Definition(object):
+    def getValue(self, key):
+        if self.keywords.__contains__(key):
+            return self.keywords[key]
+        return ''
+

Property changes on: prepareQMX/qmxDEF.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmx.py
===================================================================
--- prepareQMX/qmx.py	(revision 0)
+++ prepareQMX/qmx.py	(revision 10)
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+from ase.embed import Embed
+from ase.io.vasp import read_vasp
+from ase.calculators.qmx import Qmx
+from ase.calculators.vasp import Vasp
+from ase.optimize import QuasiNewton
+
+high_level=Vasp(write_input=False)
+low_level=Vasp(write_input=False)
+qmx=Qmx(high_level, low_level)
+
+system=read_vasp('POSCAR')
+cluster=read_vasp('POSCAR')
+embed=Embed(system, cluster, cell_cluster="Auto")
+embed.embed()
+embed.set_calculator(qmx)
+
+job=QuasiNewton(embed, trajectory="embed.traj")
+job.run(fmax=0.01, steps=100)

Property changes on: prepareQMX/qmx.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/exit.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: prepareQMX/exit.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: prepareQMX/prepareQMX.GUI.py
===================================================================
--- prepareQMX/prepareQMX.GUI.py	(revision 0)
+++ prepareQMX/prepareQMX.GUI.py	(revision 10)
@@ -0,0 +1,208 @@
+#!/usr/bin/env python
+
+# GRAPHICAL interface for setup of QMX calculations
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+#---------------------------------------------------------------------------------------------------
+from Tkinter import *
+from copy import deepcopy
+import StringIO, os
+
+#---------------------------------------------------------------------------------------------------
+from qmxEMBED import embedDefinitions
+from qmxJOB import jobDefinitions
+from qmxSTR import strDefinitions
+from qmxCALC import calcDefinitions, QmxCalcDefinition
+
+from qmxWRITE import writeData
+
+#---------------------------------------------------------------------------------------------------
+#---------------------------------------------------------------------------------------------------
+#---------------------------------------------------------------------------------------------------
+class MyLabelFrame(LabelFrame):
+    def __init__(self, mainWnd, master, title, def_list, extras):
+        LabelFrame.__init__(self, master, text=title)
+        self.mainWnd = mainWnd
+        self.definitions=[]
+        self.title = title
+
+        for definition in def_list:
+            definition_new = deepcopy(definition)
+            definition_new.system = title
+            self.definitions.append(definition_new)
+
+        fields=['import', 'class', 'class.options']
+        if extras is not None:
+            for key in extras:
+                fields.append(key)
+
+        self.entries=[]
+        for key in fields:
+            text=StringVar()
+            text.set('')
+            self.entries.append((key, text, Entry(self, textvariable=text, width=15)))
+            
+    def grid(self, **arguments):
+        LabelFrame.grid(self, arguments, sticky=(N+W+E))
+        self.listbox.selection_set(first=0)
+        self.select(None)
+        
+    def doLayout(self):
+        irow=0
+        for (key, text, textfield) in self.entries:
+            Label(self, text=key, width=15, anchor=W).grid(row=irow)
+            textfield.grid(row=irow, column=1)
+            textfield.bind("<KeyRelease>", self.update)
+            irow+=1
+        
+        scrollbar=Scrollbar(self, orient=VERTICAL)
+        self.listbox=Listbox(self, yscrollcommand=scrollbar.set, height=0, width=15, selectmode=SINGLE)
+        self.listbox.grid(row=0, column=2, rowspan=irow, columnspan=2, sticky=NS)
+        self.listbox.bind('<ButtonRelease-1>', self.select)
+
+        scrollbar.config(command=self.listbox.yview)
+        scrollbar.grid(row=0, column=4, rowspan=irow, sticky=NS)
+       
+        for item in self.definitions:
+            self.listbox.insert(END, item.name)
+        
+    def select(self, event):
+        selection=self.listbox.curselection()
+        if len(selection) == 1:
+            self.curr_definition=deepcopy(self.definitions[int(selection[0])])
+            for (key, text, textfield) in self.entries:
+                text.set(self.curr_definition.getValue(key))
+        self.mainWnd.preview()
+    
+    def getSelection(self):
+        return self.curr_definition
+        
+    def update(self, event):
+        for (key, text, textfield) in self.entries:
+            self.curr_definition.keywords[key]=text.get()
+        self.mainWnd.preview()
+
+#---------------------------------------------------------------------------------------------------
+class MainWindow(Frame):
+    frames=[]
+    text=None
+    def __init__(self, master):
+        Frame.__init__(self, master)
+        
+        #--- Structures ---
+        bigFrame = LabelFrame(self, text='Structures')
+        irow=0; icol=0
+        def_list=embedDefinitions
+        extras=['method', 'method.options', 'calculator']
+        frame=MyLabelFrame(self, bigFrame, 'Embed', def_list, extras)
+        frame.doLayout()
+        frame.grid(row=irow, column=icol)
+        self.frames.append(frame)
+
+        icol+=1;
+        for label in ['System', 'Cluster']:
+            def_list=strDefinitions
+            frame=MyLabelFrame(self, bigFrame, label, def_list, None)
+            frame.doLayout()
+            frame.grid(row=irow, column=icol)
+            self.frames.append(frame)
+            icol+=1
+        bigFrame.grid(row=0, columnspan=3)
+
+        #--- Methods ---
+        bigFrame = LabelFrame(self, text='Methods')
+        irow=0; icol=0
+        def_list=[QmxCalcDefinition()]
+        frame=MyLabelFrame(self, bigFrame, 'Qmx', def_list, None)
+        frame.doLayout()
+        frame.grid(row=irow, column=icol)
+        self.frames.append(frame)
+
+        icol+=1
+        for label in ['High-Level', 'Low-Level']:
+            def_list=calcDefinitions
+            frame=MyLabelFrame(self, bigFrame, label, def_list, None)
+            frame.doLayout()
+            frame.grid(row=irow, column=icol)
+            self.frames.append(frame)
+            icol+=1
+        bigFrame.grid(row=1, columnspan=3)
+        
+        #--- General ---
+        bigFrame = LabelFrame(self, text='General')
+        extras=['method', 'method.options']
+        frame=MyLabelFrame(self, bigFrame, 'Job', jobDefinitions, extras)
+        frame.doLayout()
+        frame.grid()
+        self.frames.append(frame)
+        bigFrame.grid(row=2, sticky=NW)
+
+        frame=LabelFrame(self, text="PREVIEW")
+        scrollbar=Scrollbar(frame, orient=VERTICAL)
+        scrollbar.set(0.0, 1.0)
+        self.text=Text(frame, yscrollcommand=scrollbar.set, width=60, heigh=10, state=DISABLED)
+        self.text.grid(sticky=(N+W+S+E))
+        scrollbar.config(command=self.text.yview)
+        scrollbar.grid(row=0, column=1, sticky=NS)        
+        frame.grid(row=2, column=1)
+
+        frame = Frame(self)
+
+        image = PhotoImage(file="exit.gif")
+        buttonExit=Button(frame, image=image, command=self.quit)
+        buttonExit.image = image
+        buttonExit.grid(row=1, column = 1, rowspan=2, sticky= W+E+N+S)
+        
+        buttonSave=Button(frame, text='save settings', state=DISABLED)
+        buttonSave.grid(row=1, column = 2, sticky=(EW))
+
+        buttonPrint=Button(frame, text='Write qmx.py input file', command=self.writeButton)
+        buttonPrint.grid(row=2, column = 2, sticky=EW)
+
+        frame.grid(row=2, column=2, sticky=SE)
+
+        #--- MainWindow ---
+        self.grid(sticky=(W+N+S+E))
+        self.preview()
+        
+    def quit(self):
+        quit()
+    
+    def writeButton(self):
+        file = open("qmx.py","w")
+        definitions=[]
+        for frame in self.frames:
+            definition = frame.getSelection()
+            if definition is not None:
+                definitions.append(definition)
+
+        writeData(file, definitions)
+        file.close()
+        os.system("chmod u+x qmx.py")
+
+    def preview(self):
+        stream = StringIO.StringIO()
+        definitions=[]
+        for frame in self.frames:
+            definition = frame.getSelection()
+            if definition is not None:
+                definitions.append(definition)
+
+        writeData(stream, definitions)
+        s = stream.getvalue()
+        
+        if self.text is not None:
+            pos, end = self.text.yview()
+            self.text.config(state=NORMAL)
+            self.text.delete(1.0, END)
+            self.text.insert(END, s)
+            self.text.config(state=DISABLED)
+            self.text.yview(MOVETO, pos)
+
+#---------------------------------------------------------------------------------------------------
+mainWnd=MainWindow(Tk())
+mainWnd.mainloop()

Property changes on: prepareQMX/prepareQMX.GUI.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/qmxCALC.py
===================================================================
--- prepareQMX/qmxCALC.py	(revision 0)
+++ prepareQMX/qmxCALC.py	(revision 10)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+# definition of CALCULATORS for qmx-setup
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+from qmxDEF import Definition
+
+#-------------------------------------------------------------------------------
+#--- PRG DEFINITIONS -----------------------------------------------------------
+#-------------------------------------------------------------------------------
+class VASPCalcDefinition(Definition):
+    def __init__(self):
+        self.name='VASP'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.vasp'
+        self.keywords['class']='Vasp'
+        self.keywords['class.options']='write_input=False'
+
+#-------------------------------------------------------------------------------
+class TURBOMOLECalcDefinition(Definition):
+    def __init__(self):
+        self.name='TURBOMOLE'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.turbomole'
+        self.keywords['class']='Turbomole'
+
+#-------------------------------------------------------------------------------
+class MOPACCalcDefinition(Definition):
+    def __init__(self):
+        self.name='MOPAC'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.mopac'
+        self.keywords['class']='Mopac'
+        self.keywords['class.options']='functional="PM6"'
+
+#-------------------------------------------------------------------------------
+class QmxCalcDefinition(Definition):
+    def __init__(self):
+        self.name='QMX'
+        self.system='Qmx'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.qmx'
+        self.keywords['class']='Qmx'
+        self.keywords['class.options']='high_level, low_level'
+
+#-------------------------------------------------------------------------------
+calcDefinitions = [VASPCalcDefinition(), TURBOMOLECalcDefinition(), MOPACCalcDefinition()]

Property changes on: prepareQMX/qmxCALC.py
___________________________________________________________________
Added: svn:executable
   + *

Index: prepareQMX/prepareQMX.new.py
===================================================================
--- prepareQMX/prepareQMX.new.py	(revision 0)
+++ prepareQMX/prepareQMX.new.py	(revision 10)
@@ -0,0 +1,264 @@
+#!/usr/bin/env python
+
+# command line interface for setup of QMX calculations
+#
+# Torsten Kerber, ENS LYON: 2011, 07, 11
+#
+# This work is supported by Award No. UK-C0017, made by King Abdullah
+# University of Science and Technology (KAUST)
+
+#---------------------------------------------------------------------------------------------------
+import os, sys
+from copy import deepcopy
+from optparse import OptionParser
+
+#---------------------------------------------------------------------------------------------------
+from qmxEMBED import embedDefinitions
+from qmxJOB  import jobDefinitions
+from qmxSTR  import strDefinitions
+from qmxCALC import calcDefinitions, QmxCalcDefinition
+
+from qmxWRITE import writeData
+
+#---------------------------------------------------------------------------------------------------
+#---------------------------------------------------------------------------------------------------
+#---------------------------------------------------------------------------------------------------
+def getline(section, subsection, lines):
+    nline = -1
+    for iline in xrange(len(lines)):
+        if lines[iline][0].strip() == subsection:
+            if nline != -1:
+                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
+                sys.exit(1)
+            nline = iline
+    if nline == -1:
+        return None
+    return lines[nline][1].strip()
+
+#---------------------------------------------------------------------------------------------------
+def analyzeSection(definitions, section, lines):
+    line = getline(section, "program", lines)
+    if line is None:
+        print "section <" + section + "> does not contain program"
+        sys.exit(1)
+        
+    myDefinition = None
+    for definition in definitions:
+        if definition.name == line:
+            myDefinition = deepcopy(definition)
+            break
+            
+    if myDefinition is None:
+        print "the program <" + line + "> is not defined for the section <" + section + ">"
+        sys.exit(1)
+        
+    myDefinition.system = section
+
+    subsections = []
+    for line in lines:
+        subsections.append(line[0].strip().lower())
+
+    for subsection in subsections:
+        line = getline(section, subsection, lines)
+        if line is None:
+            print "input error in <"+section+"."+subsection+">"
+            sys.exit(1)
+        if subsection == "program":
+            continue
+        if subsection == "options":
+            subsection = 'class.options'
+        
+        myDefinition.keywords[subsection] = line    
+        print subsection, myDefinition.keywords[subsection]
+    
+    return myDefinition
+
+#---------------------------------------------------------------------------------------------------
+#--- setting default values ------------------------------------------------------------------------
+#---------------------------------------------------------------------------------------------------
+
+#define separators
+separator=":"
+subseparator="."
+lineseparator="\n"
+
+#--- parse arguments -------------------------------------------------------------------------------
+#parse arguments (python 2.6)
+parser = OptionParser()
+parser.add_option("-i", "--infile",  dest="inputFile",  help="specifies the input file", metavar="FILE", default="qmx.in")
+parser.add_option("-o", "--outfile", dest="outputFile", help="specifies the output file", metavar="FILE")
+parser.add_option("-f", action="store_true", dest="overwrite")
+(options, args) = parser.parse_args()
+
+#--- check wether output file exists ---------------------------------------------------------------
+if options.outputFile is not None and os.path.exists(options.outputFile) and not options.overwrite:
+    sys.stderr.write(lineseparator+"the output file <"+options.outputFile+"> already exists"+lineseparator)
+    sys.exit(1)
+
+#--- read intput file ------------------------------------------------------------------------------
+file=open(options.inputFile, "r")
+lines = file.readlines()
+file.close()
+
+#--- remove comments -------------------------------------------------------------------------------
+for iline in xrange(len(lines)):
+    lines[iline] = lines[iline].split("#")[0]    
+
+#--- collect data in class -------------------------------------------------------------------------
+definitions=[]
+definitions.append(QmxCalcDefinition())
+
+#--- analyze the input file ------------------------------------------------------------------------
+for section in "high-level", "low-level", "cluster", "system", "job":
+    #search lines for section
+    lines_section=[]
+    for line in lines:
+        line = line.split(separator)
+        if line[0].find(section) >= 0:
+            line[0] = line[0].replace(section+subseparator, "")
+            lines_section.append(line)
+
+    #calculators
+    if section == "high-level" or section == "low-level":
+        definitions.append(analyzeSection(calcDefinitions, section, lines_section))
+        
+    #structures (atoms)
+    if section == "cluster" or section == "system":
+        definitions.append(analyzeSection(strDefinitions, section, lines_section))
+        
+    #job
+    if section == "job":
+        definitions.append(analyzeSection(jobDefinitions, section, lines_section))
+        
+    #embed
+    if section == "embed":
+        definitions.append(analyzeSection(embedDefinitions, section, lines_section))
+
+output = None
+if options.outputFile is None:
+    output=sys.stdout
+else:
+    output=open(options.outputFile, "w")
+    
+writeData(output, definitions)
+output.close()
+
+
+
+
+
+
+
+#
+##--- write header ----------------------------------------------------------------------------------
+#output.write("#!/usr/bin/env python\n")
+#
+##--- write import lines ----------------------------------------------------------------------------
+#xlines=[]
+#for data in data_collection:
+#    value = data.str_import
+#    if value is None or value in xlines:
+#        continue
+#    xlines.append(value)
+#    output.write(value+lineseparator)
+#output.write(lineseparator)
+#
+##--- define the methods ----------------------------------------------------------------------------
+#for system in 'high', 'low':
+#    for data in data_collection:
+#        if data.__name__ == system+"-level":
+#            output.write(system+"Level = "+data.str_class+"("+data.str_option+")"+lineseparator)
+#output.write(lineseparator)
+#
+##--- qmx class (substraction scheme ----------------------------------------------------------------
+#for data in data_collection:
+#    if data.__name__ == "qmx":
+#        output.write("qmx = "+data.str_class+"("+data.str_option+")"+lineseparator)
+#output.write(lineseparator)
+#
+##--- read all the systems --------------------------------------------------------------------------
+#for system in "cluster", "system":
+#    for data in data_collection:
+#        if data.__name__ == system:
+#            if data.str_structure is None:
+#                continue
+#            output.write(system+" = "+data.str_class+"(\""+data.str_structure+"\")"+lineseparator)
+#output.write(lineseparator)
+#
+##--- embeding class --------------------------------------------------------------------------------
+#for data in data_collection:
+#    if data.__name__ == "embed":
+#        output.write("embed = "+data.str_class+"("+data.str_option+")"+lineseparator)
+#        for method in data.str_methods:
+#            output.write("embed."+method+lineseparator)
+#output.write(lineseparator)
+#
+##--- dynamics class --------------------------------------------------------------------------------
+#for data in data_collection:
+#    if data.__name__ == "dynamics":
+#        output.write("dyn="+data.str_class+"(embed)"+lineseparator)
+#        output.write("dyn.run("+data.str_option+")"+lineseparator)
+#
+#
+#
+#
+#
+#def getline(section, subsection, lines):
+#    nline = -1
+#    for iline in xrange(len(lines)):
+#        if lines[iline][0].strip() == subsection:
+#            if nline != -1:
+#                sys.stderr.write("section: <"+section+separator+subsection+"> has been definied more than once\n")
+#                sys.exit(1)
+#            nline = iline
+#    if nline == -1:
+#        return None
+#    return lines[nline][1].strip()
+#
+##def analyzeAtoms(section, lines):
+##    data = Data(section)
+##    line = getline(section, "program", lines)
+##    if line is None:
+##        line=""
+##    if line.lower() == "turbomole":
+##        data.str_import = "from ase.io.turbomole import read_turbomole"
+##        data.str_class = "read_turbomole"
+##    elif line.lower() == "vasp":
+##        data.str_import = "from ase.io.vasp import read_vasp"
+##        data.str_class = "read_vasp"
+##        
+##    data.str_structure = getline(section, "structure", lines)
+##    return data
+##
+##def analyzeCalculator(section, lines):
+##    data = Data(section)
+##    #read programs
+##    line = getline(section, "program", lines)
+##    if line.lower() == "turbomole":
+##        data.str_import = "from ase.calculators.turbomole import Turbomole"
+##        data.str_class = "Turbomole"
+##    elif line.lower() == "vasp":
+##        data.str_import = "from ase.calculators.vasp import Vasp"
+##        data.str_class = "Vasp"
+##    
+##    str = getline(section, "class", lines)
+##    if str is not None:
+##        data.str_class = str
+##
+##    str = getline(section, "import", lines)
+##    if str is not None:
+##        data.str_import = str
+##
+##    str = getline(section, "options", lines)
+##    if str is not None:
+##        data.str_option = str
+##    return data
+##
+##def analyzeDynamics(section, lines):
+##    data = Data(section)
+##    line = getline(section, "method", lines)
+##    if line.lower() == "optimizer":
+##        data.str_import = "from ase.optimize import QuasiNewton"
+##        data.str_class = "QuasiNewton"
+##    return data
+

Property changes on: prepareQMX/prepareQMX.new.py
___________________________________________________________________
Added: svn:executable
   + *

