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

Updated save_for_qmcchem (mo_classif)

This commit is contained in:
Anthony Scemama 2014-10-17 15:07:07 +02:00
parent fd5f3dfcff
commit fea8dfd891
4 changed files with 145 additions and 2 deletions

120
ocaml/Input.ml Normal file
View File

@ -0,0 +1,120 @@
open Qputils;;
open Qptypes;;
open Core.Std;;
module Ao_basis : sig
type t
val read : unit -> t
val to_string : t -> string
end = struct
type t =
{ ao_basis : string ;
ao_num : AO_number.t ;
ao_prim_num : Strictly_positive_int.t array;
ao_prim_num_max : Strictly_positive_int.t;
ao_nucl : Nucl_number.t array;
ao_power : Symmetry.Xyz.t array;
ao_coef : float array;
ao_expo : Positive_float.t array;
}
;;
let read_ao_basis () =
if not (Ezfio.has_ao_basis_ao_basis ()) then
Ezfio.set_ao_basis_ao_basis ""
;
Ezfio.get_ao_basis_ao_basis ()
;;
let read_ao_num () =
Ezfio.get_ao_basis_ao_num ()
|> AO_number.of_int
;;
let read_ao_prim_num () =
(Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data
|> Ezfio.flattened_ezfio_data
|> Array.map ~f:Strictly_positive_int.of_int
;;
let read_ao_prim_num_max () =
(Ezfio.get_ao_basis_ao_prim_num () ).Ezfio.data
|> Ezfio.flattened_ezfio_data
|> Array.fold ~f:(fun x y -> if x>y then x else y) ~init:0
|> Strictly_positive_int.of_int
;;
let read_ao_nucl () =
(Ezfio.get_ao_basis_ao_nucl () ).Ezfio.data
|> Ezfio.flattened_ezfio_data
|> Array.map ~f:Nucl_number.of_int
;;
let read_ao_power () =
let x = Ezfio.get_ao_basis_ao_power () in
let dim = x.Ezfio.dim.(0) in
let data = Ezfio.flattened_ezfio_data x.Ezfio.data in
let result = Array.init dim ~f:(fun x -> "") in
for i=1 to dim
do
if (data.(i-1) > 0) then
result.(i-1) <- result.(i-1)^"x"^(Int.to_string data.(i-1));
if (data.(dim+i-1) > 0) then
result.(i-1) <- result.(i-1)^"y"^(Int.to_string data.(dim+i-1));
if (data.(2*dim+i-1) > 0) then
result.(i-1) <- result.(i-1)^"z"^(Int.to_string data.(2*dim+i-1));
done;
Array.map ~f:Symmetry.Xyz.of_string result
;;
let read_ao_coef () =
(Ezfio.get_ao_basis_ao_coef () ).Ezfio.data
|> Ezfio.flattened_ezfio_data
;;
let read_ao_expo () =
(Ezfio.get_ao_basis_ao_expo () ).Ezfio.data
|> Ezfio.flattened_ezfio_data
|> Array.map ~f:Positive_float.of_float
;;
let read () =
{ ao_basis = read_ao_basis ();
ao_num = read_ao_num () ;
ao_prim_num = read_ao_prim_num ();
ao_prim_num_max = read_ao_prim_num_max ();
ao_nucl = read_ao_nucl ();
ao_power = read_ao_power ();
ao_coef = read_ao_coef () ;
ao_expo = read_ao_expo () ;
}
;;
let to_string b =
Printf.sprintf "
ao_basis = \"%s\"
ao_num = %s
ao_prim_num = %s
ao_prim_num_max = %s
ao_nucl = %s
ao_power = %s
ao_coef = %s
ao_expo = %s
"
b.ao_basis
(AO_number.to_string b.ao_num)
(b.ao_prim_num |> Array.to_list |> List.map
~f:(Strictly_positive_int.to_string) |> String.concat ~sep:", " )
(Strictly_positive_int.to_string b.ao_prim_num_max)
(b.ao_nucl |> Array.to_list |> List.map ~f:Nucl_number.to_string |>
String.concat ~sep:", ")
(b.ao_power |> Array.to_list |> List.map ~f:(fun x->
"("^(Symmetry.Xyz.to_string x)^")" )|> String.concat ~sep:", ")
(b.ao_coef |> Array.to_list |> List.map ~f:Float.to_string
|> String.concat ~sep:", ")
(b.ao_expo |> Array.to_list |> List.map ~f:Positive_float.to_string
|> String.concat ~sep:", ")
end

View File

@ -49,6 +49,13 @@ let input_data = "
if (Ezfio.has_ao_basis_ao_num ()) then if (Ezfio.has_ao_basis_ao_num ()) then
assert (x <= (Ezfio.get_ao_basis_ao_num ())); assert (x <= (Ezfio.get_ao_basis_ao_num ()));
* Nucl_number : int
assert (x > 0) ;
if (x > 1000) then
warning \"More than 1000 Atoms\";
if (Ezfio.has_nuclei_nucl_num ()) then
assert (x <= (Ezfio.get_nuclei_nucl_num ()));
* N_int_number : int * N_int_number : int
assert (x > 0) ; assert (x > 0) ;
if (x > 100) then if (x > 100) then
@ -88,7 +95,7 @@ module %s : sig
type t type t
val to_%s : t -> %s val to_%s : t -> %s
val of_%s : %s -> t val of_%s : %s -> t
val to_string : %s -> string val to_string : t -> string
end = struct end = struct
type t = %s type t = %s
let to_%s x = x let to_%s x = x
@ -110,7 +117,7 @@ let parse_input input=
let typ = String.strip typ let typ = String.strip typ
and name = String.strip name in and name = String.strip name in
let typ_cap = String.capitalize typ in let typ_cap = String.capitalize typ in
let newstring = Printf.sprintf template name typ typ typ typ typ typ typ typ let newstring = Printf.sprintf template name typ typ typ typ typ typ typ
( String.strip text ) typ_cap ( String.strip text ) typ_cap
in in
List.rev (parse (newstring::result) tail ) List.rev (parse (newstring::result) tail )

8
ocaml/test_input.ml Normal file
View File

@ -0,0 +1,8 @@
let test_module () =
Ezfio.set_file "F2.ezfio" ;
let b = Input.Ao_basis.read ()
in
print_endline (Input.Ao_basis.to_string b);
;;
test_module ();;

View File

@ -34,6 +34,14 @@ subroutine save_dets_qmcchem
call ezfio_set_determinants_det_occ(occ) call ezfio_set_determinants_det_occ(occ)
call write_int(output_dets,N_det,'Determinants saved for QMC') call write_int(output_dets,N_det,'Determinants saved for QMC')
deallocate(occ) deallocate(occ)
open(unit=31,file=trim(ezfio_filename)//'/mo_basis/mo_classif')
write(31,*) 1
write(31,*) mo_tot_num
do i=1,mo_tot_num
write(31,'(A)') 'a'
enddo
close(31)
call system('gzip '//trim(ezfio_filename)//'/mo_basis/mo_classif')
end end
program save_for_qmc program save_for_qmc