10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 12:23:43 +01:00

Fix modifying determinants before mo_label exists

This commit is contained in:
Anthony Scemama 2023-11-27 14:25:05 +01:00
parent a6b02cf59e
commit b25489e14c
2 changed files with 28 additions and 7 deletions

View File

@ -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 ()
@ -290,6 +301,10 @@ end = struct
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) () =
@ -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 ;
()
;; ;;
@ -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

View File

@ -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