parameters: (self)
docstring: This function simplifies the Guassian ECP. The simplificactions are as follows:
          1. Remove all terms with coefficients that are equal to zero -- unless only one term exists.
          2. Within each component, look for terms that have matching exponents and r-powers, if any are
             present, then sum their coefficicents to make a single term. If the coefficients sum to
             zero, then remove the terms (unless that leaves the component empty)
docstring_summary: This function simplifies the Guassian ECP. The simplificactions are as follows:
          1. Remove all terms with coefficients that are equal to zero -- unless only one term exists.
          2. Within each component, look for terms that have matching exponents and r-powers, if any are
             present, then sum their coefficicents to make a single term. If the coefficients sum to
             zero, then remove the terms (unless that leaves the component empty)
docstring_tokens: This function simplifies the Guassian ECP . The simplificactions are as follows : 1 . Remove all terms with coefficients that are equal to zero -- unless only one term exists . 2 . Within each component look for terms that have matching exponents and r - powers if any are present then sum their coefficicents to make a single term . If the coefficients sum to zero then remove the terms ( unless that leaves the component empty )
function: def simplify(self):
          '''
          This function simplifies the Guassian ECP. The simplificactions are as follows:
          1. Remove all terms with coefficients that are equal to zero -- unless only one term exists.
          2. Within each component, look for terms that have matching exponents and r-powers, if any are
             present, then sum their coefficicents to make a single term. If the coefficients sum to
             zero, then remove the terms (unless that leaves the component empty)
          '''
          dec=16
          # Remove terms with coefficients equivalent to zero
          chan_labels = ['s','p','d','f','g','h','i','j']
          remove = []
          for l in np.arange(self.lmax+1):
              for term_idx,term in enumerate(self.components[chan_labels[l]]):
                  if abs(term.coeff)<1e-12 and len(self.components[chan_labels[l]])>1:
                      remove.append((chan_labels[l],term_idx))
                  #end if
              #end for
          #end for
          for r in remove:
              self.components[r[0]].delete(r[1])
          #end for
          comps = self.components.copy()
          for l in np.arange(self.lmax+1):
              comps[chan_labels[l]] = obj()
              for term_idx,term in enumerate(self.components[chan_labels[l]]):
                  comps[chan_labels[l]].append(term)
              #end for
          #end for
          self.components = comps.copy()
          comps = self.components.copy()
          for l in np.arange(self.lmax+1):
              terms = []
              comps[chan_labels[l]] = obj()
              for term_idx,term in enumerate(self.components[chan_labels[l]]):
                  terms.append(term.list())
              #end for
              terms = np.array(terms)
              like_terms = []
              if len(terms)>1:
                  rpows  = terms[:,2]
                  expons = terms[:,1]
                  coeffs = terms[:,0]
                  for ex_idx,ex in enumerate(expons.round(decimals=dec)):
                      if any(ex_idx in subl for subl in like_terms):
                          continue
                      #end if
                      match = np.argwhere(expons.round(decimals=dec)==ex)
                      if len(match)>1:
                          match = match.flatten()
                          unique_pows = np.unique(rpows[match].round(decimals=dec))
                          if len(unique_pows)==1:
                              like_terms.append(match.tolist())
                          else:
                              for uv in unique_pows:
                                  uv_count = rpows[match].round(decimals=dec).tolist().count(uv)
                                  if uv_count>1:
                                      m = match[rpows[match].round(decimals=dec)==uv][0]
                                      if any(m in subl for subl in like_terms):
                                          continue
                                      else:
                                          like_terms.append(match[rpows[match].round(decimals=dec)==uv].tolist())
                                      #end if
                                  #end if
                              #end for
                          #end if
                      #end if
                  #end for
              #end if
              # update comps
              comps[chan_labels[l]] = obj()
              added = []
              for term_idx,term in enumerate(self.components[chan_labels[l]]):
                  if any(term_idx in subl for subl in like_terms):
                      if term_idx in added:
                          continue
                      else:
                          for mlist in like_terms:
                              if term_idx in mlist and not term_idx in added:
                                  coeff = 0.0
                                  mod_term = term.copy()
                                  for ti in mlist: 
                                      coeff += self.components[chan_labels[l]][ti].coeff
                                  #end for
                                  if abs(coeff)>1e-12:
                                      mod_term.coeff = coeff
                                      comps[chan_labels[l]].append(mod_term)
                                  #end if
                                  added.extend(mlist)
                              #end if
                          #end for
                      #end if
                  else:
                      comps[chan_labels[l]].append(term)
                      added.append(term_idx)
                  #end if
              #end for
              if len(comps[chan_labels[l]])==0:
                  # All terms cancelled. Add placeholder
                  plcehldr = self.components['s'][0].copy()
                  plcehldr.coeff = 0.0
                  plcehldr.rpow = 2
                  plcehldr.expon = 1.0
                  comps[chan_labels[l]].append(plcehldr)
          #end for
          self.components = comps.copy()
