mirror of
https://github.com/LCPQ/quantum_package
synced 2024-11-03 20:54:00 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
3159ebe8b3
15
Makefile
15
Makefile
@ -28,13 +28,14 @@ EZFIO: bin/irpf90
|
||||
bin/irpf90:
|
||||
$(info $(BLUE)===== Fetching IRPF90 from the web ===== $(BLACK))
|
||||
@sleep 1
|
||||
@$(FETCH_FROM_WEB) "$(WWW_SERVER)/$(IRPF90_TGZ)" $(IRPF90_TGZ) || \
|
||||
(echo Unable to download IRPF90 : $(WWW_SERVER)/$(IRPF90_TGZ) ; exit 1)
|
||||
tar -zxf $(IRPF90_TGZ) && rm $(IRPF90_TGZ)
|
||||
$(MAKE) -C irpf90 | tee install_irpf90.log
|
||||
rm -rf -- $$PWD/bin/irpf90 $$PWD/bin/irpman
|
||||
ln -s $$PWD/irpf90/bin/irpf90 $$PWD/bin/irpf90
|
||||
ln -s $$PWD/irpf90/bin/irpman $$PWD/bin/irpman
|
||||
#@$(FETCH_FROM_WEB) "$(WWW_SERVER)/$(IRPF90_TGZ)" $(IRPF90_TGZ) || \
|
||||
# (echo Unable to download IRPF90 : $(WWW_SERVER)/$(IRPF90_TGZ) ; exit 1)
|
||||
#tar -zxf $(IRPF90_TGZ) && rm $(IRPF90_TGZ)
|
||||
#$(MAKE) -C irpf90 | tee install_irpf90.log
|
||||
#rm -rf -- $$PWD/bin/irpf90 $$PWD/bin/irpman
|
||||
echo $$PWD/irpf90/bin/irpf90 $$\@ > $$PWD/bin/irpf90
|
||||
echo $$PWD/irpf90/bin/irpman $$\@ > $$PWD/bin/irpman
|
||||
chmod +x $$PWD/bin/irpf90 $$PWD/bin/irpman
|
||||
|
||||
doc:
|
||||
$(MAKE) -C doc
|
||||
|
@ -18,7 +18,7 @@ cis_dressed
|
||||
determinants
|
||||
n_states 1
|
||||
n_states_diag determinants_n_states
|
||||
n_det_max_jacobi 5000
|
||||
n_det_max_jacobi 1000
|
||||
threshold_generators 0.99
|
||||
threshold_selectors 0.999
|
||||
read_wf False
|
||||
|
60
ocaml/Generic_input_of_rst.ml
Normal file
60
ocaml/Generic_input_of_rst.ml
Normal file
@ -0,0 +1,60 @@
|
||||
open Core.Std;;
|
||||
open Qptypes;;
|
||||
|
||||
|
||||
let fail_msg str (ex,range) =
|
||||
let msg = match ex with
|
||||
| Failure msg -> msg
|
||||
| _ -> raise ex
|
||||
in
|
||||
let range = match range with
|
||||
| Sexp.Annotated.Atom (range,_) -> range
|
||||
| Sexp.Annotated.List (range,_,_) -> range
|
||||
in
|
||||
let open Sexp.Annotated in
|
||||
let start_pos = range.start_pos.offset
|
||||
and end_pos = range.end_pos.offset
|
||||
in
|
||||
let pre = String.sub ~pos:0 ~len:start_pos str
|
||||
and mid = String.sub ~pos:start_pos ~len:(end_pos-start_pos) str
|
||||
and post = String.sub ~pos:(end_pos)
|
||||
~len:((String.length str)-(end_pos)) str
|
||||
in
|
||||
let str = Printf.sprintf "%s ## %s ## %s" pre mid post
|
||||
in
|
||||
let str = String.tr str ~target:'(' ~replacement:' '
|
||||
|> String.split ~on:')'
|
||||
|> List.map ~f:String.strip
|
||||
|> List.filter ~f:(fun x ->
|
||||
match String.substr_index x ~pos:0 ~pattern:"##" with
|
||||
| None -> false
|
||||
| Some _ -> true
|
||||
)
|
||||
|> String.concat ~sep:"\n"
|
||||
in
|
||||
Printf.eprintf "Error: (%s)\n\n %s\n\n" msg str;
|
||||
;;
|
||||
|
||||
|
||||
let evaluate_sexp t_of_sexp s =
|
||||
let sexp = ("("^s^")") in
|
||||
match ( Sexp.of_string_conv sexp t_of_sexp ) with
|
||||
| `Result r -> Some r
|
||||
| `Error ex -> ( fail_msg sexp ex; None)
|
||||
;;
|
||||
|
||||
let of_rst t_of_sexp s =
|
||||
Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
|> evaluate_sexp t_of_sexp
|
||||
;;
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ open Core.Std;;
|
||||
|
||||
module Ao_basis : sig
|
||||
type t =
|
||||
{ ao_basis : string ;
|
||||
{ ao_basis : AO_basis_name.t;
|
||||
ao_num : AO_number.t ;
|
||||
ao_prim_num : AO_prim_number.t array;
|
||||
ao_prim_num_max : AO_prim_number.t;
|
||||
@ -14,13 +14,13 @@ module Ao_basis : sig
|
||||
ao_expo : AO_expo.t array;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val to_string : t -> string
|
||||
val to_md5 : t -> MD5.t
|
||||
val to_rst : t -> Rst_string.t
|
||||
end = struct
|
||||
type t =
|
||||
{ ao_basis : string ;
|
||||
{ ao_basis : AO_basis_name.t;
|
||||
ao_num : AO_number.t ;
|
||||
ao_prim_num : AO_prim_number.t array;
|
||||
ao_prim_num_max : AO_prim_number.t;
|
||||
@ -34,10 +34,8 @@ end = struct
|
||||
let get_default = Qpackage.get_ezfio_default "ao_basis";;
|
||||
|
||||
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 ()
|
||||
|> AO_basis_name.of_string
|
||||
;;
|
||||
|
||||
let read_ao_num () =
|
||||
@ -95,15 +93,19 @@ end = struct
|
||||
;;
|
||||
|
||||
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 () ;
|
||||
}
|
||||
if (Ezfio.has_ao_basis_ao_basis ()) then
|
||||
Some
|
||||
{ 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 () ;
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
let to_long_basis b =
|
||||
@ -171,7 +173,7 @@ Basis set ::
|
||||
%s
|
||||
======= ========= ===========
|
||||
|
||||
" b.ao_basis
|
||||
" (AO_basis_name.to_string b.ao_basis)
|
||||
(Basis.to_string short_basis
|
||||
|> String.split ~on:'\n'
|
||||
|> List.map ~f:(fun x-> " "^x)
|
||||
@ -213,7 +215,7 @@ ao_coef = %s
|
||||
ao_expo = %s
|
||||
md5 = %s
|
||||
"
|
||||
b.ao_basis
|
||||
(AO_basis_name.to_string b.ao_basis)
|
||||
(AO_number.to_string b.ao_num)
|
||||
(b.ao_prim_num |> Array.to_list |> List.map
|
||||
~f:(AO_prim_number.to_string) |> String.concat ~sep:", " )
|
||||
|
@ -13,11 +13,11 @@ module Bielec_integrals : sig
|
||||
direct : bool;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ read_ao_integrals : bool;
|
||||
@ -150,7 +150,7 @@ end = struct
|
||||
if (result.read_mo_integrals &&
|
||||
result.write_mo_integrals) then
|
||||
failwith "Read and Write MO integrals are both true.";
|
||||
result
|
||||
Some result
|
||||
;;
|
||||
|
||||
let write b =
|
||||
@ -220,20 +220,8 @@ Direct calculation of integrals ::
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ module Bitmasks : sig
|
||||
generators : int64 array;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val to_string : t -> string
|
||||
end = struct
|
||||
type t =
|
||||
@ -77,11 +77,15 @@ end = struct
|
||||
;;
|
||||
|
||||
let read () =
|
||||
{ n_int = read_n_int ();
|
||||
bit_kind = read_bit_kind ();
|
||||
n_mask_gen = read_n_mask_gen ();
|
||||
generators = read_generators ();
|
||||
}
|
||||
if (Ezfio.has_mo_basis_mo_tot_num ()) then
|
||||
Some
|
||||
{ n_int = read_n_int ();
|
||||
bit_kind = read_bit_kind ();
|
||||
n_mask_gen = read_n_mask_gen ();
|
||||
generators = read_generators ();
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
let to_string b =
|
||||
|
@ -12,9 +12,10 @@ module Cis_dressed : sig
|
||||
en_2_2 : bool;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ n_state_cis : States_number.t;
|
||||
@ -85,6 +86,7 @@ end = struct
|
||||
;;
|
||||
|
||||
let read () =
|
||||
Some
|
||||
{ n_state_cis = read_n_state_cis ();
|
||||
n_core_cis = read_n_core_cis ();
|
||||
n_act_cis = read_n_act_cis ();
|
||||
@ -145,6 +147,10 @@ Epstein-Nesbet 2x2 diagonalization ::
|
||||
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -9,11 +9,11 @@ module Cisd_sc2 : sig
|
||||
do_pt2_end : bool;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ n_det_max_cisd_sc2 : Det_number_max.t;
|
||||
@ -71,6 +71,7 @@ end = struct
|
||||
|
||||
|
||||
let read () =
|
||||
Some
|
||||
{ n_det_max_cisd_sc2 = read_n_det_max_cisd_sc2 ();
|
||||
pt2_max = read_pt2_max ();
|
||||
do_pt2_end = read_do_pt2_end ();
|
||||
@ -118,22 +119,8 @@ Compute E(PT2) at the end ::
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
|
||||
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
end
|
||||
|
||||
|
@ -19,11 +19,11 @@ module Determinants : sig
|
||||
psi_coef : Det_coef.t array;
|
||||
psi_det : Determinant.t array;
|
||||
} with sexp
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ n_int : N_int_number.t;
|
||||
@ -131,9 +131,11 @@ end = struct
|
||||
|> States_number.of_int
|
||||
;;
|
||||
|
||||
let write_n_states_diag n =
|
||||
States_number.to_int n
|
||||
|> Ezfio.set_determinants_n_states_diag
|
||||
let write_n_states_diag ~n_states n =
|
||||
let n_states = States_number.to_int n_states
|
||||
and n = States_number.to_int n
|
||||
in
|
||||
Ezfio.set_determinants_n_states_diag (max n_states n)
|
||||
;;
|
||||
|
||||
|
||||
@ -232,20 +234,27 @@ end = struct
|
||||
|
||||
let read_psi_coef () =
|
||||
if not (Ezfio.has_determinants_psi_coef ()) then
|
||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| 1 |] ~data:[1.]
|
||||
|> Ezfio.set_determinants_psi_coef
|
||||
;
|
||||
begin
|
||||
let n_states =
|
||||
read_n_states ()
|
||||
|> States_number.to_int
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| 1 ; n_states |]
|
||||
~data:(List.init n_states ~f:(fun i -> if (i=0) then 1. else 0. ))
|
||||
|> Ezfio.set_determinants_psi_coef
|
||||
end;
|
||||
Ezfio.get_determinants_psi_coef ()
|
||||
|> Ezfio.flattened_ezfio
|
||||
|> Array.map ~f:Det_coef.of_float
|
||||
;;
|
||||
|
||||
let write_psi_coef ~n_det c =
|
||||
let write_psi_coef ~n_det ~n_states c =
|
||||
let n_det = Det_number.to_int n_det
|
||||
and c = Array.to_list c
|
||||
|> List.map ~f:Det_coef.to_float
|
||||
and n_states = States_number.to_int n_states
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| n_det |] ~data:c
|
||||
Ezfio.ezfio_array_of_list ~rank:2 ~dim:[| n_det ; n_states |] ~data:c
|
||||
|> Ezfio.set_determinants_psi_coef
|
||||
;;
|
||||
|
||||
@ -302,21 +311,25 @@ end = struct
|
||||
|
||||
|
||||
let read () =
|
||||
{ n_int = read_n_int () ;
|
||||
bit_kind = read_bit_kind () ;
|
||||
mo_label = read_mo_label () ;
|
||||
n_det = read_n_det () ;
|
||||
n_states = read_n_states () ;
|
||||
n_states_diag = read_n_states_diag () ;
|
||||
n_det_max_jacobi = read_n_det_max_jacobi () ;
|
||||
threshold_generators = read_threshold_generators () ;
|
||||
threshold_selectors = read_threshold_selectors () ;
|
||||
read_wf = read_read_wf () ;
|
||||
expected_s2 = read_expected_s2 () ;
|
||||
s2_eig = read_s2_eig () ;
|
||||
psi_coef = read_psi_coef () ;
|
||||
psi_det = read_psi_det () ;
|
||||
}
|
||||
if (Ezfio.has_mo_basis_mo_tot_num ()) then
|
||||
Some
|
||||
{ n_int = read_n_int () ;
|
||||
bit_kind = read_bit_kind () ;
|
||||
mo_label = read_mo_label () ;
|
||||
n_det = read_n_det () ;
|
||||
n_states = read_n_states () ;
|
||||
n_states_diag = read_n_states_diag () ;
|
||||
n_det_max_jacobi = read_n_det_max_jacobi () ;
|
||||
threshold_generators = read_threshold_generators () ;
|
||||
threshold_selectors = read_threshold_selectors () ;
|
||||
read_wf = read_read_wf () ;
|
||||
expected_s2 = read_expected_s2 () ;
|
||||
s2_eig = read_s2_eig () ;
|
||||
psi_coef = read_psi_coef () ;
|
||||
psi_det = read_psi_det () ;
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
let write { n_int ;
|
||||
@ -339,14 +352,14 @@ end = struct
|
||||
write_mo_label mo_label;
|
||||
write_n_det n_det;
|
||||
write_n_states n_states;
|
||||
write_n_states_diag n_states_diag;
|
||||
write_n_states_diag ~n_states:n_states n_states_diag;
|
||||
write_n_det_max_jacobi n_det_max_jacobi;
|
||||
write_threshold_generators threshold_generators;
|
||||
write_threshold_selectors threshold_selectors;
|
||||
write_read_wf read_wf;
|
||||
write_expected_s2 expected_s2;
|
||||
write_s2_eig s2_eig;
|
||||
write_psi_coef ~n_det:n_det psi_coef;
|
||||
write_psi_coef ~n_det:n_det psi_coef ~n_states:n_states;
|
||||
write_psi_det ~n_int:n_int ~n_det:n_det psi_det;
|
||||
;;
|
||||
|
||||
@ -538,8 +551,8 @@ psi_det = %s
|
||||
and n_int = Printf.sprintf "(n_int %d)" (N_int_number.get_max ()) in
|
||||
let s = String.concat [ header ; bitkind ; n_int ; psi_coef ; psi_det]
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
|
||||
Generic_input_of_rst.evaluate_sexp t_of_sexp s
|
||||
;;
|
||||
|
||||
end
|
||||
|
@ -8,12 +8,12 @@ module Electrons : sig
|
||||
elec_beta_num : Elec_beta_number.t;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val read_elec_num : unit -> Elec_number.t
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ elec_alpha_num : Elec_alpha_number.t;
|
||||
@ -53,9 +53,13 @@ end = struct
|
||||
|
||||
|
||||
let read () =
|
||||
{ elec_alpha_num = read_elec_alpha_num ();
|
||||
elec_beta_num = read_elec_beta_num ();
|
||||
}
|
||||
if (Ezfio.has_electrons_elec_alpha_num ()) then
|
||||
Some
|
||||
{ elec_alpha_num = read_elec_alpha_num ();
|
||||
elec_beta_num = read_elec_beta_num ();
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
let write { elec_alpha_num ; elec_beta_num } =
|
||||
@ -91,20 +95,8 @@ elec_num = %s
|
||||
(Elec_number.to_string (read_elec_num ()))
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
end
|
||||
|
||||
|
@ -9,11 +9,11 @@ module Full_ci : sig
|
||||
do_pt2_end : bool;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t-> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ n_det_max_fci : Det_number_max.t;
|
||||
@ -69,9 +69,10 @@ end = struct
|
||||
|
||||
|
||||
let read () =
|
||||
{ n_det_max_fci = read_n_det_max_fci ();
|
||||
pt2_max = read_pt2_max ();
|
||||
do_pt2_end = read_do_pt2_end ();
|
||||
Some
|
||||
{ n_det_max_fci = read_n_det_max_fci ();
|
||||
pt2_max = read_pt2_max ();
|
||||
do_pt2_end = read_do_pt2_end ();
|
||||
}
|
||||
;;
|
||||
|
||||
@ -117,20 +118,8 @@ Compute E(PT2) at the end ::
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
|
||||
end
|
||||
|
@ -8,11 +8,11 @@ module Hartree_fock : sig
|
||||
thresh_scf : Threshold.t;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ n_it_scf_max : Strictly_positive_int.t;
|
||||
@ -54,6 +54,7 @@ end = struct
|
||||
|
||||
|
||||
let read () =
|
||||
Some
|
||||
{ n_it_scf_max = read_n_it_scf_max ();
|
||||
thresh_scf = read_thresh_scf ();
|
||||
}
|
||||
@ -93,21 +94,8 @@ SCF convergence criterion (on energy) ::
|
||||
|> Rst_string.of_string
|
||||
;;
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ module Mo_basis : sig
|
||||
mo_coef : (MO_coef.t array) array;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
end = struct
|
||||
@ -68,11 +68,15 @@ end = struct
|
||||
;;
|
||||
|
||||
let read () =
|
||||
{ mo_tot_num = read_mo_tot_num ();
|
||||
mo_label = read_mo_label () ;
|
||||
mo_occ = read_mo_occ ();
|
||||
mo_coef = read_mo_coef ();
|
||||
}
|
||||
if (Ezfio.has_mo_basis_mo_tot_num ()) then
|
||||
Some
|
||||
{ mo_tot_num = read_mo_tot_num ();
|
||||
mo_label = read_mo_label () ;
|
||||
mo_occ = read_mo_occ ();
|
||||
mo_coef = read_mo_coef ();
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
let mo_coef_to_string mo_coef =
|
||||
|
@ -10,11 +10,11 @@ module Nuclei : sig
|
||||
nucl_coord : Point3d.t array;
|
||||
} with sexp
|
||||
;;
|
||||
val read : unit -> t
|
||||
val read : unit -> t option
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ nucl_num : Nucl_number.t ;
|
||||
@ -111,11 +111,15 @@ end = struct
|
||||
|
||||
|
||||
let read () =
|
||||
{ nucl_num = read_nucl_num ();
|
||||
nucl_label = read_nucl_label () ;
|
||||
nucl_charge = read_nucl_charge ();
|
||||
nucl_coord = read_nucl_coord ();
|
||||
}
|
||||
if (Ezfio.has_nuclei_nucl_num ()) then
|
||||
Some
|
||||
{ nucl_num = read_nucl_num ();
|
||||
nucl_label = read_nucl_label () ;
|
||||
nucl_charge = read_nucl_charge ();
|
||||
nucl_coord = read_nucl_coord ();
|
||||
}
|
||||
else
|
||||
None
|
||||
;;
|
||||
|
||||
let write { nucl_num ;
|
||||
@ -203,15 +207,17 @@ Nuclear coordinates in xyz format (Angstroms) ::
|
||||
| _ -> failwith "Error in xyz format"
|
||||
in
|
||||
(* Create the Nuclei.t data structure *)
|
||||
{ nucl_num = List.length atom_list
|
||||
|> Nucl_number.of_int ~max:nmax;
|
||||
nucl_label = List.map atom_list ~f:(fun x ->
|
||||
x.Atom.element) |> Array.of_list ;
|
||||
nucl_charge = List.map atom_list ~f:(fun x ->
|
||||
x.Atom.charge ) |> Array.of_list ;
|
||||
nucl_coord = List.map atom_list ~f:(fun x ->
|
||||
x.Atom.coord ) |> Array.of_list ;
|
||||
}
|
||||
let result =
|
||||
{ nucl_num = List.length atom_list
|
||||
|> Nucl_number.of_int ~max:nmax;
|
||||
nucl_label = List.map atom_list ~f:(fun x ->
|
||||
x.Atom.element) |> Array.of_list ;
|
||||
nucl_charge = List.map atom_list ~f:(fun x ->
|
||||
x.Atom.charge ) |> Array.of_list ;
|
||||
nucl_coord = List.map atom_list ~f:(fun x ->
|
||||
x.Atom.coord ) |> Array.of_list ;
|
||||
}
|
||||
in Some result
|
||||
;;
|
||||
|
||||
end
|
||||
|
@ -10,8 +10,8 @@ endif
|
||||
|
||||
LIBS=
|
||||
PKGS=
|
||||
OCAMLCFLAGS="-g"
|
||||
OCAMLBUILD=ocamlbuild -j 0 -syntax camlp4o -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS)
|
||||
OCAMLCFLAGS="-g -warn-error A"
|
||||
OCAMLBUILD=ocamlbuild -j 0 -syntax camlp4o -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) -ocamlopt ocamlc.opt
|
||||
MLFILES=$(wildcard *.ml) ezfio.ml Qptypes.ml
|
||||
MLIFILES=$(wildcard *.mli)
|
||||
ALL_TESTS=$(patsubst %.ml,%.byte,$(wildcard test_*.ml))
|
||||
|
@ -8,5 +8,6 @@ with the user.
|
||||
All executables start with `qp_` and all tests start with `test_`. Modules
|
||||
file names start with a capital letter.
|
||||
|
||||
Info on how to extend the `qp_edit` tool is given in `README_qp_edit.rst`.
|
||||
Info on how to extend the `qp_edit` tool is given in
|
||||
`README_qp_edit.rst <https://github.com/LCPQ/quantum_package/blob/master/ocaml/README_qp_edit.rst>`_.
|
||||
|
||||
|
@ -23,9 +23,8 @@ of the block.
|
||||
;;
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_string : t -> string
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
end = struct
|
||||
type t =
|
||||
{ r_x : Type_of_x.t
|
||||
@ -42,12 +41,14 @@ of the block.
|
||||
|
||||
end
|
||||
|
||||
The following functions need to be defined::
|
||||
The following functions need to be defined
|
||||
|
||||
.. code-block:: ocaml
|
||||
|
||||
val read : unit -> t
|
||||
val write : t -> unit
|
||||
val to_rst : t -> Rst_string.t
|
||||
val of_rst : Rst_string.t -> t
|
||||
val of_rst : Rst_string.t -> t option
|
||||
|
||||
|
||||
The type `t` has to be defined in a same way in the `sig` and the `struct`.
|
||||
@ -135,26 +136,12 @@ Finally, create the functions to write an RST string as
|
||||
;;
|
||||
|
||||
|
||||
and you can use this function to read it back:
|
||||
and you can use the generic `of_rst` function to read it back:
|
||||
|
||||
.. code-block:: ocaml
|
||||
|
||||
let of_rst s =
|
||||
let s = Rst_string.to_string s
|
||||
|> String.split ~on:'\n'
|
||||
|> List.filter ~f:(fun line ->
|
||||
String.contains line '=')
|
||||
|> List.map ~f:(fun line ->
|
||||
"("^(
|
||||
String.tr line ~target:'=' ~replacement:' '
|
||||
)^")" )
|
||||
|> String.concat
|
||||
in
|
||||
Sexp.of_string ("("^s^")")
|
||||
|> t_of_sexp
|
||||
;;
|
||||
|
||||
|
||||
include Generic_input_of_rst;;
|
||||
let of_rst = of_rst t_of_sexp;;
|
||||
|
||||
|
||||
|
||||
@ -201,10 +188,11 @@ vim search strings are given in brackets.
|
||||
|
||||
let get s =
|
||||
let header = (make_header s)
|
||||
and rst = match s with
|
||||
and rst = let open Input in
|
||||
match s with
|
||||
...
|
||||
| New_keyword ->
|
||||
Input.New_keyword.(to_rst (read ()))
|
||||
New_keyword.(to_rst (read ()))
|
||||
...
|
||||
|
||||
|
||||
@ -212,9 +200,10 @@ vim search strings are given in brackets.
|
||||
|
||||
.. code-block:: ocaml
|
||||
|
||||
match s with
|
||||
...
|
||||
| New_keyword ->
|
||||
Input.New_keyword.(write (of_rst str))
|
||||
let open Input in
|
||||
match s with
|
||||
...
|
||||
| New_keyword -> write New_keyword.(of_rst, write)
|
||||
...
|
||||
;;
|
||||
|
||||
|
@ -6,29 +6,85 @@ let spec =
|
||||
let open Command.Spec in
|
||||
empty
|
||||
+> flag "o" (optional string)
|
||||
~doc:"file Name of the created EZFIO file"
|
||||
~doc:"file Name of the created EZFIO file."
|
||||
+> flag "b" (required string)
|
||||
~doc:"name Basis set."
|
||||
~doc:"definition of basis set."
|
||||
+> flag "c" (optional_with_default 0 int)
|
||||
~doc:"int Total charge of the molecule. Default is 0."
|
||||
+> flag "m" (optional_with_default 1 int)
|
||||
~doc:"int Spin multiplicity (2S+1) of the molecule. Default is 1"
|
||||
~doc:"int Spin multiplicity (2S+1) of the molecule. Default is 1."
|
||||
+> anon ("xyz_file" %: string)
|
||||
;;
|
||||
|
||||
let run ?o b c m xyz_file =
|
||||
|
||||
(* Open basis set channel *)
|
||||
let basis_channel =
|
||||
In_channel.create
|
||||
(Qpackage.root ^ "/data/basis/" ^ (String.lowercase b))
|
||||
in
|
||||
|
||||
(* Read molecule *)
|
||||
let molecule =
|
||||
(Molecule.of_xyz_file xyz_file ~charge:(Charge.of_int c)
|
||||
~multiplicity:(Multiplicity.of_int m) )
|
||||
in
|
||||
let nuclei = molecule.Molecule.nuclei in
|
||||
|
||||
let basis_table = Hashtbl.Poly.create () in
|
||||
(* Open basis set channels *)
|
||||
let basis_channel element =
|
||||
let key = Element.to_string element in
|
||||
match Hashtbl.find basis_table key with
|
||||
| Some in_channel ->
|
||||
in_channel
|
||||
| None ->
|
||||
begin
|
||||
Printf.printf "%s is not defined in basis %s.\nEnter alternate basis : %!"
|
||||
(Element.to_long_string element) b ;
|
||||
let bas =
|
||||
match In_channel.input_line stdin with
|
||||
| Some line -> String.strip line |> String.lowercase
|
||||
| None -> failwith "Aborted"
|
||||
in
|
||||
let new_channel = In_channel.create
|
||||
(Qpackage.root ^ "/data/basis/" ^ bas)
|
||||
in
|
||||
Hashtbl.add_exn basis_table ~key:key ~data:new_channel;
|
||||
new_channel
|
||||
end
|
||||
in
|
||||
|
||||
let rec build_basis = function
|
||||
| [] -> ()
|
||||
| elem_and_basis_name :: rest ->
|
||||
begin
|
||||
match (String.lsplit2 ~on:':' elem_and_basis_name) with
|
||||
| None -> (* Principal basis *)
|
||||
begin
|
||||
let new_channel = In_channel.create
|
||||
(Qpackage.root ^ "/data/basis/" ^ elem_and_basis_name)
|
||||
in
|
||||
List.iter nuclei ~f:(fun x->
|
||||
let key = Element.to_string x.Atom.element
|
||||
in
|
||||
match Hashtbl.add basis_table ~key:key ~data:new_channel with
|
||||
| `Ok -> ()
|
||||
| `Duplicate -> ()
|
||||
)
|
||||
end
|
||||
| Some (key, basis) -> (*Aux basis *)
|
||||
begin
|
||||
let elem = Element.of_string key
|
||||
and basis = String.lowercase basis
|
||||
in
|
||||
let new_channel = In_channel.create
|
||||
(Qpackage.root ^ "/data/basis/" ^ basis)
|
||||
in
|
||||
match Hashtbl.add basis_table ~key:key ~data:new_channel with
|
||||
| `Ok -> ()
|
||||
| `Duplicate -> failwith ("Duplicate definition of basis for "^(Element.to_long_string elem))
|
||||
end
|
||||
end;
|
||||
build_basis rest
|
||||
in
|
||||
String.split ~on:' ' b
|
||||
|> List.rev_map ~f:String.strip
|
||||
|> build_basis;
|
||||
|
||||
(* Build EZFIO File name *)
|
||||
let ezfio_file =
|
||||
@ -54,7 +110,6 @@ let run ?o b c m xyz_file =
|
||||
molecule.Molecule.elec_beta ) ;
|
||||
|
||||
(* Write Nuclei *)
|
||||
let nuclei = molecule.Molecule.nuclei in
|
||||
let labels =
|
||||
List.map ~f:(fun x->Element.to_string x.Atom.element) nuclei
|
||||
and charges =
|
||||
@ -74,17 +129,31 @@ let run ?o b c m xyz_file =
|
||||
|
||||
(* Write Basis set *)
|
||||
let basis =
|
||||
|
||||
let nmax = Nucl_number.get_max () in
|
||||
let rec do_work (accu:(Atom.t*Nucl_number.t) list) (n:int) = function
|
||||
| [] -> accu
|
||||
| e::tail -> let new_accu = (e,(Nucl_number.of_int ~max:nmax n))::accu in
|
||||
| e::tail ->
|
||||
let new_accu = (e,(Nucl_number.of_int ~max:nmax n))::accu in
|
||||
do_work new_accu (n+1) tail
|
||||
in
|
||||
do_work [] 1 nuclei
|
||||
let result = do_work [] 1 nuclei
|
||||
|> List.rev
|
||||
|> List.map ~f:(fun (x,i) ->
|
||||
Basis.read_element basis_channel i x.Atom.element)
|
||||
try
|
||||
Basis.read_element (basis_channel x.Atom.element) i x.Atom.element
|
||||
with
|
||||
| End_of_file ->
|
||||
begin
|
||||
let alt_channel = basis_channel x.Atom.element in
|
||||
Basis.read_element alt_channel i x.Atom.element
|
||||
end
|
||||
| _ -> assert false
|
||||
)
|
||||
|> List.concat
|
||||
in
|
||||
(* close all in_channels *)
|
||||
result
|
||||
in
|
||||
let long_basis = Long_basis.of_basis basis in
|
||||
let ao_num = List.length long_basis in
|
||||
@ -150,8 +219,14 @@ let run ?o b c m xyz_file =
|
||||
let command =
|
||||
Command.basic
|
||||
~summary: "Quantum Package command"
|
||||
~readme:(fun () ->
|
||||
"Creates an EZFIO directory from a standard xyz file
|
||||
~readme:(fun () -> "
|
||||
Creates an EZFIO directory from a standard xyz file.
|
||||
The basis set is defined as a single string if all the
|
||||
atoms are taken from the same basis set, otherwise specific
|
||||
elements can be defined as follows:
|
||||
|
||||
-b \"cc-pcvdz H:cc-pvdz C:6-31g\"
|
||||
|
||||
")
|
||||
spec
|
||||
(fun o b c m xyz_file () ->
|
||||
|
140
ocaml/qp_edit.ml
140
ocaml/qp_edit.ml
@ -43,77 +43,93 @@ let make_header kw =
|
||||
;;
|
||||
|
||||
let get s =
|
||||
let header = (make_header s)
|
||||
and rst = match s with
|
||||
| Full_ci ->
|
||||
Input.Full_ci.(to_rst (read ()))
|
||||
| Hartree_fock ->
|
||||
Input.Hartree_fock.(to_rst (read ()))
|
||||
| Mo_basis ->
|
||||
Input.Mo_basis.(to_rst (read ()))
|
||||
| Electrons ->
|
||||
Input.Electrons.(to_rst (read ()))
|
||||
| Determinants ->
|
||||
Input.Determinants.(to_rst (read ()))
|
||||
| Cisd_sc2 ->
|
||||
Input.Cisd_sc2.(to_rst (read ()))
|
||||
| Nuclei ->
|
||||
Input.Nuclei.(to_rst (read ()))
|
||||
| Ao_basis ->
|
||||
Input.Ao_basis.(to_rst (read ()))
|
||||
| Bielec_integrals ->
|
||||
Input.Bielec_integrals.(to_rst (read ()))
|
||||
|
||||
in header^(Rst_string.to_string rst)
|
||||
let header = (make_header s) in
|
||||
let f (read,to_rst) =
|
||||
match read () with
|
||||
| Some text -> header ^ (Rst_string.to_string (to_rst text))
|
||||
| None -> ""
|
||||
in
|
||||
let rst =
|
||||
try
|
||||
begin
|
||||
let open Input in
|
||||
match s with
|
||||
| Full_ci ->
|
||||
f Full_ci.(read, to_rst)
|
||||
| Hartree_fock ->
|
||||
f Hartree_fock.(read, to_rst)
|
||||
| Mo_basis ->
|
||||
f Mo_basis.(read, to_rst)
|
||||
| Electrons ->
|
||||
f Electrons.(read, to_rst)
|
||||
| Cisd_sc2 ->
|
||||
f Cisd_sc2.(read, to_rst)
|
||||
| Nuclei ->
|
||||
f Nuclei.(read, to_rst)
|
||||
| Ao_basis ->
|
||||
f Ao_basis.(read, to_rst)
|
||||
| Bielec_integrals ->
|
||||
f Bielec_integrals.(read, to_rst)
|
||||
| Determinants ->
|
||||
f Determinants.(read, to_rst)
|
||||
end
|
||||
with
|
||||
| Sys_error msg -> (Printf.eprintf "Info: %s\n%!" msg ; "")
|
||||
in
|
||||
rst
|
||||
;;
|
||||
|
||||
let set str s =
|
||||
let header = (make_header s) in
|
||||
let index_begin = String.substr_index_exn ~pos:0 ~pattern:header str in
|
||||
let index_begin = index_begin + (String.length header) in
|
||||
let index_end =
|
||||
match ( String.substr_index ~pos:(index_begin+(String.length header)+1)
|
||||
~pattern:"==" str) with
|
||||
| Some i -> i
|
||||
| None -> String.length str
|
||||
in
|
||||
let l = index_end - index_begin in
|
||||
let str = String.sub ~pos:index_begin ~len:l str
|
||||
|> Rst_string.of_string
|
||||
in
|
||||
match s with
|
||||
(*
|
||||
| Mo_basis ->
|
||||
*)
|
||||
| Hartree_fock ->
|
||||
Input.Hartree_fock.(write (of_rst str ))
|
||||
| Full_ci ->
|
||||
Input.Full_ci.(write (of_rst str))
|
||||
| Electrons ->
|
||||
Input.Electrons.(write (of_rst str))
|
||||
| Determinants ->
|
||||
Input.Determinants.(write (of_rst str))
|
||||
| Cisd_sc2 ->
|
||||
Input.Cisd_sc2.(write (of_rst str))
|
||||
| Nuclei ->
|
||||
Input.Nuclei.(write (of_rst str))
|
||||
| Bielec_integrals ->
|
||||
Input.Bielec_integrals.(write (of_rst str))
|
||||
(*
|
||||
| Ao_basis ->
|
||||
*)
|
||||
|
||||
match String.substr_index ~pos:0 ~pattern:header str with
|
||||
| None -> ()
|
||||
| Some idx ->
|
||||
begin
|
||||
let index_begin = idx + (String.length header) in
|
||||
let index_end =
|
||||
match ( String.substr_index ~pos:(index_begin+(String.length header)+1)
|
||||
~pattern:"==" str) with
|
||||
| Some i -> i
|
||||
| None -> String.length str
|
||||
in
|
||||
let l = index_end - index_begin in
|
||||
let str = String.sub ~pos:index_begin ~len:l str
|
||||
|> Rst_string.of_string
|
||||
in
|
||||
let write (of_rst,w) s =
|
||||
try
|
||||
match of_rst str with
|
||||
| Some data -> w data
|
||||
| None -> ()
|
||||
with
|
||||
| _ -> (Printf.eprintf "Info: Read error in %s\n%!"
|
||||
(keyword_to_string s))
|
||||
in
|
||||
let open Input in
|
||||
match s with
|
||||
| Hartree_fock -> write Hartree_fock.(of_rst, write) s
|
||||
| Full_ci -> write Full_ci.(of_rst, write) s
|
||||
| Electrons -> write Electrons.(of_rst, write) s
|
||||
| Cisd_sc2 -> write Cisd_sc2.(of_rst, write) s
|
||||
| Bielec_integrals -> write Bielec_integrals.(of_rst, write) s
|
||||
| Determinants -> write Determinants.(of_rst, write) s
|
||||
| Nuclei -> write Nuclei.(of_rst, write) s
|
||||
| Ao_basis -> () (* TODO *)
|
||||
| Mo_basis -> () (* TODO *)
|
||||
end
|
||||
;;
|
||||
|
||||
|
||||
let create_temp_file ezfio_filename fields =
|
||||
let temp_filename = Filename.temp_file "qp_edit_" ".rst" in
|
||||
Out_channel.with_file temp_filename ~f:(fun out_channel ->
|
||||
(file_header ezfio_filename) :: (List.map ~f:get fields)
|
||||
|> String.concat ~sep:"\n"
|
||||
|> Out_channel.output_string out_channel
|
||||
);
|
||||
temp_filename
|
||||
begin
|
||||
Out_channel.with_file temp_filename ~f:(fun out_channel ->
|
||||
(file_header ezfio_filename) :: (List.map ~f:get fields)
|
||||
|> String.concat ~sep:"\n"
|
||||
|> Out_channel.output_string out_channel
|
||||
)
|
||||
end
|
||||
; temp_filename
|
||||
;;
|
||||
|
||||
let run ezfio_filename =
|
||||
|
@ -51,7 +51,10 @@ let run_i ~action ezfio_filename =
|
||||
|
||||
|
||||
let compute_charge () =
|
||||
let input = Input.Electrons.read () in
|
||||
let input = match Input.Electrons.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
let nucl_charge = Ezfio.get_nuclei_nucl_charge ()
|
||||
|> Ezfio.flattened_ezfio |> Array.map ~f:(Float.to_int)
|
||||
and n_alpha = input.Input.Electrons.elec_alpha_num
|
||||
@ -63,7 +66,10 @@ let run_i ~action ezfio_filename =
|
||||
in
|
||||
|
||||
let compute_multiplicity () =
|
||||
let input = Input.Electrons.read () in
|
||||
let input = match Input.Electrons.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
let n_alpha = input.Input.Electrons.elec_alpha_num
|
||||
and n_beta = input.Input.Electrons.elec_beta_num
|
||||
in Multiplicity.of_alpha_beta n_alpha n_beta
|
||||
|
@ -100,6 +100,9 @@ let input_data = "
|
||||
|
||||
* Rst_string : string
|
||||
|
||||
* AO_basis_name : string
|
||||
assert (x <> \"\") ;
|
||||
|
||||
"
|
||||
;;
|
||||
|
||||
@ -228,9 +231,9 @@ let parse_input_ezfio input=
|
||||
and (min, max) = String.lsplit2_exn ~on:':' c
|
||||
and msg = d
|
||||
in
|
||||
let name :: typ :: ezfio_func :: min :: max :: msg :: [] =
|
||||
match (name :: typ :: ezfio_func :: min :: max :: msg :: []) with
|
||||
| l -> List.map ~f:String.strip l
|
||||
let (name, typ, ezfio_func, min, max, msg) =
|
||||
match (List.map [ name ; typ ; ezfio_func ; min ; max ; msg ] ~f:String.strip) with
|
||||
| [ name ; typ ; ezfio_func ; min ; max ; msg ] -> (name, typ, ezfio_func, min, max, msg)
|
||||
| _ -> assert false
|
||||
in
|
||||
Printf.sprintf ezfio_template
|
||||
|
@ -9,12 +9,12 @@ let test_module () =
|
||||
In_channel.create (Qpackage.root^"/data/basis/"^(String.lowercase b))
|
||||
in
|
||||
|
||||
(*
|
||||
let molecule =
|
||||
let xyz_file = "F2.xyz" in
|
||||
Molecule.of_xyz_file xyz_file
|
||||
in
|
||||
|
||||
let nuclei = molecule.Molecule.nuclei in
|
||||
*)
|
||||
|
||||
let basis =
|
||||
(Basis.read_element basis_channel (Nucl_number.of_int 1) Element.F) @
|
||||
|
@ -2,7 +2,9 @@ open Qptypes;;
|
||||
|
||||
let test_ao () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Ao_basis.read ()
|
||||
let b = match Input.Ao_basis.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Ao_basis.to_string b);
|
||||
print_endline (Input.Ao_basis.to_rst b |> Rst_string.to_string);
|
||||
@ -10,13 +12,18 @@ let test_ao () =
|
||||
|
||||
let test_bielec_intergals () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Bielec_integrals.read ()
|
||||
let b = match Input.Bielec_integrals.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
let output = Input.Bielec_integrals.to_string b
|
||||
in
|
||||
print_endline output;
|
||||
let rst = Input.Bielec_integrals.to_rst b in
|
||||
let b2 = Input.Bielec_integrals.of_rst rst in
|
||||
let b2 = match Input.Bielec_integrals.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
if (b = b2) then
|
||||
print_endline "OK"
|
||||
else
|
||||
@ -25,26 +32,35 @@ let test_bielec_intergals () =
|
||||
|
||||
let test_bitmasks () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Bitmasks.read ()
|
||||
let b = match Input.Bitmasks.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Bitmasks.to_string b);
|
||||
;;
|
||||
|
||||
let test_cis () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Cis_dressed.read ()
|
||||
let b = match Input.Cis_dressed.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Cis_dressed.to_string b);
|
||||
;;
|
||||
|
||||
let test_dets () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Determinants.read ()
|
||||
let b = match Input.Determinants.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Determinants.to_rst b |> Rst_string.to_string ) ;
|
||||
print_endline (Input.Determinants.sexp_of_t b |> Sexplib.Sexp.to_string ) ;
|
||||
let r = Input.Determinants.to_rst b in
|
||||
let b2 = Input.Determinants.of_rst r in
|
||||
let rst = Input.Determinants.to_rst b in
|
||||
let b2 = match Input.Determinants.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
if (b2 = b) then
|
||||
print_endline "OK"
|
||||
else
|
||||
@ -53,11 +69,16 @@ let test_dets () =
|
||||
|
||||
let test_cisd_sc2 () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Cisd_sc2.read ()
|
||||
let b = match Input.Cisd_sc2.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Cisd_sc2.to_string b);
|
||||
let rst = Input.Cisd_sc2.to_rst b in
|
||||
let b2 = Input.Cisd_sc2.of_rst rst in
|
||||
let b2 = match Input.Cisd_sc2.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
if (b = b2) then
|
||||
print_endline "OK"
|
||||
else
|
||||
@ -67,12 +88,17 @@ let test_cisd_sc2 () =
|
||||
|
||||
let test_electrons () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Electrons.read ()
|
||||
let b = match Input.Electrons.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Electrons.to_string b);
|
||||
let rst = Input.Electrons.to_rst b in
|
||||
let new_b = Input.Electrons.of_rst rst in
|
||||
if (b = new_b) then
|
||||
let b2 = match Input.Electrons.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
if (b = b2) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
@ -80,13 +106,18 @@ let test_electrons () =
|
||||
|
||||
let test_fci () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Full_ci.read ()
|
||||
let b = match Input.Full_ci.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Full_ci.to_string b);
|
||||
let rst = Input.Full_ci.to_rst b in
|
||||
let new_b = Input.Full_ci.of_rst rst in
|
||||
let b2 = match Input.Full_ci.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Full_ci.to_string b);
|
||||
if (b = new_b) then
|
||||
if (b = b2) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
@ -94,13 +125,18 @@ let test_fci () =
|
||||
|
||||
let test_hf () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Hartree_fock.read ()
|
||||
let b = match Input.Hartree_fock.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Hartree_fock.to_string b);
|
||||
let rst = Input.Hartree_fock.to_rst b in
|
||||
let new_b = Input.Hartree_fock.of_rst rst in
|
||||
let b2 = match Input.Hartree_fock.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Hartree_fock.to_string b);
|
||||
if (b = new_b) then
|
||||
if (b = b2) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
@ -108,18 +144,26 @@ let test_hf () =
|
||||
|
||||
let test_mo () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Mo_basis.read ()
|
||||
let b = match Input.Mo_basis.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Mo_basis.to_string b);
|
||||
;;
|
||||
|
||||
let test_nucl () =
|
||||
Ezfio.set_file "F2.ezfio" ;
|
||||
let b = Input.Nuclei.read () in
|
||||
let b = match Input.Nuclei.read () with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
let rst = Input.Nuclei.to_rst b in
|
||||
let new_b = Input.Nuclei.of_rst rst in
|
||||
let b2 = match Input.Nuclei.of_rst rst with
|
||||
| Some x -> x
|
||||
| None -> assert false
|
||||
in
|
||||
print_endline (Input.Nuclei.to_string b);
|
||||
if (b = new_b) then
|
||||
if (b = b2) then
|
||||
print_endline "OK"
|
||||
else
|
||||
print_endline "Failed in rst"
|
||||
|
@ -149,7 +149,7 @@ END_PROVIDER
|
||||
duplicate(i) = .False.
|
||||
enddo
|
||||
|
||||
do i=1,N_det
|
||||
do i=1,N_det-1
|
||||
if (duplicate(i)) then
|
||||
cycle
|
||||
endif
|
||||
|
@ -148,7 +148,6 @@ subroutine make_s2_eigenfunction
|
||||
integer, parameter :: bufsze = 1000
|
||||
logical, external :: is_in_wavefunction
|
||||
|
||||
print *, irp_here
|
||||
! !TODO DEBUG
|
||||
! do i=1,N_det
|
||||
! do j=i+1,N_det
|
||||
|
Loading…
Reference in New Issue
Block a user