parameters: (self)
docstring: Specialized initialization, compute integrals and does everything to prepare for iterations
docstring_summary: Specialized initialization, compute integrals and does everything to prepare for iterations
docstring_tokens: Specialized initialization compute integrals and does everything to prepare for iterations
function: def scf_initialize(self):
      """Specialized initialization, compute integrals and does everything to prepare for iterations"""
  
      # Figure out memory distributions
  
      # Get memory in terms of doubles
      total_memory = (core.get_memory() / 8) * core.get_global_option("SCF_MEM_SAFETY_FACTOR")
  
      # Figure out how large the DFT collocation matrices are
      vbase = self.V_potential()
      if vbase:
          collocation_size = vbase.grid().collocation_size()
          if vbase.functional().ansatz() == 1:
              collocation_size *= 4  # First derivs
          elif vbase.functional().ansatz() == 2:
              collocation_size *= 10  # Second derivs
      else:
          collocation_size = 0
  
      # Change allocation for collocation matrices based on DFT type
      jk = _build_jk(self, total_memory)
      jk_size = jk.memory_estimate()
  
      # Give remaining to collocation
      if total_memory > jk_size:
          collocation_memory = total_memory - jk_size
      # Give up to 10% to collocation
      elif (total_memory * 0.1) > collocation_size:
          collocation_memory = collocation_size
      else:
          collocation_memory = total_memory * 0.1
  
      if collocation_memory > collocation_size:
          collocation_memory = collocation_size
  
      # Set constants
      self.iteration_ = 0
      self.memory_jk_ = int(total_memory - collocation_memory)
      self.memory_collocation_ = int(collocation_memory)
  
      if self.get_print():
          core.print_out("  ==> Integral Setup <==\n\n")
  
      # Initialize EFP
      efp_enabled = hasattr(self.molecule(), 'EFP')
      if efp_enabled:
          # EFP: Set QM system, options, and callback. Display efp geom in [A]
          efpobj = self.molecule().EFP
          core.print_out(efpobj.banner())
          core.print_out(efpobj.geometry_summary(units_to_bohr=constants.bohr2angstroms))
  
          efpptc, efpcoords, efpopts = get_qm_atoms_opts(self.molecule())
          efpobj.set_point_charges(efpptc, efpcoords)
          efpobj.set_opts(efpopts, label='psi', append='psi')
  
          efpobj.set_electron_density_field_fn(efp_field_fn)
  
      # Initialize all integrals and perform the first guess
      if self.attempt_number_ == 1:
          mints = core.MintsHelper(self.basisset())
  
          self.initialize_jk(self.memory_jk_, jk=jk)
          if self.V_potential():
              self.V_potential().build_collocation_cache(self.memory_collocation_)
          core.timer_on("HF: Form core H")
          self.form_H()
          core.timer_off("HF: Form core H")
  
          if efp_enabled:
              # EFP: Add in permanent moment contribution and cache
              core.timer_on("HF: Form Vefp")
              verbose = core.get_option('SCF', "PRINT")
              Vefp = modify_Fock_permanent(self.molecule(), mints, verbose=verbose - 1)
              Vefp = core.Matrix.from_array(Vefp)
              self.H().add(Vefp)
              Horig = self.H().clone()
              self.Horig = Horig
              core.print_out("  QM/EFP: iterating Total Energy including QM/EFP Induction\n")
              core.timer_off("HF: Form Vefp")
  
          core.timer_on("HF: Form S/X")
          self.form_Shalf()
          core.timer_off("HF: Form S/X")
  
          core.print_out("\n  ==> Pre-Iterations <==\n\n")
  
          core.timer_on("HF: Guess")
          self.guess()
          core.timer_off("HF: Guess")
          # Print out initial docc/socc/etc data
          if self.get_print():                    
              lack_occupancy = core.get_local_option('SCF', 'GUESS') in ['SAD']
              if core.get_global_option('GUESS') in ['SAD']:
                  lack_occupancy = core.get_local_option('SCF', 'GUESS') in ['AUTO']
                  self.print_preiterations(small=lack_occupancy)
              else:
                  self.print_preiterations(small=lack_occupancy)
  
      else:
          # We're reading the orbitals from the previous set of iterations.
          self.form_D()
          self.set_energies("Total Energy", self.compute_initial_E())
  
      # turn off VV10 for iterations
      if core.get_option('SCF', "DFT_VV10_POSTSCF") and self.functional().vv10_b() > 0.0:
          core.print_out("  VV10: post-SCF option active \n \n")
          self.functional().set_lock(False)
          self.functional().set_do_vv10(False)
          self.functional().set_lock(True)
  
      # Print iteration header
      is_dfjk = core.get_global_option('SCF_TYPE').endswith('DF')
      diis_rms = core.get_option('SCF', 'DIIS_RMS_ERROR')
      core.print_out("  ==> Iterations <==\n\n")
      core.print_out("%s                        Total Energy        Delta E     %s |[F,P]|\n\n" %
                     ("   " if is_dfjk else "", "RMS" if diis_rms else "MAX"))
