10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-08-24 21:41:46 +02:00

qp_edit fails better

This commit is contained in:
Anthony Scemama 2014-11-12 17:17:44 +01:00
parent 7db57da1fd
commit a700718078
11 changed files with 79 additions and 150 deletions

View File

@ -17,7 +17,7 @@ module Bielec_integrals : sig
val write : t -> unit val write : t -> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ read_ao_integrals : bool; { read_ao_integrals : bool;
@ -220,20 +220,8 @@ Direct calculation of integrals ::
|> Rst_string.of_string |> Rst_string.of_string
;; ;;
let of_rst s = include Generic_input_of_rst;;
let s = Rst_string.to_string s let of_rst = of_rst t_of_sexp;;
|> 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
;;
end end

View File

@ -15,6 +15,7 @@ module Cis_dressed : sig
val read : unit -> t val read : unit -> 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
val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ n_state_cis : States_number.t; { n_state_cis : States_number.t;
@ -145,6 +146,10 @@ Epstein-Nesbet 2x2 diagonalization ::
|> Rst_string.of_string |> Rst_string.of_string
;; ;;
include Generic_input_of_rst;;
let of_rst = of_rst t_of_sexp;;
end end

View File

@ -13,7 +13,7 @@ module Cisd_sc2 : sig
val write : t -> unit val write : t -> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ n_det_max_cisd_sc2 : Det_number_max.t; { n_det_max_cisd_sc2 : Det_number_max.t;
@ -118,22 +118,8 @@ Compute E(PT2) at the end ::
|> Rst_string.of_string |> Rst_string.of_string
;; ;;
let of_rst s = include Generic_input_of_rst;;
let s = Rst_string.to_string s let of_rst = of_rst t_of_sexp;;
|> 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
;;
end end

View File

@ -23,7 +23,7 @@ module Determinants : sig
val write : t -> unit val write : t -> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ n_int : N_int_number.t; { n_int : N_int_number.t;
@ -538,8 +538,8 @@ psi_det = %s
and n_int = Printf.sprintf "(n_int %d)" (N_int_number.get_max ()) in 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] let s = String.concat [ header ; bitkind ; n_int ; psi_coef ; psi_det]
in in
Sexp.of_string ("("^s^")")
|> t_of_sexp Generic_input_of_rst.evaluate_sexp t_of_sexp s
;; ;;
end end

View File

@ -13,7 +13,7 @@ module Electrons : sig
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
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ elec_alpha_num : Elec_alpha_number.t; { elec_alpha_num : Elec_alpha_number.t;
@ -91,20 +91,8 @@ elec_num = %s
(Elec_number.to_string (read_elec_num ())) (Elec_number.to_string (read_elec_num ()))
;; ;;
let of_rst s = include Generic_input_of_rst;;
let s = Rst_string.to_string s let of_rst = of_rst t_of_sexp;;
|> 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
;;
end end

View File

@ -13,7 +13,7 @@ module Full_ci : sig
val write : t-> unit val write : t-> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ n_det_max_fci : Det_number_max.t; { n_det_max_fci : Det_number_max.t;
@ -117,20 +117,8 @@ Compute E(PT2) at the end ::
|> Rst_string.of_string |> Rst_string.of_string
;; ;;
let of_rst s = include Generic_input_of_rst;;
let s = Rst_string.to_string s let of_rst = of_rst t_of_sexp;;
|> 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
;;
end end

View File

@ -12,7 +12,7 @@ module Hartree_fock : sig
val write : t -> unit val write : t -> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ n_it_scf_max : Strictly_positive_int.t; { n_it_scf_max : Strictly_positive_int.t;
@ -93,21 +93,8 @@ SCF convergence criterion (on energy) ::
|> Rst_string.of_string |> Rst_string.of_string
;; ;;
let of_rst s = include Generic_input_of_rst;;
let s = Rst_string.to_string s let of_rst = of_rst t_of_sexp;;
|> 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
;;
end end

View File

@ -14,7 +14,7 @@ module Nuclei : sig
val write : t -> unit val write : t -> unit
val to_string : t -> string val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ nucl_num : Nucl_number.t ; { nucl_num : Nucl_number.t ;
@ -203,6 +203,7 @@ Nuclear coordinates in xyz format (Angstroms) ::
| _ -> failwith "Error in xyz format" | _ -> failwith "Error in xyz format"
in in
(* Create the Nuclei.t data structure *) (* Create the Nuclei.t data structure *)
let result =
{ nucl_num = List.length atom_list { nucl_num = List.length atom_list
|> Nucl_number.of_int ~max:nmax; |> Nucl_number.of_int ~max:nmax;
nucl_label = List.map atom_list ~f:(fun x -> nucl_label = List.map atom_list ~f:(fun x ->
@ -212,6 +213,7 @@ Nuclear coordinates in xyz format (Angstroms) ::
nucl_coord = List.map atom_list ~f:(fun x -> nucl_coord = List.map atom_list ~f:(fun x ->
x.Atom.coord ) |> Array.of_list ; x.Atom.coord ) |> Array.of_list ;
} }
in Some result
;; ;;
end end

View File

@ -10,7 +10,7 @@ endif
LIBS= LIBS=
PKGS= PKGS=
OCAMLCFLAGS="-g" OCAMLCFLAGS="-g -warn-error A"
OCAMLBUILD=ocamlbuild -j 0 -syntax camlp4o -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) OCAMLBUILD=ocamlbuild -j 0 -syntax camlp4o -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS)
MLFILES=$(wildcard *.ml) ezfio.ml Qptypes.ml MLFILES=$(wildcard *.ml) ezfio.ml Qptypes.ml
MLIFILES=$(wildcard *.mli) MLIFILES=$(wildcard *.mli)

View File

@ -23,9 +23,8 @@ of the block.
;; ;;
val read : unit -> t val read : unit -> t
val write : t -> unit val write : t -> unit
val to_string : t -> string
val to_rst : t -> Rst_string.t val to_rst : t -> Rst_string.t
val of_rst : Rst_string.t -> t val of_rst : Rst_string.t -> t option
end = struct end = struct
type t = type t =
{ r_x : Type_of_x.t { r_x : Type_of_x.t
@ -42,12 +41,14 @@ of the block.
end end
The following functions need to be defined:: The following functions need to be defined
.. code-block:: ocaml
val read : unit -> t val read : unit -> t
val write : t -> unit val write : t -> unit
val to_rst : t -> Rst_string.t 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`. 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 .. code-block:: ocaml
let of_rst s = include Generic_input_of_rst;;
let s = Rst_string.to_string s let of_rst = of_rst t_of_sexp;;
|> 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
;;
@ -201,10 +188,11 @@ vim search strings are given in brackets.
let get s = let get s =
let header = (make_header s) let header = (make_header s)
and rst = match s with and rst = let open Input in
match s with
... ...
| New_keyword -> | 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 .. code-block:: ocaml
let open Input in
match s with match s with
... ...
| New_keyword -> | New_keyword -> write New_keyword.(of_rst, write)
Input.New_keyword.(write (of_rst str)) ...
;; ;;

View File

@ -44,25 +44,26 @@ let make_header kw =
let get s = let get s =
let header = (make_header s) let header = (make_header s)
and rst = match s with and rst = let open Input in
match s with
| Full_ci -> | Full_ci ->
Input.Full_ci.(to_rst (read ())) Full_ci.(to_rst (read ()))
| Hartree_fock -> | Hartree_fock ->
Input.Hartree_fock.(to_rst (read ())) Hartree_fock.(to_rst (read ()))
| Mo_basis -> | Mo_basis ->
Input.Mo_basis.(to_rst (read ())) Mo_basis.(to_rst (read ()))
| Electrons -> | Electrons ->
Input.Electrons.(to_rst (read ())) Electrons.(to_rst (read ()))
| Determinants -> | Determinants ->
Input.Determinants.(to_rst (read ())) Determinants.(to_rst (read ()))
| Cisd_sc2 -> | Cisd_sc2 ->
Input.Cisd_sc2.(to_rst (read ())) Cisd_sc2.(to_rst (read ()))
| Nuclei -> | Nuclei ->
Input.Nuclei.(to_rst (read ())) Nuclei.(to_rst (read ()))
| Ao_basis -> | Ao_basis ->
Input.Ao_basis.(to_rst (read ())) Ao_basis.(to_rst (read ()))
| Bielec_integrals -> | Bielec_integrals ->
Input.Bielec_integrals.(to_rst (read ())) Bielec_integrals.(to_rst (read ()))
in header^(Rst_string.to_string rst) in header^(Rst_string.to_string rst)
;; ;;
@ -81,27 +82,22 @@ let set str s =
let str = String.sub ~pos:index_begin ~len:l str let str = String.sub ~pos:index_begin ~len:l str
|> Rst_string.of_string |> Rst_string.of_string
in in
let write (of_rst,w) =
match of_rst str with
| Some data -> w data
| None -> ()
in
let open Input in
match s with match s with
(* | Hartree_fock -> write Hartree_fock.(of_rst, write)
| Mo_basis -> | Full_ci -> write Full_ci.(of_rst, write)
*) | Electrons -> write Electrons.(of_rst, write)
| Hartree_fock -> | Cisd_sc2 -> write Cisd_sc2.(of_rst, write)
Input.Hartree_fock.(write (of_rst str )) | Bielec_integrals -> write Bielec_integrals.(of_rst, write)
| Full_ci -> | Determinants -> write Determinants.(of_rst, write)
Input.Full_ci.(write (of_rst str)) | Nuclei -> write Nuclei.(of_rst, write)
| Electrons -> | Ao_basis -> () (* TODO *)
Input.Electrons.(write (of_rst str)) | Mo_basis -> () (* TODO *)
| 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 ->
*)
;; ;;