mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-11-07 22:53:41 +01:00
CAS+EN OK for 1 det
This commit is contained in:
parent
e7780804bf
commit
963441b434
58
CI/CI.ml
58
CI/CI.ml
@ -442,8 +442,32 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
|
|||||||
*)
|
*)
|
||||||
|
|
||||||
|
|
||||||
|
let symmetric = i_o1_alfa == alfa_o2_i in
|
||||||
|
|
||||||
|
let is_internal alfa =
|
||||||
|
let rec aux = function
|
||||||
|
| -1 -> false
|
||||||
|
| j -> if (Determinant.degree (fst psi0.(j)) alfa = 0) then true
|
||||||
|
else aux (j-1)
|
||||||
|
in
|
||||||
|
aux (Array.length psi0 - 1)
|
||||||
|
in
|
||||||
|
|
||||||
|
|
||||||
let det_contribution i =
|
let det_contribution i =
|
||||||
|
|
||||||
|
let already_generated alfa =
|
||||||
|
if is_internal alfa then
|
||||||
|
true
|
||||||
|
else
|
||||||
|
let rec aux = function
|
||||||
|
| -1 -> false
|
||||||
|
| j -> if (Determinant.degree (fst psi0.(j)) alfa <= 2) then true
|
||||||
|
else aux (j-1)
|
||||||
|
in
|
||||||
|
aux (i-1)
|
||||||
|
in
|
||||||
|
|
||||||
let psi_filtered_idx =
|
let psi_filtered_idx =
|
||||||
let rec aux accu = function
|
let rec aux accu = function
|
||||||
| j when j < i -> List.rev accu
|
| j when j < i -> List.rev accu
|
||||||
@ -458,8 +482,6 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
|
|||||||
List.map (fun i -> psi0.(i)) psi_filtered_idx
|
List.map (fun i -> psi0.(i)) psi_filtered_idx
|
||||||
in
|
in
|
||||||
|
|
||||||
let symmetric = i_o1_alfa == alfa_o2_i in
|
|
||||||
|
|
||||||
let psi_h_alfa alfa =
|
let psi_h_alfa alfa =
|
||||||
List.fold_left (fun accu (det, coef) ->
|
List.fold_left (fun accu (det, coef) ->
|
||||||
accu +. coef *. (i_o1_alfa det alfa)) 0. psi_filtered
|
accu +. coef *. (i_o1_alfa det alfa)) 0. psi_filtered
|
||||||
@ -481,25 +503,6 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
|
|||||||
(psi_h_alfa alfa) *. (alfa_h_psi alfa)
|
(psi_h_alfa alfa) *. (alfa_h_psi alfa)
|
||||||
in
|
in
|
||||||
|
|
||||||
let is_internal alfa =
|
|
||||||
let rec aux = function
|
|
||||||
| -1 -> false
|
|
||||||
| j -> Determinant.degree (fst psi0.(j)) alfa = 0 || aux (j-1)
|
|
||||||
in
|
|
||||||
aux (Array.length psi0 - 1)
|
|
||||||
in
|
|
||||||
|
|
||||||
let already_generated alfa =
|
|
||||||
if is_internal alfa then
|
|
||||||
true
|
|
||||||
else
|
|
||||||
let rec aux = function
|
|
||||||
| -1 -> false
|
|
||||||
| j -> Determinant.degree (fst psi0.(j)) alfa <= 2 || aux (j-1)
|
|
||||||
in
|
|
||||||
aux (i-1)
|
|
||||||
in
|
|
||||||
|
|
||||||
let det_i = fst psi0.(i) in
|
let det_i = fst psi0.(i) in
|
||||||
let w_alfa = w_alfa det_i in
|
let w_alfa = w_alfa det_i in
|
||||||
|
|
||||||
@ -584,7 +587,7 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
|
|||||||
same_spin +. opposite_spin
|
same_spin +. opposite_spin
|
||||||
in
|
in
|
||||||
|
|
||||||
Array.mapi (fun i (_,c_i) -> c_i *. det_contribution i) psi0
|
Array.mapi (fun i (_,c_i) -> det_contribution i) psi0
|
||||||
|> Array.fold_left (+.) 0.
|
|> Array.fold_left (+.) 0.
|
||||||
|
|
||||||
|
|
||||||
@ -627,3 +630,14 @@ let pt2_mp ci =
|
|||||||
second_order_sum ci i_o1_alfa i_o1_alfa w_alfa
|
second_order_sum ci i_o1_alfa i_o1_alfa w_alfa
|
||||||
|
|
||||||
|
|
||||||
|
let variance ci =
|
||||||
|
|
||||||
|
let mo_basis = Ds.mo_basis ci.det_space in
|
||||||
|
|
||||||
|
let i_o1_alfa = h_ij mo_basis in
|
||||||
|
|
||||||
|
let w_alfa _ _ = 1. in
|
||||||
|
|
||||||
|
second_order_sum ci i_o1_alfa i_o1_alfa w_alfa
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,8 +72,14 @@ let () =
|
|||||||
let ci = CI.make space in
|
let ci = CI.make space in
|
||||||
Format.fprintf ppf "CAS-CI energy : %20.16f@." ((CI.eigenvalues ci).{1} +. Simulation.nuclear_repulsion s);
|
Format.fprintf ppf "CAS-CI energy : %20.16f@." ((CI.eigenvalues ci).{1} +. Simulation.nuclear_repulsion s);
|
||||||
|
|
||||||
|
let pt2 = CI.pt2_mp ci in
|
||||||
|
Format.fprintf ppf "CAS-MP2 energy : %20.16f@." ((CI.eigenvalues ci).{1} +. Simulation.nuclear_repulsion s +. pt2);
|
||||||
|
|
||||||
let pt2 = CI.pt2_en ci in
|
let pt2 = CI.pt2_en ci in
|
||||||
Format.fprintf ppf "CAS-EN2 energy : %20.16f@." ((CI.eigenvalues ci).{1} +. Simulation.nuclear_repulsion s +. pt2)
|
Format.fprintf ppf "CAS-EN2 energy : %20.16f@." ((CI.eigenvalues ci).{1} +. Simulation.nuclear_repulsion s +. pt2);
|
||||||
|
|
||||||
|
let variance = CI.variance ci in
|
||||||
|
Format.fprintf ppf "CAS variance : %20.16f@." variance
|
||||||
(*
|
(*
|
||||||
let s2 = Util.xt_o_x ~o:(CI.s2_matrix ci) ~x:(CI.eigenvectors ci) in
|
let s2 = Util.xt_o_x ~o:(CI.s2_matrix ci) ~x:(CI.eigenvectors ci) in
|
||||||
Util.list_range 1 (DeterminantSpace.size space)
|
Util.list_range 1 (DeterminantSpace.size space)
|
||||||
|
Loading…
Reference in New Issue
Block a user