mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-08-30 08:13:40 +02:00
Cleaned AO Basis
This commit is contained in:
parent
8454863e91
commit
ccb4967993
@ -12,6 +12,16 @@ type t =
|
||||
cartesian : bool;
|
||||
}
|
||||
|
||||
let basis t = t.basis
|
||||
let overlap t = Lazy.force t.overlap
|
||||
let ortho t = Lazy.force t.ortho
|
||||
let eN_ints t = Lazy.force t.eN_ints
|
||||
let ee_ints t = Lazy.force t.ee_ints
|
||||
let kin_ints t = Lazy.force t.kin_ints
|
||||
let cartesian t = t.cartesian
|
||||
|
||||
|
||||
|
||||
let make ~cartesian ~basis nuclei =
|
||||
|
||||
let overlap = lazy (
|
||||
|
@ -1,16 +1,32 @@
|
||||
(** Data structure for Atomic Orbitals. *)
|
||||
|
||||
type t = private
|
||||
{
|
||||
basis : Basis.t ; (* One-electron basis set *)
|
||||
overlap : Overlap.t lazy_t; (* Overlap matrix *)
|
||||
ortho : Orthonormalization.t lazy_t; (* Orthonormalization matrix of the overlap *)
|
||||
eN_ints : NucInt.t lazy_t; (* Electron-nucleus potential integrals *)
|
||||
ee_ints : ERI.t lazy_t; (* Electron-electron potential integrals *)
|
||||
kin_ints : KinInt.t lazy_t; (* Kinetic energy integrals *)
|
||||
cartesian : bool ; (* If true, use cartesian Gaussians (6d, 10f, ...) *)
|
||||
}
|
||||
type t
|
||||
|
||||
(** {1 Accessors} *)
|
||||
|
||||
val basis : t -> Basis.t
|
||||
(** One-electron basis set *)
|
||||
|
||||
val overlap : t -> Overlap.t
|
||||
(** Overlap matrix *)
|
||||
|
||||
val ortho : t -> Orthonormalization.t
|
||||
(** Orthonormalization matrix of the overlap *)
|
||||
|
||||
val eN_ints : t -> NucInt.t
|
||||
(** Electron-nucleus potential integrals *)
|
||||
|
||||
val ee_ints : t -> ERI.t
|
||||
(** Electron-electron potential integrals *)
|
||||
|
||||
val kin_ints : t -> KinInt.t
|
||||
(** Kinetic energy integrals *)
|
||||
|
||||
val cartesian : t -> bool
|
||||
(** If true, use cartesian Gaussians (6d, 10f, ...) *)
|
||||
|
||||
|
||||
(** {1 Creators} *)
|
||||
|
||||
val make : cartesian:bool -> basis:Basis.t -> Nuclei.t -> t
|
||||
(** Creates the data structure for atomic orbitals from a {Basis.t} and the
|
||||
@ -18,4 +34,5 @@ val make : cartesian:bool -> basis:Basis.t -> Nuclei.t -> t
|
||||
|
||||
|
||||
(** {2 Tests} *)
|
||||
|
||||
val test_case : t -> unit Alcotest.test_case list
|
||||
|
@ -130,19 +130,19 @@ let make ~simulation ~mo_type ~mo_occupation ~mo_coef () =
|
||||
Si.ao_basis simulation
|
||||
in
|
||||
let eN_ints = lazy (
|
||||
Lazy.force ao_basis.AOBasis.eN_ints
|
||||
AOBasis.eN_ints ao_basis
|
||||
|> NucInt.matrix
|
||||
|> mo_matrix_of_ao_matrix ~mo_coef
|
||||
|> NucInt.of_matrix
|
||||
)
|
||||
and kin_ints = lazy (
|
||||
Lazy.force ao_basis.AOBasis.kin_ints
|
||||
AOBasis.kin_ints ao_basis
|
||||
|> KinInt.matrix
|
||||
|> mo_matrix_of_ao_matrix ~mo_coef
|
||||
|> KinInt.of_matrix
|
||||
)
|
||||
and ee_ints = lazy (
|
||||
Lazy.force ao_basis.AOBasis.ee_ints
|
||||
AOBasis.ee_ints ao_basis
|
||||
|> four_index_transform ~mo_coef
|
||||
)
|
||||
in
|
||||
|
@ -18,9 +18,9 @@ module Ao = AOBasis
|
||||
|
||||
let make ~density ?(threshold=Constants.epsilon) ao_basis =
|
||||
let m_P = density
|
||||
and m_T = Lazy.force ao_basis.Ao.kin_ints |> KinInt.matrix
|
||||
and m_V = Lazy.force ao_basis.Ao.eN_ints |> NucInt.matrix
|
||||
and m_G = Lazy.force ao_basis.Ao.ee_ints
|
||||
and m_T = Ao.kin_ints ao_basis |> KinInt.matrix
|
||||
and m_V = Ao.eN_ints ao_basis |> NucInt.matrix
|
||||
and m_G = Ao.ee_ints ao_basis
|
||||
in
|
||||
let nBas = Mat.dim1 m_T
|
||||
in
|
||||
|
18
SCF/Guess.ml
18
SCF/Guess.ml
@ -12,19 +12,19 @@ module El = Electrons
|
||||
module Ov = Overlap
|
||||
|
||||
let hcore_guess ao_basis =
|
||||
let eN_ints = Lazy.force ao_basis.Ao.eN_ints |> NucInt.matrix
|
||||
and kin_ints = Lazy.force ao_basis.Ao.kin_ints |> KinInt.matrix
|
||||
let eN_ints = Ao.eN_ints ao_basis |> NucInt.matrix
|
||||
and kin_ints = Ao.kin_ints ao_basis |> KinInt.matrix
|
||||
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 |> NucInt.matrix
|
||||
and kin_ints = Lazy.force ao_basis.Ao.kin_ints |> KinInt.matrix
|
||||
and overlap = Lazy.force ao_basis.Ao.overlap |> Ov.matrix
|
||||
and m_X = Lazy.force ao_basis.Ao.ortho
|
||||
let ao_num = Ao.basis ao_basis |> Basis.size in
|
||||
let eN_ints = Ao.eN_ints ao_basis |> NucInt.matrix
|
||||
and kin_ints = Ao.kin_ints ao_basis |> KinInt.matrix
|
||||
and overlap = Ao.overlap ao_basis |> Ov.matrix
|
||||
and m_X = Ao.ortho ao_basis
|
||||
in
|
||||
let diag = Array.init (ao_num+1) (fun i -> if i=0 then 0. else
|
||||
eN_ints.{i,i} +. kin_ints.{i,i})
|
||||
@ -62,8 +62,8 @@ let test_case ao_basis =
|
||||
let a = Lacaml.D.Mat.to_array matrix in
|
||||
let reference =
|
||||
Lacaml.D.Mat.add
|
||||
(Lazy.force ao_basis.AOBasis.eN_ints |> NucInt.matrix)
|
||||
(Lazy.force ao_basis.AOBasis.kin_ints |> KinInt.matrix)
|
||||
(AOBasis.eN_ints ao_basis |> NucInt.matrix)
|
||||
(AOBasis.kin_ints ao_basis |> KinInt.matrix)
|
||||
|> Lacaml.D.Mat.to_array
|
||||
in
|
||||
Array.iteri (fun i x ->
|
||||
|
@ -30,18 +30,18 @@ let make ?guess:(guess=`Huckel) ?max_scf:(max_scf=64) ?level_shift:(level_shift=
|
||||
|
||||
(* Orthogonalization matrix *)
|
||||
let m_X =
|
||||
Lazy.force ao_basis.Ao.ortho
|
||||
Ao.ortho ao_basis
|
||||
in
|
||||
|
||||
|
||||
(* Overlap matrix *)
|
||||
let m_S =
|
||||
Lazy.force ao_basis.Ao.overlap
|
||||
Ao.overlap ao_basis
|
||||
|> Ov.matrix
|
||||
in
|
||||
|
||||
let m_T = Lazy.force ao_basis.Ao.kin_ints |> KinInt.matrix
|
||||
and m_V = Lazy.force ao_basis.Ao.eN_ints |> NucInt.matrix
|
||||
let m_T = Ao.kin_ints ao_basis |> KinInt.matrix
|
||||
and m_V = Ao.eN_ints ao_basis |> NucInt.matrix
|
||||
in
|
||||
|
||||
(* Level shift in MO basis *)
|
||||
|
@ -37,10 +37,10 @@ let run ~out =
|
||||
print_endline @@ Basis.to_string @@ Simulation.basis s;
|
||||
|
||||
let ao_basis = Simulation.ao_basis s in
|
||||
let overlap = Lazy.force ao_basis.AOBasis.overlap in
|
||||
let eN_ints = Lazy.force ao_basis.AOBasis.eN_ints in
|
||||
let kin_ints = Lazy.force ao_basis.AOBasis.kin_ints in
|
||||
let ee_ints = Lazy.force ao_basis.AOBasis.ee_ints in
|
||||
let overlap = AOBasis.overlap ao_basis in
|
||||
let eN_ints = AOBasis.eN_ints ao_basis in
|
||||
let kin_ints = AOBasis.kin_ints ao_basis in
|
||||
let ee_ints = AOBasis.ee_ints ao_basis in
|
||||
Overlap.to_file ~filename:(out_file^".overlap") overlap;
|
||||
NucInt.to_file ~filename:(out_file^".nuc") eN_ints;
|
||||
KinInt.to_file ~filename:(out_file^".kin") kin_ints;
|
||||
|
Loading…
Reference in New Issue
Block a user