Index: ase/embed.py
===================================================================
--- ase/embed.py	(revision 4)
+++ ase/embed.py	(revision 5)
@@ -225,15 +225,15 @@
         # go over all pairs of atoms
         for iat_sys in xrange(nat_sys):
             xyz = positions_new[iat_sys]
+            self.atoms_system[iat_sys].set_position(xyz)
             iat_cl = self.atom_map_sys_cl[iat_sys]
-            self.atoms_system[iat_sys].set_position(xyz)
             if iat_cl > -1:
                 self.atoms_cluster[iat_cl].set_position(xyz)
 
         for cell_L, iat_cl_sys, iat_sys, r, iat in self.linkatoms:
             # determine position of the link atom
-            xyz_cl = self.atoms_system[iat_cl_sys].get_position()
-            xyz = self.atoms_system[iat_sys].get_position() - xyz_cl + cell_L
+            xyz_cl = positions_new[iat_cl_sys]
+            xyz = positions_new[iat_sys] - xyz_cl + cell_L
             xyz *= r / np.sqrt(np.dot(xyz, xyz))
             xyz += xyz_cl
             # update xyz coordinates of the cluster
Index: ase/io/turbomole.py
===================================================================
--- ase/io/turbomole.py	(revision 4)
+++ ase/io/turbomole.py	(revision 5)
@@ -49,8 +49,8 @@
         f.close()
 
     atoms = Atoms(positions = atoms_pos, symbols = atom_symbols, pbc = False)
-    c = FixAtoms(myconstraints)
-    atoms.set_constraint(c)
+#    c = FixAtoms(myconstraints)
+#    atoms.set_constraint(c)
     #print c
     
 
@@ -99,4 +99,3 @@
             f.write('%20.14f  %20.14f  %20.14f      %2s \n' 
                     % (x/Bohr, y/Bohr, z/Bohr, s.lower()))
     f.write("$end\n")
-    
Index: ase/calculators/qmx.py
===================================================================
--- ase/calculators/qmx.py	(revision 4)
+++ ase/calculators/qmx.py	(revision 5)
@@ -15,11 +15,15 @@
 import sys, os
 
 class Qmx(Calculator):
-    def __init__(self, calculator_high,  calculator_low):
+    def __init__(self, calculator_high_cluster,  calculator_low_cluster,  calculator_low_system=None,  print_forces=False):
         self._constraints=None
-        self.calculator_low_cluster = calculator_low
-        self.calculator_low_system = deepcopy(calculator_low)
-        self.calculator_high = calculator_high            
+        
+        self.calculator_low_cluster = calculator_low_cluster
+        self.calculator_low_system = calculator_low_system
+        if self.calculator_low_system is None:
+            self.calculator_low_system = deepcopy(calculator_low_cluster)
+        self.calculator_high_cluster = calculator_high_cluster
+        self.print_forces = print_forces
 
     def get_energy_subsystem(self, path, calculator, atoms, force_consistent):
         # go to directory and calculate energies
@@ -43,12 +47,12 @@
         # perform energy calculations
         e_sys_lo = self.get_energy_subsystem("system.low-level", self.calculator_low_system, embed.get_system(), force_consistent)
         e_cl_lo  = self.get_energy_subsystem("cluster.low-level", self.calculator_low_cluster, embed.get_cluster(), force_consistent)
-        e_cl_hi  = self.get_energy_subsystem("cluster.high-level", self.calculator_high, embed.get_cluster(), force_consistent)
+        e_cl_hi  = self.get_energy_subsystem("cluster.high-level", self.calculator_high_cluster, embed.get_cluster(), force_consistent)
         # calculate energies
         energy = e_sys_lo - e_cl_lo + e_cl_hi
         # print energies
-        print "%20s=%15s - %15s + %15s" %("E(C:S)", "E(S-MM)", "E(C-MM)", "E(C-QM)")
-        print "%20f=%15f - %15f + %15f" %(energy, e_sys_lo, e_cl_lo, e_cl_hi)
+        print "%20s = %15s - %15s + %15s" %("E(C:S)", "E(S-MM)", "E(C-MM)", "E(C-QM)")
+        print "%20f = %15f - %15f + %15f" %(energy, e_sys_lo, e_cl_lo, e_cl_hi)
         # set energies and return
         if force_consistent:
             self.energy_free = energy