function_tokens: def simplify ( self ) : dec = 16 # Remove terms with coefficients equivalent to zero chan_labels = [ 's' , 'p' , 'd' , 'f' , 'g' , 'h' , 'i' , 'j' ] remove = [ ] for l in np . arange ( self . lmax + 1 ) : for term_idx , term in enumerate ( self . components [ chan_labels [ l ] ] ) : if abs ( term . coeff ) < 1e-12 and len ( self . components [ chan_labels [ l ] ] ) > 1 : remove . append ( ( chan_labels [ l ] , term_idx ) ) #end if #end for #end for for r in remove : self . components [ r [ 0 ] ] . delete ( r [ 1 ] ) #end for comps = self . components . copy ( ) for l in np . arange ( self . lmax + 1 ) : comps [ chan_labels [ l ] ] = obj ( ) for term_idx , term in enumerate ( self . components [ chan_labels [ l ] ] ) : comps [ chan_labels [ l ] ] . append ( term ) #end for #end for self . components = comps . copy ( ) comps = self . components . copy ( ) for l in np . arange ( self . lmax + 1 ) : terms = [ ] comps [ chan_labels [ l ] ] = obj ( ) for term_idx , term in enumerate ( self . components [ chan_labels [ l ] ] ) : terms . append ( term . list ( ) ) #end for terms = np . array ( terms ) like_terms = [ ] if len ( terms ) > 1 : rpows = terms [ : , 2 ] expons = terms [ : , 1 ] coeffs = terms [ : , 0 ] for ex_idx , ex in enumerate ( expons . round ( decimals = dec ) ) : if any ( ex_idx in subl for subl in like_terms ) : continue #end if match = np . argwhere ( expons . round ( decimals = dec ) == ex ) if len ( match ) > 1 : match = match . flatten ( ) unique_pows = np . unique ( rpows [ match ] . round ( decimals = dec ) ) if len ( unique_pows ) == 1 : like_terms . append ( match . tolist ( ) ) else : for uv in unique_pows : uv_count = rpows [ match ] . round ( decimals = dec ) . tolist ( ) . count ( uv ) if uv_count > 1 : m = match [ rpows [ match ] . round ( decimals = dec ) == uv ] [ 0 ] if any ( m in subl for subl in like_terms ) : continue else : like_terms . append ( match [ rpows [ match ] . round ( decimals = dec ) == uv ] . tolist ( ) ) #end if #end if #end for #end if #end if #end for #end if # update comps comps [ chan_labels [ l ] ] = obj ( ) added = [ ] for term_idx , term in enumerate ( self . components [ chan_labels [ l ] ] ) : if any ( term_idx in subl for subl in like_terms ) : if term_idx in added : continue else : for mlist in like_terms : if term_idx in mlist and not term_idx in added : coeff = 0.0 mod_term = term . copy ( ) for ti in mlist : coeff += self . components [ chan_labels [ l ] ] [ ti ] . coeff #end for if abs ( coeff ) > 1e-12 : mod_term . coeff = coeff comps [ chan_labels [ l ] ] . append ( mod_term ) #end if added . extend ( mlist ) #end if #end for #end if else : comps [ chan_labels [ l ] ] . append ( term ) added . append ( term_idx ) #end if #end for if len ( comps [ chan_labels [ l ] ] ) == 0 : # All terms cancelled. Add placeholder plcehldr = self . components [ 's' ] [ 0 ] . copy ( ) plcehldr . coeff = 0.0 plcehldr . rpow = 2 plcehldr . expon = 1.0 comps [ chan_labels [ l ] ] . append ( plcehldr ) #end for self . components = comps . copy ( )