def __init__(self, name):
 
     self.name = name
     self.input_name = self.get_input_name()
     self.linear = 0
     self.n_atoms = ri.read_molecule(self.get_molecule_input_name())[4]
     self.coordinates = ri.read_molecule(self.get_molecule_input_name())[0]
     self.atom_list = ri.read_molecule(self.get_molecule_input_name())[5]
     self.n_coordinates = self.get_coordinates() 
     self.number_of_normal_modes = self.get_number_of_normal_modes()
     self.hessian = self.get_hessian()
     
     self.eigenvalues,\
     self.eigenvectors,\
     self.frequencies, \
     self.eigenvalues_full, \
     self.eigenvectors_full = self.diagonalize(self.hessian)
     
     self.cff_norm = self.to_normal_coordinates_3D\
     (ri.read_cubic_force_field_anal(self.get_cubic_force_field_name(), self.n_coordinates))
     
     #self.qff_norm = self.to_normal_coordinates_4D(ri.read_quartic_force_field1(self.input_name + 'quartic', self.n_coordinates))
     
     self.effective_geometry = self.get_effective_geometry()
     
     open(self.get_output_name(), 'w').close() # As we are appending to the output, the old results must be deleted before each run
    def diagonalize(self, hessian): 
        """Computes the normal coordinates, eigenvalues and fundamental 
        frequencies of the molecule. 
        hessian: The hessian of the molecule as an np.array
        num_atoms_list: A list of the how many of each atoms type there are
        charge list: A list over the charges of the atoms in the molecle
        coordinates: The cartessian coordinates of the molecule as an np.array
        n_atoms: The number of atoms composing the molecule as an int
        masses: The masses of the atoms in a molecule along the diagonal of
                an np.array
        returns: The non-zero eigenvalues of the molecule as an np.array
                 The normal coordinates of the molecule, ie. the eigenvectors
                 corresponding the non-zero eigevalues as an np.array
                 The fundalmental frequencies of the molecule as an np.array
                 All the eigenvectos of the molecules, both the ones 
                 corresponding the zero and non-zero eigenvalues as an np.array
        """
       
        coordinates, masses, num_atoms_list, charge_list,\
        n_atoms, atom_list = ri.read_molecule(self.get_molecule_input_name())
    
        
        M_I = self.mass_hessian(masses)
        if (self.linear):
            n_nm += 1
        
        hess_proj = self.hessian_trans_rot(hessian, coordinates, self.number_of_normal_modes, n_atoms)
        
        hessian_proj = dot(M_I.transpose(), hess_proj)
        hessian_proj = dot(hessian_proj, M_I)
        
        
        v, La = linalg.eig(hessian_proj)
    
        v_reduced = v[:self.number_of_normal_modes]
         
        v_args = v_reduced.argsort()[::-1]
        v_reduced = array(v_reduced, double)
        v_reduced = v_reduced[v_args]
        
        La= dot(M_I, array(La, double))
        La_reduced = La[:,v_args]
    
        freq = sqrt(absolute(v_reduced))
        
        closefunc = lambda x: abs(x) < 0.0001
        closevect = vectorize(closefunc)
        reldiff = lambda x, y: x/y
        reldiff = vectorize(reldiff)
        eqsign = lambda x, y: x*y > 0
        eqsign = vectorize(eqsign)

        return v_reduced, La_reduced, freq, v, La