@@ -62,23 +66,47 @@
         # get forces for the three systems
         f_sys_lo = self.get_forces_subsystem("system.low-level", self.calculator_low_system, embed.get_system())
         f_cl_lo  = self.get_forces_subsystem("cluster.low-level", self.calculator_low_cluster, embed.get_cluster())
-        f_cl_hi  = self.get_forces_subsystem("cluster.high-level", self.calculator_high, embed.get_cluster())
+        f_cl_hi  = self.get_forces_subsystem("cluster.high-level", self.calculator_high_cluster, embed.get_cluster())
+
         # forces correction for the atoms
         f_cl = f_cl_hi - f_cl_lo
-        # number of atoms
-        nat_sys = len(embed)
+
+        if self.print_forces:
+            cluster=embed.get_cluster()
+            print "Forces: System LOW - Cluster LOW + Cluster HIGH"
+            for iat_sys in xrange(len(embed)):
+                print "%-2s (" % embed[iat_sys].get_symbol(),
+                for idir in xrange(3):
+                    print "%10.6f" % f_sys_lo[iat_sys][idir], 
+                print ") <system LOW>"
+
+                iat_cl = atom_map_sys_cl[iat_sys]
+                if iat_cl > -1:
+                    print "%s" % "-  (",
+                    for idir in xrange(3):
+                        print "%10.6f" % f_cl_lo[iat_cl][idir], 
+                    print ") <cluster LOW>"
+                    print "%s" % "+  (",
+                    for idir in xrange(3):
+                        print "%10.6f" % f_cl_hi[iat_cl][idir], 
+                    print ") <cluster HIGH>"
+                print
+            print
+    
         # lo-sys + (hi-lo)
-        for iat_sys in xrange(nat_sys):
+        for iat_sys in xrange(len(embed)):
             iat_cl = atom_map_sys_cl[iat_sys]
             if iat_cl > -1:
                 f_sys_lo[iat_sys] += f_cl[iat_cl]
-
+        # some settings for the output
+        i_change = np.zeros(len(embed), int)
+        if self.print_forces:
+            f_sys_lo_orig = f_sys_lo.copy()
         # correct gradients
         # Reference: Eichler, Koelmel, Sauer, J. of Comput. Chem., 18(4). 1997, 463-477.
         for cell_L, iat_cl_sys, iat_sys, r, iat_link in embed.linkatoms:
             # calculate the bond distance (r_bond) at the border
             xyz = embed[iat_sys].get_position() - embed[iat_cl_sys].get_position() + cell_L
-            
             # calculate the bond lenght and the factor f
             rbond = np.sqrt(np.dot(xyz, xyz))
             f = r / rbond
@@ -87,11 +115,29 @@
             # receive the gradients for the link atom
             fL = f_cl[iat_link]
             # dot product fL, xyz
-            fs = np.dot(xyz, fL)
+            fs = np.dot(fL, xyz)
             # apply corrections for each direction
+            i_change[iat_sys] = 1
+            i_change[iat_cl_sys] = 1
             for idir in xrange(3):
                 # correct the atom in the system
-                f_sys_lo[iat_sys][idir] += f*fL[idir] - f*fs*xyz[idir]
+                f_sys_lo[iat_sys][idir] = f_sys_lo[iat_sys][idir] + f*fL[idir] - f*fs*xyz[idir]
                 # correct the atom in the cluster
-                f_sys_lo[iat_cl_sys][idir] += (1-f)*fL[idir] + f*fs*xyz[idir]
+                f_sys_lo[iat_cl_sys][idir] = f_sys_lo[iat_cl_sys][idir] + (1-f)*fL[idir] + f*fs*xyz[idir]
+
+        if self.print_forces:
+            print " TOTAL FORCE (uncorrected : corrected) for link atoms"
+            for iat_sys in xrange(len(embed)):
+                print "%-2s (" % embed[iat_sys].get_symbol(),
+                for idir in xrange(3):
+                    print "%10.6f" % f_sys_lo_orig[iat_sys][idir], 
+                print ") : (", 
+                for idir in xrange(3):
+                    print "%10.6f" % f_sys_lo[iat_sys][idir], 
+                print ")", 
+                if i_change[iat_sys]:
+                    print " *", 
+                print
+            print
+        
         return f_sys_lo
