10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-07-03 09:55:59 +02:00

Write electrons with qp_edit

This commit is contained in:
Anthony Scemama 2014-11-04 00:39:10 +01:00
parent fb2b7966e1
commit bab7aac3a8
3 changed files with 49 additions and 17 deletions

View File

@ -24,12 +24,35 @@ let to_bitlist_couple x =
in (xa,xb) in (xa,xb)
;; ;;
let bitlist_to_string ~mo_tot_num x =
List.map x ~f:(fun i -> match i with
| Bit.Zero -> "-"
| Bit.One -> "+" )
|> String.concat
|> String.sub ~pos:0 ~len:(MO_number.to_int mo_tot_num)
;;
let of_int64_array ~n_int ~alpha ~beta x = let of_int64_array ~n_int ~alpha ~beta x =
assert ((Array.length x) = (N_int_number.to_int n_int)*2) ; assert ((Array.length x) = (N_int_number.to_int n_int)*2) ;
let (a,b) = to_bitlist_couple x in let (a,b) = to_bitlist_couple x
assert (Bitlist.popcnt a = Elec_alpha_number.to_int alpha); and alpha = Elec_alpha_number.to_int alpha
assert (Bitlist.popcnt b = Elec_beta_number.to_int beta ); and beta = Elec_beta_number.to_int beta
in
if ( (Bitlist.popcnt a) <> alpha) then
begin
let mo_tot_num = MO_number.get_max () in
let mo_tot_num = MO_number.of_int mo_tot_num ~max:mo_tot_num in
failwith (Printf.sprintf "Expected %d electrons in alpha determinant
%s" alpha (bitlist_to_string ~mo_tot_num:mo_tot_num a) )
end;
if ( (Bitlist.popcnt b) <> beta ) then
begin
let mo_tot_num = MO_number.get_max () in
let mo_tot_num = MO_number.of_int mo_tot_num ~max:mo_tot_num in
failwith (Printf.sprintf "Expected %d electrons in beta determinant
%s" beta (bitlist_to_string ~mo_tot_num:mo_tot_num b) )
end;
x x
;; ;;
@ -40,14 +63,6 @@ let of_bitlist_couple ~alpha ~beta (xa,xb) =
of_int64_array ~n_int:n_int ~alpha:alpha ~beta:beta (Array.of_list (ba@bb)) of_int64_array ~n_int:n_int ~alpha:alpha ~beta:beta (Array.of_list (ba@bb))
;; ;;
let bitlist_to_string ~mo_tot_num x =
List.map x ~f:(fun i -> match i with
| Bit.Zero -> "-"
| Bit.One -> "+" )
|> String.concat
|> String.sub ~pos:0 ~len:(MO_number.to_int mo_tot_num)
;;
let to_string ~mo_tot_num x = let to_string ~mo_tot_num x =
let (xa,xb) = to_bitlist_couple x in let (xa,xb) = to_bitlist_couple x in
[ bitlist_to_string ~mo_tot_num:mo_tot_num xa ; [ bitlist_to_string ~mo_tot_num:mo_tot_num xa ;

View File

@ -8,7 +8,8 @@ module Electrons : sig
elec_beta_num : Elec_beta_number.t; elec_beta_num : Elec_beta_number.t;
} with sexp } with sexp
;; ;;
val read : unit -> t val read : unit -> t
val write : t -> unit
val read_elec_num : unit -> Elec_number.t val read_elec_num : unit -> Elec_number.t
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
@ -27,11 +28,22 @@ end = struct
|> Elec_alpha_number.of_int |> Elec_alpha_number.of_int
;; ;;
let write_elec_alpha_num n =
Elec_alpha_number.to_int n
|> Ezfio.set_electrons_elec_alpha_num
;;
let read_elec_beta_num() = let read_elec_beta_num() =
Ezfio.get_electrons_elec_beta_num () Ezfio.get_electrons_elec_beta_num ()
|> Elec_beta_number.of_int |> Elec_beta_number.of_int
;; ;;
let write_elec_beta_num n =
Elec_beta_number.to_int n
|> Ezfio.set_electrons_elec_beta_num
;;
let read_elec_num () = let read_elec_num () =
let na = Ezfio.get_electrons_elec_alpha_num () let na = Ezfio.get_electrons_elec_alpha_num ()
and nb = Ezfio.get_electrons_elec_beta_num () and nb = Ezfio.get_electrons_elec_beta_num ()
@ -46,6 +58,12 @@ end = struct
} }
;; ;;
let write { elec_alpha_num ; elec_beta_num } =
write_elec_alpha_num elec_alpha_num;
write_elec_beta_num elec_beta_num;
;;
let to_rst b = let to_rst b =
Printf.sprintf " Printf.sprintf "
Spin multiplicity is %s. Spin multiplicity is %s.

View File

@ -86,8 +86,10 @@ let set str s =
| Full_ci -> | Full_ci ->
| Hartree_fock -> | Hartree_fock ->
| Mo_basis -> | Mo_basis ->
| Electrons ->
*) *)
| Electrons ->
Input.Electrons.of_rst str
|> Input.Electrons.write
| Determinants -> | Determinants ->
Input.Determinants.of_rst str Input.Determinants.of_rst str
|> Input.Determinants.write |> Input.Determinants.write
@ -128,12 +130,8 @@ let run ezfio_filename =
(* (*
let output = (file_header ezfio_filename) :: ( let output = (file_header ezfio_filename) :: (
List.map ~f:get [ List.map ~f:get [
Nuclei ;
Electrons ;
Ao_basis ; Ao_basis ;
Mo_basis ; Mo_basis ;
Bielec_integrals ;
Determinants ;
Full_ci ; Full_ci ;
Hartree_fock ; Hartree_fock ;
]) ])
@ -144,6 +142,7 @@ let run ezfio_filename =
let tasks = [ let tasks = [
Nuclei ; Nuclei ;
Electrons ;
Bielec_integrals ; Bielec_integrals ;
Cisd_sc2 ; Cisd_sc2 ;
Determinants ; Determinants ;