<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Forte Tutorial 2.02
Step2:  We will start by generating SCF orbitals for methane via psi4 using the forte.util.psi4_scf function
Step3:  Next we start forte, setup the MOSpaceInfo object specifying the number of orbitals, and start the integral object
Step4:  Localizing the orbitals
To localize the orbitals we create a Localize object. We have to pass a few object to perform the localization
Step5:  Once the Localize object is created, we specify which orbital space we want to be localized and compute the unitary transformation
Step6:  From the localizer we can then extract the unitary transformation matrix that correspond to the orbital localizaition. Here we get the alpha part
Step7:  We are now ready to read the MOs from psi4 and transform them by computing the product $\mathbf{C}' = \mathbf{C} \mathbf{U}$. We then place the orbitals back into psi4 by calling the copy function on wfn.Ca(). We have to do this because this function returns a smart pointer to the matrix that holds $\mathbf{C}$. If we assigned Ca_local via wfn.Ca() = Ca_local we would not change the orbitals in psi4.
Step8:  Lastly, we can optionally generate cube files for all the occupied orbitals and visualize them. The resulting orbitals consist of a core orbital (which cannot be seen) and four localized C-H $\sigma$ bond orbitals
<ASSISTANT_TASK:>
Python Code:
import psi4
import forte
import forte.utils
Explanation: Forte Tutorial 2.02: Orbital localization
In this tutorial we are going to explore how to localize orbitals and visualize them in Jupyter notebooks using the Python API.
Let's import the psi4 and forte modules, including the forte.utils submodule
End of explanation
xyz = 
0 1
C       -1.9565506735      0.4146729724      0.0000000000                 
H       -0.8865506735      0.4146729724      0.0000000000                 
H       -2.3132134555      1.1088535618     -0.7319870007                 
H       -2.3132183114      0.7015020975      0.9671697106                 
H       -2.3132196063     -0.5663349614     -0.2351822830
symmetry c1
E_scf, wfn = forte.utils.psi4_scf(xyz, 'sto-3g', 'rhf', functional = 'hf')
Explanation: We will start by generating SCF orbitals for methane via psi4 using the forte.util.psi4_scf function
End of explanation
from forte import forte_options
options = forte.forte_options
mos_spaces = {'RESTRICTED_DOCC' : [5], 'ACTIVE' : [0]}
nmopi = wfn.nmopi()
point_group = wfn.molecule().point_group().symbol()
mo_space_info = forte.make_mo_space_info_from_map(nmopi,point_group,mos_spaces,[])
scf_info = forte.SCFInfo(wfn)
ints = forte.make_ints_from_psi4(wfn, options, mo_space_info)
Explanation: Next we start forte, setup the MOSpaceInfo object specifying the number of orbitals, and start the integral object
End of explanation
localizer = forte.Localize(forte.forte_options, ints, mo_space_info)
Explanation: Localizing the orbitals
To localize the orbitals we create a Localize object. We have to pass a few object to perform the localization
End of explanation
localizer.set_orbital_space(['RESTRICTED_DOCC'])
localizer.compute_transformation()
Explanation: Once the Localize object is created, we specify which orbital space we want to be localized and compute the unitary transformation
End of explanation
Ua = localizer.get_Ua()
Explanation: From the localizer we can then extract the unitary transformation matrix that correspond to the orbital localizaition. Here we get the alpha part
End of explanation
Ca = wfn.Ca()
Ca_local = psi4.core.doublet(Ca,Ua,False,False)
wfn.Ca().copy(Ca_local)
Explanation: We are now ready to read the MOs from psi4 and transform them by computing the product $\mathbf{C}' = \mathbf{C} \mathbf{U}$. We then place the orbitals back into psi4 by calling the copy function on wfn.Ca(). We have to do this because this function returns a smart pointer to the matrix that holds $\mathbf{C}$. If we assigned Ca_local via wfn.Ca() = Ca_local we would not change the orbitals in psi4.
End of explanation
# make cube files
# forte.utils.psi4_cubeprop(wfn,path='cubes',nocc=5,nvir=0, load=True)
Explanation: Lastly, we can optionally generate cube files for all the occupied orbitals and visualize them. The resulting orbitals consist of a core orbital (which cannot be seen) and four localized C-H $\sigma$ bond orbitals
End of explanation
<END_TASK>