10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-06-26 15:12:05 +02:00

Searching bug in CAS+EN2

This commit is contained in:
Anthony Scemama 2019-03-23 01:06:38 +01:00
parent 2735688efe
commit 494b0a2e3c
2 changed files with 31 additions and 37 deletions

View File

@ -414,14 +414,12 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
list_holes2 list_particles2 is_internal list_holes2 list_particles2 is_internal
i_o1_alfa alfa_o2_i w_alfa psi0 = i_o1_alfa alfa_o2_i w_alfa psi0 =
let list_holes1 = Array.of_list list_holes1 let list_holes1 = Array.of_list list_holes1 in
and list_holes2 = Array.of_list list_holes2 let list_particles1 = Array.of_list list_particles1 in
and list_particles1 = Array.of_list list_particles1 let list_holes2 = Array.of_list list_holes2 in
and list_particles2 = Array.of_list list_particles2 let list_particles2 = Array.of_list list_particles2 in
in
let psi0 = let psi0 =
let stream = let stream =
Ds.determinant_stream det_space Ds.determinant_stream det_space
in in
@ -448,7 +446,8 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
|| aux (j-1) || aux (j-1)
in in
aux (i-1) aux (i-1)
) else )
else
is_internal is_internal
in in
@ -513,18 +512,17 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
let double = let double =
Array.fold_left (fun accu particle' -> Array.fold_left (fun accu particle' ->
if particle' > particle || particle' = hole then if particle' >= particle || particle' = hole then
accu accu
else else
accu +. accu +.
Array.fold_left (fun accu hole' -> Array.fold_left (fun accu hole' ->
if hole' = particle' || hole' = particle || hole' < hole then if hole' = particle' || hole' = particle || hole' <= hole then
accu accu
else else
let alfa = let alfa =
Determinant.double_excitation Determinant.single_excitation
spin hole particle spin hole' particle' alfa
spin hole' particle' det_i
in in
if Determinant.is_none alfa || if Determinant.is_none alfa ||
already_generated alfa then already_generated alfa then
@ -550,7 +548,7 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
in in
if Determinant.is_none alfa then accu else if Determinant.is_none alfa then accu else
let double = let double_ab =
Array.fold_left (fun accu particle' -> Array.fold_left (fun accu particle' ->
accu +. accu +.
Array.fold_left (fun accu hole' -> Array.fold_left (fun accu hole' ->
@ -568,7 +566,8 @@ let second_order_sum { det_space ; m_H ; m_S2 ; eigensystem ; n_states }
) 0. list_holes1 ) 0. list_holes1
) 0. list_particles1 ) 0. list_particles1
in in
accu +. double
accu +. double_ab
) 0. list_holes2 ) 0. list_holes2
) 0. list_particles2 ) 0. list_particles2
in in

View File

@ -197,7 +197,6 @@ debug "Four-idx transform of f12 intergals";
else else
1. +. gamma *. (f_ij aux_basis ki kj) 1. +. gamma *. (f_ij aux_basis ki kj)
in in
debug "Computing F matrix";
let m_F = let m_F =
CI.create_matrix_spin f det_space CI.create_matrix_spin f det_space
|> Lazy.force |> Lazy.force
@ -228,18 +227,10 @@ Util.debug_matrix "H" (Matrix.to_mat m_H);
*) *)
let rec iteration ?(state=1) psi = let rec iteration ?(state=1) psi =
(*
debug "Iteration"; debug "Iteration";
Util.debug_matrix "T" (f12_amplitudes psi);
*)
let delta = let delta =
dressing_vector aux_basis (f12_amplitudes psi) ci dressing_vector aux_basis (f12_amplitudes psi) ci
in in
(*
Util.debug_matrix "psi" psi;
*)
Format.printf "Amplitude (1,1) : %f@." (f12_amplitudes psi).{1,1};
Format.printf "Dressing vector(1,1) : %f@." (Matrix.get delta 1 1);
let f = 1.0 /. psi.{1,1} in let f = 1.0 /. psi.{1,1} in
let delta_00 = let delta_00 =
@ -262,6 +253,7 @@ TODO SINGLE STATE HERE
Matrix.get m_H i i Matrix.get m_H i i
) )
in in
let matrix_prod c = let matrix_prod c =
let w = let w =
Matrix.mm ~transa:`T m_H c Matrix.mm ~transa:`T m_H c
@ -279,15 +271,18 @@ TODO SINGLE STATE HERE
); );
Matrix.dense_of_mat w Matrix.dense_of_mat w
in in
let eigenvectors, eigenvalues = let eigenvectors, eigenvalues =
Davidson.make ~threshold:1.e-6 ~guess:psi ~n_states diagonal matrix_prod Davidson.make ~threshold:1.e-6 ~guess:psi ~n_states diagonal matrix_prod
in in
let conv = let conv =
1.0 -. abs_float ( dot 1.0 -. abs_float ( dot
(Mat.to_col_vecs psi).(0) (Mat.to_col_vecs psi).(0)
(Mat.to_col_vecs eigenvectors).(0) ) (Mat.to_col_vecs eigenvectors).(0) )
in in
Printf.printf "Convergence : %e %f\n" conv (eigenvalues.{1} +. e_shift); Printf.printf "Convergence : %e %f\n" conv (eigenvalues.{1} +. e_shift);
if conv > threshold then if conv > threshold then
iteration eigenvectors iteration eigenvectors
else else