mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-21 11:03:29 +01:00
Fix modifying determinants before mo_label exists
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
a6b02cf59e
commit
b25489e14c
@ -13,6 +13,7 @@ module Determinants_by_hand : sig
|
|||||||
psi_coef : Det_coef.t array;
|
psi_coef : Det_coef.t array;
|
||||||
psi_det : Determinant.t array;
|
psi_det : Determinant.t array;
|
||||||
state_average_weight : Positive_float.t array;
|
state_average_weight : Positive_float.t array;
|
||||||
|
mo_label : MO_label.t;
|
||||||
} [@@deriving sexp]
|
} [@@deriving sexp]
|
||||||
val read : ?full:bool -> unit -> t option
|
val read : ?full:bool -> unit -> t option
|
||||||
val write : ?force:bool -> t -> unit
|
val write : ?force:bool -> t -> unit
|
||||||
@ -34,11 +35,21 @@ end = struct
|
|||||||
psi_coef : Det_coef.t array;
|
psi_coef : Det_coef.t array;
|
||||||
psi_det : Determinant.t array;
|
psi_det : Determinant.t array;
|
||||||
state_average_weight : Positive_float.t array;
|
state_average_weight : Positive_float.t array;
|
||||||
|
mo_label : MO_label.t;
|
||||||
} [@@deriving sexp]
|
} [@@deriving sexp]
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let get_default = Qpackage.get_ezfio_default "determinants";;
|
let get_default = Qpackage.get_ezfio_default "determinants";;
|
||||||
|
|
||||||
|
let read_mo_label () =
|
||||||
|
if not (Ezfio.has_determinants_mo_label ()) then
|
||||||
|
if Ezfio.has_mo_basis_mo_label () then (
|
||||||
|
let label = Ezfio.get_mo_basis_mo_label () in
|
||||||
|
Ezfio.set_determinants_mo_label label) ;
|
||||||
|
Ezfio.get_determinants_mo_label ()
|
||||||
|
|> MO_label.of_string
|
||||||
|
;;
|
||||||
|
|
||||||
let read_n_int () =
|
let read_n_int () =
|
||||||
if not (Ezfio.has_determinants_n_int()) then
|
if not (Ezfio.has_determinants_n_int()) then
|
||||||
Ezfio.get_mo_basis_mo_num ()
|
Ezfio.get_mo_basis_mo_num ()
|
||||||
@ -222,7 +233,7 @@ end = struct
|
|||||||
and n_states =
|
and n_states =
|
||||||
States_number.to_int n_states
|
States_number.to_int n_states
|
||||||
in
|
in
|
||||||
let r =
|
let r =
|
||||||
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|
||||||
in
|
in
|
||||||
Ezfio.set_determinants_psi_coef r;
|
Ezfio.set_determinants_psi_coef r;
|
||||||
@ -283,19 +294,23 @@ end = struct
|
|||||||
|> Array.concat
|
|> Array.concat
|
||||||
|> Array.to_list
|
|> Array.to_list
|
||||||
in
|
in
|
||||||
let r =
|
let r =
|
||||||
Ezfio.ezfio_array_of_list ~rank:3 ~dim:[| N_int_number.to_int n_int ; 2 ; Det_number.to_int n_det |] ~data:data
|
Ezfio.ezfio_array_of_list ~rank:3 ~dim:[| N_int_number.to_int n_int ; 2 ; Det_number.to_int n_det |] ~data:data
|
||||||
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 write_mo_label a =
|
||||||
|
MO_label.to_string a
|
||||||
|
|> Ezfio.set_determinants_mo_label
|
||||||
|
|
||||||
|
|
||||||
let read ?(full=true) () =
|
let read ?(full=true) () =
|
||||||
|
|
||||||
let n_det_qp_edit = read_n_det_qp_edit () in
|
let n_det_qp_edit = read_n_det_qp_edit () in
|
||||||
let n_det = read_n_det () in
|
let n_det = read_n_det () in
|
||||||
let read_only =
|
let read_only =
|
||||||
if full then false else n_det_qp_edit <> n_det
|
if full then false else n_det_qp_edit <> n_det
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -311,6 +326,7 @@ end = struct
|
|||||||
psi_det = read_psi_det ~read_only () ;
|
psi_det = read_psi_det ~read_only () ;
|
||||||
n_states = read_n_states () ;
|
n_states = read_n_states () ;
|
||||||
state_average_weight = read_state_average_weight () ;
|
state_average_weight = read_state_average_weight () ;
|
||||||
|
mo_label = read_mo_label () ;
|
||||||
}
|
}
|
||||||
with _ -> None
|
with _ -> None
|
||||||
else
|
else
|
||||||
@ -328,6 +344,7 @@ end = struct
|
|||||||
psi_det ;
|
psi_det ;
|
||||||
n_states ;
|
n_states ;
|
||||||
state_average_weight ;
|
state_average_weight ;
|
||||||
|
mo_label ;
|
||||||
} =
|
} =
|
||||||
write_n_int n_int ;
|
write_n_int n_int ;
|
||||||
write_bit_kind bit_kind;
|
write_bit_kind bit_kind;
|
||||||
@ -340,7 +357,9 @@ end = struct
|
|||||||
write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ;
|
write_psi_coef ~n_det:n_det ~n_states:n_states psi_coef ;
|
||||||
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 ;
|
||||||
|
write_mo_label mo_label ;
|
||||||
|
()
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
||||||
@ -439,7 +458,7 @@ psi_det = %s
|
|||||||
in
|
in
|
||||||
|
|
||||||
(* Split into header and determinants data *)
|
(* Split into header and determinants data *)
|
||||||
let idx =
|
let idx =
|
||||||
match String_ext.substr_index r ~pos:0 ~pattern:"\nDeterminants" with
|
match String_ext.substr_index r ~pos:0 ~pattern:"\nDeterminants" with
|
||||||
| Some x -> x
|
| Some x -> x
|
||||||
| None -> assert false
|
| None -> assert false
|
||||||
@ -545,6 +564,8 @@ psi_det = %s
|
|||||||
let bitkind =
|
let bitkind =
|
||||||
Printf.sprintf "(bit_kind %d)" (Lazy.force Qpackage.bit_kind
|
Printf.sprintf "(bit_kind %d)" (Lazy.force Qpackage.bit_kind
|
||||||
|> Bit_kind.to_int)
|
|> Bit_kind.to_int)
|
||||||
|
and mo_label =
|
||||||
|
Printf.sprintf "(mo_label %s)" (MO_label.to_string @@ read_mo_label ())
|
||||||
and n_int =
|
and n_int =
|
||||||
Printf.sprintf "(n_int %d)" (N_int_number.get_max ())
|
Printf.sprintf "(n_int %d)" (N_int_number.get_max ())
|
||||||
and n_states =
|
and n_states =
|
||||||
@ -553,7 +574,7 @@ psi_det = %s
|
|||||||
Printf.sprintf "(n_det_qp_edit %d)" (Det_number.to_int @@ read_n_det_qp_edit ())
|
Printf.sprintf "(n_det_qp_edit %d)" (Det_number.to_int @@ read_n_det_qp_edit ())
|
||||||
in
|
in
|
||||||
let s =
|
let s =
|
||||||
String.concat "" [ header ; bitkind ; n_int ; n_states ; psi_coef ; psi_det ; n_det_qp_edit ]
|
String.concat "" [ header ; mo_label ; bitkind ; n_int ; n_states ; psi_coef ; psi_det ; n_det_qp_edit ]
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ default: True
|
|||||||
|
|
||||||
[export_mos]
|
[export_mos]
|
||||||
type: logical
|
type: logical
|
||||||
doc: If True, export basis set and AOs
|
doc: If True, export MO coefficients
|
||||||
interface: ezfio, ocaml, provider
|
interface: ezfio, ocaml, provider
|
||||||
default: True
|
default: True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user