mirror of
https://gitlab.com/scemama/QCaml.git
synced 2025-01-10 13:08:10 +01:00
Working on CI
This commit is contained in:
parent
5bd2edde7b
commit
3c3b2f14ab
49
CI/CI.ml
49
CI/CI.ml
@ -323,9 +323,6 @@ let create_matrix_spin f det_space =
|
|||||||
in
|
in
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
if Parallel.master then
|
|
||||||
Array.init ndet (fun _ -> Vector.sparse_of_assoc_list ndet [])
|
|
||||||
else
|
|
||||||
Array.init ndet (fun _ -> Vector.sparse_of_assoc_list ndet [])
|
Array.init ndet (fun _ -> Vector.sparse_of_assoc_list ndet [])
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -334,7 +331,7 @@ let create_matrix_spin f det_space =
|
|||||||
|> Farm.run ~ordered:false ~f:task
|
|> Farm.run ~ordered:false ~f:task
|
||||||
|> Stream.iter (fun (k, r) ->
|
|> Stream.iter (fun (k, r) ->
|
||||||
Array.iteri (fun j r_j -> result.(k+j) <- r_j) r;
|
Array.iteri (fun j r_j -> result.(k+j) <- r_j) r;
|
||||||
Printf.eprintf "%8d / %8d\r%!" (k+1) ndet;
|
Printf.eprintf "%8d / %8d\r%!" (k+Array.length r) ndet;
|
||||||
) ;
|
) ;
|
||||||
Matrix.sparse_of_vector_array result
|
Matrix.sparse_of_vector_array result
|
||||||
)
|
)
|
||||||
@ -343,8 +340,7 @@ let create_matrix_spin f det_space =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let make ?(n_states=1) ?(algo=`Direct) det_space =
|
||||||
let make ?(n_states=1) det_space =
|
|
||||||
|
|
||||||
let mo_basis = Ds.mo_basis det_space in
|
let mo_basis = Ds.mo_basis det_space in
|
||||||
|
|
||||||
@ -372,7 +368,7 @@ let make ?(n_states=1) det_space =
|
|||||||
if ki <> kj then
|
if ki <> kj then
|
||||||
h_ij mo_basis ki kj
|
h_ij mo_basis ki kj
|
||||||
else
|
else
|
||||||
h_ij mo_basis ki kj -. e_shift
|
h_ij mo_basis ki ki -. e_shift
|
||||||
) det_space
|
) det_space
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -386,6 +382,8 @@ let make ?(n_states=1) det_space =
|
|||||||
in
|
in
|
||||||
|
|
||||||
let eigensystem = lazy (
|
let eigensystem = lazy (
|
||||||
|
|
||||||
|
let eigensystem_incore () =
|
||||||
let m_H =
|
let m_H =
|
||||||
Lazy.force m_H
|
Lazy.force m_H
|
||||||
in
|
in
|
||||||
@ -396,12 +394,45 @@ let make ?(n_states=1) det_space =
|
|||||||
Matrix.mm ~transa:`T m_H psi
|
Matrix.mm ~transa:`T m_H psi
|
||||||
in
|
in
|
||||||
let eigenvectors, eigenvalues =
|
let eigenvectors, eigenvalues =
|
||||||
Parallel.broadcast (lazy (
|
let result = lazy (
|
||||||
Davidson.make ~threshold:1.e-6 ~n_states diagonal matrix_prod
|
Davidson.make ~threshold:1.e-6 ~n_states diagonal matrix_prod
|
||||||
))
|
) in
|
||||||
|
Parallel.broadcast result
|
||||||
in
|
in
|
||||||
let eigenvalues = Vec.map (fun x -> x +. e_shift) eigenvalues in
|
let eigenvalues = Vec.map (fun x -> x +. e_shift) eigenvalues in
|
||||||
eigenvectors, eigenvalues
|
eigenvectors, eigenvalues
|
||||||
|
in
|
||||||
|
|
||||||
|
let eigensystem_direct () =
|
||||||
|
eigensystem_incore ()
|
||||||
|
in
|
||||||
|
(*
|
||||||
|
let diagonal =
|
||||||
|
let stream = Ds.determinant_stream det_space in
|
||||||
|
Vec.init (Ds.size det_space) (fun _ ->
|
||||||
|
let ki = Stream.next stream in
|
||||||
|
h_ij mo_basis ki ki -. e_shift)
|
||||||
|
in
|
||||||
|
|
||||||
|
|
||||||
|
let matrix_prod psi =
|
||||||
|
(*TODO*)
|
||||||
|
in
|
||||||
|
|
||||||
|
let eigenvectors, eigenvalues =
|
||||||
|
let result =
|
||||||
|
Davidson.make ~threshold:1.e-6 ~n_states diagonal matrix_prod
|
||||||
|
in
|
||||||
|
Parallel.broadcast (lazy result)
|
||||||
|
in
|
||||||
|
let eigenvalues = Vec.map (fun x -> x +. e_shift) eigenvalues in
|
||||||
|
eigenvectors, eigenvalues
|
||||||
|
in
|
||||||
|
*)
|
||||||
|
|
||||||
|
match algo with
|
||||||
|
| `Direct -> eigensystem_direct ()
|
||||||
|
| `InCore -> eigensystem_incore ()
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
{ det_space ; e_shift ; m_H ; m_S2 ; eigensystem ; n_states }
|
{ det_space ; e_shift ; m_H ; m_S2 ; eigensystem ; n_states }
|
||||||
|
@ -22,26 +22,13 @@ let make
|
|||||||
in
|
in
|
||||||
|
|
||||||
(* Create guess vectors u, with randomly initialized unknown vectors. *)
|
(* Create guess vectors u, with randomly initialized unknown vectors. *)
|
||||||
let random_vectors =
|
let init_vectors =
|
||||||
let random_vector k =
|
let init_vector k =
|
||||||
Vec.init n (fun i ->
|
Vector.sparse_of_assoc_list n [ (k,1.0) ]
|
||||||
if i<k then 0.
|
|
||||||
else if i=k then 1.e5
|
|
||||||
else
|
|
||||||
0.
|
|
||||||
(*
|
|
||||||
let r1 = Random.float 1.
|
|
||||||
and r2 = Random.float 1.
|
|
||||||
in
|
in
|
||||||
let a = sqrt (-2. *. log r1)
|
Array.init m (fun i -> init_vector (i+1))
|
||||||
and b = Constants.two_pi *. r2 in
|
|> Matrix.sparse_of_vector_array
|
||||||
let c = a *. cos b in
|
|> Matrix.to_mat
|
||||||
if abs_float c > 1.e-1 then c else 0.
|
|
||||||
*)
|
|
||||||
)
|
|
||||||
|> Util.normalize
|
|
||||||
in
|
|
||||||
List.init m (fun i -> random_vector (i+1))
|
|
||||||
in
|
in
|
||||||
|
|
||||||
let pick_new u =
|
let pick_new u =
|
||||||
@ -54,7 +41,7 @@ let make
|
|||||||
let u_new =
|
let u_new =
|
||||||
match guess with
|
match guess with
|
||||||
| Some vectors -> Mat.to_col_vecs_list vectors
|
| Some vectors -> Mat.to_col_vecs_list vectors
|
||||||
| None -> random_vectors
|
| None -> Mat.to_col_vecs_list init_vectors
|
||||||
in
|
in
|
||||||
|
|
||||||
let rec iteration u u_new w iter =
|
let rec iteration u u_new w iter =
|
||||||
|
Loading…
Reference in New Issue
Block a user