See examples in LocalizeMO.mw and LocalizeMO folder
LocalizeMO(mo,pro,typ,nof,evorH, moSorS:=1(N),purifymo:=undefined,
{minocc,donotdiagonalize,nprint,digits,printout}) ::lmo,lmoS,lme,occ2,occ1,T
localize molecular orbitals, where
mo::Matrix(N,n)pro::{list,Matrix} projector onto inner/outer space or list of basis set indices of the inner space,typ::"in,out,inU,inV,outU,outV,on" type of localization algorithm, see Notes,nof::{posint,numeric} either number of LMOs or outer space occupation threshold,evorH::{Matrix,Vector,0} Hamiltonian in mo-basis or eigenvalues if it is diagonal, LMOs are rotated to diagonalize this matrix unless donotdiagonalize,moSorS::Matrix basis set ovelap or moS=mo+.Spurifymo::name remove irrelevant MOs and rerun the command, list([mo#,T.T+[mo#,mo#]]) sorted by MO weights (second element) is returned in purifymo,minocc::numeric:=.01 to print,nprint::posint:=8 minimum number of LMOs to print,digits::posint:=3 for printing occupationsT::Matrix(n,no) unitary matrix transforming mo to lmo (in principle unitarity is not required but is checked),lmo::Matrix(N,no)=mo.T resulting LMOs,lmoS::Matrix(no,N)=lmo+.S lme::Vector(no) if donotdiagonalize then diagonal energies otherwise eigenenergies,occ2,occ1::Matrix occupations after and before the diagonalization, see Notes.typ="on" the command rotates mo to match pro
by compact SVD of the matrix mo+.S.prо=U.Sigma.V+, so that T=U.V+.
The final occupations are calculated as o->|lmoS[o,..].prо| in the quadratic norm.typ=in/out the command maximizes/minimizes U+.mo+.P'.S.P.mo.V
wrt to norm-preserving U and V, where P is algorithm-dependent projector.
If P'=P+ then U=V=T and the extremum is determined
by solving generalized eigenvalue problem with the normalization T+.mo+.S.mo.T=1.
Otherwise the optimization problem is solved by compact SVD.P are supported:
projective matrix P=pro with P'=P+,
and list of basis set indices K=pro of the projection space.
In the latter case the matrix mo+.P'.S.P.mo is constructed as
either mo[lsk,..]+.S[lsk,lsk].mo[lsk,..] for typ=in/out (so that P'=P+)
or mo+.S[..,lsk].mo[lsk,..] for typ=in/out+U/V (so that P'≠P+)
with lsk=K for "in" and complementary set of indices to K for "out".
In the former case the "direction" of the projector pro is provided by typ.
The final occupations are calculated as the diagonal of lmo+.P'.S.P.lmo.T=U or T=V, the choice is set by typ.nof are kept.typ are meaningful: often "in,inV,outU" produce wrong results (in particular for unoccuped MOs).
The most universal are "inU" and "outV", because "out" requires full overlap matrix, whereas "on" requires good initial guess of LMO.MultimerH(ev,evr,evcs,{exact,printout,maxsize})::Ho,H,S,T,W,lso
calculate effective one-particle Hamiltonian for a given molecular multimer, where
ev::Vector(n),evr::Matrix(n,N) MO energies and row-MOs of the multimer,evcs::list(Matrix(Nm,nom)) monomers basis, add(Nm,m)=N, add(nom,m)=no≤n,exact determine set of covered MOs and repeat with only those MOs,
set to false for entangled bands in incomplete monomer basis,maxsize::posint:=99 passed to PrintMatrix,T::Matrix(n,no)=evr.evcs projection matrix,S::Matrix(no)=T+.T overlap matrix in the monomers basis,H::Matrix(no)=T+.ev.T effective Hamiltonian in the monomers basis,Ho=S^(-1/2).H.S^(-1/2) orthogonalized Hamiltonian,W=Vector(n,k->add(T[k,o]^2,o=1..no)) weights of MOs of the multimer in the monomers basis,lso::list[no](posint) list of MOs of the multimer covered by the monomers basis.