function_tokens: def scf_initialize ( self ) : # Figure out memory distributions # Get memory in terms of doubles total_memory = ( core . get_memory ( ) / 8 ) * core . get_global_option ( "SCF_MEM_SAFETY_FACTOR" ) # Figure out how large the DFT collocation matrices are vbase = self . V_potential ( ) if vbase : collocation_size = vbase . grid ( ) . collocation_size ( ) if vbase . functional ( ) . ansatz ( ) == 1 : collocation_size *= 4 # First derivs elif vbase . functional ( ) . ansatz ( ) == 2 : collocation_size *= 10 # Second derivs else : collocation_size = 0 # Change allocation for collocation matrices based on DFT type jk = _build_jk ( self , total_memory ) jk_size = jk . memory_estimate ( ) # Give remaining to collocation if total_memory > jk_size : collocation_memory = total_memory - jk_size # Give up to 10% to collocation elif ( total_memory * 0.1 ) > collocation_size : collocation_memory = collocation_size else : collocation_memory = total_memory * 0.1 if collocation_memory > collocation_size : collocation_memory = collocation_size # Set constants self . iteration_ = 0 self . memory_jk_ = int ( total_memory - collocation_memory ) self . memory_collocation_ = int ( collocation_memory ) if self . get_print ( ) : core . print_out ( "  ==> Integral Setup <==\n\n" ) # Initialize EFP efp_enabled = hasattr ( self . molecule ( ) , 'EFP' ) if efp_enabled : # EFP: Set QM system, options, and callback. Display efp geom in [A] efpobj = self . molecule ( ) . EFP core . print_out ( efpobj . banner ( ) ) core . print_out ( efpobj . geometry_summary ( units_to_bohr = constants . bohr2angstroms ) ) efpptc , efpcoords , efpopts = get_qm_atoms_opts ( self . molecule ( ) ) efpobj . set_point_charges ( efpptc , efpcoords ) efpobj . set_opts ( efpopts , label = 'psi' , append = 'psi' ) efpobj . set_electron_density_field_fn ( efp_field_fn ) # Initialize all integrals and perform the first guess if self . attempt_number_ == 1 : mints = core . MintsHelper ( self . basisset ( ) ) self . initialize_jk ( self . memory_jk_ , jk = jk ) if self . V_potential ( ) : self . V_potential ( ) . build_collocation_cache ( self . memory_collocation_ ) core . timer_on ( "HF: Form core H" ) self . form_H ( ) core . timer_off ( "HF: Form core H" ) if efp_enabled : # EFP: Add in permanent moment contribution and cache core . timer_on ( "HF: Form Vefp" ) verbose = core . get_option ( 'SCF' , "PRINT" ) Vefp = modify_Fock_permanent ( self . molecule ( ) , mints , verbose = verbose - 1 ) Vefp = core . Matrix . from_array ( Vefp ) self . H ( ) . add ( Vefp ) Horig = self . H ( ) . clone ( ) self . Horig = Horig core . print_out ( "  QM/EFP: iterating Total Energy including QM/EFP Induction\n" ) core . timer_off ( "HF: Form Vefp" ) core . timer_on ( "HF: Form S/X" ) self . form_Shalf ( ) core . timer_off ( "HF: Form S/X" ) core . print_out ( "\n  ==> Pre-Iterations <==\n\n" ) core . timer_on ( "HF: Guess" ) self . guess ( ) core . timer_off ( "HF: Guess" ) # Print out initial docc/socc/etc data if self . get_print ( ) : lack_occupancy = core . get_local_option ( 'SCF' , 'GUESS' ) in [ 'SAD' ] if core . get_global_option ( 'GUESS' ) in [ 'SAD' ] : lack_occupancy = core . get_local_option ( 'SCF' , 'GUESS' ) in [ 'AUTO' ] self . print_preiterations ( small = lack_occupancy ) else : self . print_preiterations ( small = lack_occupancy ) else : # We're reading the orbitals from the previous set of iterations. self . form_D ( ) self . set_energies ( "Total Energy" , self . compute_initial_E ( ) ) # turn off VV10 for iterations if core . get_option ( 'SCF' , "DFT_VV10_POSTSCF" ) and self . functional ( ) . vv10_b ( ) > 0.0 : core . print_out ( "  VV10: post-SCF option active \n \n" ) self . functional ( ) . set_lock ( False ) self . functional ( ) . set_do_vv10 ( False ) self . functional ( ) . set_lock ( True ) # Print iteration header is_dfjk = core . get_global_option ( 'SCF_TYPE' ) . endswith ( 'DF' ) diis_rms = core . get_option ( 'SCF' , 'DIIS_RMS_ERROR' ) core . print_out ( "  ==> Iterations <==\n\n" ) core . print_out ( "%s                        Total Energy        Delta E     %s |[F,P]|\n\n" % ( "   " if is_dfjk else "" , "RMS" if diis_rms else "MAX" ) )