parameters: (name, **kwargs)
return_statement: return ciwfn
docstring: Function encoding sequence of PSI module calls for
      determinant-based multireference wavefuncations,
      namely CASSCF and RASSCF.
docstring_summary: Function encoding sequence of PSI module calls for
      determinant-based multireference wavefuncations,
      namely CASSCF and RASSCF.
docstring_tokens: Function encoding sequence of PSI module calls for determinant - based multireference wavefuncations namely CASSCF and RASSCF .
function: def run_detcas(name, **kwargs):
      """Function encoding sequence of PSI module calls for
      determinant-based multireference wavefuncations,
      namely CASSCF and RASSCF.
      """
      optstash = p4util.OptionsState(
          ['DETCI', 'WFN'],
          ['SCF_TYPE'],
          ['ONEPDM'],
          ['OPDM_RELAX']
          )
  
      user_ref = core.get_option('DETCI', 'REFERENCE')
      if user_ref not in ['RHF', 'ROHF']:
          raise ValidationError('Reference %s for DETCI is not available.' % user_ref)
  
      if name == 'rasscf':
          core.set_local_option('DETCI', 'WFN', 'RASSCF')
      elif name == 'casscf':
          core.set_local_option('DETCI', 'WFN', 'CASSCF')
      else:
          raise ValidationError("Run DETCAS: Name %s not understood" % name)
  
      ref_wfn = kwargs.get('ref_wfn', None)
      if ref_wfn is None:
  
          ref_optstash = p4util.OptionsState(
              ['SCF_TYPE'],
              ['DF_BASIS_SCF'],
              ['DF_BASIS_MP2'],
              ['ONEPDM'],
              ['OPDM_RELAX']
              )
  
          # No real reason to do a conventional guess
          if not core.has_global_option_changed('SCF_TYPE'):
              core.set_global_option('SCF_TYPE', 'DF')
  
          # If RHF get MP2 NO's
          # Why doesnt this work for conv?
          if (('DF' in core.get_global_option('SCF_TYPE')) and (user_ref == 'RHF') and
                      (core.get_option('DETCI', 'MCSCF_TYPE') in ['DF', 'AO']) and
                      (core.get_option("DETCI", "MCSCF_GUESS") == "MP2")):
              core.set_global_option('ONEPDM', True)
              core.set_global_option('OPDM_RELAX', False)
              ref_wfn = run_dfmp2_gradient(name, **kwargs)
          else:
              ref_wfn = scf_helper(name, **kwargs)
  
          # Ensure IWL files have been written
          if (core.get_option('DETCI', 'MCSCF_TYPE') == 'CONV'):
              mints = core.MintsHelper(ref_wfn.basisset())
              mints.set_print(1)
              mints.integrals()
  
          ref_optstash.restore()
  
      # The DF case
      if core.get_option('DETCI', 'MCSCF_TYPE') == 'DF':
          if not core.has_global_option_changed('SCF_TYPE'):
              core.set_global_option('SCF_TYPE', 'DF')
  
          core.print_out("  Constructing Basis Sets for MCSCF...\n\n")
          scf_aux_basis = core.BasisSet.build(ref_wfn.molecule(), "DF_BASIS_SCF",
                                              core.get_option("SCF", "DF_BASIS_SCF"),
                                              "JKFIT", core.get_global_option('BASIS'),
                                              puream=ref_wfn.basisset().has_puream())
          ref_wfn.set_basisset("DF_BASIS_SCF", scf_aux_basis)
  
      # The AO case
      elif core.get_option('DETCI', 'MCSCF_TYPE') == 'AO':
          if not core.has_global_option_changed('SCF_TYPE'):
              core.set_global_option('SCF_TYPE', 'DIRECT')
  
      # The conventional case
      elif core.get_option('DETCI', 'MCSCF_TYPE') == 'CONV':
          if not core.has_global_option_changed('SCF_TYPE'):
              core.set_global_option('SCF_TYPE', 'PK')
  
          # Ensure IWL files have been written
          proc_util.check_iwl_file_from_scf_type(core.get_global_option('SCF_TYPE'), ref_wfn)
      else:
          raise ValidationError("Run DETCAS: MCSCF_TYPE %s not understood." % str(core.get_option('DETCI', 'MCSCF_TYPE')))
  
  
      # Second-order SCF requires non-symmetric density matrix support
      if core.get_option('DETCI', 'MCSCF_ALGORITHM') in ['AH', 'OS']:
          proc_util.check_non_symmetric_jk_density("Second-order MCSCF")
  
      ciwfn = mcscf.mcscf_solver(ref_wfn)
  
      # We always would like to print a little dipole information
      oeprop = core.OEProp(ciwfn)
      oeprop.set_title(name.upper())
      oeprop.add("DIPOLE")
      oeprop.compute()
      ciwfn.oeprop = oeprop
      # retire components by v1.5
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          core.set_variable("CURRENT DIPOLE X", core.variable(name.upper() + " DIPOLE X"))
          core.set_variable("CURRENT DIPOLE Y", core.variable(name.upper() + " DIPOLE Y"))
          core.set_variable("CURRENT DIPOLE Z", core.variable(name.upper() + " DIPOLE Z"))
      core.set_variable("CURRENT DIPOLE", core.variable(name.upper() + " DIPOLE"))
  
      # Shove variables into global space
      for k, v in ciwfn.variables().items():
          core.set_variable(k, v)
  
      optstash.restore()
      return ciwfn
