QCaml/SCF/Guess.ml

51 lines
1.2 KiB
OCaml

open Lacaml.D
open Util
type guess =
| Hcore of Mat.t
| Huckel of Mat.t
type t = guess
module Ao = AOBasis
module El = Electrons
let hcore_guess ao_basis =
let eN_ints = Lazy.force ao_basis.Ao.eN_ints
and kin_ints = Lazy.force ao_basis.Ao.kin_ints
in
Mat.add eN_ints kin_ints
let huckel_guess ao_basis =
let c = 0.5 *. 1.75 in
let ao_num = Basis.size ao_basis.Ao.basis in
let eN_ints = Lazy.force ao_basis.Ao.eN_ints
and kin_ints = Lazy.force ao_basis.Ao.kin_ints
and overlap = Lazy.force ao_basis.Ao.overlap
and m_X = Lazy.force ao_basis.Ao.ortho
in
let diag = Array.init (ao_num+1) (fun i -> if i=0 then 0. else
eN_ints.{i,i} +. kin_ints.{i,i})
in
function
| 0 -> invalid_arg "Huckel guess needs a non-zero number of occupied MOs."
| nocc ->
let m_F = (Fock.make ~density:(gemm ~alpha:2. ~transb:`T ~k:nocc m_X m_X) ao_basis).Fock.fock in
for j=1 to ao_num do
for i=1 to ao_num do
if (i <> j) then
m_F.{i,j} <- c *. overlap.{i,j} *. (diag.(i) +. diag.(j)) (*TODO Pseudo *)
done;
done;
m_F
let make ?(nocc=0) ~guess ao_basis =
match guess with
| `Hcore -> Hcore (hcore_guess ao_basis)
| `Huckel -> Huckel (huckel_guess ao_basis nocc)