mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-23 04:43:50 +01:00
Errors in QPtypes
This commit is contained in:
parent
e986a3cd44
commit
7a2acd04ea
@ -31,22 +31,7 @@ let build_mask from upto n_int =
|
||||
|
||||
|
||||
|
||||
type t =
|
||||
| Core
|
||||
| Inactive
|
||||
| Active
|
||||
| Virtual
|
||||
| Deleted
|
||||
| None
|
||||
|
||||
|
||||
let t_to_string = function
|
||||
| Core -> "core"
|
||||
| Inactive -> "inactive"
|
||||
| Active -> "active"
|
||||
| Virtual -> "virtual"
|
||||
| Deleted -> "deleted"
|
||||
| None -> assert false
|
||||
type t = MO_class.t option
|
||||
|
||||
|
||||
let set ~core ~inact ~act ~virt ~del =
|
||||
@ -71,26 +56,34 @@ let set ~core ~inact ~act ~virt ~del =
|
||||
| k::tail -> let i = MO_number.to_int k in
|
||||
begin
|
||||
match mo_class.(i-1) with
|
||||
| None -> mo_class.(i-1) <- t ;
|
||||
| None -> mo_class.(i-1) <- Some t ;
|
||||
apply_class t tail;
|
||||
| x -> failwith
|
||||
| Some x -> failwith
|
||||
(Printf.sprintf "Orbital %d is defined both in the %s and %s spaces"
|
||||
i (t_to_string x) (t_to_string t))
|
||||
i (MO_class.to_string x) (MO_class.to_string t))
|
||||
end
|
||||
in
|
||||
match l with
|
||||
| MO_class.Core x -> apply_class Core x
|
||||
| MO_class.Inactive x -> apply_class Inactive x
|
||||
| MO_class.Active x -> apply_class Active x
|
||||
| MO_class.Virtual x -> apply_class Virtual x
|
||||
| MO_class.Deleted x -> apply_class Deleted x
|
||||
| MO_class.Core x -> apply_class (MO_class.Core []) x
|
||||
| MO_class.Inactive x -> apply_class (MO_class.Inactive []) x
|
||||
| MO_class.Active x -> apply_class (MO_class.Active []) x
|
||||
| MO_class.Virtual x -> apply_class (MO_class.Virtual []) x
|
||||
| MO_class.Deleted x -> apply_class (MO_class.Deleted []) x
|
||||
in
|
||||
|
||||
let core = MO_class.create_core core in
|
||||
let inact = MO_class.create_inactive inact in
|
||||
let act = MO_class.create_active act in
|
||||
let virt = MO_class.create_virtual virt in
|
||||
let del = MO_class.create_deleted del in
|
||||
let check f x =
|
||||
try f x with Invalid_argument a ->
|
||||
begin
|
||||
Printf.printf "Number of MOs: %d\n%!" mo_tot_num;
|
||||
raise (Invalid_argument a)
|
||||
end
|
||||
in
|
||||
|
||||
let core = check MO_class.create_core core in
|
||||
let inact = check MO_class.create_inactive inact in
|
||||
let act = check MO_class.create_active act in
|
||||
let virt = check MO_class.create_virtual virt in
|
||||
let del = check MO_class.create_deleted del in
|
||||
|
||||
apply_class core ;
|
||||
apply_class inact ;
|
||||
@ -98,6 +91,8 @@ let set ~core ~inact ~act ~virt ~del =
|
||||
apply_class virt ;
|
||||
apply_class del ;
|
||||
|
||||
|
||||
|
||||
for i=1 to (Array.length mo_class)
|
||||
do
|
||||
if (mo_class.(i-1) = None) then
|
||||
@ -193,7 +188,18 @@ let set ~core ~inact ~act ~virt ~del =
|
||||
in
|
||||
Ezfio.set_bitmasks_n_mask_cas 1;
|
||||
Ezfio.ezfio_array_of_list ~rank:3 ~dim:([| (N_int_number.to_int n_int) ; 2; 1|]) ~data:result
|
||||
|> Ezfio.set_bitmasks_cas
|
||||
|> Ezfio.set_bitmasks_cas;
|
||||
|
||||
let data =
|
||||
Array.to_list mo_class
|
||||
|> List.map ~f:(fun x -> match x with
|
||||
|None -> assert false
|
||||
| Some x -> MO_class.to_string x
|
||||
)
|
||||
in
|
||||
Ezfio.ezfio_array_of_list ~rank:1 ~dim:[| mo_tot_num |] ~data
|
||||
|> Ezfio.set_mo_basis_mo_class
|
||||
|
||||
|
||||
|
||||
let get () =
|
||||
@ -228,17 +234,17 @@ let get () =
|
||||
in
|
||||
set ~core ~inact ~act ~virt ~del
|
||||
| (MO_class.Core _) :: rest ->
|
||||
work ~core:(Printf.sprintf "%s,%d" core i) ~inact ~act ~virt ~del (i-1) rest
|
||||
work ~core:(Printf.sprintf "%s,%d" core i) ~inact ~act ~virt ~del (i+1) rest
|
||||
| (MO_class.Inactive _) :: rest ->
|
||||
work ~inact:(Printf.sprintf "%s,%d" inact i) ~core ~act ~virt ~del (i-1) rest
|
||||
work ~inact:(Printf.sprintf "%s,%d" inact i) ~core ~act ~virt ~del (i+1) rest
|
||||
| (MO_class.Active _) :: rest ->
|
||||
work ~act:(Printf.sprintf "%s,%d" act i) ~inact ~core ~virt ~del (i-1) rest
|
||||
work ~act:(Printf.sprintf "%s,%d" act i) ~inact ~core ~virt ~del (i+1) rest
|
||||
| (MO_class.Virtual _) :: rest ->
|
||||
work ~virt:(Printf.sprintf "%s,%d" virt i) ~inact ~act ~core ~del (i-1) rest
|
||||
work ~virt:(Printf.sprintf "%s,%d" virt i) ~inact ~act ~core ~del (i+1) rest
|
||||
| (MO_class.Deleted _) :: rest ->
|
||||
work ~del:(Printf.sprintf "%s,%d" del i) ~inact ~act ~virt ~core (i-1) rest
|
||||
work ~del:(Printf.sprintf "%s,%d" del i) ~inact ~act ~virt ~core (i+1) rest
|
||||
in
|
||||
work (Array.length data.Input_mo_basis.mo_class) (Array.to_list data.Input_mo_basis.mo_class)
|
||||
work 1 (Array.to_list data.Input_mo_basis.mo_class)
|
||||
|
||||
|
||||
|
||||
|
@ -2,42 +2,52 @@ open Core.Std;;
|
||||
|
||||
let input_data = "
|
||||
* Positive_float : float
|
||||
assert (x >= 0.) ;
|
||||
if not (x >= 0.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Positive_float : (x >= 0.) : x=%f\" x));
|
||||
|
||||
* Strictly_positive_float : float
|
||||
assert (x > 0.) ;
|
||||
if not (x > 0.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Strictly_positive_float : (x > 0.) : x=%f\" x));
|
||||
|
||||
* Negative_float : float
|
||||
assert (x <= 0.) ;
|
||||
if not (x <= 0.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Negative_float : (x <= 0.) : x=%f\" x));
|
||||
|
||||
* Strictly_negative_float : float
|
||||
assert (x < 0.) ;
|
||||
if not (x < 0.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Strictly_negative_float : (x < 0.) : x=%f\" x));
|
||||
|
||||
* Positive_int64 : int64
|
||||
assert (x >= 0L) ;
|
||||
if not (x >= 0L) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Positive_int64 : (x >= 0L) : x=%s\" (Int64.to_string x)));
|
||||
|
||||
* Positive_int : int
|
||||
assert (x >= 0) ;
|
||||
if not (x >= 0) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Positive_int : (x >= 0) : x=%d\" x));
|
||||
|
||||
* Strictly_positive_int : int
|
||||
assert (x > 0) ;
|
||||
if not (x > 0) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Strictly_positive_int : (x > 0) : x=%d\" x));
|
||||
|
||||
* Negative_int : int
|
||||
assert (x <= 0) ;
|
||||
if not (x <= 0) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Negative_int : (x <= 0) : x=%d\" x));
|
||||
|
||||
* Det_coef : float
|
||||
assert (x >= -1.) ;
|
||||
assert (x <= 1.) ;
|
||||
if (x < -1.) || (x > 1.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Det_coef : (-1. <= x <= 1.) : x=%f\" x));
|
||||
|
||||
* Normalized_float : float
|
||||
assert (x <= 1.) ;
|
||||
assert (x >= 0.) ;
|
||||
if (x < 0.) || (x > 1.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Normalized_float : (0. <= x <= 1.) : x=%f\" x));
|
||||
|
||||
* Strictly_negative_int : int
|
||||
assert (x < 0) ;
|
||||
if not (x < 0) then
|
||||
raise (Invalid_argument (Printf.sprintf \"Strictly_negative_int : (x < 0) : x=%d\" x));
|
||||
|
||||
* Non_empty_string : string
|
||||
assert (x <> \"\") ;
|
||||
if (x = \"\") then
|
||||
raise (Invalid_argument \"Non_empty_string\");
|
||||
|
||||
|
||||
* Det_number_max : int
|
||||
@ -53,13 +63,13 @@ let input_data = "
|
||||
* Bit_kind_size : int
|
||||
begin match x with
|
||||
| 8 | 16 | 32 | 64 -> ()
|
||||
| _ -> raise (Failure \"Bit_kind_size should be (8|16|32|64).\")
|
||||
| _ -> raise (Invalid_argument \"Bit_kind_size should be (8|16|32|64).\")
|
||||
end;
|
||||
|
||||
* Bit_kind : int
|
||||
begin match x with
|
||||
| 1 | 2 | 4 | 8 -> ()
|
||||
| _ -> raise (Failure \"Bit_kind should be (1|2|4|8).\")
|
||||
| _ -> raise (Invalid_argument \"Bit_kind should be (1|2|4|8).\")
|
||||
end;
|
||||
|
||||
* Bitmask_number : int
|
||||
@ -68,12 +78,14 @@ let input_data = "
|
||||
* MO_coef : float
|
||||
|
||||
* MO_occ : float
|
||||
assert (x >= 0.);
|
||||
if (x < 0.) || (x > 2.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"MO_occ : (0. <= x <= 2.) : x=%f\" x));
|
||||
|
||||
* AO_coef : float
|
||||
|
||||
* AO_expo : float
|
||||
assert (x >= 0.) ;
|
||||
if (x < 0.) then
|
||||
raise (Invalid_argument (Printf.sprintf \"AO_expo : (x >= 0.) : x=%f\" x));
|
||||
|
||||
* AO_prim_number : int
|
||||
assert (x > 0) ;
|
||||
@ -165,7 +177,7 @@ end = struct
|
||||
match (String.lowercase s) with
|
||||
| \"huckel\" -> Huckel
|
||||
| \"hcore\" -> HCore
|
||||
| _ -> failwith (\"Wrong Guess type : \"^s)
|
||||
| _ -> raise (Invalid_argument (\"Wrong Guess type : \"^s))
|
||||
|
||||
end
|
||||
|
||||
@ -189,7 +201,7 @@ end = struct
|
||||
| \"read\" -> Read
|
||||
| \"write\" -> Write
|
||||
| \"none\" -> None
|
||||
| _ -> failwith (\"Wrong IO type : \"^s)
|
||||
| _ -> raise (Invalid_argument (\"Wrong IO type : \"^s))
|
||||
|
||||
end
|
||||
"
|
||||
@ -267,7 +279,9 @@ end = struct
|
||||
begin
|
||||
match max with
|
||||
| %s -> ()
|
||||
| i -> assert ( x <= i )
|
||||
| i ->
|
||||
if ( x > i ) then
|
||||
raise (Invalid_argument (Printf.sprintf \"%s: %%s\" (%s.to_string x) ))
|
||||
end ;
|
||||
x
|
||||
end
|
||||
@ -296,7 +310,7 @@ let parse_input_ezfio input=
|
||||
in
|
||||
Printf.sprintf ezfio_template
|
||||
name typ typ typ typ typ typ typ typ (String.capitalize typ)
|
||||
ezfio_func ezfio_func max min typ typ max msg min
|
||||
ezfio_func ezfio_func max min typ typ max msg min name (String.capitalize typ)
|
||||
end
|
||||
| _ -> failwith "Error in input_ezfio"
|
||||
in
|
||||
|
Loading…
Reference in New Issue
Block a user