*****
PySCF
*****

.. py:class:: PySCF

This interface supports energy and gradient evaluations with the
`PySCF <https://pyscf.org/>`_ electronic structure package

A PySCF :ref:`Theory <theories>` object can be specified as follows::

  my_frag = Fragment(...)

  my_theory = PySCF(frag=my_frag,
                   method="hf",
                   basis='3-21g'
                   ...)

or for DFT::

  from pyscf.dft import DFT

  my_frag = Fragment(...)

  my_theory = PySCF(frag=my_frag,
                   method="dft",
                   basis='3-21g'
                   ...)

Alternatively, ChemShell supports passing pyscf methods directly::

  from pyscf.scf import RHF

  my_frag = Fragment(...)

  my_theory = PySCF(frag=my_frag,
                   method=RHF,
                   basis='3-21g'
                   ...)

or for DFT::

  from pyscf.dft import DFT

  my_frag = Fragment(...)

  my_theory = PySCF(frag=my_frag,
                   method=DFT,
                   basis='3-21g'
                   ...)

which would then be called as ``theory=my_theory`` in subsequent tasks.


Method options
==============

.. py:attribute:: gridsize

   (default: ``5``)  DFT integration grid size [0 (very sparse) -9 (very dense)] (See `PySCF's dft user manual <https://pyscf.org/user/dft.html>`_ for more details)


.. py:attribute:: fcidump

   (default: ``False``) Boolean flag determining if an FCIDUMP file should be written.

Basis set options
=================

.. py:attribute:: basis 

   Input basis set to use in PySCF

SCF options
===========

.. py:attribute:: convergence

   (default: ``1e-8``)  Convergence criteria for SCF procedure.

.. py:attribute:: scftype

   (default: ``"rhf"``)  Determines which scftype to use (supported: ``"rhf"``, ``"uhf"``, ``"rohf"``). If ``method`` is set explicitly as a pyscf class (i.e. ``method=pyscf.scf.RHF``) then this option is ignored.  

Interacting with PySCF directly
===============================

The user can interact directly with PySCF in chemshell via the ``method_pyscf`` attribute (e.g)::

   from chemsh import *
   
   water = Fragment(coords="water.cjson")
   
   pyscf = PySCF(frag=water, method="dft", functional="blyp", basis="3-21g")
   
   # We can now change the initial guess as described in the pyscf user documentation
   pyscf.method_pyscf.init_guess = "huckel"
   
   sp = SP(theory=pyscf)
   sp.run()
   
   ecalc = sp.result.energy

.. note:: As the ``method_pyscf`` allows the user fine-grained control of PySCF in ChemShell, users should take care as not all interactions between PySCF and ChemShell have been tested.
