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
|
||||
|
||||
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 [])
|
||||
in
|
||||
|
||||
@ -334,7 +331,7 @@ let create_matrix_spin f det_space =
|
||||
|> Farm.run ~ordered:false ~f:task
|
||||
|> Stream.iter (fun (k, 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
|
||||
)
|
||||
@ -343,8 +340,7 @@ let create_matrix_spin f det_space =
|
||||
|
||||
|
||||
|
||||
|
||||
let make ?(n_states=1) det_space =
|
||||
let make ?(n_states=1) ?(algo=`Direct) det_space =
|
||||
|
||||
let mo_basis = Ds.mo_basis det_space in
|
||||
|
||||
@ -372,7 +368,7 @@ let make ?(n_states=1) det_space =
|
||||
if ki <> kj then
|
||||
h_ij mo_basis ki kj
|
||||
else
|
||||
h_ij mo_basis ki kj -. e_shift
|
||||
h_ij mo_basis ki ki -. e_shift
|
||||
) det_space
|
||||
in
|
||||
|
||||
@ -386,6 +382,8 @@ let make ?(n_states=1) det_space =
|
||||
in
|
||||
|
||||
let eigensystem = lazy (
|
||||
|
||||
let eigensystem_incore () =
|
||||
let m_H =
|
||||
Lazy.force m_H
|
||||
in
|
||||
@ -396,12 +394,45 @@ let make ?(n_states=1) det_space =
|
||||
Matrix.mm ~transa:`T m_H psi
|
||||
in
|
||||
let eigenvectors, eigenvalues =
|
||||
Parallel.broadcast (lazy (
|
||||
let result = lazy (
|
||||
Davidson.make ~threshold:1.e-6 ~n_states diagonal matrix_prod
|
||||
))
|
||||
) in
|
||||
Parallel.broadcast result
|
||||
in
|
||||
let eigenvalues = Vec.map (fun x -> x +. e_shift) eigenvalues in
|
||||
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
|
||||
{ det_space ; e_shift ; m_H ; m_S2 ; eigensystem ; n_states }
|
||||
|
@ -22,26 +22,13 @@ let make
|
||||
in
|
||||
|
||||
(* Create guess vectors u, with randomly initialized unknown vectors. *)
|
||||
let random_vectors =
|
||||
let random_vector k =
|
||||
Vec.init n (fun i ->
|
||||
if i<k then 0.
|
||||
else if i=k then 1.e5
|
||||
else
|
||||
0.
|
||||
(*
|
||||
let r1 = Random.float 1.
|
||||
and r2 = Random.float 1.
|
||||
let init_vectors =
|
||||
let init_vector k =
|
||||
Vector.sparse_of_assoc_list n [ (k,1.0) ]
|
||||
in
|
||||
let a = sqrt (-2. *. log r1)
|
||||
and b = Constants.two_pi *. r2 in
|
||||
let c = a *. cos b in
|
||||
if abs_float c > 1.e-1 then c else 0.
|
||||
*)
|
||||
)
|
||||
|> Util.normalize
|
||||
in
|
||||
List.init m (fun i -> random_vector (i+1))
|
||||
Array.init m (fun i -> init_vector (i+1))
|
||||
|> Matrix.sparse_of_vector_array
|
||||
|> Matrix.to_mat
|
||||
in
|
||||
|
||||
let pick_new u =
|
||||
@ -54,7 +41,7 @@ let make
|
||||
let u_new =
|
||||
match guess with
|
||||
| Some vectors -> Mat.to_col_vecs_list vectors
|
||||
| None -> random_vectors
|
||||
| None -> Mat.to_col_vecs_list init_vectors
|
||||
in
|
||||
|
||||
let rec iteration u u_new w iter =
|
||||
|
Loading…
Reference in New Issue
Block a user