Index: ase/calculators/turbomole.py
===================================================================
--- ase/calculators/turbomole.py	(revision 4)
+++ ase/calculators/turbomole.py	(revision 5)
@@ -1,5 +1,4 @@
 """This module defines an ASE interface to Turbomole
-
 http://www.turbomole.com/
 """
 import os, sys, string
@@ -11,52 +10,7 @@
 import numpy as np
 
 class Turbomole(Calculator):
-    """Class for doing Turbomole calculations.
-    """
     def __init__(self, label='turbomole', calculate_energy="dscf", calculate_forces="grad", post_HF = False):
-        """Construct TURBOMOLE-calculator object.
-
-        Parameters
-        ==========
-        label: str
-            Prefix to use for filenames (label.txt, ...).
-            Default is 'turbomole'.
-
-        Examples
-        ========
-        This is poor man's version of ASE-Turbomole:
-
-        First you do a normal turbomole preparation using turbomole's
-        define-program for the initial and final states.
-
-        (for instance in subdirectories Initial and Final)
-
-        Then relax the initial and final coordinates with desired constraints
-        using standard turbomole.
-
-        Copy the relaxed initial and final coordinates 
-        (initial.coord and final.coord)
-        and the turbomole related files (from the subdirectory Initial) 
-        control, coord, alpha, beta, mos, basis, auxbasis etc to the directory
-        you do the diffusion run.
-        
-        For instance:
-        cd $My_Turbomole_diffusion_directory
-        cd Initial; cp control alpha beta mos basis auxbasis ../;
-        cp coord ../initial.coord;
-        cd ../;
-        cp Final/coord ./final.coord;
-        mkdir Gz ; cp * Gz ; gzip -r Gz
-        
-        from ase.io import read
-        from ase.calculators.turbomole import Turbomole
-        a = read('coord', index=-1, format='turbomole')
-        calc = Turbomole()
-        a.set_calculator(calc)
-        e = a.get_potential_energy()
-        
-        """
-       
         self.label = label
         self.converged = False
         
@@ -88,13 +42,15 @@
     def execute(self, command):
         from subprocess import Popen, PIPE
         try:
+            # the sub process gets started here
             proc = Popen([command], shell=True, stderr=PIPE)
             error = proc.communicate()[1]
-            if "abnormally" in error:
+            # check the error output
+            if not " ended normally" in error:
                 raise OSError(error)
             print "TM command: ", command, "successfully executed"
         except OSError, e:
-            print >>sys.stderr, "Execution failed:", e
+            print >>sys.stderr, "Execution failed: ", e
             sys.exit(1)
 
     def get_potential_energy(self, atoms):
@@ -134,7 +90,7 @@
         return self.forces.copy()
     
     def get_stress(self, atoms):
-        return self.stress.copy()
+        return self.stress
         
     def set_atoms(self, atoms):
         if self.atoms == atoms:
@@ -162,6 +118,7 @@
                 energy_tmp = float(line.split()[1])
                 if self.post_HF:
                     energy_tmp += float(line.split()[4])
+        # update energy units
         self.e_total = energy_tmp * Hartree
         
 
@@ -184,8 +141,11 @@
             print 'Gradients not found'
             raise RuntimeError("Please check TURBOMOLE gradients")
 
+        # next line
         iline += len(self.atoms) + 1
+        # $end line
         nline -= 1
+        # read gradients
         for i in xrange(iline, nline):
             line = string.replace(lines[i],'D','E')
             #tmp=np.append(forces_tmp,np.array\
Index: prepareQMX.py
===================================================================
--- prepareQMX.py	(revision 0)
+++ prepareQMX.py	(revision 5)
@@ -0,0 +1 @@
+link ../../10-programming/ASE.QMX/prepareQMX.py
\ No newline at end of file

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

Index: prepareQMX.GUI.py
===================================================================
--- prepareQMX.GUI.py	(revision 0)
+++ prepareQMX.GUI.py	(revision 5)
@@ -0,0 +1 @@
+link ../../10-programming/ASE.QMX/prepareQMX.GUI.py
\ No newline at end of file

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

