mirror of
https://gitlab.com/scemama/qmcchem.git
synced 2024-10-06 16:25:57 +02:00
Added ocaml files
This commit is contained in:
parent
e49713ee98
commit
a629b30051
105
ezfio_config/qmc.config
Normal file
105
ezfio_config/qmc.config
Normal file
@ -0,0 +1,105 @@
|
||||
ao_basis
|
||||
ao_num integer
|
||||
ao_prim_num integer (ao_basis_ao_num)
|
||||
ao_nucl integer (ao_basis_ao_num)
|
||||
ao_power integer (ao_basis_ao_num,3)
|
||||
ao_prim_num_max integer = maxval(ao_basis_ao_prim_num)
|
||||
ao_coef real (ao_basis_ao_num,ao_basis_ao_prim_num_max)
|
||||
ao_expo real (ao_basis_ao_num,ao_basis_ao_prim_num_max)
|
||||
|
||||
mo_basis
|
||||
mo_tot_num integer
|
||||
mo_coef real (ao_basis_ao_num,mo_basis_mo_tot_num)
|
||||
mo_classif character (mo_basis_mo_tot_num)
|
||||
mo_closed_num integer =n_count_ch(mo_basis_mo_classif,size(mo_basis_mo_classif),'c')
|
||||
mo_active_num integer =n_count_ch(mo_basis_mo_classif,size(mo_basis_mo_classif),'a')
|
||||
mo_virtual_num integer =n_count_ch(mo_basis_mo_classif,size(mo_basis_mo_classif),'v')
|
||||
mo_energy real (mo_basis_mo_tot_num)
|
||||
mo_occ real (mo_basis_mo_tot_num)
|
||||
mo_symmetry character*(8) (mo_basis_mo_tot_num)
|
||||
|
||||
electrons
|
||||
elec_alpha_num integer
|
||||
elec_beta_num integer
|
||||
elec_num integer = electrons_elec_alpha_num + electrons_elec_beta_num
|
||||
elec_walk_num_tot integer
|
||||
elec_walk_num integer
|
||||
elec_coord_pool real (electrons_elec_num+1,3,electrons_elec_coord_pool_size)
|
||||
elec_coord_pool_size integer
|
||||
elec_fitcusp_radius real
|
||||
|
||||
nuclei
|
||||
nucl_num integer
|
||||
nucl_label character*(32) (nuclei_nucl_num)
|
||||
nucl_charge real (nuclei_nucl_num)
|
||||
nucl_coord real (nuclei_nucl_num,3)
|
||||
nucl_fitcusp_radius real (nuclei_nucl_num)
|
||||
|
||||
spindeterminants
|
||||
n_det_alpha integer
|
||||
n_det_beta integer
|
||||
n_det integer
|
||||
n_int integer
|
||||
bit_kind integer
|
||||
n_states integer
|
||||
psi_det_alpha integer*8 (spindeterminants_n_int*spindeterminants_bit_kind/8,spindeterminants_n_det_alpha)
|
||||
psi_det_beta integer*8 (spindeterminants_n_int*spindeterminants_bit_kind/8,spindeterminants_n_det_beta)
|
||||
psi_coef_matrix_rows integer (spindeterminants_n_det)
|
||||
psi_coef_matrix_columns integer (spindeterminants_n_det)
|
||||
psi_coef_matrix_values double precision (spindeterminants_n_det,spindeterminants_n_states)
|
||||
|
||||
|
||||
simulation
|
||||
do_run integer
|
||||
stop_time integer
|
||||
equilibration logical
|
||||
title character*(128)
|
||||
http_server character*(128)
|
||||
do_jast logical
|
||||
do_nucl_fitcusp logical
|
||||
method character*(32)
|
||||
block_time integer
|
||||
sampling character*(32)
|
||||
save_data logical
|
||||
time_step real
|
||||
print_level integer
|
||||
ci_threshold double precision
|
||||
md5_key character*(32)
|
||||
orig_time double precision
|
||||
E_ref double precision
|
||||
|
||||
jastrow
|
||||
jast_type character*(32)
|
||||
jast_a_up_up real
|
||||
jast_a_up_dn real
|
||||
jast_b_up_up real
|
||||
jast_b_up_dn real
|
||||
jast_pen real (nuclei_nucl_num)
|
||||
jast_eeN_e_a real (nuclei_nucl_num)
|
||||
jast_eeN_e_b real (nuclei_nucl_num)
|
||||
jast_eeN_N real (nuclei_nucl_num)
|
||||
jast_core_a1 real (nuclei_nucl_num)
|
||||
jast_core_a2 real (nuclei_nucl_num)
|
||||
jast_core_b1 real (nuclei_nucl_num)
|
||||
jast_core_b2 real (nuclei_nucl_num)
|
||||
|
||||
blocks
|
||||
empty integer
|
||||
|
||||
pseudo
|
||||
ao_pseudo_grid double precision (ao_basis_ao_num,pseudo_pseudo_lmax+pseudo_pseudo_lmax+1,pseudo_pseudo_lmax-0+1,nuclei_nucl_num,pseudo_pseudo_grid_size)
|
||||
do_pseudo logical
|
||||
mo_pseudo_grid double precision (ao_basis_ao_num,pseudo_pseudo_lmax+pseudo_pseudo_lmax+1,pseudo_pseudo_lmax-0+1,nuclei_nucl_num,pseudo_pseudo_grid_size)
|
||||
pseudo_dz_k double precision (nuclei_nucl_num,pseudo_pseudo_klocmax)
|
||||
pseudo_dz_kl double precision (nuclei_nucl_num,pseudo_pseudo_kmax,pseudo_pseudo_lmax+1)
|
||||
pseudo_grid_rmax double precision
|
||||
pseudo_grid_size integer
|
||||
pseudo_klocmax integer
|
||||
pseudo_kmax integer
|
||||
pseudo_lmax integer
|
||||
pseudo_n_k integer (nuclei_nucl_num,pseudo_pseudo_klocmax)
|
||||
pseudo_n_kl integer (nuclei_nucl_num,pseudo_pseudo_kmax,pseudo_pseudo_lmax+1)
|
||||
pseudo_v_k double precision (nuclei_nucl_num,pseudo_pseudo_klocmax)
|
||||
pseudo_v_kl double precision (nuclei_nucl_num,pseudo_pseudo_kmax,pseudo_pseudo_lmax+1)
|
||||
|
||||
|
@ -14,7 +14,9 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +u
|
||||
source "${QMCCHEM_PATH}"/qmcchemrc
|
||||
set -u
|
||||
cd Downloads
|
||||
chmod +x opam_installer.sh
|
||||
|
||||
|
150
ocaml/Block.ml
Normal file
150
ocaml/Block.ml
Normal file
@ -0,0 +1,150 @@
|
||||
open Core.Std;;
|
||||
open Qptypes;;
|
||||
|
||||
type t =
|
||||
{ property : Property.t ;
|
||||
value : Sample.t ;
|
||||
weight : Weight.t ;
|
||||
compute_node : Compute_node.t ;
|
||||
pid : Pid.t ;
|
||||
block_id : Block_id.t ;
|
||||
}
|
||||
|
||||
let re =
|
||||
Str.regexp "[ |#|\n]+"
|
||||
|
||||
let of_string s =
|
||||
|
||||
try
|
||||
let lst =
|
||||
Str.split re s
|
||||
|> List.rev
|
||||
in
|
||||
match lst with
|
||||
| b :: pid :: c:: p :: w :: v :: [] -> Some
|
||||
{ property = Property.of_string p ;
|
||||
value = Sample.of_float (Float.of_string v) ;
|
||||
weight = Weight.of_float (Float.of_string w) ;
|
||||
compute_node = Compute_node.of_string c;
|
||||
pid = Pid.of_string pid;
|
||||
block_id = Block_id.of_int (Int.of_string b) ;
|
||||
}
|
||||
| b :: pid :: c:: p :: w :: v ->
|
||||
let v =
|
||||
List.rev v
|
||||
|> Array.of_list
|
||||
|> Array.map ~f:Float.of_string
|
||||
in
|
||||
let dim =
|
||||
Array.length v
|
||||
in
|
||||
Some
|
||||
{ property = Property.of_string p ;
|
||||
value = Sample.of_float_array ~dim v ;
|
||||
weight = Weight.of_float (Float.of_string w) ;
|
||||
compute_node = Compute_node.of_string c;
|
||||
pid = Pid.of_string pid;
|
||||
block_id = Block_id.of_int (Int.of_string b) ;
|
||||
}
|
||||
| _ -> None
|
||||
with
|
||||
| _ -> None
|
||||
|
||||
|
||||
|
||||
let to_string b =
|
||||
Printf.sprintf "%s %s # %s %s %s %d"
|
||||
(Sample.to_string b.value )
|
||||
(Weight.to_float b.weight |> Float.to_string)
|
||||
(Property.to_string b.property)
|
||||
(Compute_node.to_string b.compute_node)
|
||||
(Pid.to_string b.pid)
|
||||
(Block_id.to_int b.block_id)
|
||||
|
||||
|
||||
|
||||
let dir_name = lazy(
|
||||
let ezfio_filename =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
let md5 =
|
||||
Md5.hash ()
|
||||
in
|
||||
List.fold_right ~init:"" ~f:Filename.concat
|
||||
[ ezfio_filename ; "blocks" ; md5 ; Filename.dir_sep ]
|
||||
)
|
||||
|
||||
|
||||
(* Fetch raw data from the EZFIO file *)
|
||||
let _raw_data =
|
||||
ref None
|
||||
|
||||
|
||||
let update_raw_data ?(locked=true) () =
|
||||
(* Create array of files to read *)
|
||||
let dir_name =
|
||||
Lazy.force dir_name
|
||||
in
|
||||
let files =
|
||||
let result =
|
||||
match Sys.is_directory dir_name with
|
||||
| `Yes ->
|
||||
begin
|
||||
Sys.readdir dir_name
|
||||
|> Array.map ~f:(fun x -> dir_name^x)
|
||||
|> Array.to_list
|
||||
end
|
||||
| _ -> []
|
||||
in
|
||||
if locked then
|
||||
result
|
||||
else
|
||||
List.filter result ~f:(fun x ->
|
||||
match String.substr_index ~pattern:"locked" x with
|
||||
| Some x -> false
|
||||
| None -> true
|
||||
)
|
||||
in
|
||||
|
||||
let rec transform new_list = function
|
||||
| [] -> new_list
|
||||
| head :: tail ->
|
||||
let head = String.strip head in
|
||||
let item = of_string head in
|
||||
match item with
|
||||
| None -> transform new_list tail
|
||||
| Some x -> transform (x::new_list) tail
|
||||
in
|
||||
|
||||
let result =
|
||||
List.map files ~f:(fun filename ->
|
||||
In_channel.with_file filename ~f:(fun in_channel ->
|
||||
In_channel.input_all in_channel)
|
||||
)
|
||||
|> String.concat
|
||||
|> String.split_lines
|
||||
|> List.rev
|
||||
|> transform []
|
||||
in
|
||||
result
|
||||
|
||||
|
||||
let raw_data ?(locked=true) () =
|
||||
match !_raw_data with
|
||||
| Some x -> x
|
||||
| None ->
|
||||
let result =
|
||||
update_raw_data ~locked ()
|
||||
in
|
||||
_raw_data := Some result;
|
||||
result
|
||||
|
||||
|
||||
|
||||
let properties = lazy (
|
||||
let set = Set.empty ~comparator:Comparator.Poly.comparator in
|
||||
List.fold (raw_data ()) ~init:set ~f:(fun s x -> Set.add s x.property)
|
||||
|> Set.to_list
|
||||
)
|
||||
|
||||
|
37
ocaml/Default.ml
Normal file
37
ocaml/Default.ml
Normal file
@ -0,0 +1,37 @@
|
||||
open Core.Std;;
|
||||
|
||||
let simulation_do_nucl_fitcusp =
|
||||
if (not (Ezfio.has_simulation_do_nucl_fitcusp ())) then
|
||||
begin
|
||||
if (not (Ezfio.has_pseudo_do_pseudo ())) then
|
||||
true
|
||||
else
|
||||
not (Ezfio.get_pseudo_do_pseudo ())
|
||||
end
|
||||
else
|
||||
Ezfio.get_simulation_do_nucl_fitcusp ()
|
||||
|
||||
|
||||
let electrons_elec_walk_num = 30
|
||||
let electrons_elec_walk_num_tot = 10000
|
||||
let jastrow_jast_type = "None"
|
||||
let simulation_block_time = 30
|
||||
let simulation_ci_threshold = 1.e-8
|
||||
let simulation_method = "VMC"
|
||||
let simulation_sampling = "Langevin"
|
||||
let simulation_stop_time = 3600
|
||||
let simulation_time_step = 0.15
|
||||
|
||||
let reset_defaults () =
|
||||
List.iter ~f:(fun x -> Sys.remove ( (Lazy.force Qputils.ezfio_filename) ^ x))
|
||||
[ "/electrons/elec_walk_num" ;
|
||||
"/electrons/elec_walk_num_tot" ;
|
||||
"/jastrow/jast_type" ;
|
||||
"/simulation/block_time" ;
|
||||
"/simulation/ci_threshold" ;
|
||||
"/simulation/do_nucl_fitcusp" ;
|
||||
"/simulation/method" ;
|
||||
"/simulation/sampling" ;
|
||||
"/simulation/stop_time" ;
|
||||
"/simulation/time_step" ]
|
||||
|
865
ocaml/Input.ml
Normal file
865
ocaml/Input.ml
Normal file
@ -0,0 +1,865 @@
|
||||
open Core.Std
|
||||
open Qptypes
|
||||
open Qputils
|
||||
|
||||
|
||||
|
||||
module Pseudo: sig
|
||||
|
||||
type t = bool
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val to_bool : t -> bool
|
||||
val of_bool : bool -> t
|
||||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = bool
|
||||
|
||||
let doc = "Correct wave function to verify electron-nucleus cusp condition"
|
||||
|
||||
let of_bool x = x
|
||||
|
||||
let to_bool x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_pseudo_do_pseudo ())) then
|
||||
Ezfio.set_pseudo_do_pseudo false;
|
||||
Ezfio.get_pseudo_do_pseudo ()
|
||||
|> of_bool
|
||||
|
||||
|
||||
let to_string t =
|
||||
to_bool t
|
||||
|> Bool.to_string
|
||||
|
||||
|
||||
let of_string t =
|
||||
try
|
||||
String.lowercase t
|
||||
|> Bool.of_string
|
||||
|> of_bool
|
||||
with
|
||||
| Invalid_argument msg -> failwith msg
|
||||
|
||||
|
||||
let to_int t =
|
||||
let t =
|
||||
to_bool t
|
||||
in
|
||||
if t then 1
|
||||
else 0
|
||||
|
||||
|
||||
let of_int = function
|
||||
| 0 -> false
|
||||
| 1 -> true
|
||||
| _ -> failwith "Expected 0 or 1"
|
||||
|
||||
|
||||
end
|
||||
|
||||
module Fitcusp : sig
|
||||
|
||||
type t = bool
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_bool : t -> bool
|
||||
val of_bool : bool -> t
|
||||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = bool
|
||||
|
||||
let doc = "Correct wave function to verify electron-nucleus cusp condition"
|
||||
|
||||
let of_bool x = x
|
||||
|
||||
let to_bool x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_do_nucl_fitcusp ())) then
|
||||
Ezfio.set_simulation_do_nucl_fitcusp Default.simulation_do_nucl_fitcusp;
|
||||
Ezfio.get_simulation_do_nucl_fitcusp ()
|
||||
|> of_bool
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
let () =
|
||||
match (Pseudo.read () |> Pseudo.to_bool, to_bool t) with
|
||||
| (true, true) -> failwith "Pseudopotentials and Fitcusp are incompatible"
|
||||
| _ -> ()
|
||||
in
|
||||
to_bool t
|
||||
|> Ezfio.set_simulation_do_nucl_fitcusp
|
||||
|
||||
|
||||
let to_string t =
|
||||
to_bool t
|
||||
|> Bool.to_string
|
||||
|
||||
|
||||
let of_string t =
|
||||
try
|
||||
String.lowercase t
|
||||
|> Bool.of_string
|
||||
|> of_bool
|
||||
with
|
||||
| Invalid_argument msg -> failwith msg
|
||||
|
||||
|
||||
let to_int t =
|
||||
let t =
|
||||
to_bool t
|
||||
in
|
||||
if t then 1
|
||||
else 0
|
||||
|
||||
|
||||
let of_int = function
|
||||
| 0 -> false
|
||||
| 1 -> true
|
||||
| _ -> failwith "Expected 0 or 1"
|
||||
|
||||
|
||||
end
|
||||
|
||||
module Block_time : sig
|
||||
|
||||
type t = int
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
val to_float : t -> float
|
||||
val of_float : float-> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = int
|
||||
|
||||
let doc = "Length (seconds) of a block"
|
||||
|
||||
let of_int x =
|
||||
if (x < 1) then
|
||||
failwith "Block time should be >=1";
|
||||
if (x > 36000) then
|
||||
failwith "Block time is too large (<= 36000)";
|
||||
x
|
||||
|
||||
|
||||
let to_int x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_block_time ())) then
|
||||
Ezfio.set_simulation_block_time Default.simulation_block_time;
|
||||
Ezfio.get_simulation_block_time ()
|
||||
|> of_int
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_int t
|
||||
|> Ezfio.set_simulation_block_time
|
||||
|
||||
|
||||
let to_string t =
|
||||
to_int t
|
||||
|> Int.to_string
|
||||
|
||||
|
||||
let of_string t =
|
||||
Int.of_string t
|
||||
|> of_int
|
||||
|
||||
|
||||
let to_float t =
|
||||
to_int t
|
||||
|> Float.of_int
|
||||
|
||||
|
||||
let of_float t =
|
||||
Int.of_float t
|
||||
|> of_int
|
||||
|
||||
|
||||
end
|
||||
|
||||
module Walk_num : sig
|
||||
|
||||
type t = int
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = int
|
||||
let doc = "Number of walkers per CPU core"
|
||||
|
||||
let of_int x =
|
||||
if (x < 1) then
|
||||
failwith "Number of walkers should be >=1";
|
||||
if (x > 100_000) then
|
||||
failwith "Number of walkers is too large (<= 100_000)";
|
||||
x
|
||||
|
||||
|
||||
let to_int x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_electrons_elec_walk_num () )) then
|
||||
Ezfio.set_electrons_elec_walk_num Default.electrons_elec_walk_num;
|
||||
Ezfio.get_electrons_elec_walk_num ()
|
||||
|> of_int
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_int t
|
||||
|> Ezfio.set_electrons_elec_walk_num
|
||||
|
||||
|
||||
let to_string t =
|
||||
to_int t
|
||||
|> Int.to_string
|
||||
|
||||
|
||||
let of_string t =
|
||||
Int.of_string t
|
||||
|> of_int
|
||||
|
||||
|
||||
end
|
||||
|
||||
module Walk_num_tot : sig
|
||||
|
||||
type t = int
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = int
|
||||
let doc = "Total number of stored walkers for restart"
|
||||
|
||||
let of_int x =
|
||||
if (x < 2) then
|
||||
failwith "Total number of stored walkers should be > 1";
|
||||
if (x > 100_000_000) then
|
||||
failwith "Number of walkers to store too large (<= 100.10^6)";
|
||||
x
|
||||
|
||||
|
||||
let to_int x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_electrons_elec_walk_num_tot () )) then
|
||||
Ezfio.set_electrons_elec_walk_num_tot Default.electrons_elec_walk_num_tot;
|
||||
Ezfio.get_electrons_elec_walk_num_tot ()
|
||||
|> of_int
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_int t
|
||||
|> Ezfio.set_electrons_elec_walk_num_tot
|
||||
|
||||
|
||||
let to_string t =
|
||||
to_int t
|
||||
|> Int.to_string
|
||||
|
||||
|
||||
let of_string t =
|
||||
Int.of_string t
|
||||
|> of_int
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
module Stop_time : sig
|
||||
|
||||
type t = int
|
||||
val read : unit -> t
|
||||
val doc : string
|
||||
val write : t -> unit
|
||||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
val to_float : t -> float
|
||||
val of_float : float -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = int
|
||||
|
||||
let doc = "Requested simulation time (seconds)"
|
||||
|
||||
let of_int x =
|
||||
if (x < 1) then
|
||||
failwith "Simulation time too short (>=1 s)";
|
||||
x
|
||||
|
||||
|
||||
let to_int x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_stop_time ())) then
|
||||
Ezfio.set_simulation_stop_time Default.simulation_stop_time;
|
||||
Ezfio.get_simulation_stop_time ()
|
||||
|> of_int
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_int t
|
||||
|> Ezfio.set_simulation_stop_time
|
||||
|
||||
|
||||
let to_string t =
|
||||
to_int t
|
||||
|> Int.to_string
|
||||
|
||||
|
||||
let of_string t =
|
||||
Int.of_string t
|
||||
|> of_int
|
||||
|
||||
|
||||
let to_float t =
|
||||
to_int t
|
||||
|> Float.of_int
|
||||
|
||||
|
||||
let of_float t =
|
||||
Int.of_float t
|
||||
|> of_int
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
module Method : sig
|
||||
|
||||
type t = VMC | DMC
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = VMC | DMC
|
||||
|
||||
let doc = "QMC Method : [ VMC | DMC ]"
|
||||
|
||||
let of_string = function
|
||||
| "VMC" | "vmc" -> VMC
|
||||
| "DMC" | "dmc" -> DMC
|
||||
| x -> failwith ("Method should be [ VMC | DMC ], not "^x^".")
|
||||
|
||||
|
||||
let to_string = function
|
||||
| VMC -> "VMC"
|
||||
| DMC -> "DMC"
|
||||
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_method ())) then
|
||||
Ezfio.set_simulation_method Default.simulation_method;
|
||||
Ezfio.get_simulation_method ()
|
||||
|> of_string
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_string t
|
||||
|> Ezfio.set_simulation_method
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
module Sampling : sig
|
||||
|
||||
type t = Brownian | Langevin
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = Brownian | Langevin
|
||||
|
||||
let doc = "Sampling algorithm : [ Langevin | Brownian ]"
|
||||
|
||||
let of_string s =
|
||||
match String.capitalize (String.strip s) with
|
||||
| "Langevin" -> Langevin
|
||||
| "Brownian" -> Brownian
|
||||
| x -> failwith ("Sampling should be [ Brownian | Langevin ], not "^x^".")
|
||||
|
||||
|
||||
let to_string = function
|
||||
| Langevin -> "Langevin"
|
||||
| Brownian -> "Brownian"
|
||||
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_sampling ())) then
|
||||
Ezfio.set_simulation_sampling Default.simulation_sampling;
|
||||
Ezfio.get_simulation_sampling ()
|
||||
|> of_string
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_string t
|
||||
|> Ezfio.set_simulation_sampling
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
module Ref_energy : sig
|
||||
|
||||
type t = float
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_float : t -> float
|
||||
val of_float : float -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = float
|
||||
let doc = "Fixed reference energy to normalize DMC weights"
|
||||
|
||||
let of_float x =
|
||||
if (x > 0.) then
|
||||
failwith "Reference energy should not be positive.";
|
||||
if (x <= -1_000_000.) then
|
||||
failwith "Reference energy is too low.";
|
||||
x
|
||||
|
||||
|
||||
let to_float x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_e_ref ())) then
|
||||
to_float 0.
|
||||
|> Ezfio.set_simulation_e_ref;
|
||||
Ezfio.get_simulation_e_ref ()
|
||||
|> of_float
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_float t
|
||||
|> Ezfio.set_simulation_e_ref
|
||||
|
||||
|
||||
let of_string x =
|
||||
Float.of_string x
|
||||
|> of_float
|
||||
|
||||
|
||||
let to_string x =
|
||||
to_float x
|
||||
|> Float.to_string
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
module CI_threshold : sig
|
||||
|
||||
type t = float
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_float : t -> float
|
||||
val of_float : float -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = float
|
||||
let doc = "Truncation t of the wave function : Remove determinants with a
|
||||
contribution to the norm less than t"
|
||||
|
||||
let of_float x =
|
||||
if (x >= 1.) then
|
||||
failwith "Truncation of the wave function should be < 1.";
|
||||
if (x < 0.) then
|
||||
failwith "Truncation of the wave function should be positive.";
|
||||
x
|
||||
|
||||
|
||||
let to_float x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_ci_threshold ())) then
|
||||
Ezfio.set_simulation_ci_threshold Default.simulation_ci_threshold ;
|
||||
Ezfio.get_simulation_ci_threshold ()
|
||||
|> of_float
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_float t
|
||||
|> Ezfio.set_simulation_ci_threshold
|
||||
|
||||
|
||||
let of_string x =
|
||||
Float.of_string x
|
||||
|> of_float
|
||||
|
||||
|
||||
let to_string x =
|
||||
to_float x
|
||||
|> Float.to_string
|
||||
|
||||
end
|
||||
|
||||
module Time_step : sig
|
||||
|
||||
type t = float
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_float : t -> float
|
||||
val of_float : float -> t
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = float
|
||||
let doc = "Simulation time step"
|
||||
|
||||
let of_float x =
|
||||
if (x >= 10.) then
|
||||
failwith "Time step should be < 10.";
|
||||
if (x <= 0.) then
|
||||
failwith "Time step should be positive.";
|
||||
x
|
||||
|
||||
|
||||
let to_float x = x
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_simulation_time_step ())) then
|
||||
Ezfio.set_simulation_time_step Default.simulation_time_step;
|
||||
Ezfio.get_simulation_time_step ()
|
||||
|> of_float
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
to_float t
|
||||
|> Ezfio.set_simulation_time_step
|
||||
|
||||
|
||||
let of_string x =
|
||||
Float.of_string x
|
||||
|> of_float
|
||||
|
||||
|
||||
let to_string x =
|
||||
to_float x
|
||||
|> Float.to_string
|
||||
|
||||
end
|
||||
|
||||
module Jastrow_type : sig
|
||||
|
||||
type t = None | Core | Simple
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = None | Core | Simple
|
||||
let doc = "Type of Jastrow factor [ None | Core | Simple ]"
|
||||
|
||||
let of_string s =
|
||||
match String.capitalize (String.strip s) with
|
||||
| "Core" -> Core
|
||||
| "Simple" -> Simple
|
||||
| "None" -> None
|
||||
| _ -> failwith "Jastrow type should be [ None | Core | Simple ]"
|
||||
|
||||
|
||||
let to_string = function
|
||||
| Core -> "Core"
|
||||
| Simple -> "Simple"
|
||||
| None -> "None"
|
||||
|
||||
|
||||
let read () =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
if (not (Ezfio.has_jastrow_jast_type ())) then
|
||||
Ezfio.set_jastrow_jast_type Default.jastrow_jast_type;
|
||||
Ezfio.get_jastrow_jast_type ();
|
||||
|> of_string
|
||||
|
||||
|
||||
let write t =
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
let () =
|
||||
match (Pseudo.read () |> Pseudo.to_bool, t) with
|
||||
| (false, _)
|
||||
| (true , None) -> ()
|
||||
| _ -> failwith "Jastrow and Pseudopotentials are incompatible"
|
||||
in
|
||||
|
||||
to_string t
|
||||
|> Ezfio.set_jastrow_jast_type
|
||||
|
||||
|
||||
end
|
||||
|
||||
module Properties: sig
|
||||
|
||||
type t = (Property.t * bool) list
|
||||
val doc : string
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
end = struct
|
||||
|
||||
type t = (Property.t * bool) list
|
||||
|
||||
let doc =
|
||||
"Properties to sample. (X) is true and ( ) is false"
|
||||
|
||||
|
||||
let read () =
|
||||
List.map Property.all ~f:(fun x -> (x, Property.calc x))
|
||||
|
||||
|
||||
let write l =
|
||||
List.iter l ~f:(fun (x,b) -> Property.set_calc x b)
|
||||
|
||||
|
||||
let to_string l =
|
||||
List.map l ~f:(fun (x,b) ->
|
||||
let ch =
|
||||
if b then "X" else " "
|
||||
in
|
||||
Printf.sprintf "(%s) %s" ch (Property.to_string x))
|
||||
|> String.concat ~sep:"\n"
|
||||
|
||||
|
||||
let of_string s =
|
||||
String.split s ~on:'\n'
|
||||
|> List.map ~f:(fun x ->
|
||||
let (calc,prop) =
|
||||
String.strip x
|
||||
|> String.rsplit2_exn ~on:' '
|
||||
in
|
||||
let prop =
|
||||
String.strip prop
|
||||
|> Property.of_string
|
||||
and calc =
|
||||
match calc with
|
||||
| "(X)" -> true
|
||||
| "( )" -> false
|
||||
| _ -> failwith " (X) or ( ) expected"
|
||||
in
|
||||
(prop, calc)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
(** Check if everything is correct in the input file. *)
|
||||
let validate () =
|
||||
|
||||
let _ =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
|
||||
(* Check if walkers are present *)
|
||||
if (not (Ezfio.has_electrons_elec_coord_pool ())) then
|
||||
Printf.printf "Warning: No initial walkers\n";
|
||||
|
||||
let meth =
|
||||
Method.read ()
|
||||
and sampling =
|
||||
Sampling.read ()
|
||||
and ts =
|
||||
Time_step.read ()
|
||||
and jast_type =
|
||||
Jastrow_type.read ()
|
||||
and do_fitcusp =
|
||||
Fitcusp.read ()
|
||||
and do_pseudo =
|
||||
Pseudo.read ()
|
||||
in
|
||||
|
||||
(* Check sampling and time steps *)
|
||||
let () =
|
||||
match (sampling, meth, Pseudo.to_bool do_pseudo) with
|
||||
| (Sampling.Brownian, Method.DMC, true) ->
|
||||
if ( (Time_step.to_float ts) >= 0.5 ) then
|
||||
warn "Time step seems large for DMC.";
|
||||
| (Sampling.Brownian, Method.DMC, false) ->
|
||||
if ( (Time_step.to_float ts) >= 0.01 ) then
|
||||
warn "Time step seems large for DMC.";
|
||||
| (Sampling.Brownian, Method.VMC, _) ->
|
||||
if ( (Time_step.to_float ts) >= 10. ) then
|
||||
warn "Time step seems large for VMC.";
|
||||
| (Sampling.Langevin, Method.VMC, _) ->
|
||||
if ( (Time_step.to_float ts) <= 0.01 ) then
|
||||
warn "Time step seems small for Langevin sampling."
|
||||
| (Sampling.Langevin, Method.DMC, _) ->
|
||||
failwith "Lanvegin sampling is incompatible with DMC"
|
||||
in
|
||||
|
||||
|
||||
(* Check E_ref is not zero *)
|
||||
let () =
|
||||
match (meth, Ref_energy.(read () |> to_float) ) with
|
||||
| (Method.DMC,0.) -> failwith "E_ref should not be zero in DMC"
|
||||
| _ -> ()
|
||||
in
|
||||
|
||||
(* Set block and total time*)
|
||||
let () =
|
||||
if ( (Block_time.read ()) > Stop_time.read ()) then
|
||||
failwith "Block time is longer than total time"
|
||||
in
|
||||
|
||||
(* Check if E_loc if computed *)
|
||||
let () =
|
||||
match (meth, Property.(calc E_loc)) with
|
||||
| (Method.DMC, false) -> failwith "E_loc should be sampled in DMC"
|
||||
| (Method.VMC, false) -> warn "Sampling of E_loc is not activated in input"
|
||||
| _ -> ()
|
||||
in
|
||||
|
||||
(* Pseudo and Jastrow are incompatible *)
|
||||
let () =
|
||||
match (Pseudo.to_bool do_pseudo, jast_type) with
|
||||
| (true, Jastrow_type.Core )
|
||||
| (true, Jastrow_type.Simple) -> failwith "Jastrow and Pseudopotentials are incompatible"
|
||||
| _ -> ()
|
||||
in
|
||||
|
||||
(* Fitcusp is not recommended with pseudo *)
|
||||
let () =
|
||||
match (Pseudo.to_bool do_pseudo, Fitcusp.to_bool do_fitcusp) with
|
||||
| (true, true) -> warn "Fitcusp is incompatible with Pseudopotentials"
|
||||
| _ -> ()
|
||||
in
|
||||
|
||||
(* Other Checks *)
|
||||
let () =
|
||||
let _ =
|
||||
Walk_num.read ()
|
||||
and _ =
|
||||
Walk_num_tot.read ()
|
||||
and _ =
|
||||
CI_threshold.read ()
|
||||
in ()
|
||||
in
|
||||
()
|
||||
|
||||
|
||||
|
79
ocaml/Launcher.ml
Normal file
79
ocaml/Launcher.ml
Normal file
@ -0,0 +1,79 @@
|
||||
open Core.Std;;
|
||||
|
||||
type t =
|
||||
| Srun
|
||||
| MPI
|
||||
| Bash
|
||||
|
||||
let to_string = function
|
||||
| Srun -> "srun"
|
||||
| Bash -> "env"
|
||||
| MPI -> Lazy.force Qmcchem_config.mpirun
|
||||
|
||||
|
||||
(** Find the launcher for the current job scheduler *)
|
||||
let find () =
|
||||
|
||||
let result =
|
||||
match Scheduler.find () with
|
||||
| Scheduler.SLURM -> Srun
|
||||
| Scheduler.Batch
|
||||
| Scheduler.PBS
|
||||
| Scheduler.SGE ->
|
||||
if Lazy.force Qmcchem_config.has_mpirun then
|
||||
MPI
|
||||
else
|
||||
Bash
|
||||
in
|
||||
result
|
||||
|
||||
|
||||
(** Create a file contaning the list of nodes and the number of available CPUs *)
|
||||
let create_nodefile () =
|
||||
|
||||
let launcher =
|
||||
find ()
|
||||
in
|
||||
|
||||
let launcher_command =
|
||||
to_string launcher
|
||||
in
|
||||
|
||||
let h =
|
||||
Hashtbl.create ~hashable:String.hashable ~size:1000 ()
|
||||
in
|
||||
|
||||
let in_channel =
|
||||
Unix.open_process_in (launcher_command^" hostname -s")
|
||||
in
|
||||
In_channel.input_lines in_channel
|
||||
|> List.map ~f:String.strip
|
||||
|> List.iter ~f:( fun host ->
|
||||
Hashtbl.change h host (function
|
||||
| Some x -> Some (x+1)
|
||||
| None -> Some 1
|
||||
)
|
||||
);
|
||||
match
|
||||
Unix.close_process_in in_channel
|
||||
with
|
||||
| _ -> ();
|
||||
|
||||
|
||||
let f =
|
||||
match launcher with
|
||||
| MPI ->
|
||||
fun (node, n) ->
|
||||
Printf.sprintf "%s slots=%d\n" node n
|
||||
| Srun
|
||||
| Bash ->
|
||||
fun (node, n) ->
|
||||
Printf.sprintf "%s %d\n" node n
|
||||
in
|
||||
Hashtbl.to_alist h
|
||||
|> List.map ~f
|
||||
|> String.concat
|
||||
|
||||
|
||||
|
||||
|
143
ocaml/Md5.ml
Normal file
143
ocaml/Md5.ml
Normal file
@ -0,0 +1,143 @@
|
||||
open Core.Std
|
||||
|
||||
(** Directory containing the list of input files. The directory is created is inexistant. *)
|
||||
let input_directory = lazy (
|
||||
|
||||
let ezfio_filename =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
|
||||
let dirname =
|
||||
Filename.concat ezfio_filename "input"
|
||||
in
|
||||
|
||||
begin
|
||||
match ( Sys.is_directory dirname ) with
|
||||
| `No -> Unix.mkdir dirname
|
||||
| _ -> ()
|
||||
end ;
|
||||
|
||||
dirname
|
||||
)
|
||||
|
||||
|
||||
(** List of files responsible for the MD5 key of the input *)
|
||||
let files_to_track = [
|
||||
"ao_basis/ao_coef.gz" ;
|
||||
"ao_basis/ao_expo.gz" ;
|
||||
"ao_basis/ao_nucl.gz" ;
|
||||
"ao_basis/ao_num" ;
|
||||
"ao_basis/ao_power.gz" ;
|
||||
"ao_basis/ao_prim_num.gz" ;
|
||||
"electrons/elec_alpha_num" ;
|
||||
"electrons/elec_beta_num" ;
|
||||
"jastrow/jast_type" ;
|
||||
"mo_basis/mo_coef.gz" ;
|
||||
"mo_basis/mo_tot_num" ;
|
||||
"nuclei/nucl_charge.gz" ;
|
||||
"nuclei/nucl_coord.gz" ;
|
||||
"nuclei/nucl_fitcusp_radius.gz" ;
|
||||
"nuclei/nucl_num" ;
|
||||
"simulation/ci_threshold" ;
|
||||
"simulation/do_nucl_fitcusp" ;
|
||||
"simulation/jast_a_up_dn" ;
|
||||
"simulation/jast_a_up_up" ;
|
||||
"simulation/jast_b_up_dn" ;
|
||||
"simulation/jast_b_up_up" ;
|
||||
"simulation/jast_core_a1" ;
|
||||
"simulation/jast_core_a2" ;
|
||||
"simulation/jast_core_b1" ;
|
||||
"simulation/jast_core_b2" ;
|
||||
"simulation/jast_een_e_a.gz" ;
|
||||
"simulation/jast_een_e_b.gz" ;
|
||||
"simulation/jast_een_n.gz" ;
|
||||
"simulation/jast_pen.gz" ;
|
||||
"simulation/method" ;
|
||||
"simulation/time_step" ;
|
||||
"spindeterminants/bit_kind" ;
|
||||
"spindeterminants/n_det" ;
|
||||
"spindeterminants/n_det_alpha" ;
|
||||
"spindeterminants/n_det_beta" ;
|
||||
"spindeterminants/n_int" ;
|
||||
"spindeterminants/n_states" ;
|
||||
"spindeterminants/psi_coef_matrix_columns.gz" ;
|
||||
"spindeterminants/psi_coef_matrix_rows.gz" ;
|
||||
"spindeterminants/psi_coef_matrix_values.gz" ;
|
||||
"spindeterminants/psi_det_alpha.gz" ;
|
||||
"spindeterminants/psi_det_beta.gz" ;
|
||||
"/pseudo/do_pseudo" ;
|
||||
"/pseudo/mo_pseudo_grid.gz" ;
|
||||
"/pseudo/pseudo_dz_kl.gz";
|
||||
"/pseudo/pseudo_klocmax" ;
|
||||
"/pseudo/pseudo_n_k.gz" ;
|
||||
"/pseudo/pseudo_v_kl.gz" ;
|
||||
"/pseudo/pseudo_grid_rmax" ;
|
||||
"/pseudo/pseudo_kmax" ;
|
||||
"/pseudo/pseudo_n_kl.gz" ;
|
||||
"/pseudo/pseudo_dz_k.gz" ;
|
||||
"/pseudo/pseudo_grid_size" ;
|
||||
"/pseudo/pseudo_v_k.gz" ;
|
||||
]
|
||||
|
||||
|
||||
(** Get an MD5 ke from the content of a file. *)
|
||||
let hash_file filename =
|
||||
match Sys.is_file filename with
|
||||
| `Yes ->
|
||||
begin
|
||||
In_channel.with_file filename ~f:(fun ic ->
|
||||
Cryptokit.hash_channel (Cryptokit.Hash.md5 ()) ic
|
||||
|> Cryptokit.transform_string (Cryptokit.Hexa.encode ()) )
|
||||
end
|
||||
| _ -> ""
|
||||
|
||||
|
||||
(** Cache containing the current value of the MD5 hash. *)
|
||||
let _hash =
|
||||
ref None
|
||||
|
||||
(** Get the hash correcponding to the EZFIO file. *)
|
||||
let hash () =
|
||||
let compute_hash () =
|
||||
let ezfio_filename =
|
||||
Lazy.force Qputils.ezfio_filename
|
||||
in
|
||||
let old_md5 =
|
||||
if Ezfio.has_simulation_md5_key () then
|
||||
Ezfio.get_simulation_md5_key ()
|
||||
else
|
||||
""
|
||||
in
|
||||
let new_md5 = files_to_track
|
||||
|> List.map ~f:(fun x -> Printf.sprintf "%s/%s" ezfio_filename x)
|
||||
|> List.map ~f:hash_file
|
||||
|> String.concat
|
||||
|> Cryptokit.hash_string (Cryptokit.Hash.md5 ())
|
||||
|> Cryptokit.transform_string (Cryptokit.Hexa.encode ())
|
||||
in
|
||||
if (new_md5 <> old_md5) then
|
||||
begin
|
||||
Printf.eprintf "Info : MD5 key changed\n %s\n-> %s\n%!" old_md5 new_md5 ;
|
||||
Ezfio.set_simulation_md5_key new_md5
|
||||
end
|
||||
;
|
||||
new_md5
|
||||
in
|
||||
match (!_hash) with
|
||||
| Some key -> key
|
||||
| None ->
|
||||
begin
|
||||
let key =
|
||||
compute_hash ()
|
||||
in
|
||||
_hash := Some key ;
|
||||
key
|
||||
end
|
||||
|
||||
(** Reset the cache of the MD5 hash. *)
|
||||
let reset_hash () =
|
||||
_hash := None;
|
||||
ignore (hash ())
|
||||
|
||||
|
||||
|
126
ocaml/Message.ml
Normal file
126
ocaml/Message.ml
Normal file
@ -0,0 +1,126 @@
|
||||
open Core.Std
|
||||
open Qptypes
|
||||
|
||||
type t =
|
||||
| Property of Block.t
|
||||
| Walkers of Compute_node.t * Pid.t * (float array) array
|
||||
| Register of Compute_node.t * Pid.t
|
||||
| Unregister of Compute_node.t * Pid.t
|
||||
| Test
|
||||
| GetWalkers of Strictly_positive_int.t
|
||||
| Ezfio of string
|
||||
|
||||
|
||||
let create = function
|
||||
| [ "cpu" ; c ; pid ; b ; "1" ; v ] ->
|
||||
let open Block in
|
||||
Property
|
||||
{ property = Property.Cpu;
|
||||
value = Sample.of_float (Float.of_string v) ;
|
||||
weight = Weight.of_float 1.;
|
||||
compute_node = Compute_node.of_string c;
|
||||
pid = Pid.of_string pid;
|
||||
block_id = Block_id.of_int (Int.of_string b);
|
||||
}
|
||||
| [ "accep" ; c ; pid ; b ; "1" ; v ] ->
|
||||
let open Block in
|
||||
Property
|
||||
{ property = Property.Accep;
|
||||
value = Sample.of_float (Float.of_string v) ;
|
||||
weight = Weight.of_float 1.;
|
||||
compute_node = Compute_node.of_string c;
|
||||
pid = Pid.of_string pid;
|
||||
block_id = Block_id.of_int (Int.of_string b);
|
||||
}
|
||||
| [ prop ; c ; pid ; b ; w ; v ] ->
|
||||
let open Block in
|
||||
Property
|
||||
{ property = Property.of_string prop;
|
||||
value = Sample.of_float (Float.of_string v);
|
||||
weight = Weight.of_float (Float.of_string w);
|
||||
compute_node = Compute_node.of_string c;
|
||||
pid = Pid.of_string pid;
|
||||
block_id = Block_id.of_int (Int.of_string b);
|
||||
}
|
||||
| "elec_coord" :: c :: pid :: _ :: n ::walkers ->
|
||||
begin
|
||||
let walk_num =
|
||||
Lazy.force Qputils.walk_num
|
||||
and elec_num =
|
||||
Lazy.force Qputils.elec_num
|
||||
and n =
|
||||
Int.of_string n
|
||||
in
|
||||
assert (n = List.length walkers);
|
||||
assert (n = walk_num*(elec_num+1)*3);
|
||||
let rec build_walker accu = function
|
||||
| (0,tail) ->
|
||||
let result =
|
||||
List.rev accu
|
||||
|> List.map ~f:Float.of_string
|
||||
|> Array.of_list
|
||||
in
|
||||
(result, tail)
|
||||
| (n,head::tail) ->
|
||||
build_walker (head::accu) (n-1, tail)
|
||||
| _ -> failwith "Bad walkers"
|
||||
in
|
||||
let rec build accu = function
|
||||
| [] -> Array.of_list accu
|
||||
| w ->
|
||||
let (result, tail) =
|
||||
build_walker [] (3*elec_num+3, w)
|
||||
in
|
||||
build (result::accu) tail
|
||||
in
|
||||
Walkers (Compute_node.of_string c, Pid.of_string pid, build [] walkers)
|
||||
end
|
||||
| [ "get_walkers" ; n ] -> GetWalkers (n |> Int.of_string |> Strictly_positive_int.of_int)
|
||||
| [ "register" ; c ; pid ] -> Register (Compute_node.of_string c, Pid.of_string pid)
|
||||
| [ "unregister" ; c ; pid ] -> Unregister (Compute_node.of_string c, Pid.of_string pid)
|
||||
| [ "Test" ] -> Test
|
||||
| [ "Ezfio" ; ezfio_msg ] -> Ezfio ezfio_msg
|
||||
| prop :: c :: pid :: b :: d :: w :: l ->
|
||||
let property =
|
||||
Property.of_string prop
|
||||
in
|
||||
begin
|
||||
assert (not (Property.is_scalar property));
|
||||
let a =
|
||||
Array.of_list l
|
||||
|> Array.map ~f:Float.of_string
|
||||
and dim =
|
||||
Int.of_string d
|
||||
in
|
||||
assert (Array.length a = dim);
|
||||
let open Block in
|
||||
Property
|
||||
{ property = property ;
|
||||
value = Sample.of_float_array ~dim a;
|
||||
weight = Weight.of_float (Float.of_string w);
|
||||
compute_node = Compute_node.of_string c;
|
||||
pid = Pid.of_string pid;
|
||||
block_id = Block_id.of_int (Int.of_string b);
|
||||
}
|
||||
end
|
||||
| l ->
|
||||
begin
|
||||
List.iter ~f:(Printf.printf ":%s:") l;
|
||||
failwith "Message not understood"
|
||||
end
|
||||
|
||||
|
||||
let to_string = function
|
||||
| Property b -> "Property : "^(Block.to_string b)
|
||||
| Walkers (h,p,w) -> Printf.sprintf "Walkers : %s %s : %d walkers"
|
||||
(Compute_node.to_string h) (Pid.to_string p)
|
||||
(Array.length w)
|
||||
| GetWalkers n -> Printf.sprintf "GetWalkers %d" (Strictly_positive_int.to_int n)
|
||||
| Register (h,p) -> Printf.sprintf "Register : %s %s"
|
||||
(Compute_node.to_string h) (Pid.to_string p)
|
||||
| Unregister (h,p) -> Printf.sprintf "Unregister : %s %s"
|
||||
(Compute_node.to_string h) (Pid.to_string p)
|
||||
| Test -> "Test"
|
||||
| Ezfio msg -> "Ezfio "^msg
|
||||
|
||||
|
629
ocaml/Property.ml
Normal file
629
ocaml/Property.ml
Normal file
@ -0,0 +1,629 @@
|
||||
|
||||
(* File generated by ${QMCCHEM_PATH}/src/create_properties.py. Do not
|
||||
modify here
|
||||
*)
|
||||
|
||||
type t =
|
||||
| Cpu
|
||||
| Wall
|
||||
| Accep
|
||||
| D_var_jast_a_up_dn
|
||||
| D_var_jast_a_up_up
|
||||
| D_var_jast_b_up_dn
|
||||
| D_var_jast_b_up_up
|
||||
| D_var_jast_core_a1
|
||||
| D_var_jast_core_b1
|
||||
| D_var_jast_een_e_a
|
||||
| D_var_jast_een_e_b
|
||||
| D_var_jast_een_n
|
||||
| D_var_jast_pen
|
||||
| Density1d
|
||||
| Dipole
|
||||
| Drift_mod
|
||||
| E_kin
|
||||
| E_loc
|
||||
| E_loc_one
|
||||
| E_loc_per_electron
|
||||
| E_loc_split_core
|
||||
| E_loc_two
|
||||
| E_nucl
|
||||
| E_pot
|
||||
| E_pot_one
|
||||
| N_s_inverted
|
||||
| N_s_updated
|
||||
| N_s_updates
|
||||
| Voronoi_charges
|
||||
| Voronoi_charges_covariance
|
||||
| Voronoi_dipoles
|
||||
| Wf_extension
|
||||
| D_var_jast_a_up_dn_qmcvar
|
||||
| D_var_jast_a_up_up_qmcvar
|
||||
| D_var_jast_b_up_dn_qmcvar
|
||||
| D_var_jast_b_up_up_qmcvar
|
||||
| D_var_jast_core_a1_qmcvar
|
||||
| D_var_jast_core_b1_qmcvar
|
||||
| D_var_jast_een_e_a_qmcvar
|
||||
| D_var_jast_een_e_b_qmcvar
|
||||
| D_var_jast_een_n_qmcvar
|
||||
| D_var_jast_pen_qmcvar
|
||||
| Density1d_qmcvar
|
||||
| Dipole_qmcvar
|
||||
| Drift_mod_qmcvar
|
||||
| E_kin_qmcvar
|
||||
| E_loc_qmcvar
|
||||
| E_loc_one_qmcvar
|
||||
| E_loc_per_electron_qmcvar
|
||||
| E_loc_split_core_qmcvar
|
||||
| E_loc_two_qmcvar
|
||||
| E_nucl_qmcvar
|
||||
| E_pot_qmcvar
|
||||
| E_pot_one_qmcvar
|
||||
| N_s_inverted_qmcvar
|
||||
| N_s_updated_qmcvar
|
||||
| N_s_updates_qmcvar
|
||||
| Voronoi_charges_qmcvar
|
||||
| Voronoi_charges_covariance_qmcvar
|
||||
| Voronoi_dipoles_qmcvar
|
||||
| Wf_extension_qmcvar
|
||||
;;
|
||||
|
||||
let calc = function
|
||||
| Cpu
|
||||
| Wall
|
||||
| Accep -> true
|
||||
| D_var_jast_a_up_dn
|
||||
| D_var_jast_a_up_dn_qmcvar ->
|
||||
begin
|
||||
if (Ezfio.has_properties_d_var_jast_a_up_dn ()) then
|
||||
Ezfio.get_properties_d_var_jast_a_up_dn ()
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||