mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-08-24 21:21:47 +02:00
Started working on OCaml. Need to go further for qp_edit
This commit is contained in:
parent
df4c9431d0
commit
bc04139a54
@ -37,7 +37,9 @@ end = struct
|
|||||||
} [@@deriving sexp]
|
} [@@deriving sexp]
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let get_default = Qpackage.get_ezfio_default "determinants";;
|
let get_default = Qpackage.get_ezfio_default "determinants"
|
||||||
|
|
||||||
|
let is_complex = lazy (Ezfio.get_nuclei_is_complex () )
|
||||||
|
|
||||||
let read_n_int () =
|
let read_n_int () =
|
||||||
if not (Ezfio.has_determinants_n_int()) then
|
if not (Ezfio.has_determinants_n_int()) then
|
||||||
@ -48,12 +50,12 @@ end = struct
|
|||||||
;
|
;
|
||||||
Ezfio.get_determinants_n_int ()
|
Ezfio.get_determinants_n_int ()
|
||||||
|> N_int_number.of_int
|
|> N_int_number.of_int
|
||||||
;;
|
|
||||||
|
|
||||||
let write_n_int n =
|
let write_n_int n =
|
||||||
N_int_number.to_int n
|
N_int_number.to_int n
|
||||||
|> Ezfio.set_determinants_n_int
|
|> Ezfio.set_determinants_n_int
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
let read_bit_kind () =
|
let read_bit_kind () =
|
||||||
@ -64,12 +66,12 @@ end = struct
|
|||||||
;
|
;
|
||||||
Ezfio.get_determinants_bit_kind ()
|
Ezfio.get_determinants_bit_kind ()
|
||||||
|> Bit_kind.of_int
|
|> Bit_kind.of_int
|
||||||
;;
|
|
||||||
|
|
||||||
let write_bit_kind b =
|
let write_bit_kind b =
|
||||||
Bit_kind.to_int b
|
Bit_kind.to_int b
|
||||||
|> Ezfio.set_determinants_bit_kind
|
|> Ezfio.set_determinants_bit_kind
|
||||||
;;
|
|
||||||
|
|
||||||
let read_n_det () =
|
let read_n_det () =
|
||||||
if not (Ezfio.has_determinants_n_det ()) then
|
if not (Ezfio.has_determinants_n_det ()) then
|
||||||
@ -77,7 +79,7 @@ end = struct
|
|||||||
;
|
;
|
||||||
Ezfio.get_determinants_n_det ()
|
Ezfio.get_determinants_n_det ()
|
||||||
|> Det_number.of_int
|
|> Det_number.of_int
|
||||||
;;
|
|
||||||
|
|
||||||
let read_n_det_qp_edit () =
|
let read_n_det_qp_edit () =
|
||||||
if not (Ezfio.has_determinants_n_det_qp_edit ()) then
|
if not (Ezfio.has_determinants_n_det_qp_edit ()) then
|
||||||
@ -87,18 +89,18 @@ end = struct
|
|||||||
end;
|
end;
|
||||||
Ezfio.get_determinants_n_det_qp_edit ()
|
Ezfio.get_determinants_n_det_qp_edit ()
|
||||||
|> Det_number.of_int
|
|> Det_number.of_int
|
||||||
;;
|
|
||||||
|
|
||||||
let write_n_det n =
|
let write_n_det n =
|
||||||
Det_number.to_int n
|
Det_number.to_int n
|
||||||
|> Ezfio.set_determinants_n_det
|
|> Ezfio.set_determinants_n_det
|
||||||
;;
|
|
||||||
|
|
||||||
let write_n_det_qp_edit n =
|
let write_n_det_qp_edit n =
|
||||||
let n_det = read_n_det () |> Det_number.to_int in
|
let n_det = read_n_det () |> Det_number.to_int in
|
||||||
min n_det (Det_number.to_int n)
|
min n_det (Det_number.to_int n)
|
||||||
|> Ezfio.set_determinants_n_det_qp_edit
|
|> Ezfio.set_determinants_n_det_qp_edit
|
||||||
;;
|
|
||||||
|
|
||||||
let read_n_states () =
|
let read_n_states () =
|
||||||
if not (Ezfio.has_determinants_n_states ()) then
|
if not (Ezfio.has_determinants_n_states ()) then
|
||||||
@ -106,7 +108,7 @@ end = struct
|
|||||||
;
|
;
|
||||||
Ezfio.get_determinants_n_states ()
|
Ezfio.get_determinants_n_states ()
|
||||||
|> States_number.of_int
|
|> States_number.of_int
|
||||||
;;
|
|
||||||
|
|
||||||
let write_n_states n =
|
let write_n_states n =
|
||||||
let n_states =
|
let n_states =
|
||||||
@ -130,7 +132,7 @@ end = struct
|
|||||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_states |] ~data
|
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_states |] ~data
|
||||||
|> Ezfio.set_determinants_state_average_weight
|
|> Ezfio.set_determinants_state_average_weight
|
||||||
end
|
end
|
||||||
;;
|
|
||||||
|
|
||||||
let write_state_average_weight data =
|
let write_state_average_weight data =
|
||||||
let n_states =
|
let n_states =
|
||||||
@ -143,7 +145,7 @@ end = struct
|
|||||||
in
|
in
|
||||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_states |] ~data
|
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_states |] ~data
|
||||||
|> Ezfio.set_determinants_state_average_weight
|
|> Ezfio.set_determinants_state_average_weight
|
||||||
;;
|
|
||||||
|
|
||||||
let read_state_average_weight () =
|
let read_state_average_weight () =
|
||||||
let n_states =
|
let n_states =
|
||||||
@ -171,7 +173,7 @@ end = struct
|
|||||||
|> Array.map Positive_float.of_float
|
|> Array.map Positive_float.of_float
|
||||||
in
|
in
|
||||||
(write_state_average_weight data; data)
|
(write_state_average_weight data; data)
|
||||||
;;
|
|
||||||
|
|
||||||
let read_expected_s2 () =
|
let read_expected_s2 () =
|
||||||
if not (Ezfio.has_determinants_expected_s2 ()) then
|
if not (Ezfio.has_determinants_expected_s2 ()) then
|
||||||
@ -186,12 +188,12 @@ end = struct
|
|||||||
;
|
;
|
||||||
Ezfio.get_determinants_expected_s2 ()
|
Ezfio.get_determinants_expected_s2 ()
|
||||||
|> Positive_float.of_float
|
|> Positive_float.of_float
|
||||||
;;
|
|
||||||
|
|
||||||
let write_expected_s2 s2 =
|
let write_expected_s2 s2 =
|
||||||
Positive_float.to_float s2
|
Positive_float.to_float s2
|
||||||
|> Ezfio.set_determinants_expected_s2
|
|> Ezfio.set_determinants_expected_s2
|
||||||
;;
|
|
||||||
|
|
||||||
let read_psi_coef ~read_only () =
|
let read_psi_coef ~read_only () =
|
||||||
if not (Ezfio.has_determinants_psi_coef ()) then
|
if not (Ezfio.has_determinants_psi_coef ()) then
|
||||||
@ -200,19 +202,36 @@ end = struct
|
|||||||
read_n_states ()
|
read_n_states ()
|
||||||
|> States_number.to_int
|
|> States_number.to_int
|
||||||
in
|
in
|
||||||
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| 1 ; n_states |]
|
(
|
||||||
~data:(List.init n_states (fun i -> if (i=0) then 1. else 0. ))
|
if Lazy.force is_complex then
|
||||||
|
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| 1 ; n_states |]
|
||||||
|
~data:(List.init (2*n_states) (fun i -> if (i=0) then 1. else 0. ))
|
||||||
|> Ezfio.set_determinants_psi_coef
|
|> Ezfio.set_determinants_psi_coef
|
||||||
|
else
|
||||||
|
Ezfio.ezfio_array_of_list ~rank:3 ~dim:[| 2 ; 1 ; n_states |]
|
||||||
|
~data:(List.init n_states (fun i -> if (i=0) then 1. else 0. ))
|
||||||
|
|> Ezfio.set_determinants_psi_coef_complex
|
||||||
|
)
|
||||||
end;
|
end;
|
||||||
begin
|
begin
|
||||||
if read_only then
|
if read_only then
|
||||||
Ezfio.get_determinants_psi_coef_qp_edit ()
|
begin
|
||||||
|
if Lazy.force is_complex then
|
||||||
|
Ezfio.get_determinants_psi_coef_complex_qp_edit ()
|
||||||
|
else
|
||||||
|
Ezfio.get_determinants_psi_coef_qp_edit ()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Ezfio.get_determinants_psi_coef ()
|
begin
|
||||||
|
if Lazy.force is_complex then
|
||||||
|
Ezfio.get_determinants_psi_coef_complex ()
|
||||||
|
else
|
||||||
|
Ezfio.get_determinants_psi_coef ()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|> Ezfio.flattened_ezfio
|
|> Ezfio.flattened_ezfio
|
||||||
|> Array.map Det_coef.of_float
|
|> Array.map Det_coef.of_float
|
||||||
;;
|
|
||||||
|
|
||||||
let write_psi_coef ~n_det ~n_states c =
|
let write_psi_coef ~n_det ~n_states c =
|
||||||
let n_det = Det_number.to_int n_det
|
let n_det = Det_number.to_int n_det
|
||||||
@ -222,12 +241,23 @@ end = struct
|
|||||||
and n_states =
|
and n_states =
|
||||||
States_number.to_int n_states
|
States_number.to_int n_states
|
||||||
in
|
in
|
||||||
let r =
|
if Lazy.force is_complex then
|
||||||
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|
begin
|
||||||
in
|
let r =
|
||||||
Ezfio.set_determinants_psi_coef r;
|
Ezfio.ezfio_array_of_list ~rank:3 ~dim:[| 2 ; n_det ; n_states |] ~data:c
|
||||||
Ezfio.set_determinants_psi_coef_qp_edit r
|
in
|
||||||
;;
|
Ezfio.set_determinants_psi_coef_complex r;
|
||||||
|
Ezfio.set_determinants_psi_coef_complex_qp_edit r
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
let r =
|
||||||
|
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|
||||||
|
in
|
||||||
|
Ezfio.set_determinants_psi_coef r;
|
||||||
|
Ezfio.set_determinants_psi_coef_qp_edit r
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let read_psi_det ~read_only () =
|
let read_psi_det ~read_only () =
|
||||||
@ -276,7 +306,7 @@ end = struct
|
|||||||
|> Array.map (Determinant.of_int64_array
|
|> Array.map (Determinant.of_int64_array
|
||||||
~n_int:(N_int_number.of_int n_int)
|
~n_int:(N_int_number.of_int n_int)
|
||||||
~alpha:n_alpha ~beta:n_beta )
|
~alpha:n_alpha ~beta:n_beta )
|
||||||
;;
|
|
||||||
|
|
||||||
let write_psi_det ~n_int ~n_det d =
|
let write_psi_det ~n_int ~n_det d =
|
||||||
let data = Array.to_list d
|
let data = Array.to_list d
|
||||||
@ -288,7 +318,7 @@ end = struct
|
|||||||
in
|
in
|
||||||
Ezfio.set_determinants_psi_det r;
|
Ezfio.set_determinants_psi_det r;
|
||||||
Ezfio.set_determinants_psi_det_qp_edit r
|
Ezfio.set_determinants_psi_det_qp_edit r
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
let read ?(full=true) () =
|
let read ?(full=true) () =
|
||||||
@ -316,7 +346,7 @@ end = struct
|
|||||||
else
|
else
|
||||||
(* No molecular orbitals, so no determinants *)
|
(* No molecular orbitals, so no determinants *)
|
||||||
None
|
None
|
||||||
;;
|
|
||||||
|
|
||||||
let write ?(force=false)
|
let write ?(force=false)
|
||||||
{ n_int ;
|
{ n_int ;
|
||||||
@ -341,7 +371,7 @@ end = struct
|
|||||||
write_psi_det ~n_int:n_int ~n_det:n_det psi_det
|
write_psi_det ~n_int:n_int ~n_det:n_det psi_det
|
||||||
end;
|
end;
|
||||||
write_state_average_weight state_average_weight
|
write_state_average_weight state_average_weight
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
let to_rst b =
|
let to_rst b =
|
||||||
@ -557,10 +587,8 @@ psi_det = %s
|
|||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Generic_input_of_rst.evaluate_sexp t_of_sexp s
|
Generic_input_of_rst.evaluate_sexp t_of_sexp s
|
||||||
;;
|
|
||||||
|
|
||||||
let update_ndet n_det_new =
|
let update_ndet n_det_new =
|
||||||
Printf.printf "Reducing n_det to %d\n" (Det_number.to_int n_det_new);
|
Printf.printf "Reducing n_det to %d\n" (Det_number.to_int n_det_new);
|
||||||
@ -596,7 +624,7 @@ psi_det = %s
|
|||||||
{ det with n_det = (Det_number.of_int n_det_new) }
|
{ det with n_det = (Det_number.of_int n_det_new) }
|
||||||
in
|
in
|
||||||
write ~force:true new_det
|
write ~force:true new_det
|
||||||
;;
|
|
||||||
|
|
||||||
let extract_state istate =
|
let extract_state istate =
|
||||||
Printf.printf "Extracting state %d\n" (States_number.to_int istate);
|
Printf.printf "Extracting state %d\n" (States_number.to_int istate);
|
||||||
@ -628,7 +656,7 @@ psi_det = %s
|
|||||||
{ det with n_states = (States_number.of_int 1) }
|
{ det with n_states = (States_number.of_int 1) }
|
||||||
in
|
in
|
||||||
write ~force:true new_det
|
write ~force:true new_det
|
||||||
;;
|
|
||||||
|
|
||||||
let extract_states range =
|
let extract_states range =
|
||||||
Printf.printf "Extracting states %s\n" (Range.to_string range);
|
Printf.printf "Extracting states %s\n" (Range.to_string range);
|
||||||
@ -673,7 +701,7 @@ psi_det = %s
|
|||||||
{ det with n_states = (States_number.of_int @@ List.length sorted_list) }
|
{ det with n_states = (States_number.of_int @@ List.length sorted_list) }
|
||||||
in
|
in
|
||||||
write ~force:true new_det
|
write ~force:true new_det
|
||||||
;;
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user