function_tokens: def run_detcas ( name , * * kwargs ) : optstash = p4util . OptionsState ( [ 'DETCI' , 'WFN' ] , [ 'SCF_TYPE' ] , [ 'ONEPDM' ] , [ 'OPDM_RELAX' ] ) user_ref = core . get_option ( 'DETCI' , 'REFERENCE' ) if user_ref not in [ 'RHF' , 'ROHF' ] : raise ValidationError ( 'Reference %s for DETCI is not available.' % user_ref ) if name == 'rasscf' : core . set_local_option ( 'DETCI' , 'WFN' , 'RASSCF' ) elif name == 'casscf' : core . set_local_option ( 'DETCI' , 'WFN' , 'CASSCF' ) else : raise ValidationError ( "Run DETCAS: Name %s not understood" % name ) ref_wfn = kwargs . get ( 'ref_wfn' , None ) if ref_wfn is None : ref_optstash = p4util . OptionsState ( [ 'SCF_TYPE' ] , [ 'DF_BASIS_SCF' ] , [ 'DF_BASIS_MP2' ] , [ 'ONEPDM' ] , [ 'OPDM_RELAX' ] ) # No real reason to do a conventional guess if not core . has_global_option_changed ( 'SCF_TYPE' ) : core . set_global_option ( 'SCF_TYPE' , 'DF' ) # If RHF get MP2 NO's # Why doesnt this work for conv? if ( ( 'DF' in core . get_global_option ( 'SCF_TYPE' ) ) and ( user_ref == 'RHF' ) and ( core . get_option ( 'DETCI' , 'MCSCF_TYPE' ) in [ 'DF' , 'AO' ] ) and ( core . get_option ( "DETCI" , "MCSCF_GUESS" ) == "MP2" ) ) : core . set_global_option ( 'ONEPDM' , True ) core . set_global_option ( 'OPDM_RELAX' , False ) ref_wfn = run_dfmp2_gradient ( name , * * kwargs ) else : ref_wfn = scf_helper ( name , * * kwargs ) # Ensure IWL files have been written if ( core . get_option ( 'DETCI' , 'MCSCF_TYPE' ) == 'CONV' ) : mints = core . MintsHelper ( ref_wfn . basisset ( ) ) mints . set_print ( 1 ) mints . integrals ( ) ref_optstash . restore ( ) # The DF case if core . get_option ( 'DETCI' , 'MCSCF_TYPE' ) == 'DF' : if not core . has_global_option_changed ( 'SCF_TYPE' ) : core . set_global_option ( 'SCF_TYPE' , 'DF' ) core . print_out ( "  Constructing Basis Sets for MCSCF...\n\n" ) scf_aux_basis = core . BasisSet . build ( ref_wfn . molecule ( ) , "DF_BASIS_SCF" , core . get_option ( "SCF" , "DF_BASIS_SCF" ) , "JKFIT" , core . get_global_option ( 'BASIS' ) , puream = ref_wfn . basisset ( ) . has_puream ( ) ) ref_wfn . set_basisset ( "DF_BASIS_SCF" , scf_aux_basis ) # The AO case elif core . get_option ( 'DETCI' , 'MCSCF_TYPE' ) == 'AO' : if not core . has_global_option_changed ( 'SCF_TYPE' ) : core . set_global_option ( 'SCF_TYPE' , 'DIRECT' ) # The conventional case elif core . get_option ( 'DETCI' , 'MCSCF_TYPE' ) == 'CONV' : if not core . has_global_option_changed ( 'SCF_TYPE' ) : core . set_global_option ( 'SCF_TYPE' , 'PK' ) # Ensure IWL files have been written proc_util . check_iwl_file_from_scf_type ( core . get_global_option ( 'SCF_TYPE' ) , ref_wfn ) else : raise ValidationError ( "Run DETCAS: MCSCF_TYPE %s not understood." % str ( core . get_option ( 'DETCI' , 'MCSCF_TYPE' ) ) ) # Second-order SCF requires non-symmetric density matrix support if core . get_option ( 'DETCI' , 'MCSCF_ALGORITHM' ) in [ 'AH' , 'OS' ] : proc_util . check_non_symmetric_jk_density ( "Second-order MCSCF" ) ciwfn = mcscf . mcscf_solver ( ref_wfn ) # We always would like to print a little dipole information oeprop = core . OEProp ( ciwfn ) oeprop . set_title ( name . upper ( ) ) oeprop . add ( "DIPOLE" ) oeprop . compute ( ) ciwfn . oeprop = oeprop # retire components by v1.5 with warnings . catch_warnings ( ) : warnings . simplefilter ( "ignore" ) core . set_variable ( "CURRENT DIPOLE X" , core . variable ( name . upper ( ) + " DIPOLE X" ) ) core . set_variable ( "CURRENT DIPOLE Y" , core . variable ( name . upper ( ) + " DIPOLE Y" ) ) core . set_variable ( "CURRENT DIPOLE Z" , core . variable ( name . upper ( ) + " DIPOLE Z" ) ) core . set_variable ( "CURRENT DIPOLE" , core . variable ( name . upper ( ) + " DIPOLE" ) ) # Shove variables into global space for k , v in ciwfn . variables ( ) . items ( ) : core . set_variable ( k , v ) optstash . restore ( ) return ciwfn